mirror of
https://github.com/WhatCD/Gazelle.git
synced 2024-12-13 19:06:27 +00:00
Empty commit
This commit is contained in:
parent
0a0d9b8aa6
commit
6a47225ddd
@ -22,6 +22,7 @@
|
|||||||
g.ID,
|
g.ID,
|
||||||
g.Name,
|
g.Name,
|
||||||
g.CategoryID,
|
g.CategoryID,
|
||||||
|
g.wikiImage,
|
||||||
g.TagList,
|
g.TagList,
|
||||||
t.Format,
|
t.Format,
|
||||||
t.Encoding,
|
t.Encoding,
|
||||||
@ -36,7 +37,8 @@
|
|||||||
t.Snatched,
|
t.Snatched,
|
||||||
t.Seeders,
|
t.Seeders,
|
||||||
t.Leechers,
|
t.Leechers,
|
||||||
((t.Size * t.Snatched) + (t.Size * 0.5 * t.Leechers)) AS Data
|
((t.Size * t.Snatched) + (t.Size * 0.5 * t.Leechers)) AS Data,
|
||||||
|
g.ReleaseType
|
||||||
FROM torrents AS t
|
FROM torrents AS t
|
||||||
LEFT JOIN torrents_group AS g ON g.ID = t.GroupID ";
|
LEFT JOIN torrents_group AS g ON g.ID = t.GroupID ";
|
||||||
|
|
||||||
@ -44,87 +46,117 @@
|
|||||||
|
|
||||||
if($Details == 'all' || $Details == 'day') {
|
if($Details == 'all' || $Details == 'day') {
|
||||||
if (!$TopTorrentsActiveLastDay = $Cache->get_value('top10tor_day_'.$Limit.$WhereSum)) {
|
if (!$TopTorrentsActiveLastDay = $Cache->get_value('top10tor_day_'.$Limit.$WhereSum)) {
|
||||||
$DayAgo = time_minus(86400);
|
if ($Cache->get_query_lock('top10')) {
|
||||||
$Query = $BaseQuery.' WHERE t.Seeders>0 AND ';
|
$DayAgo = time_minus(86400);
|
||||||
if (!empty($Where)) { $Query .= $Where.' AND '; }
|
$Query = $BaseQuery.' WHERE t.Seeders>0 AND ';
|
||||||
$Query .= "
|
if (!empty($Where)) { $Query .= $Where.' AND '; }
|
||||||
t.Time>'$DayAgo'
|
$Query .= "
|
||||||
ORDER BY (t.Seeders + t.Leechers) DESC
|
t.Time>'$DayAgo'
|
||||||
LIMIT $Limit;";
|
ORDER BY (t.Seeders + t.Leechers) DESC
|
||||||
$DB->query($Query);
|
LIMIT $Limit;";
|
||||||
$TopTorrentsActiveLastDay = $DB->to_array();
|
$DB->query($Query);
|
||||||
$Cache->cache_value('top10tor_day_'.$Limit.$WhereSum,$TopTorrentsActiveLastDay,3600*2);
|
$TopTorrentsActiveLastDay = $DB->to_array(false, MYSQLI_NUM);
|
||||||
|
$Cache->cache_value('top10tor_day_'.$Limit.$WhereSum,$TopTorrentsActiveLastDay,3600*2);
|
||||||
|
$Cache->clear_query_lock('top10');
|
||||||
|
} else {
|
||||||
|
$TopTorrentsActiveLastDay = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$OuterResults[] = generate_torrent_json('Most Active Torrents Uploaded in the Past Day', 'day', $TopTorrentsActiveLastDay, $Limit);
|
$OuterResults[] = generate_torrent_json('Most Active Torrents Uploaded in the Past Day', 'day', $TopTorrentsActiveLastDay, $Limit);
|
||||||
}
|
}
|
||||||
if($Details == 'all' || $Details == 'week') {
|
if($Details == 'all' || $Details == 'week') {
|
||||||
if (!$TopTorrentsActiveLastWeek = $Cache->get_value('top10tor_week_'.$Limit.$WhereSum)) {
|
if (!$TopTorrentsActiveLastWeek = $Cache->get_value('top10tor_week_'.$Limit.$WhereSum)) {
|
||||||
$WeekAgo = time_minus(604800);
|
if ($Cache->get_query_lock('top10')) {
|
||||||
$Query = $BaseQuery.' WHERE ';
|
$WeekAgo = time_minus(604800);
|
||||||
if (!empty($Where)) { $Query .= $Where.' AND '; }
|
$Query = $BaseQuery.' WHERE ';
|
||||||
$Query .= "
|
if (!empty($Where)) { $Query .= $Where.' AND '; }
|
||||||
t.Time>'$WeekAgo'
|
$Query .= "
|
||||||
ORDER BY (t.Seeders + t.Leechers) DESC
|
t.Time>'$WeekAgo'
|
||||||
LIMIT $Limit;";
|
ORDER BY (t.Seeders + t.Leechers) DESC
|
||||||
$DB->query($Query);
|
LIMIT $Limit;";
|
||||||
$TopTorrentsActiveLastWeek = $DB->to_array();
|
$DB->query($Query);
|
||||||
$Cache->cache_value('top10tor_week_'.$Limit.$WhereSum,$TopTorrentsActiveLastWeek,3600*6);
|
$TopTorrentsActiveLastWeek = $DB->to_array(false, MYSQLI_NUM);
|
||||||
|
$Cache->cache_value('top10tor_week_'.$Limit.$WhereSum,$TopTorrentsActiveLastWeek,3600*6);
|
||||||
|
$Cache->clear_query_lock('top10');
|
||||||
|
} else {
|
||||||
|
$TopTorrentsActiveLastWeek = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$OuterResults[] = generate_torrent_json('Most Active Torrents Uploaded in the Past Week', 'week', $TopTorrentsActiveLastWeek, $Limit);
|
$OuterResults[] = generate_torrent_json('Most Active Torrents Uploaded in the Past Week', 'week', $TopTorrentsActiveLastWeek, $Limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($Details == 'all' || $Details == 'overall') {
|
if($Details == 'all' || $Details == 'overall') {
|
||||||
if (!$TopTorrentsActiveAllTime = $Cache->get_value('top10tor_overall_'.$Limit.$WhereSum)) {
|
if (!$TopTorrentsActiveAllTime = $Cache->get_value('top10tor_overall_'.$Limit.$WhereSum)) {
|
||||||
// IMPORTANT NOTE - we use WHERE t.Seeders>500 in order to speed up this query. You should remove it!
|
if ($Cache->get_query_lock('top10')) {
|
||||||
$Query = $BaseQuery;
|
// IMPORTANT NOTE - we use WHERE t.Seeders>500 in order to speed up this query. You should remove it!
|
||||||
if (!empty($Where)) { $Query .= ' WHERE '.$Where; }
|
$Query = $BaseQuery;
|
||||||
elseif ($Details=='all') { $Query .= " WHERE t.Seeders>500 "; }
|
if (!empty($Where)) { $Query .= ' WHERE '.$Where; }
|
||||||
$Query .= "
|
elseif ($Details=='all') { $Query .= " WHERE t.Seeders>500 "; }
|
||||||
ORDER BY (t.Seeders + t.Leechers) DESC
|
$Query .= "
|
||||||
LIMIT $Limit;";
|
ORDER BY (t.Seeders + t.Leechers) DESC
|
||||||
$DB->query($Query);
|
LIMIT $Limit;";
|
||||||
$TopTorrentsActiveAllTime = $DB->to_array();
|
$DB->query($Query);
|
||||||
$Cache->cache_value('top10tor_overall_'.$Limit.$WhereSum,$TopTorrentsActiveAllTime,3600*6);
|
$TopTorrentsActiveAllTime = $DB->to_array(false, MYSQLI_NUM);
|
||||||
|
$Cache->cache_value('top10tor_overall_'.$Limit.$WhereSum,$TopTorrentsActiveAllTime,3600*6);
|
||||||
|
$Cache->clear_query_lock('top10');
|
||||||
|
} else {
|
||||||
|
$TopTorrentsActiveAllTime = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$OuterResults[] = generate_torrent_json('Most Active Torrents of All Time', 'overall', $TopTorrentsActiveAllTime, $Limit);
|
$OuterResults[] = generate_torrent_json('Most Active Torrents of All Time', 'overall', $TopTorrentsActiveAllTime, $Limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(($Details == 'all' || $Details == 'snatched') && empty($Where)) {
|
if(($Details == 'all' || $Details == 'snatched') && empty($Where)) {
|
||||||
if (!$TopTorrentsSnatched = $Cache->get_value('top10tor_snatched_'.$Limit.$WhereSum)) {
|
if (!$TopTorrentsSnatched = $Cache->get_value('top10tor_snatched_'.$Limit.$WhereSum)) {
|
||||||
$Query = $BaseQuery;
|
if ($Cache->get_query_lock('top10')) {
|
||||||
$Query .= "
|
$Query = $BaseQuery;
|
||||||
ORDER BY t.Snatched DESC
|
$Query .= "
|
||||||
LIMIT $Limit;";
|
ORDER BY t.Snatched DESC
|
||||||
$DB->query($Query);
|
LIMIT $Limit;";
|
||||||
$TopTorrentsSnatched = $DB->to_array();
|
$DB->query($Query);
|
||||||
$Cache->cache_value('top10tor_snatched_'.$Limit.$WhereSum,$TopTorrentsSnatched,3600*6);
|
$TopTorrentsSnatched = $DB->to_array(false, MYSQLI_NUM);
|
||||||
|
$Cache->cache_value('top10tor_snatched_'.$Limit.$WhereSum,$TopTorrentsSnatched,3600*6);
|
||||||
|
$Cache->clear_query_lock('top10');
|
||||||
|
} else {
|
||||||
|
$TopTorrentsSnatched = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$OuterResults[] = generate_torrent_json('Most Snatched Torrents', 'snatched', $TopTorrentsSnatched, $Limit);
|
$OuterResults[] = generate_torrent_json('Most Snatched Torrents', 'snatched', $TopTorrentsSnatched, $Limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(($Details == 'all' || $Details == 'data') && empty($Where)) {
|
if(($Details == 'all' || $Details == 'data') && empty($Where)) {
|
||||||
if (!$TopTorrentsTransferred = $Cache->get_value('top10tor_data_'.$Limit.$WhereSum)) {
|
if (!$TopTorrentsTransferred = $Cache->get_value('top10tor_data_'.$Limit.$WhereSum)) {
|
||||||
// IMPORTANT NOTE - we use WHERE t.Snatched>100 in order to speed up this query. You should remove it!
|
if ($Cache->get_query_lock('top10')) {
|
||||||
$Query = $BaseQuery;
|
// IMPORTANT NOTE - we use WHERE t.Snatched>100 in order to speed up this query. You should remove it!
|
||||||
if ($Details=='all') { $Query .= " WHERE t.Snatched>100 "; }
|
$Query = $BaseQuery;
|
||||||
$Query .= "
|
if ($Details=='all') { $Query .= " WHERE t.Snatched>100 "; }
|
||||||
ORDER BY Data DESC
|
$Query .= "
|
||||||
LIMIT $Limit;";
|
ORDER BY Data DESC
|
||||||
$DB->query($Query);
|
LIMIT $Limit;";
|
||||||
$TopTorrentsTransferred = $DB->to_array();
|
$DB->query($Query);
|
||||||
$Cache->cache_value('top10tor_data_'.$Limit.$WhereSum,$TopTorrentsTransferred,3600*6);
|
$TopTorrentsTransferred = $DB->to_array(false, MYSQLI_NUM);
|
||||||
|
$Cache->cache_value('top10tor_data_'.$Limit.$WhereSum,$TopTorrentsTransferred,3600*6);
|
||||||
|
$Cache->clear_query_lock('top10');
|
||||||
|
} else {
|
||||||
|
$TopTorrentsTransferred = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$OuterResults[] = generate_torrent_json('Most Data Transferred Torrents', 'data', $TopTorrentsTransferred, $Limit);
|
$OuterResults[] = generate_torrent_json('Most Data Transferred Torrents', 'data', $TopTorrentsTransferred, $Limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(($Details == 'all' || $Details == 'seeded') && empty($Where)) {
|
if(($Details == 'all' || $Details == 'seeded') && empty($Where)) {
|
||||||
if (!$TopTorrentsSeeded = $Cache->get_value('top10tor_seeded_'.$Limit.$WhereSum)) {
|
if (!$TopTorrentsSeeded = $Cache->get_value('top10tor_seeded_'.$Limit.$WhereSum)) {
|
||||||
$Query = $BaseQuery."
|
if ($Cache->get_query_lock('top10')) {
|
||||||
ORDER BY t.Seeders DESC
|
$Query = $BaseQuery."
|
||||||
LIMIT $Limit;";
|
ORDER BY t.Seeders DESC
|
||||||
$DB->query($Query);
|
LIMIT $Limit;";
|
||||||
$TopTorrentsSeeded = $DB->to_array();
|
$DB->query($Query);
|
||||||
$Cache->cache_value('top10tor_seeded_'.$Limit.$WhereSum,$TopTorrentsSeeded,3600*6);
|
$TopTorrentsSeeded = $DB->to_array(false, MYSQLI_NUM);
|
||||||
|
$Cache->cache_value('top10tor_seeded_'.$Limit.$WhereSum,$TopTorrentsSeeded,3600*6);
|
||||||
|
$Cache->clear_query_lock('top10');
|
||||||
|
} else {
|
||||||
|
$TopTorrentsSeeded = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$OuterResults[] = generate_torrent_json('Best Seeded Torrents', 'seeded', $TopTorrentsSeeded, $Limit);
|
$OuterResults[] = generate_torrent_json('Best Seeded Torrents', 'seeded', $TopTorrentsSeeded, $Limit);
|
||||||
}
|
}
|
||||||
@ -141,10 +173,19 @@
|
|||||||
function generate_torrent_json($Caption, $Tag, $Details, $Limit) {
|
function generate_torrent_json($Caption, $Tag, $Details, $Limit) {
|
||||||
global $LoggedUser,$Categories;
|
global $LoggedUser,$Categories;
|
||||||
$results = array();
|
$results = array();
|
||||||
|
if ($Details === false) {
|
||||||
|
// Failed to get cache lock; server is (hopefully) already processing a top10 request
|
||||||
|
return array(
|
||||||
|
'caption' => $Caption,
|
||||||
|
'tag' => $Tag,
|
||||||
|
'limit' => (int) $Limit,
|
||||||
|
'results' => array()
|
||||||
|
);
|
||||||
|
}
|
||||||
foreach ($Details as $Detail) {
|
foreach ($Details as $Detail) {
|
||||||
list($TorrentID,$GroupID,$GroupName,$GroupCategoryID,$TorrentTags,
|
list($TorrentID,$GroupID,$GroupName,$GroupCategoryID,$WikiImage,$TorrentTags,
|
||||||
$Format,$Encoding,$Media,$Scene,$HasLog,$HasCue,$LogScore,$Year,$GroupYear,
|
$Format,$Encoding,$Media,$Scene,$HasLog,$HasCue,$LogScore,$Year,$GroupYear,
|
||||||
$RemasterTitle,$Snatched,$Seeders,$Leechers,$Data) = $Detail;
|
$RemasterTitle,$Snatched,$Seeders,$Leechers,$Data,$ReleaseType) = $Detail;
|
||||||
|
|
||||||
$Artist = Artists::display_artists(Artists::get_artist($GroupID), false, true);
|
$Artist = Artists::display_artists(Artists::get_artist($GroupID), false, true);
|
||||||
$TruncArtist = substr($Artist, 0, strlen($Artist)-3);
|
$TruncArtist = substr($Artist, 0, strlen($Artist)-3);
|
||||||
|
@ -59,7 +59,7 @@
|
|||||||
} else {
|
} else {
|
||||||
$RS .= " i.JoinDate > '".time_minus(3600*24*3)."'";
|
$RS .= " i.JoinDate > '".time_minus(3600*24*3)."'";
|
||||||
}
|
}
|
||||||
$RS .= " ORDER BY i.Joindate DESC";
|
$RS .= " ORDER BY i.Joindate DESC LIMIT $Limit";
|
||||||
$QueryID = $DB->query($RS);
|
$QueryID = $DB->query($RS);
|
||||||
$DB->query("SELECT FOUND_ROWS()");
|
$DB->query("SELECT FOUND_ROWS()");
|
||||||
list($Results) = $DB->next_record();
|
list($Results) = $DB->next_record();
|
||||||
|
Loading…
Reference in New Issue
Block a user