Oppaitime's version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

artist.php 34KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917
  1. <?
  2. //~~~~~~~~~~~ Main artist page ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
  3. //For sorting tags
  4. function compare($X, $Y) {
  5. return($Y['count'] - $X['count']);
  6. }
  7. // Similar Artist Map
  8. include(SERVER_ROOT.'/classes/artists_similar.class.php');
  9. $UserVotes = Votes::get_user_votes($LoggedUser['ID']);
  10. $ArtistID = $_GET['id'];
  11. if (!is_number($ArtistID)) {
  12. error(0);
  13. }
  14. if (!empty($_GET['revisionid'])) { // if they're viewing an old revision
  15. $RevisionID = $_GET['revisionid'];
  16. if (!is_number($RevisionID)) {
  17. error(0);
  18. }
  19. $Data = $Cache->get_value("artist_{$ArtistID}_revision_$RevisionID", true);
  20. } else { // viewing the live version
  21. $Data = $Cache->get_value("artist_$ArtistID", true);
  22. $RevisionID = false;
  23. }
  24. if ($Data) {
  25. #list($K, list($Name, $Image, $Body, $NumSimilar, $SimilarArray, , , $VanityHouseArtist)) = each($Data);
  26. list($K, list($Name, $Image, $Body, $NumSimilar, $SimilarArray)) = each($Data);
  27. } else {
  28. if ($RevisionID) {
  29. $sql = "
  30. SELECT
  31. a.Name,
  32. wiki.Image,
  33. wiki.body
  34. FROM wiki_artists AS wiki
  35. LEFT JOIN artists_group AS a ON wiki.RevisionID = a.RevisionID
  36. WHERE wiki.RevisionID = '$RevisionID' ";
  37. } else {
  38. $sql = "
  39. SELECT
  40. a.Name,
  41. wiki.Image,
  42. wiki.body
  43. FROM artists_group AS a
  44. LEFT JOIN wiki_artists AS wiki ON wiki.RevisionID = a.RevisionID
  45. WHERE a.ArtistID = '$ArtistID' ";
  46. }
  47. $sql .= "
  48. GROUP BY a.ArtistID";
  49. $DB->query($sql);
  50. if (!$DB->has_results()) {
  51. error(404);
  52. }
  53. list($Name, $Image, $Body) = $DB->next_record(MYSQLI_NUM, array(0));
  54. }
  55. //----------------- Build list and get stats
  56. ob_start();
  57. // Requests
  58. $Requests = [];
  59. if (empty($LoggedUser['DisableRequests'])) {
  60. $Requests = $Cache->get_value("artists_requests_$ArtistID");
  61. if (!is_array($Requests)) {
  62. $DB->query("
  63. SELECT
  64. r.ID,
  65. r.CategoryID,
  66. r.Title,
  67. r.TitleRJ,
  68. r.TitleJP,
  69. r.CatalogueNumber,
  70. r.DLSiteID,
  71. r.TimeAdded,
  72. COUNT(rv.UserID) AS Votes,
  73. SUM(rv.Bounty) AS Bounty
  74. FROM requests AS r
  75. LEFT JOIN requests_votes AS rv ON rv.RequestID = r.ID
  76. LEFT JOIN requests_artists AS ra ON r.ID = ra.RequestID
  77. WHERE ra.ArtistID = $ArtistID
  78. AND r.TorrentID = 0
  79. GROUP BY r.ID
  80. ORDER BY Votes DESC");
  81. if ($DB->has_results()) {
  82. $Requests = $DB->to_array('ID', MYSQLI_ASSOC, false);
  83. } else {
  84. $Requests = [];
  85. }
  86. $Cache->cache_value("artists_requests_$ArtistID", $Requests);
  87. }
  88. }
  89. $NumRequests = count($Requests);
  90. if (($GroupIDs = $Cache->get_value("artist_groups_$ArtistID")) === false) {
  91. $DB->query("
  92. SELECT
  93. DISTINCTROW ta.GroupID
  94. FROM torrents_artists AS ta
  95. WHERE ta.ArtistID = '$ArtistID'");
  96. $GroupIDs = $DB->collect('GroupID');
  97. $Cache->cache_value("artist_groups_$ArtistID", $GroupIDs, 0);
  98. }
  99. if (count($GroupIDs) > 0) {
  100. $TorrentList = Torrents::get_groups($GroupIDs, true, true);
  101. } else {
  102. $TorrentList = [];
  103. }
  104. $NumGroups = count($TorrentList);
  105. if (!empty($TorrentList)) {
  106. ?>
  107. <div id="discog_table" class="box">
  108. <?
  109. }
  110. // Deal with torrents without release types, which can end up here
  111. // if they're uploaded with a non-grouping category ID
  112. $UnknownRT = array_search('Unknown', $ReleaseTypes);
  113. if ($UnknownRT === false) {
  114. $UnknownRT = 1025;
  115. $ReleaseTypes[$UnknownRT] = 'Unknown';
  116. }
  117. //Custom sorting for releases
  118. if (!empty($LoggedUser['SortHide'])) {
  119. $SortOrder = array_flip(array_keys($LoggedUser['SortHide']));
  120. } else {
  121. $SortOrder = $ReleaseTypes;
  122. }
  123. // If the $SortOrder array doesn't have all release types, put the missing ones at the end
  124. $MissingTypes = array_diff_key($ReleaseTypes, $SortOrder);
  125. if (!empty($MissingTypes)) {
  126. $MaxOrder = max($SortOrder);
  127. foreach (array_keys($MissingTypes) as $Missing) {
  128. $SortOrder[$Missing] = ++$MaxOrder;
  129. }
  130. }
  131. // Sort the anchors at the top of the page the same way as release types
  132. reset($TorrentList);
  133. $NumTorrents = 0;
  134. $NumSeeders = 0;
  135. $NumLeechers = 0;
  136. $NumSnatches = 0;
  137. foreach ($TorrentList as $GroupID => $Group) {
  138. // $Tags array is for the sidebar on the right.
  139. $TorrentTags = new Tags($Group['TagList'], true);
  140. foreach ($Group['Torrents'] as $TorrentID => $Torrent) {
  141. $NumTorrents++;
  142. $Torrent['Seeders'] = (int)$Torrent['Seeders'];
  143. $Torrent['Leechers'] = (int)$Torrent['Leechers'];
  144. $Torrent['Snatched'] = (int)$Torrent['Snatched'];
  145. $NumSeeders += $Torrent['Seeders'];
  146. $NumLeechers += $Torrent['Leechers'];
  147. $NumSnatches += $Torrent['Snatched'];
  148. }
  149. }
  150. $OpenTable = false;
  151. $ShowGroups = !isset($LoggedUser['TorrentGrouping']) || $LoggedUser['TorrentGrouping'] == 0;
  152. $HideTorrents = ($ShowGroups ? '' : ' hidden');
  153. $OldGroupID = 0;
  154. ?>
  155. <table class="torrent_table grouped release_table">
  156. <tr class="colhead_dark">
  157. <td class="small"><!-- expand/collapse --></td>
  158. <td width="70%"><a href="#">&uarr;</a>&nbsp;<strong>Name</strong></td>
  159. <td>Size</td>
  160. <td class="sign snatches">
  161. <a><svg width="15" height="15" fill="white" class="tooltip" alt="Snatches" title="Snatches" viewBox="3 0 88 98"><path d="M20 20 A43 43,0,1,0,77 23 L90 10 L55 10 L55 45 L68 32 A30.27 30.27,0,1,1,28 29"></path></svg></a>
  162. </td>
  163. <td class="sign seeders">
  164. <a><svg width="11" height="15" fill="white" class="tooltip" alt="Seeders" title="Seeders"><polygon points="0,7 5.5,0 11,7 8,7 8,15 3,15 3,7"></polygon></svg></a>
  165. </td>
  166. <td class="sign leechers">
  167. <a><svg width="11" height="15" fill="white" class="tooltip" alt="Leechers" title="Leechers"><polygon points="0,8 5.5,15 11,8 8,8 8,0 3,0 3,8"></polygon></svg></a>
  168. </td>
  169. </tr>
  170. <?
  171. foreach ($TorrentList as $Group) {
  172. extract(Torrents::array_group($TorrentList[$Group['ID']]), EXTR_OVERWRITE);
  173. if ($GroupID == $OldGroupID) {
  174. continue;
  175. } else {
  176. $OldGroupID = $GroupID;
  177. }
  178. if (count($Torrents) > 1) {
  179. $TorrentTags = new Tags($TagList, false);
  180. $DisplayName = Artists::display_artists(Artists::get_artist($GroupID), true, true);
  181. $DisplayName .= "<a href=\"torrents.php?id=$GroupID\" class=\"tooltip\" title=\"View torrent group\" ";
  182. if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
  183. $DisplayName .= 'onmouseover="getCover(event)" data-cover="'.ImageTools::process($WikiImage, true).'" onmouseleave="ungetCover()" ';
  184. }
  185. $GroupName = empty($GroupName) ? (empty($GroupNameRJ) ? $GroupNameJP : $GroupNameRJ) : $GroupName;
  186. $DisplayName .= "dir=\"ltr\">$GroupName</a>";
  187. if ($GroupYear) {
  188. $DisplayName .= " [$GroupYear]";
  189. }
  190. if ($GroupStudio) {
  191. $DisplayName .= " [$GroupStudio]";
  192. }
  193. if ($GroupCatalogueNumber) {
  194. $DisplayName .= " [$GroupCatalogueNumber]";
  195. }
  196. if ($GroupPages) {
  197. $DisplayName .= " [{$GroupPages}p]";
  198. }
  199. if ($GroupDLSiteID) {
  200. $DisplayName .= " [$GroupDLSiteID]";
  201. }
  202. if (check_perms('users_mod') || check_perms('torrents_fix_ghosts')) {
  203. $DisplayName .= ' <a href="torrents.php?action=fix_group&amp;groupid='.$GroupID.'&amp;artistid='.$ArtistID.'&amp;auth='.$LoggedUser['AuthKey'].'" class="brackets tooltip" title="Fix ghost DB entry">Fix</a>';
  204. }
  205. $SnatchedGroupClass = ($GroupFlags['IsSnatched'] ? ' snatched_group' : '');
  206. ?>
  207. <tr class="group<?=$SnatchedGroupClass?>">
  208. <?
  209. $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] == 1);
  210. ?>
  211. <td class="center">
  212. <div id="showimg_<?=$GroupID?>" class="<?=($ShowGroups ? 'hide' : 'show')?>_torrents">
  213. <a class="tooltip show_torrents_link" onclick="toggle_group(<?=$GroupID?>, this, event);" title="Toggle this group (Hold &quot;Shift&quot; to toggle all groups)"></a>
  214. </div>
  215. </td>
  216. <td colspan="5" class="big_info">
  217. <div class="group_info clear">
  218. <strong><?=$DisplayName?></strong>
  219. <? if (Bookmarks::has_bookmarked('torrent', $GroupID)) { ?>
  220. <span class="remove_bookmark float_right">
  221. <a style="float: right;" href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="brackets" onclick="Unbookmark('torrent', <?=$GroupID?>, 'Bookmark'); return false;">Remove bookmark</a>
  222. </span>
  223. <? } else { ?>
  224. <span class="add_bookmark float_right">
  225. <a style="float: right;" href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="brackets" onclick="Bookmark('torrent', <?=$GroupID?>, 'Remove bookmark'); return false;">Bookmark</a>
  226. </span>
  227. <? }
  228. $VoteType = isset($UserVotes[$GroupID]['Type']) ? $UserVotes[$GroupID]['Type'] : '';
  229. Votes::vote_link($GroupID, $VoteType);
  230. ?>
  231. <div class="tags"><?=$TorrentTags->format('torrents.php?taglist=', $Name)?></div>
  232. </div>
  233. </td>
  234. <?
  235. foreach($Torrents as $TorrentID => $Torrent) {
  236. $Reported = false;
  237. $Reports = Torrents::get_reports($TorrentID);
  238. if (count($Reports) > 0) {
  239. $Reported = true;
  240. }
  241. $SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : '';
  242. $TorrentDL = "torrents.php?action=download&amp;id=".$TorrentID."&amp;authkey=".$LoggedUser['AuthKey']."&amp;torrent_pass=".$LoggedUser['torrent_pass'];
  243. $TorrentMG = "magnet:?xt=urn:btih:".$Torrent['info_hash']."&as=https://".SITE_DOMAIN."/".str_replace('&amp;','%26',$TorrentDL)."&tr=".implode("/".$LoggedUser['torrent_pass']."/announce&tr=",ANNOUNCE_URLS[0])."/".$LoggedUser['torrent_pass']."/announce&xl=".$Torrent['Size'];
  244. ?>
  245. <tr class="torrent_row groupid_<?=$GroupID?> group_torrent discog<?=$SnatchedTorrentClass . $SnatchedGroupClass . $HideTorrents?>">
  246. <td colspan="2">
  247. <span>
  248. [ <a href="<?=$TorrentDL?>" class="tooltip" title="Download">DL</a>
  249. | <a href="<?=$TorrentMG?>" class="tooltip" title="Magnet Link">MG</a>
  250. <? if (Torrents::can_use_token($Torrent)) { ?>
  251. | <a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&amp;usetoken=1" class="tooltip" title="Use a FL Token" onclick="return confirm('Are you sure you want to use a freeleech token here?');">FL</a>
  252. <? } ?>
  253. | <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" class="tooltip" title="Report">RP</a> ]
  254. </span>
  255. &nbsp;&nbsp;&raquo;&nbsp; <a href="torrents.php?id=<?=$GroupID?>&amp;torrentid=<?=$TorrentID?>"><?=Torrents::torrent_info($Torrent)?></a>
  256. </td>
  257. <td class="number_column nobr"><?=Format::get_size($Torrent['Size'])?></td>
  258. <td class="number_column"><?=number_format($Torrent['Snatched'])?></td>
  259. <td class="number_column<?=(($Torrent['Seeders'] == 0) ? ' r00' : '')?>"><?=number_format($Torrent['Seeders'])?></td>
  260. <td class="number_column"><?=number_format($Torrent['Leechers'])?></td>
  261. </tr>
  262. <?
  263. }
  264. } else {
  265. list($TorrentID, $Torrent) = each($Torrents);
  266. if (!$TorrentID) { continue; }
  267. $TorrentTags = new Tags($TagList, false);
  268. $DisplayName = Artists::display_artists(Artists::get_artist($GroupID), true, true);
  269. $Reported = false;
  270. $Reports = Torrents::get_reports($TorrentID);
  271. if (count($Reports) > 0) {
  272. $Reported = true;
  273. }
  274. $DisplayName .= "<a class=\"torrent_name\" href=\"torrents.php?id=$GroupID&amp;torrentid=$TorrentID#torrent$TorrentID\" ";
  275. if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
  276. $DisplayName .= "onmouseover=\"getCover(event)\" data-cover=\"".ImageTools::process($WikiImage, true)."\" onmouseleave=\"ungetCover(event)\" ";
  277. }
  278. $GroupName = empty($GroupName) ? (empty($GroupNameRJ) ? $GroupNameJP : $GroupNameRJ) : $GroupName;
  279. $DisplayName .= "dir=\"ltr\">$GroupName</a>";
  280. if ($GroupYear) {
  281. $DisplayName .= " [$GroupYear]";
  282. }
  283. if ($GroupStudio) {
  284. $DisplayName .= " [$GroupStudio]";
  285. }
  286. if ($GroupCatalogueNumber) {
  287. $DisplayName .= " [$GroupCatalogueNumber]";
  288. }
  289. if ($GroupPages) {
  290. $DisplayName .= " [{$GroupPages}p]";
  291. }
  292. if ($GroupDLSiteID) {
  293. $DisplayName .= " [$GroupDLSiteID]";
  294. }
  295. if (check_perms('users_mod') || check_perms('torrents_fix_ghosts')) {
  296. $DisplayName .= ' <a href="torrents.php?action=fix_group&amp;groupid='.$GroupID.'&amp;artistid='.$ArtistID.'&amp;auth='.$LoggedUser['AuthKey'].'" class="brackets tooltip" title="Fix ghost DB entry">Fix</a>';
  297. }
  298. $ExtraInfo = Torrents::torrent_info($Torrent, true, true);
  299. $SnatchedGroupClass = ($GroupFlags['IsSnatched'] ? ' snatched_group' : '');
  300. $SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : '';
  301. $TorrentDL = "torrents.php?action=download&amp;id=".$TorrentID."&amp;authkey=".$LoggedUser['AuthKey']."&amp;torrent_pass=".$LoggedUser['torrent_pass'];
  302. $TorrentMG = "magnet:?xt=urn:btih:".$Torrent['info_hash']."&as=https://".SITE_DOMAIN."/".str_replace('&amp;','%26',$TorrentDL)."&tr=".implode("/".$LoggedUser['torrent_pass']."/announce&tr=",ANNOUNCE_URLS[0])."/".$LoggedUser['torrent_pass']."/announce&xl=".$Torrent['Size'];
  303. ?>
  304. <tr class="torrent<?=$SnatchedTorrentClass . $SnatchedGroupClass?>">
  305. <td class="center">
  306. </td>
  307. <td class="big_info">
  308. <div class="group_info clear">
  309. <div class="float_right">
  310. <span>
  311. [ <a href="<?=$TorrentDL?>" class="tooltip" title="Download">DL</a>
  312. | <a href="<?=$TorrentMG?>" class="tooltip" title="Magnet Link">MG</a>
  313. <? if (Torrents::can_use_token($Torrent)) { ?>
  314. | <a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&amp;usetoken=1" class="tooltip" title="Use a FL Token" onclick="return confirm('Are you sure you want to use a freeleech token here?');">FL</a>
  315. <? } ?>
  316. | <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" class="tooltip" title="Report">RP</a> ]
  317. </span>
  318. <br />
  319. <? if (Bookmarks::has_bookmarked('torrent', $GroupID)) { ?>
  320. <span class="remove_bookmark float_right">
  321. <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="brackets" onclick="Unbookmark('torrent', <?=$GroupID?>, 'Bookmark'); return false;">Remove bookmark</a>
  322. </span>
  323. <? } else { ?>
  324. <span class="add_bookmark float_right">
  325. <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="brackets" onclick="Bookmark('torrent', <?=$GroupID?>, 'Remove bookmark'); return false;">Bookmark</a>
  326. </span>
  327. <? } ?>
  328. </div>
  329. <?=$DisplayName?>
  330. <br />
  331. <div style="display: inline;" class="torrent_info"><?=$ExtraInfo?><? if ($Reported) { ?> / <strong class="torrent_label tl_reported">Reported</strong><? } ?></div>
  332. <div class="tags"><?=$TorrentTags->format('torrents.php?taglist=', $Name)?></div>
  333. </div>
  334. </td>
  335. <td class="number_column nobr"><?=Format::get_size($Torrent['Size'])?></td>
  336. <td class="number_column"><?=number_format($Torrent['Snatched'])?></td>
  337. <td class="number_column<?=(($Torrent['Seeders'] == 0) ? ' r00' : '')?>"><?=number_format($Torrent['Seeders'])?></td>
  338. <td class="number_column"><?=number_format($Torrent['Leechers'])?></td>
  339. </tr>
  340. <?
  341. }
  342. }
  343. ?>
  344. </table>
  345. </div>
  346. <?
  347. $TorrentDisplayList = ob_get_clean();
  348. //----------------- End building list and getting stats
  349. // Comments (must be loaded before View::show_header so that subscriptions and quote notifications are handled properly)
  350. list($NumComments, $Page, $Thread, $LastRead) = Comments::load('artist', $ArtistID);
  351. View::show_header($Name, 'browse,requests,bbcode,comments,voting,recommend,subscriptions');
  352. ?>
  353. <div class="thin">
  354. <div class="header">
  355. <h2><?=display_str($Name)?><? if ($RevisionID) { ?> (Revision #<?=$RevisionID?>)<? } ?></h2>
  356. <div class="linkbox">
  357. <? if (check_perms('site_submit_requests')) { ?>
  358. <a href="requests.php?action=new&amp;artistid=<?=$ArtistID?>" class="brackets">Add request</a>
  359. <?
  360. }
  361. if (check_perms('site_torrents_notify')) {
  362. if (($Notify = $Cache->get_value('notify_artists_'.$LoggedUser['ID'])) === false) {
  363. $DB->query("
  364. SELECT ID, Artists
  365. FROM users_notify_filters
  366. WHERE UserID = '$LoggedUser[ID]'
  367. AND Label = 'Artist notifications'
  368. LIMIT 1");
  369. $Notify = $DB->next_record(MYSQLI_ASSOC, false);
  370. $Cache->cache_value('notify_artists_'.$LoggedUser['ID'], $Notify, 0);
  371. }
  372. if (stripos($Notify['Artists'], "|$Name|") === false) {
  373. ?>
  374. <a href="artist.php?action=notify&amp;artistid=<?=$ArtistID?>&amp;auth=<?=$LoggedUser['AuthKey']?>" class="brackets">Notify of new uploads</a>
  375. <? } else { ?>
  376. <a href="artist.php?action=notifyremove&amp;artistid=<?=$ArtistID?>&amp;auth=<?=$LoggedUser['AuthKey']?>" class="brackets">Do not notify of new uploads</a>
  377. <?
  378. }
  379. }
  380. if (Bookmarks::has_bookmarked('artist', $ArtistID)) {
  381. ?>
  382. <a href="#" id="bookmarklink_artist_<?=$ArtistID?>" onclick="Unbookmark('artist', <?=$ArtistID?>, 'Bookmark'); return false;" class="brackets">Remove bookmark</a>
  383. <? } else { ?>
  384. <a href="#" id="bookmarklink_artist_<?=$ArtistID?>" onclick="Bookmark('artist', <?=$ArtistID?>, 'Remove bookmark'); return false;" class="brackets">Bookmark</a>
  385. <? } ?>
  386. <a href="#" id="subscribelink_artist<?=$ArtistID?>" class="brackets" onclick="SubscribeComments('artist', <?=$ArtistID?>);return false;"><?=Subscriptions::has_subscribed_comments('artist', $ArtistID) !== false ? 'Unsubscribe' : 'Subscribe'?></a>
  387. <!-- <a href="#" id="recommend" class="brackets">Recommend</a> -->
  388. <?
  389. if (check_perms('site_edit_wiki')) {
  390. ?>
  391. <a href="artist.php?action=edit&amp;artistid=<?=$ArtistID?>" class="brackets">Edit</a>
  392. <? } ?>
  393. <a href="artist.php?action=history&amp;artistid=<?=$ArtistID?>" class="brackets">View history</a>
  394. <? if ($RevisionID && check_perms('site_edit_wiki')) { ?>
  395. <a href="artist.php?action=revert&amp;artistid=<?=$ArtistID?>&amp;revisionid=<?=$RevisionID?>&amp;auth=<?=$LoggedUser['AuthKey']?>" class="brackets">Revert to this revision</a>
  396. <? } ?>
  397. <a href="artist.php?id=<?=$ArtistID?>#info" class="brackets">Info</a>
  398. <a href="artist.php?id=<?=$ArtistID?>#artistcomments" class="brackets">Comments</a>
  399. <? if (check_perms('site_delete_artist') && check_perms('torrents_delete')) { ?>
  400. <a href="artist.php?action=delete&amp;artistid=<?=$ArtistID?>&amp;auth=<?=$LoggedUser['AuthKey']?>" class="brackets">Delete</a>
  401. <? } ?>
  402. </div>
  403. </div>
  404. <? /* Misc::display_recommend($ArtistID, "artist"); */ ?>
  405. <div class="sidebar">
  406. <? if ($Image) { ?>
  407. <div class="box box_image">
  408. <div class="head"><strong><?=$Name?></strong></div>
  409. <div style="text-align: center; padding: 10px 0px;">
  410. <img style="max-width: 220px;" class="lightbox-init" src="<?=ImageTools::process($Image, true)?>" alt="<?=$Name?>" />
  411. </div>
  412. </div>
  413. <? } ?>
  414. <div class="box box_search">
  415. <div class="head"><strong>File Lists Search</strong></div>
  416. <ul class="nobullet">
  417. <li>
  418. <form class="search_form" name="filelists" action="torrents.php">
  419. <input type="hidden" name="artistname" value="<?=$Name?>" />
  420. <input type="hidden" name="action" value="advanced" />
  421. <input type="text" autocomplete="off" id="filelist" name="filelist" size="20" />
  422. <input type="submit" value="&gt;" />
  423. </form>
  424. </li>
  425. </ul>
  426. </div>
  427. <?
  428. /* if (check_perms('zip_downloader')) {
  429. if (isset($LoggedUser['Collector'])) {
  430. list($ZIPList, $ZIPPrefs) = $LoggedUser['Collector'];
  431. $ZIPList = explode(':', $ZIPList);
  432. } else {
  433. $ZIPList = array('00', '11');
  434. $ZIPPrefs = 1;
  435. }
  436. ?>
  437. <div class="box box_zipdownload">
  438. <div class="head colhead_dark"><strong>Collector</strong></div>
  439. <div class="pad">
  440. <form class="download_form" name="zip" action="artist.php" method="post">
  441. <input type="hidden" name="action" value="download" />
  442. <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
  443. <input type="hidden" name="artistid" value="<?=$ArtistID?>" />
  444. <ul id="list" class="nobullet">
  445. <? foreach ($ZIPList as $ListItem) { ?>
  446. <li id="list<?=$ListItem?>">
  447. <input type="hidden" name="list[]" value="<?=$ListItem?>" />
  448. <span style="float: left;"><?=$ZIPOptions[$ListItem]['2']?></span>
  449. <span class="remove remove_collector"><a href="#" onclick="remove_selection('<?=$ListItem?>'); return false;" style="float: right;" class="brackets tooltip" title="Remove format from the Collector">X</a></span>
  450. <br style="clear: all;" />
  451. </li>
  452. <? } ?>
  453. </ul>
  454. <select id="formats" style="width: 180px;">
  455. <?
  456. $OpenGroup = false;
  457. $LastGroupID = -1;
  458. foreach ($ZIPOptions as $Option) {
  459. list($GroupID, $OptionID, $OptName) = $Option;
  460. if ($GroupID != $LastGroupID) {
  461. $LastGroupID = $GroupID;
  462. if ($OpenGroup) { ?>
  463. </optgroup>
  464. <? } ?>
  465. <optgroup label="<?=$ZIPGroups[$GroupID]?>">
  466. <? $OpenGroup = true;
  467. }
  468. ?>
  469. <option id="opt<?=$GroupID.$OptionID?>" value="<?=$GroupID.$OptionID?>"<? if (in_array($GroupID.$OptionID, $ZIPList)) { echo ' disabled="disabled"'; } ?>><?=$OptName?></option>
  470. <?
  471. }
  472. ?>
  473. </optgroup>
  474. </select>
  475. <button type="button" onclick="add_selection()">+</button>
  476. <select name="preference" style="width: 210px;">
  477. <option value="0"<? if ($ZIPPrefs == 0) { echo ' selected="selected"'; } ?>>Prefer Original</option>
  478. <option value="1"<? if ($ZIPPrefs == 1) { echo ' selected="selected"'; } ?>>Prefer Best Seeded</option>
  479. <option value="2"<? if ($ZIPPrefs == 2) { echo ' selected="selected"'; } ?>>Prefer Bonus Tracks</option>
  480. </select>
  481. <input type="submit" style="width: 210px;" value="Download" />
  482. </form>
  483. </div>
  484. </div>
  485. <?
  486. } //if (check_perms('zip_downloader'))*/ ?>
  487. <div class="box box_tags">
  488. <div class="head"><strong>Tags</strong></div>
  489. <ul class="stats nobullet">
  490. <? Tags::format_top(50, 'torrents.php?taglist=', $Name); ?>
  491. </ul>
  492. </div>
  493. <?
  494. // Stats
  495. ?>
  496. <div class="box box_info box_statistics_artist">
  497. <div class="head"><strong>Statistics</strong></div>
  498. <ul class="stats nobullet">
  499. <li>Number of groups: <?=number_format($NumGroups)?></li>
  500. <li>Number of torrents: <?=number_format($NumTorrents)?></li>
  501. <li>Number of seeders: <?=number_format($NumSeeders)?></li>
  502. <li>Number of leechers: <?=number_format($NumLeechers)?></li>
  503. <li>Number of snatches: <?=number_format($NumSnatches)?></li>
  504. </ul>
  505. </div>
  506. <?
  507. if (empty($SimilarArray)) {
  508. $DB->query("
  509. SELECT
  510. s2.ArtistID,
  511. a.Name,
  512. ass.Score,
  513. ass.SimilarID
  514. FROM artists_similar AS s1
  515. JOIN artists_similar AS s2 ON s1.SimilarID = s2.SimilarID AND s1.ArtistID != s2.ArtistID
  516. JOIN artists_similar_scores AS ass ON ass.SimilarID = s1.SimilarID
  517. JOIN artists_group AS a ON a.ArtistID = s2.ArtistID
  518. WHERE s1.ArtistID = '$ArtistID'
  519. ORDER BY ass.Score DESC
  520. LIMIT 30
  521. ");
  522. $SimilarArray = $DB->to_array();
  523. $NumSimilar = count($SimilarArray);
  524. }
  525. ?>
  526. <div class="box box_artists">
  527. <div class="head"><strong>Similar</strong></div>
  528. <ul class="stats nobullet">
  529. <? if ($NumSimilar == 0) { ?>
  530. <li><span style="font-style: italic;">None found</span></li>
  531. <?
  532. }
  533. $First = true;
  534. foreach ($SimilarArray as $SimilarArtist) {
  535. list($Artist2ID, $Artist2Name, $Score, $SimilarID) = $SimilarArtist;
  536. $Score = $Score / 100;
  537. if ($First) {
  538. $Max = $Score + 1;
  539. $First = false;
  540. }
  541. $FontSize = (ceil(((($Score - 2) / $Max - 2) * 4))) + 8;
  542. ?>
  543. <li>
  544. <span class="tooltip" title="<?=$Score?>"><a href="artist.php?id=<?=$Artist2ID?>" style="float: left; display: block;"><?=$Artist2Name?></a></span>
  545. <div style="float: right; display: block; letter-spacing: -1px;">
  546. <a href="artist.php?action=vote_similar&amp;artistid=<?=$ArtistID?>&amp;similarid=<?=$SimilarID?>&amp;way=up" class="tooltip brackets vote_artist_up" title="Vote up this similar artist. Use this when you feel that the two artists are quite similar.">&and;</a>
  547. <a href="artist.php?action=vote_similar&amp;artistid=<?=$ArtistID?>&amp;similarid=<?=$SimilarID?>&amp;way=down" class="tooltip brackets vote_artist_down" title="Vote down this similar artist. Use this when you feel that the two artists are not all that similar.">&or;</a>
  548. <? if (check_perms('site_delete_tag')) { ?>
  549. <span class="remove remove_artist"><a href="artist.php?action=delete_similar&amp;similarid=<?=$SimilarID?>&amp;auth=<?=$LoggedUser['AuthKey']?>" class="tooltip brackets" title="Remove this similar artist">X</a></span>
  550. <? } ?>
  551. </div>
  552. <br style="clear: both;" />
  553. </li>
  554. <? } ?>
  555. </ul>
  556. </div>
  557. <div class="box box_addartists box_addartists_similar">
  558. <div class="head"><strong>Add similar</strong></div>
  559. <ul class="nobullet">
  560. <li>
  561. <form class="add_form" name="similar_artists" action="artist.php" method="post">
  562. <input type="hidden" name="action" value="add_similar" />
  563. <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
  564. <input type="hidden" name="artistid" value="<?=$ArtistID?>" />
  565. <input type="text" autocomplete="off" id="artistsimilar" name="artistname" size="20"<? Users::has_autocomplete_enabled('other'); ?> />
  566. <input type="submit" value="+" />
  567. </form>
  568. </li>
  569. </ul>
  570. </div>
  571. </div>
  572. <div class="main_column">
  573. <div id="artist_information" class="box">
  574. <div id="info" class="head">
  575. <a href="#">&uarr;</a>&nbsp;
  576. <strong>Information</strong>
  577. <a class="brackets" data-toggle-target="#body">Toggle</a>
  578. </div>
  579. <div id="body" class="body"><?=Text::full_format($Body)?></div>
  580. </div>
  581. <?
  582. echo $TorrentDisplayList;
  583. $Collages = $Cache->get_value("artists_collages_$ArtistID");
  584. if (!is_array($Collages)) {
  585. $DB->query("
  586. SELECT c.Name, c.NumTorrents, c.ID
  587. FROM collages AS c
  588. JOIN collages_artists AS ca ON ca.CollageID = c.ID
  589. WHERE ca.ArtistID = '$ArtistID'
  590. AND Deleted = '0'
  591. AND CategoryID = '7'");
  592. $Collages = $DB->to_array();
  593. $Cache->cache_value("artists_collages_$ArtistID", $Collages, 3600 * 6);
  594. }
  595. if (count($Collages) > 0) {
  596. if (count($Collages) > MAX_COLLAGES) {
  597. // Pick some at random
  598. $Range = range(0,count($Collages) - 1);
  599. shuffle($Range);
  600. $Indices = array_slice($Range, 0, MAX_COLLAGES);
  601. $SeeAll = ' <a data-toggle-target=".collage_rows">(See all)</a>';
  602. } else {
  603. $Indices = range(0, count($Collages)-1);
  604. $SeeAll = '';
  605. }
  606. ?>
  607. <table class="collage_table" id="collages">
  608. <tr class="colhead">
  609. <td width="85%"><a href="#">&uarr;</a>&nbsp;This artist is in <?=number_format(count($Collages))?> collage<?=((count($Collages) > 1) ? 's' : '')?><?=$SeeAll?></td>
  610. <td># artists</td>
  611. </tr>
  612. <?
  613. foreach ($Indices as $i) {
  614. list($CollageName, $CollageArtists, $CollageID) = $Collages[$i];
  615. unset($Collages[$i]);
  616. ?>
  617. <tr>
  618. <td><a href="collages.php?id=<?=$CollageID?>"><?=$CollageName?></a></td>
  619. <td><?=number_format($CollageArtists)?></td>
  620. </tr>
  621. <?
  622. }
  623. foreach ($Collages as $Collage) {
  624. list($CollageName, $CollageArtists, $CollageID) = $Collage;
  625. ?>
  626. <tr class="collage_rows hidden">
  627. <td><a href="collages.php?id=<?=$CollageID?>"><?=$CollageName?></a></td>
  628. <td><?=number_format($CollageArtists)?></td>
  629. </tr>
  630. <? } ?>
  631. </table>
  632. <?
  633. }
  634. if ($NumRequests > 0) {
  635. ?>
  636. <table cellpadding="6" cellspacing="1" border="0" class="request_table border" width="100%" id="requests">
  637. <tr class="colhead_dark">
  638. <td style="width: 48%;">
  639. <a href="#">&uarr;</a>&nbsp;
  640. <strong>Request Name</strong>
  641. </td>
  642. <td class="nobr">
  643. <strong>Vote</strong>
  644. </td>
  645. <td class="nobr">
  646. <strong>Bounty</strong>
  647. </td>
  648. <td>
  649. <strong>Added</strong>
  650. </td>
  651. </tr>
  652. <?
  653. $Tags = Requests::get_tags(array_keys($Requests));
  654. foreach ($Requests as $RequestID => $Request) {
  655. $CategoryName = $Categories[$Request['CategoryID'] - 1];
  656. $Title = empty($Request['Title']) ? (empty($Request['TitleRJ']) ? display_str($Request['TitleJP']) : display_str($Request['TitleRJ'])) : display_str($Request['Title']);
  657. if ($CategoryName != 'Other') {
  658. $ArtistForm = Requests::get_artists($RequestID);
  659. $ArtistLink = Artists::display_artists($ArtistForm, true, true);
  660. $FullName = $ArtistLink."<a href=\"requests.php?action=view&amp;id=$RequestID\"><span dir=\"ltr\">$Title</span></a>";
  661. if ($Request['CatalogueNumber']) {
  662. $FullName .= " [$Request[CatalogueNumber]]";
  663. }
  664. if ($Request['DLSiteID']) {
  665. $FullName.= " [$Request[DLSiteID]]";
  666. }
  667. } else {
  668. $FullName = "<a href=\"requests.php?action=view&amp;id=$RequestID\" dir=\"ltr\">$Title</a>";
  669. }
  670. if (!empty($Tags[$RequestID])) {
  671. $ReqTagList = [];
  672. foreach ($Tags[$RequestID] as $TagID => $TagName) {
  673. $ReqTagList[] = "<a href=\"requests.php?tags=$TagName\">".display_str($TagName).'</a>';
  674. }
  675. $ReqTagList = implode(', ', $ReqTagList);
  676. } else {
  677. $ReqTagList = '';
  678. }
  679. ?>
  680. <tr class="row">
  681. <td>
  682. <?=$FullName?>
  683. <div class="tags"><?=$ReqTagList?></div>
  684. </td>
  685. <td class="nobr">
  686. <span id="vote_count_<?=$RequestID?>"><?=$Request['Votes']?></span>
  687. <? if (check_perms('site_vote')) { ?>
  688. <input type="hidden" id="auth" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
  689. &nbsp;&nbsp; <a href="javascript:Vote(0, <?=$RequestID?>)" class="brackets"><strong>+</strong></a>
  690. <? } ?>
  691. </td>
  692. <td class="nobr">
  693. <span id="bounty_<?=$RequestID?>"><?=Format::get_size($Request['Bounty'])?></span>
  694. </td>
  695. <td>
  696. <?=time_diff($Request['TimeAdded'])?>
  697. </td>
  698. </tr>
  699. <? } ?>
  700. </table>
  701. <?
  702. }
  703. // Similar Artist Map
  704. if ($NumSimilar > 0) {
  705. if ($SimilarData = $Cache->get_value("similar_positions_$ArtistID")) {
  706. $Similar = new ARTISTS_SIMILAR($ArtistID, $Name);
  707. $Similar->load_data($SimilarData);
  708. if (!(current($Similar->Artists)->NameLength)) {
  709. unset($Similar);
  710. }
  711. }
  712. if (empty($Similar) || empty($Similar->Artists)) {
  713. include(SERVER_ROOT.'/classes/image.class.php');
  714. $Img = new IMAGE;
  715. $Img->create(WIDTH, HEIGHT);
  716. $Img->color(255, 255, 255, 127);
  717. $Similar = new ARTISTS_SIMILAR($ArtistID, $Name);
  718. $Similar->set_up();
  719. $Similar->set_positions();
  720. $Similar->background_image();
  721. $SimilarData = $Similar->dump_data();
  722. $Cache->cache_value("similar_positions_$ArtistID", $SimilarData, 3600 * 24);
  723. }
  724. ?>
  725. <div id="similar_artist_map" class="box">
  726. <div id="flipper_head" class="head">
  727. <a href="#">&uarr;</a>&nbsp;
  728. <strong id="flipper_title">Similar Map</strong>
  729. <a id="flip_to" class="brackets" href="#" onclick="flipView(); return false;">Switch to cloud</a>
  730. </div>
  731. <div id="flip_view_1" style="display: block; width: <?=(WIDTH)?>px; height: <?=(HEIGHT)?>px; position: relative; background-image: url(static/similar/<?=($ArtistID)?>.png?t=<?=(time())?>);">
  732. <?
  733. $Similar->write_artists();
  734. ?>
  735. </div>
  736. <div id="flip_view_2" style="display: none; width: <?=WIDTH?>px; height: <?=HEIGHT?>px;">
  737. <canvas width="<?=WIDTH?>px" height="<?=(HEIGHT - 20)?>px" id="similarArtistsCanvas"></canvas>
  738. <div id="artistTags" style="display: none;">
  739. <ul><li></li></ul>
  740. </div>
  741. <strong style="margin-left: 10px;"><a id="currentArtist" href="#null">Loading...</a></strong>
  742. </div>
  743. </div>
  744. <script type="text/javascript">//<![CDATA[
  745. var cloudLoaded = false;
  746. function flipView() {
  747. var state = document.getElementById('flip_view_1').style.display == 'block';
  748. if (state) {
  749. document.getElementById('flip_view_1').style.display = 'none';
  750. document.getElementById('flip_view_2').style.display = 'block';
  751. document.getElementById('flipper_title').innerHTML = 'Similar Cloud';
  752. document.getElementById('flip_to').innerHTML = 'Switch to map';
  753. if (!cloudLoaded) {
  754. require("static/functions/tagcanvas.js", function () {
  755. require("static/functions/artist_cloud.js", function () {
  756. });
  757. });
  758. cloudLoaded = true;
  759. }
  760. }
  761. else {
  762. document.getElementById('flip_view_1').style.display = 'block';
  763. document.getElementById('flip_view_2').style.display = 'none';
  764. document.getElementById('flipper_title').innerHTML = 'Similar Map';
  765. document.getElementById('flip_to').innerHTML = 'Switch to cloud';
  766. }
  767. }
  768. //TODO move this to global, perhaps it will be used elsewhere in the future
  769. //http://stackoverflow.com/questions/7293344/load-javascript-dynamically
  770. function require(file, callback) {
  771. var script = document.getElementsByTagName('script')[0],
  772. newjs = document.createElement('script');
  773. // IE
  774. newjs.onreadystatechange = function () {
  775. if (newjs.readyState === 'loaded' || newjs.readyState === 'complete') {
  776. newjs.onreadystatechange = null;
  777. callback();
  778. }
  779. };
  780. // others
  781. newjs.onload = function () {
  782. callback();
  783. };
  784. newjs.src = file;
  785. script.parentNode.insertBefore(newjs, script);
  786. }
  787. //]]>
  788. </script>
  789. <? }
  790. // --- Comments ---
  791. $Pages = Format::get_pages($Page, $NumComments, TORRENT_COMMENTS_PER_PAGE, 9, '#comments');
  792. ?>
  793. <div id="artistcomments">
  794. <div class="linkbox"><a name="comments"></a>
  795. <?=($Pages)?>
  796. </div>
  797. <?
  798. //---------- Begin printing
  799. CommentsView::render_comments($Thread, $LastRead, "artist.php?id=$ArtistID");
  800. ?>
  801. <div class="linkbox">
  802. <?=($Pages)?>
  803. </div>
  804. <?
  805. View::parse('generic/reply/quickreply.php', array(
  806. 'InputName' => 'pageid',
  807. 'InputID' => $ArtistID,
  808. 'Action' => 'comments.php?page=artist',
  809. 'InputAction' => 'take_post',
  810. 'SubscribeBox' => true
  811. ));
  812. ?>
  813. </div>
  814. </div>
  815. </div>
  816. <?
  817. View::show_footer();
  818. // Cache page for later use
  819. if ($RevisionID) {
  820. $Key = "artist_$ArtistID" . "_revision_$RevisionID";
  821. } else {
  822. $Key = "artist_$ArtistID";
  823. }
  824. $Data = array(array($Name, $Image, $Body, $NumSimilar, $SimilarArray, [], [], $VanityHouseArtist));
  825. $Cache->cache_value($Key, $Data, 3600);
  826. ?>