Gazelle/sections/ajax/user_recents.php

75 lines
1.9 KiB
PHP
Raw Normal View History

2013-06-24 08:00:28 +00:00
<?
2013-10-30 08:01:19 +00:00
$UserID = (int)$_GET['userid'];
$Limit = (int)$_GET['limit'];
2013-06-24 08:00:28 +00:00
if (empty($UserID) || $Limit > 50) {
json_die("failure", "bad parameters");
}
if (empty($Limit)) {
$Limit = 15;
}
$Results = array();
if (check_paranoia_here('snatched')) {
$DB->query("
2013-06-25 08:00:52 +00:00
SELECT
g.ID,
g.Name,
g.WikiImage
FROM xbt_snatched AS s
2013-06-24 08:00:28 +00:00
INNER JOIN torrents AS t ON t.ID = s.fid
INNER JOIN torrents_group AS g ON t.GroupID = g.ID
2013-06-25 08:00:52 +00:00
WHERE s.uid = '$UserID'
2013-06-24 08:00:28 +00:00
AND g.CategoryID = '1'
AND g.WikiImage != ''
2013-06-25 08:00:52 +00:00
GROUP BY g.ID
ORDER BY s.tstamp DESC
LIMIT $Limit");
2013-06-24 08:00:28 +00:00
$RecentSnatches = $DB->to_array(false, MYSQLI_ASSOC);
$Artists = Artists::get_artists($DB->collect('ID'));
foreach ($RecentSnatches as $Key => $SnatchInfo) {
$RecentSnatches[$Key]['artists'][] = $Artists[$SnatchInfo['ID']];
2013-10-30 08:01:19 +00:00
$RecentSnatches[$Key]['ID'] = (int)$RecentSnatches[$Key]['ID'];
2013-06-24 08:00:28 +00:00
}
$Results['snatches'] = $RecentSnatches;
} else {
$Results['snatches'] = "hidden";
}
if (check_paranoia_here('uploads')) {
$DB->query("
2013-06-25 08:00:52 +00:00
SELECT
g.ID,
g.Name,
g.WikiImage
FROM torrents_group AS g
2013-06-24 08:00:28 +00:00
INNER JOIN torrents AS t ON t.GroupID = g.ID
2013-06-25 08:00:52 +00:00
WHERE t.UserID = '$UserID'
2013-06-24 08:00:28 +00:00
AND g.CategoryID = '1'
AND g.WikiImage != ''
2013-06-25 08:00:52 +00:00
GROUP BY g.ID
ORDER BY t.Time DESC
LIMIT $Limit");
2013-06-24 08:00:28 +00:00
$RecentUploads = $DB->to_array(false, MYSQLI_ASSOC);
$Artists = Artists::get_artists($DB->collect('ID'));
foreach ($RecentUploads as $Key => $UploadInfo) {
$RecentUploads[$Key]['artists'][] = $Artists[$UploadInfo['ID']];
2013-10-30 08:01:19 +00:00
$RecentUploads[$Key]['ID'] = (int)$RecentUploads[$Key]['ID'];
2013-06-24 08:00:28 +00:00
}
$Results['uploads'] = $RecentUploads;
} else {
$Results['uploads'] = "hidden";
}
2015-01-28 08:00:26 +00:00
json_print("success", $Results);
2013-06-24 08:00:28 +00:00
function check_paranoia_here($Setting) {
global $Paranoia, $Class, $UserID, $Preview;
if ($Preview == 1) {
return check_paranoia($Setting, $Paranoia, $Class);
} else {
return check_paranoia($Setting, $Paranoia, $Class, $UserID);
}
2013-06-25 08:00:52 +00:00
}