BioTorrents.de’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 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. #declare(strict_types=1);
  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. /*
  43. if ($GroupCategoryID === 1 && $GroupYear > 0) {
  44. $DisplayName .= " [$GroupYear]";
  45. }
  46. */
  47. // Append extra info to torrent title
  48. $ExtraInfo = '';
  49. $AddExtra = '&thinsp;|&thinsp;'; # breaking
  50. if ($Media) {
  51. $ExtraInfo .= $AddExtra.$Media;
  52. }
  53. if ($Year > 0) {
  54. $ExtraInfo .= $AddExtra.$Year;
  55. }
  56. if ($ExtraInfo !== '') {
  57. $ExtraInfo = $AddExtra.$ExtraInfo;
  58. }
  59. $TitleString = "$DisplayName $ExtraInfo";
  60. $TagString = str_replace('|', ' ', $TorrentTags);
  61. $DB->query("
  62. INSERT INTO top10_history_torrents(
  63. `HistoryID`,
  64. `Rank`,
  65. `TorrentID`,
  66. `TitleString`,
  67. `TagString`
  68. )
  69. VALUES(
  70. $HistoryID,
  71. $i,
  72. $TorrentID,
  73. '".db_string($TitleString)."',
  74. '".db_string($TagString)."'
  75. )
  76. ");
  77. $i++;
  78. }