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_daily.php 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. #declare(strict_types=1);
  3. $DB->query("
  4. INSERT INTO top10_history (Date, Type)
  5. VALUES ('$sqltime', 'Daily')");
  6. $HistoryID = $DB->inserted_id();
  7. $Top10 = $Cache->get_value('top10tor_day_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 DAY)
  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,
  43. $Snatched, $Seeders, $Leechers, $Data) = $Torrent;
  44. $DisplayName = '';
  45. $DisplayName .= $GroupName;
  46. /*
  47. $Artists = Artists::get_artist($GroupID);
  48. if (!empty($Artists)) {
  49. $DisplayName = Artists::display_artists($Artists, false, true);
  50. }
  51. */
  52. /*
  53. if ($GroupCategoryID === 1 && $GroupYear > 0) {
  54. $DisplayName .= " [$GroupYear]";
  55. }
  56. */
  57. // Append extra info to torrent title
  58. $ExtraInfo = '';
  59. $AddExtra = '&thinsp;|&thinsp;'; # breaking
  60. if ($Media) {
  61. $ExtraInfo .= $Media;
  62. }
  63. if ($Year > 0) {
  64. $ExtraInfo .= $AddExtra.$Year;
  65. }
  66. if ($ExtraInfo !== '') {
  67. $ExtraInfo = $AddExtra.$ExtraInfo;
  68. }
  69. $TitleString = "$DisplayName $ExtraInfo";
  70. $TagString = str_replace('|', ' ', $TorrentTags);
  71. $DB->query("
  72. INSERT INTO top10_history_torrents(
  73. `HistoryID`,
  74. `Rank`,
  75. `TorrentID`,
  76. `TitleString`,
  77. `TagString`
  78. )
  79. VALUES(
  80. $HistoryID,
  81. $i,
  82. $TorrentID,
  83. '".db_string($TitleString)."',
  84. '".db_string($TagString)."'
  85. )
  86. ");
  87. $i++;
  88. }