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.

freeleechize.php 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. $Cost = 2000;
  3. if (isset($_POST['torrent'])) {
  4. // Validation
  5. if (!empty($_GET['torrentid']) && is_number($_GET['torrentid'])) {
  6. $TorrentID = $_GET['torrentid'];
  7. } else {
  8. if (empty($_POST['torrent'])) {
  9. error('You forgot to supply a link to the torrent to freeleech');
  10. } else {
  11. $Link = $_POST['torrent'];
  12. if (!preg_match('/'.TORRENT_REGEX.'/i', $Link, $Matches)) {
  13. error('Your link didn\'t seem to be a valid torrent link');
  14. } else {
  15. $TorrentID = $Matches[4];
  16. }
  17. }
  18. if (!$TorrentID || !is_number($TorrentID)) {
  19. error(404);
  20. }
  21. }
  22. $UserID = $LoggedUser['ID'];
  23. // Make sure torrent exists
  24. $DB->query("
  25. SELECT FreeTorrent, FreeLeechType
  26. FROM torrents
  27. WHERE ID = $TorrentID");
  28. if ($DB->has_results()) {
  29. list($FreeTorrent, $FreeLeechType) = $DB->next_record();
  30. if ($FreeTorrent === 2) {
  31. error('Torrent is already neutral leech.');
  32. } elseif ($FreeTorrent === 1 && $FreeLeechType !== 3) {
  33. error('Torrent is already freeleech for another reason.');
  34. }
  35. } else {
  36. error('Torrent does not exist');
  37. }
  38. $DB->query("
  39. SELECT BonusPoints
  40. FROM users_main
  41. WHERE ID = $UserID");
  42. if ($DB->has_results()) {
  43. list($Points) = $DB->next_record();
  44. if ($Points >= $Cost) {
  45. $DB->query("
  46. SELECT TorrentID
  47. FROM shop_freeleeches
  48. WHERE TorrentID = $TorrentID");
  49. if ($DB->has_results()) {
  50. $DB->query("
  51. UPDATE shop_freeleeches
  52. SET ExpiryTime = ExpiryTime + INTERVAL 1 DAY
  53. WHERE TorrentID = $TorrentID");
  54. } else {
  55. $DB->query("
  56. INSERT INTO shop_freeleeches
  57. (TorrentID, ExpiryTime)
  58. VALUES($TorrentID, NOW() + INTERVAL 1 DAY)");
  59. Torrents::freeleech_torrents($TorrentID, 1, 3);
  60. }
  61. $DB->query("
  62. UPDATE users_main
  63. SET BonusPoints = BonusPoints - $Cost
  64. WHERE ID = $UserID");
  65. $DB->query("
  66. UPDATE users_info
  67. SET AdminComment = CONCAT('".sqltime()." - Made TorrentID $TorrentID freeleech for 24 more hours via the store\n\n', AdminComment)
  68. WHERE UserID = $UserID");
  69. $Cache->delete_value('user_info_heavy_'.$UserID);
  70. $Cache->delete_value('shop_freeleech_list');
  71. } else {
  72. error("Not enough points");
  73. }
  74. }
  75. View::show_header('Store'); ?>
  76. <div>
  77. <h2>Purchase Successful</h2>
  78. <div class="box">
  79. <p>
  80. You purchased 24 hours of freeleech for
  81. <a href="/torrents.php?torrentid=<?= $TorrentID ?>">this
  82. torrent</a>
  83. </p>
  84. <p>
  85. <a href="/store.php">Back to Store</a>
  86. </p>
  87. </div>
  88. </div>
  89. <?php
  90. View::show_footer();
  91. } else {
  92. View::show_header('Store'); ?>
  93. <div>
  94. <div class="box text-align: center;">
  95. <form action="store.php" method="POST">
  96. <input type="hidden" name="item" value="freeleechize">
  97. <strong>
  98. Enter the URL of the torrent you wish to make freeleech for 24 hours:
  99. </strong>
  100. <br />
  101. <input type="text" name="torrent" value="">
  102. <input type="submit">
  103. </form>
  104. <p>
  105. <a href="/store.php">Back to Store</a>
  106. </p>
  107. </div>
  108. </div>
  109. <?php
  110. View::show_footer();
  111. }