Gazelle/sections/ajax/better/single.php

55 lines
1.3 KiB
PHP
Raw Normal View History

2012-01-19 08:00:18 +00:00
<?
2013-05-05 08:00:31 +00:00
if (($GroupIDs = $Cache->get_value('better_single_groupids')) === false) {
$DB->query("
SELECT
t.ID AS TorrentID,
2013-05-14 08:00:34 +00:00
t.GroupID AS GroupID
2012-01-19 08:00:18 +00:00
FROM xbt_files_users AS x
JOIN torrents AS t ON t.ID=x.fid
WHERE t.Format='FLAC'
GROUP BY x.fid
2013-05-05 08:00:31 +00:00
HAVING COUNT(x.uid) = 1
ORDER BY t.LogScore DESC, t.Time ASC
LIMIT 30");
2012-01-19 08:00:18 +00:00
$GroupIDs = $DB->to_array('GroupID');
2013-05-05 08:00:31 +00:00
$Cache->cache_value('better_single_groupids', $GroupIDs, 30 * 60);
2012-01-19 08:00:18 +00:00
}
2012-10-11 08:00:15 +00:00
$Results = Torrents::get_groups(array_keys($GroupIDs));
2012-01-19 08:00:18 +00:00
$Results = $Results['matches'];
$JsonResults = array();
foreach ($Results as $GroupID=>$Group) {
2013-02-25 21:16:55 +00:00
extract(Torrents::array_group($Group));
2012-01-19 08:00:18 +00:00
$FlacID = $GroupIDs[$GroupID]['TorrentID'];
2013-02-22 08:00:24 +00:00
2012-03-29 08:00:19 +00:00
$JsonArtists = array();
2013-05-05 08:00:31 +00:00
if (count($Artists) > 0) {
2012-03-29 08:00:19 +00:00
foreach ($Artists as $Artist) {
$JsonArtists[] = array(
'id' => (int) $Artist['id'],
'name' => $Artist['name'],
'aliasId' => (int) $Artist['aliasid']
);
}
2012-01-19 08:00:18 +00:00
}
2013-02-22 08:00:24 +00:00
2012-01-19 08:00:18 +00:00
$JsonResults[] = array(
2012-01-28 08:00:29 +00:00
'torrentId' => (int) $FlacID,
'groupId' => (int) $GroupID,
2012-03-29 08:00:19 +00:00
'artist' => $JsonArtists,
2012-01-19 08:00:18 +00:00
'groupName' => $GroupName,
2012-01-28 08:00:29 +00:00
'groupYear' => (int) $GroupYear,
2012-01-19 08:00:18 +00:00
'downloadUrl' => 'torrents.php?action=download&id='.$FlacID.'&authkey='.$LoggedUser['AuthKey'].'&torrent_pass='.$LoggedUser['torrent_pass']
);
}
print json_encode(
array(
'status' => 'success',
'response' => $JsonResults
)
2012-01-28 08:00:29 +00:00
);