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

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