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.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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.`title`,
  14. g.`category_id`,
  15. g.`picture`,
  16. g.`tag_list`,
  17. t.`Media`,
  18. g.`published`,
  19. t.`Snatched`,
  20. t.`Seeders`,
  21. t.`Leechers`,
  22. (
  23. (t.`Size` * t.`Snatched`) +(t.`Size` * 0.5 * t.`Leechers`)
  24. ) AS `Data`
  25. FROM
  26. `torrents` AS t
  27. LEFT JOIN `torrents_group` AS g
  28. ON
  29. g.`id` = t.`GroupID`
  30. WHERE
  31. t.`Seeders` > 0 AND t.`Time` >('$sqltime' - INTERVAL 1 WEEK)
  32. ORDER BY
  33. (t.`Seeders` + t.`Leechers`)
  34. DESC
  35. LIMIT 10;
  36. ");
  37. $Top10 = $DB->to_array();
  38. }
  39. $i = 1;
  40. foreach ($Top10 as $Torrent) {
  41. list($TorrentID, $GroupID, $GroupName, $GroupCategoryID,
  42. $WikiImage, $TorrentTags, $Media, $Year, $GroupYear,
  43. $Snatched, $Seeders, $Leechers, $Data) = $Torrent;
  44. $DisplayName = '';
  45. $Artists = Artists::get_artist($GroupID);
  46. if (!empty($Artists)) {
  47. $DisplayName = Artists::display_artists($Artists, false, true);
  48. }
  49. $DisplayName .= $GroupName;
  50. /*
  51. if ($GroupCategoryID === 1 && $GroupYear > 0) {
  52. $DisplayName .= " [$GroupYear]";
  53. }
  54. */
  55. // Append extra info to torrent title
  56. $ExtraInfo = '';
  57. $AddExtra = '&thinsp;|&thinsp;'; # breaking
  58. if ($Media) {
  59. $ExtraInfo .= $AddExtra.$Media;
  60. }
  61. if ($Year > 0) {
  62. $ExtraInfo .= $AddExtra.$Year;
  63. }
  64. if ($ExtraInfo !== '') {
  65. $ExtraInfo = $AddExtra.$ExtraInfo;
  66. }
  67. $TitleString = "$DisplayName $ExtraInfo";
  68. $TagString = str_replace('|', ' ', $TorrentTags);
  69. $DB->query("
  70. INSERT INTO top10_history_torrents(
  71. `HistoryID`,
  72. `Rank`,
  73. `TorrentID`,
  74. `TitleString`,
  75. `TagString`
  76. )
  77. VALUES(
  78. $HistoryID,
  79. $i,
  80. $TorrentID,
  81. '".db_string($TitleString)."',
  82. '".db_string($TagString)."'
  83. )
  84. ");
  85. $i++;
  86. }