Oppaitime'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.4KB

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