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.

sitewide_freeleech.php 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <?php
  2. declare(strict_types=1);
  3. if (isset($_POST['type'])) {
  4. if ($_POST['type'] === 'tag') {
  5. authorize();
  6. if (!isset($_POST['tag'])) {
  7. error("You didn't enter a tag, dipshit.");
  8. }
  9. $Tag = db_string($_POST['tag']);
  10. $DB->query("
  11. SELECT `ID`
  12. FROM `tags`
  13. WHERE `Name` = '$Tag'
  14. ");
  15. if ($DB->has_results()) {
  16. $Tag = str_replace('.', '_', $Tag);
  17. $DB->query("
  18. SELECT t.`ID`
  19. FROM `torrents` AS t
  20. JOIN `torrents_group` AS tg ON t.`GroupID` = tg.`id`
  21. WHERE t.`FreeTorrent` != '2'
  22. AND (t.`FreeLeechType` = '0' OR t.`FreeLeechType` = '3')
  23. AND tg.`tag_list` LIKE '%$Tag%'
  24. ");
  25. if ($DB->has_results()) {
  26. $IDs = $DB->collect('ID');
  27. $Duration = db_string($_POST['duration']);
  28. $Query = "INSERT IGNORE INTO `shop_freeleeches` (TorrentID, ExpiryTime) VALUES ";
  29. foreach ($IDs as $ID) {
  30. $Query .= "(" . $ID . ", NOW() + INTERVAL " . $Duration . " HOUR), ";
  31. }
  32. $Query = substr($Query, 0, strlen($Query) - 2);
  33. $Query .= " ON DUPLICATE KEY UPDATE ExpiryTime = ExpiryTime + INTERVAL " . $Duration . " HOUR";
  34. $DB->query($Query);
  35. $DB->query(
  36. "
  37. INSERT INTO `misc`
  38. (Name, First, Second)
  39. VALUES
  40. ('$Tag', '" . (time() + (60 * 60 * $Duration)) . "', 'freeleech')
  41. ON DUPLICATE KEY UPDATE
  42. `First` = CONVERT(`First`, UNSIGNED INTEGER) + " . (60 * 60 * $Duration)
  43. );
  44. Torrents::freeleech_torrents($IDs, 1, 3, false);
  45. echo("Success! Now run the indexer.");
  46. } else {
  47. error('No torrents with that tag exist.');
  48. }
  49. } else {
  50. error("That tag doesn't exist.");
  51. }
  52. } elseif ($_POST['type'] === 'global') {
  53. authorize();
  54. $DB->query("
  55. SELECT t.`ID`
  56. FROM `torrents` AS t
  57. JOIN `torrents_group` AS tg ON t.`GroupID` = tg.`id`
  58. WHERE t.`FreeTorrent` != '2'
  59. AND (t.`FreeLeechType` = '0' OR t.`FreeLeechType` = '3')
  60. ");
  61. if ($DB->has_results()) {
  62. $IDs = $DB->collect('ID');
  63. $Duration = db_string($_POST['duration']);
  64. $Query = "INSERT IGNORE INTO shop_freeleeches (TorrentID, ExpiryTime) VALUES ";
  65. foreach ($IDs as $ID) {
  66. $Query .= "(" . $ID . ", NOW() + INTERVAL " . $Duration . " HOUR), ";
  67. }
  68. $Query = substr($Query, 0, strlen($Query) - 2);
  69. $Query .= " ON DUPLICATE KEY UPDATE ExpiryTime = ExpiryTime + INTERVAL " . $Duration . " HOUR";
  70. $DB->query($Query);
  71. $DB->query(
  72. "
  73. INSERT INTO `misc`
  74. (`Name`, `First`, `Second`)
  75. VALUES
  76. ('global', '" . (time() + (60 * 60 * $Duration)) . "', 'freeleech')
  77. ON DUPLICATE KEY UPDATE
  78. `First` = CONVERT(`First`, UNSIGNED INTEGER) + " . (60 * 60 * $Duration)
  79. );
  80. Torrents::freeleech_torrents($IDs, 1, 3, false);
  81. echo("Success! Now run the indexer.");
  82. } else {
  83. error("RIP Oppaitime");
  84. }
  85. }
  86. } else {
  87. View::show_header('Site-Wide Freeleech'); ?>
  88. <div>
  89. <div class="box text-align: center;">
  90. <strong>Make sure you run the indexer after using either of these tools, or torrents may disappear from search until
  91. the indexer runs.</strong>
  92. </div>
  93. <div class="box text-align: center;">
  94. <form action="tools.php" method="POST">
  95. <input type="hidden" name="action" value="freeleech" />
  96. <input type="hidden" name="type" value="tag">
  97. <input type="hidden" name="auth"
  98. value="<?=$LoggedUser['AuthKey']?>" />
  99. <strong>Single Tag Freeleech</strong>
  100. <br />
  101. <input id="tag_name" type="text" name="tag" placeholder="Tag" value="" />
  102. <br />
  103. <input id="tag_duration" type="number" name="duration" placeholder="Duration (hours)" value="" />
  104. <br />
  105. <input type="submit" class="button-primary" value="RELEASE THE LEECH" />
  106. </form>
  107. </div>
  108. <div class="box text-align: center;">
  109. <form action="tools.php" method="POST">
  110. <input type="hidden" name="action" value="freeleech" />
  111. <input type="hidden" name="type" value="global" />
  112. <input type="hidden" name="auth"
  113. value="<?=$LoggedUser['AuthKey']?>" />
  114. <strong>Global Freeleech</strong>
  115. <br />
  116. <input id="global_duration" type="number" name="duration" placeholder="Duration (hours)" value="" />
  117. <br />
  118. <input type="submit" class="button-primary" value="RELEASE THE LEECH" />
  119. </div>
  120. </div>
  121. <?php View::show_footer();
  122. }