Gazelle/sections/ajax/torrentgroup.php

119 lines
4.6 KiB
PHP
Raw Normal View History

2011-08-25 08:00:11 +00:00
<?php
require(SERVER_ROOT.'/sections/torrents/functions.php');
2013-03-29 08:00:08 +00:00
2011-08-25 08:00:11 +00:00
$GroupAllowed = array('WikiBody', 'WikiImage', 'ID', 'Name', 'Year', 'RecordLabel', 'CatalogueNumber', 'ReleaseType', 'CategoryID', 'Time', 'VanityHouse');
$TorrentAllowed = array('ID', 'Media', 'Format', 'Encoding', 'Remastered', 'RemasterYear', 'RemasterTitle', 'RemasterRecordLabel', 'RemasterCatalogueNumber', 'Scene', 'HasLog', 'HasCue', 'LogScore', 'FileCount', 'Size', 'Seeders', 'Leechers', 'Snatched', 'FreeTorrent', 'Time', 'Description', 'FileList', 'FilePath', 'UserID', 'Username');
$GroupID = (int)$_GET['id'];
2013-04-24 08:00:23 +00:00
$TorrentHash = (string)$_GET['hash'];
2011-08-25 08:00:11 +00:00
2013-04-24 08:00:23 +00:00
if ($GroupID && $TorrentHash) {
2013-05-14 08:00:34 +00:00
json_die("failure", "bad parameters");
2013-04-24 08:00:23 +00:00
}
if ($TorrentHash) {
2013-05-14 08:00:34 +00:00
if (!is_valid_torrenthash($TorrentHash)) {
json_die("failure", "bad hash parameter");
} else {
$GroupID = (int)torrenthash_to_groupid($TorrentHash);
if (!$GroupID) {
json_die("failure", "bad hash parameter");
}
}
2013-04-24 08:00:23 +00:00
}
if ($GroupID <= 0) {
2013-05-14 08:00:34 +00:00
json_die("failure", "bad id parameter");
2013-04-24 08:00:23 +00:00
}
$TorrentCache = get_group_info($GroupID, true, 0, true, true);
if (!$TorrentCache) {
2013-05-14 08:00:34 +00:00
json_die("failure", "bad id parameter");
2013-04-19 08:00:55 +00:00
}
2011-08-25 08:00:11 +00:00
2012-10-16 08:00:18 +00:00
list($TorrentDetails, $TorrentList) = $TorrentCache;
2012-03-10 08:00:21 +00:00
2012-10-11 08:00:15 +00:00
$ArtistForm = Artists::get_artist($GroupID);
2013-04-19 08:00:55 +00:00
if ($TorrentDetails['CategoryID'] == 0) {
$CategoryName = 'Unknown';
2012-03-10 08:00:21 +00:00
} else {
$CategoryName = $Categories[$TorrentDetails['CategoryID'] - 1];
}
$JsonMusicInfo = array();
2013-04-19 08:00:55 +00:00
if ($CategoryName == 'Music') {
2012-03-10 08:00:21 +00:00
$JsonMusicInfo = array(
2013-06-22 08:01:03 +00:00
'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])
2012-03-10 08:00:21 +00:00
);
2013-04-19 08:00:55 +00:00
} else {
2013-07-17 08:00:52 +00:00
$JsonMusicInfo = null;
2012-08-05 08:00:13 +00:00
}
2012-03-10 08:00:21 +00:00
2012-01-28 08:00:29 +00:00
$JsonTorrentDetails = array(
2013-12-12 08:01:01 +00:00
'wikiBody' => Text::full_format($TorrentDetails['WikiBody']),
2013-06-22 08:01:03 +00:00
'wikiImage' => $TorrentDetails['WikiImage'],
2013-10-30 08:01:19 +00:00
'id' => (int)$TorrentDetails['ID'],
2013-06-22 08:01:03 +00:00
'name' => $TorrentDetails['Name'],
2013-10-30 08:01:19 +00:00
'year' => (int)$TorrentDetails['Year'],
2013-06-22 08:01:03 +00:00
'recordLabel' => $TorrentDetails['RecordLabel'],
2012-01-28 08:00:29 +00:00
'catalogueNumber' => $TorrentDetails['CatalogueNumber'],
2013-10-30 08:01:19 +00:00
'releaseType' => (int)$TorrentDetails['ReleaseType'],
'categoryId' => (int)$TorrentDetails['CategoryID'],
2013-06-22 08:01:03 +00:00
'categoryName' => $CategoryName,
'time' => $TorrentDetails['Time'],
'vanityHouse' => ($TorrentDetails['VanityHouse'] == 1),
'isBookmarked' => Bookmarks::has_bookmarked('torrent', $GroupID),
'musicInfo' => $JsonMusicInfo
2012-01-28 08:00:29 +00:00
);
2012-10-16 08:00:18 +00:00
2012-01-28 08:00:29 +00:00
$JsonTorrentList = array();
foreach ($TorrentList as $Torrent) {
2013-02-25 08:00:45 +00:00
// Convert file list back to the old format
$FileList = explode("\n", $Torrent['FileList']);
foreach ($FileList as &$File) {
$File = Torrents::filelist_old_format($File);
}
unset($File);
$FileList = implode('|||', $FileList);
2013-02-16 08:00:57 +00:00
$Userinfo = Users::user_info($Torrent['UserID']);
2013-08-12 08:00:44 +00:00
$Reports = Torrents::get_reports($Torrent['ID']);
2013-11-07 08:00:43 +00:00
$Torrent['Reported'] = count($Reports) > 0;
2012-01-28 08:00:29 +00:00
$JsonTorrentList[] = array(
2013-10-30 08:01:19 +00:00
'id' => (int)$Torrent['ID'],
2013-06-22 08:01:03 +00:00
'media' => $Torrent['Media'],
'format' => $Torrent['Format'],
'encoding' => $Torrent['Encoding'],
2013-10-30 08:01:19 +00:00
'remastered' => $Torrent['Remastered'] == 1,
'remasterYear' => (int)$Torrent['RemasterYear'],
2013-06-22 08:01:03 +00:00
'remasterTitle' => $Torrent['RemasterTitle'],
'remasterRecordLabel' => $Torrent['RemasterRecordLabel'],
2012-01-28 08:00:29 +00:00
'remasterCatalogueNumber' => $Torrent['RemasterCatalogueNumber'],
2013-10-30 08:01:19 +00:00
'scene' => $Torrent['Scene'] == 1,
'hasLog' => $Torrent['HasLog'] == 1,
'hasCue' => $Torrent['HasCue'] == 1,
'logScore' => (int)$Torrent['LogScore'],
'fileCount' => (int)$Torrent['FileCount'],
'size' => (int)$Torrent['Size'],
'seeders' => (int)$Torrent['Seeders'],
'leechers' => (int)$Torrent['Leechers'],
'snatched' => (int)$Torrent['Snatched'],
'freeTorrent' => $Torrent['FreeTorrent'] == 1,
2013-06-22 08:01:03 +00:00
'reported' => $Torrent['Reported'],
'time' => $Torrent['Time'],
2013-04-19 08:00:55 +00:00
'description' => $Torrent['Description'],
2013-06-22 08:01:03 +00:00
'fileList' => $FileList,
'filePath' => $Torrent['FilePath'],
2013-10-30 08:01:19 +00:00
'userId' => (int)$Torrent['UserID'],
2013-06-22 08:01:03 +00:00
'username' => $Userinfo['Username']
2012-01-28 08:00:29 +00:00
);
}
2011-08-25 08:00:11 +00:00
2013-04-24 08:00:23 +00:00
json_die("success", array('group' => $JsonTorrentDetails, 'torrents' => $JsonTorrentList));