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

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