Oppaitime's version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

top10_weekly.php 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?
  2. //------------------- Weekly Top 10 History -----------------//
  3. $DB->query("
  4. INSERT INTO top10_history (Date, Type)
  5. VALUES ('$sqltime', 'Weekly')");
  6. $HistoryID = $DB->inserted_id();
  7. $Top10 = $Cache->get_value('top10tor_week_10');
  8. if ($Top10 === false) {
  9. $DB->query("
  10. SELECT
  11. t.ID,
  12. g.ID,
  13. g.Name,
  14. g.CategoryID,
  15. g.WikiImage,
  16. g.TagList,
  17. t.Media,
  18. g.Year,
  19. t.Snatched,
  20. t.Seeders,
  21. t.Leechers,
  22. ((t.Size * t.Snatched) + (t.Size * 0.5 * t.Leechers)) AS Data
  23. FROM torrents AS t
  24. LEFT JOIN torrents_group AS g ON g.ID = t.GroupID
  25. WHERE t.Seeders > 0
  26. AND t.Time > ('$sqltime' - INTERVAL 1 WEEK)
  27. ORDER BY (t.Seeders + t.Leechers) DESC
  28. LIMIT 10;");
  29. $Top10 = $DB->to_array();
  30. }
  31. $i = 1;
  32. foreach ($Top10 as $Torrent) {
  33. list($TorrentID, $GroupID, $GroupName, $GroupCategoryID,
  34. $WikiImage, $TorrentTags, $Media, $Year, $GroupYear,
  35. $Snatched, $Seeders, $Leechers, $Data) = $Torrent;
  36. $DisplayName = '';
  37. $Artists = Artists::get_artist($GroupID);
  38. if (!empty($Artists)) {
  39. $DisplayName = Artists::display_artists($Artists, false, true);
  40. }
  41. $DisplayName .= $GroupName;
  42. if ($GroupCategoryID == 1 && $GroupYear > 0) {
  43. $DisplayName .= " [$GroupYear]";
  44. }
  45. // append extra info to torrent title
  46. $ExtraInfo = '';
  47. $AddExtra = '';
  48. if ($Media) {
  49. $ExtraInfo .= $AddExtra.$Media;
  50. $AddExtra = ' / ';
  51. }
  52. if ($Year > 0) {
  53. $ExtraInfo .= $AddExtra.$Year;
  54. $AddExtra = ' ';
  55. }
  56. if ($ExtraInfo != '') {
  57. $ExtraInfo = "- [$ExtraInfo]";
  58. }
  59. $TitleString = "$DisplayName $ExtraInfo";
  60. $TagString = str_replace('|', ' ', $TorrentTags);
  61. $DB->query("
  62. INSERT INTO top10_history_torrents
  63. (HistoryID, Rank, TorrentID, TitleString, TagString)
  64. VALUES
  65. ($HistoryID, $i, $TorrentID, '" . db_string($TitleString) . "', '" . db_string($TagString) . "')");
  66. $i++;
  67. }
  68. ?>