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.

freeleechize.php 3.3KB

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