json_die("failure", "bad id parameter"); } list($TorrentDetails, $TorrentList) = $TorrentCache; if (!isset($TorrentList[$TorrentID])) { json_die("failure", "bad id parameter"); } $GroupID = $TorrentDetails['ID']; $ArtistForm = Artists::get_artist($GroupID); if ($TorrentDetails['CategoryID'] == 0) { $CategoryName = "Unknown"; } else { $CategoryName = $Categories[$TorrentDetails['CategoryID'] - 1]; } $JsonMusicInfo = array(); if ($CategoryName == "Music") { $JsonMusicInfo = array('composers' => $ArtistForm[4] == null ? array() : pullmediainfo($ArtistForm[4]), 'dj' => $ArtistForm[6] == null ? array() : pullmediainfo($ArtistForm[6]), 'artists' => $ArtistForm[1] == null ? array() : pullmediainfo($ArtistForm[1]), 'with' => $ArtistForm[2] == null ? array() : pullmediainfo($ArtistForm[2]), 'conductor' => $ArtistForm[5] == null ? array() : pullmediainfo($ArtistForm[5]), 'remixedBy' => $ArtistForm[3] == null ? array() : pullmediainfo($ArtistForm[3]), 'producer' => $ArtistForm[7] == null ? array() : pullmediainfo($ArtistForm[7])); } else { $JsonMusicInfo = null; } $TagList = explode('|', $TorrentDetails['GROUP_CONCAT(DISTINCT tags.Name SEPARATOR \'|\')']); $JsonTorrentDetails = array('wikiBody' => Text::full_format($TorrentDetails['WikiBody']), 'wikiImage' => $TorrentDetails['WikiImage'], 'id' => (int) $TorrentDetails['ID'], 'name' => $TorrentDetails['Name'], 'year' => (int) $TorrentDetails['Year'], 'recordLabel' => $TorrentDetails['RecordLabel'], 'catalogueNumber' => $TorrentDetails['CatalogueNumber'], 'releaseType' => (int) $TorrentDetails['ReleaseType'], 'categoryId' => (int) $TorrentDetails['CategoryID'], 'categoryName' => $CategoryName, 'time' => $TorrentDetails['Time'], 'vanityHouse' => $TorrentDetails['VanityHouse'] == 1, 'isBookmarked' => Bookmarks::has_bookmarked('torrent', $GroupID), 'musicInfo' => $JsonMusicInfo, 'tags' => $TagList); $Torrent = $TorrentList[$TorrentID]; $Reports = Torrents::get_reports($TorrentID); if (count($Reports) > 0) { $Torrent['Reported'] = true; } else { $Torrent['Reported'] = false; } // Convert file list back to the old format $FileList = explode("\n", $Torrent['FileList']); foreach ($FileList as &$File) {
if ($CategoryName == 'Music') { $ArtistForm = Requests::get_artists($RequestID); if (empty($Request['ReleaseType'])) { $ReleaseName = 'Unknown'; } else { $ReleaseName = $ReleaseTypes[$Request['ReleaseType']]; } } //Votes time $RequestVotes = Requests::get_votes_array($RequestID); $VoteCount = count($RequestVotes['Voters']); $ProjectCanEdit = check_perms('project_team') && !$IsFilled && ($CategoryID == 0 || $CategoryName == 'Music' && $Request['Year'] == 0); $UserCanEdit = !$IsFilled && $LoggedUser['ID'] == $Request['UserID'] && $VoteCount < 2; $CanEdit = $UserCanEdit || $ProjectCanEdit || check_perms('site_moderate_requests'); if ($CategoryName == "Music") { $JsonMusicInfo = array('composers' => isset($ArtistForm[4]) ? pullmediainfo($ArtistForm[4]) : array(), 'dj' => isset($ArtistForm[6]) ? pullmediainfo($ArtistForm[6]) : array(), 'artists' => isset($ArtistForm[1]) ? pullmediainfo($ArtistForm[1]) : array(), 'with' => isset($ArtistForm[2]) ? pullmediainfo($ArtistForm[2]) : array(), 'conductor' => isset($ArtistForm[5]) ? pullmediainfo($ArtistForm[5]) : array(), 'remixedBy' => isset($ArtistForm[3]) ? pullmediainfo($ArtistForm[3]) : array(), 'producer' => isset($ArtistForm[7]) ? pullmediainfo($ArtistForm[7]) : array()); } else { $JsonMusicInfo = new stdClass(); //json_encodes into an empty object: {} } $JsonTopContributors = array(); $VoteMax = $VoteCount < 5 ? $VoteCount : 5; for ($i = 0; $i < $VoteMax; $i++) { $User = array_shift($RequestVotes['Voters']); $JsonTopContributors[] = array('userId' => (int) $User['UserID'], 'userName' => $User['Username'], 'bounty' => (int) $User['Bounty']); } reset($RequestVotes['Voters']); list($NumComments, $Page, $Thread) = Comments::load('requests', $RequestID, false); $JsonRequestComments = array(); foreach ($Thread as $Key => $Post) { list($PostID, $AuthorID, $AddedTime, $Body, $EditedUserID, $EditedTime, $EditedUsername) = array_values($Post);