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.

nonwikiedit.php 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <?
  2. authorize();
  3. //Set by system
  4. if (!$_POST['groupid'] || !is_number($_POST['groupid'])) {
  5. error(404);
  6. }
  7. $GroupID = $_POST['groupid'];
  8. //Usual perm checks
  9. if (!check_perms('torrents_edit')) {
  10. $DB->query("
  11. SELECT UserID
  12. FROM torrents
  13. WHERE GroupID = $GroupID");
  14. if (!in_array($LoggedUser['ID'], $DB->collect('UserID'))) {
  15. error(403);
  16. }
  17. }
  18. if (check_perms('torrents_freeleech') && (isset($_POST['freeleech']) xor isset($_POST['neutralleech']) xor isset($_POST['unfreeleech']))) {
  19. if (isset($_POST['freeleech'])) {
  20. $Free = 1;
  21. } elseif (isset($_POST['neutralleech'])) {
  22. $Free = 2;
  23. } else {
  24. $Free = 0;
  25. }
  26. if (isset($_POST['freeleechtype']) && in_array($_POST['freeleechtype'], array(0, 1, 2, 3))) {
  27. $FreeType = $_POST['freeleechtype'];
  28. } else {
  29. error(404);
  30. }
  31. Torrents::freeleech_groups($GroupID, $Free, $FreeType);
  32. }
  33. $Artists = $_POST['idols'];
  34. //Escape fields
  35. $Studio = db_string($_POST['studio']);
  36. $Series = db_string($_POST['series']);
  37. $DLsiteID = db_string($_POST['dlsiteid']);
  38. $Year = db_string((int)$_POST['year']);
  39. $CatalogueNumber = db_string($_POST['catalogue']);
  40. $Pages = db_string($_POST['pages']);
  41. // Get some info for the group log
  42. $DB->query("
  43. SELECT Year
  44. FROM torrents_group
  45. WHERE ID = $GroupID");
  46. list($OldYear) = $DB->next_record();
  47. $DB->query("
  48. UPDATE torrents_group
  49. SET
  50. Year = '$Year',
  51. CatalogueNumber = '".$CatalogueNumber."',
  52. Pages = '".$Pages."',
  53. Studio = '$Studio',
  54. Series = '$Series',
  55. DLsiteID = '$DLsiteID'
  56. WHERE ID = $GroupID");
  57. if ($OldYear != $Year) {
  58. $DB->query("
  59. INSERT INTO group_log (GroupID, UserID, Time, Info)
  60. VALUES ('$GroupID', ".$LoggedUser['ID'].", '".sqltime()."', '".db_string("Year changed from $OldYear to $Year")."')");
  61. }
  62. $DB->query("
  63. SELECT ag.Name
  64. FROM artists_group AS ag
  65. JOIN torrents_artists AS ta ON ag.ArtistID = ta.ArtistID
  66. WHERE ta.GroupID = ".$GroupID);
  67. while ($r = $DB->next_record(MYSQLI_ASSOC, true)) {
  68. $CurrArtists[] = $r['Name'];
  69. }
  70. foreach ($Artists as $Artist) {
  71. if (!in_array($Artist, $CurrArtists)) {
  72. $DB->query("
  73. SELECT ArtistID
  74. FROM artists_group
  75. WHERE Name = '".db_string($Artist)."'");
  76. if ($DB->has_results()) {
  77. list($ArtistID) = $DB->next_record();
  78. } else {
  79. $DB->query("
  80. INSERT INTO artists_group
  81. (Name)
  82. VALUES
  83. ('".db_string($Artist)."')");
  84. $ArtistID = $DB->inserted_id();
  85. }
  86. $DB->query("
  87. INSERT INTO torrents_artists
  88. (GroupID, ArtistID, UserID)
  89. VALUES
  90. (".$GroupID.", ".$ArtistID.", ".$LoggedUser['ID'].")");
  91. $Cache->delete_value('artist_groups_'.$ArtistID);
  92. }
  93. }
  94. foreach ($CurrArtists as $CurrArtist) {
  95. if (!in_array($CurrArtist, $Artists)) {
  96. $DB->query("
  97. SELECT ArtistID
  98. FROM artists_group
  99. WHERE Name = '".db_string($CurrArtist)."'");
  100. if ($DB->has_results()) {
  101. list($ArtistID) = $DB->next_record();
  102. $DB->query("
  103. DELETE FROM torrents_artists
  104. WHERE ArtistID = ".$ArtistID."
  105. AND GroupID = ".$GroupID);
  106. $DB->query("
  107. SELECT GroupID
  108. FROM torrents_artists
  109. WHERE ArtistID = ".$ArtistID);
  110. $Cache->delete_value('artist_groups_'.$ArtistID);
  111. if (!$DB->has_results()) {
  112. $DB->query("
  113. SELECT RequestID
  114. FROM requests_artists
  115. WHERE ArtistID = ".$ArtistID."
  116. AND ArtistID != 0");
  117. if (!$DB->has_results()) {
  118. Artists::delete_artist($ArtistID);
  119. }
  120. }
  121. }
  122. }
  123. }
  124. $DB->query("
  125. SELECT ID
  126. FROM torrents
  127. WHERE GroupID = '$GroupID'");
  128. while (list($TorrentID) = $DB->next_record()) {
  129. $Cache->delete_value("torrent_download_$TorrentID");
  130. }
  131. Torrents::update_hash($GroupID);
  132. $Cache->delete_value("torrents_details_$GroupID");
  133. header("Location: torrents.php?id=$GroupID");
  134. ?>