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.

edit.php 7.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. <?php
  2. #declare(strict_types = 1);
  3. /**
  4. * Edit form
  5. *
  6. * This page relies on the TorrentForm class.
  7. * All it does is call the necessary functions.
  8. * At the bottom, there are grouping functions,
  9. * which are off limits to most members.
  10. */
  11. require_once SERVER_ROOT.'/classes/torrent_form.class.php';
  12. if (!is_number($_GET['id']) || !$_GET['id']) {
  13. error(400);
  14. }
  15. # DB query for the main torrent parameters
  16. # todo: Simplify based on unused tables
  17. $TorrentID = $_GET['id'];
  18. $DB->query("
  19. SELECT
  20. t.`Media`,
  21. t.`Container`,
  22. t.`Codec`,
  23. t.`Resolution`,
  24. t.`Version`,
  25. t.`Censored`,
  26. t.`Anonymous`,
  27. t.`Archive`,
  28. t.`FreeTorrent`,
  29. t.`FreeLeechType`,
  30. t.`Description` AS TorrentDescription,
  31. t.`FileList`,
  32. tg.`category_id`,
  33. tg.`title` AS title,
  34. tg.`subject` AS subject,
  35. tg.`object` AS object,
  36. tg.`published`,
  37. tg.`workgroup`,
  38. tg.`location`,
  39. tg.`identifier`,
  40. ag.`Name` AS ArtistName,
  41. t.`GroupID`,
  42. t.`UserID`,
  43. bt.`TorrentID` AS BadTags,
  44. bf.`TorrentID` AS BadFolders,
  45. bfi.`TorrentID` AS BadFiles
  46. FROM
  47. `torrents` AS t
  48. LEFT JOIN `torrents_group` AS tg
  49. ON
  50. tg.`id` = t.`GroupID`
  51. LEFT JOIN `torrents_artists` AS ta
  52. ON
  53. tg.`id` = ta.`GroupID`
  54. LEFT JOIN `artists_group` AS ag
  55. ON
  56. ag.`ArtistID` = ta.`ArtistID`
  57. LEFT JOIN `torrents_bad_tags` AS bt
  58. ON
  59. bt.`TorrentID` = t.`ID`
  60. LEFT JOIN `torrents_bad_folders` AS bf
  61. ON
  62. bf.`TorrentID` = t.`ID`
  63. LEFT JOIN `torrents_bad_files` AS bfi
  64. ON
  65. bfi.`TorrentID` = t.`ID`
  66. WHERE
  67. t.`ID` = '$TorrentID'
  68. ");
  69. # Error on no results
  70. list($Properties) = $DB->to_array(false, MYSQLI_BOTH);
  71. if (!$Properties) {
  72. error(404);
  73. }
  74. # Error on bad permissions
  75. $UploadForm = $Categories[$Properties['CategoryID'] - 1];
  76. if (($LoggedUser['ID'] !== $Properties['UserID']
  77. && !check_perms('torrents_edit'))
  78. || $LoggedUser['DisableWiki']) {
  79. error(403);
  80. }
  81. /**
  82. * Torrent Form
  83. *
  84. * This is the actual edit form.
  85. * Commenting only to see it better.
  86. */
  87. View::show_header('Edit torrent', 'upload,torrent,bbcode');
  88. $TorrentForm = new TorrentForm(
  89. $Torrent = $Properties,
  90. $Error = $Err,
  91. $NewTorrent = false
  92. );
  93. $TorrentForm->upload_form();
  94. /**
  95. * Moderator tools
  96. *
  97. * Various inlined tools to manage torrent grouping, etc.
  98. */
  99. if (check_perms('torrents_edit') || check_perms('users_mod')) { ?>
  100. <!-- Start HTML -->
  101. <!--
  102. Change Group
  103. -->
  104. <div class="header">
  105. <h2>Change Group</h2>
  106. </div>
  107. <div class="box pad">
  108. <form class="edit_form" name="torrent_group" action="torrents.php" method="post">
  109. <!-- Hidden values -->
  110. <input type="hidden" name="action" value="editgroupid" />
  111. <input type="hidden" name="auth"
  112. value="<?=$LoggedUser['AuthKey']?>" />
  113. <input type="hidden" name="torrentid" value="<?=$TorrentID?>" />
  114. <input type="hidden" name="oldgroupid"
  115. value="<?=$Properties['GroupID']?>" />
  116. <!-- Formlet table -->
  117. <table class="layout">
  118. <tr>
  119. <td class="label">
  120. Group ID
  121. </td>
  122. <td>
  123. <input type="text" name="groupid"
  124. value="<?=$Properties['GroupID']?>"
  125. size="10" />
  126. </td>
  127. </tr>
  128. <tr>
  129. <td colspan="2" class="center">
  130. <input type="submit" value="Change Group ID" />
  131. </td>
  132. </tr>
  133. </table>
  134. </form>
  135. </div> <!-- box pad -->
  136. <!--
  137. Split off into new group
  138. -->
  139. <h2 class="header">
  140. Split off into new group
  141. </h2>
  142. <div class="box pad">
  143. <form class="split_form" name="torrent_group" action="torrents.php" method="post">
  144. <!-- Hidden values -->
  145. <input type="hidden" name="action" value="newgroup" />
  146. <input type="hidden" name="auth"
  147. value="<?=$LoggedUser['AuthKey']?>" />
  148. <input type="hidden" name="torrentid" value="<?=$TorrentID?>" />
  149. <input type="hidden" name="oldgroupid"
  150. value="<?=$Properties['GroupID']?>" />
  151. <!-- Formlet table -->
  152. <table class="layout">
  153. <tr>
  154. <td class="label">
  155. Author
  156. </td>
  157. <td>
  158. <input type="text" name="artist"
  159. value="<?=$Properties['ArtistName']?>"
  160. size="50" />
  161. </td>
  162. </tr>
  163. <tr>
  164. <td class="label">
  165. Torrent Title
  166. </td>
  167. <td>
  168. <input type="text" name="title"
  169. value="<?=$Properties['Title']?>"
  170. size="50" />
  171. </td>
  172. </tr>
  173. <tr>
  174. <td class="label">
  175. Organism
  176. </td>
  177. <td>
  178. <input type="test" name="title_rj"
  179. value="<?=$Properties['Title2']?>"
  180. size=50" />
  181. </td>
  182. </tr>
  183. <tr>
  184. <td class="label">
  185. Strain/Variety
  186. </td>
  187. <td>
  188. <input type="test" name="title_jp"
  189. value="<?=$Properties['TitleJP']?>"
  190. size=50" />
  191. </td>
  192. </tr>
  193. <tr>
  194. <td class="label">
  195. Year
  196. </td>
  197. <td>
  198. <input type="text" name="year"
  199. value="<?=$Properties['Year']?>"
  200. size="10" />
  201. </td>
  202. </tr>
  203. <tr>
  204. <td colspan="2" class="center">
  205. <input type="submit" value="Split into new group" />
  206. </td>
  207. </tr>
  208. </table>
  209. </form>
  210. </div> <!-- box pad -->
  211. <?php
  212. if (check_perms('users_mod')) { ?>
  213. <!-- Change Category -->
  214. <h2>Change Category</h2>
  215. <div class="box pad">
  216. <form action="torrents.php" method="post">
  217. <input type="hidden" name="action" value="changecategory" />
  218. <input type="hidden" name="auth"
  219. value="<?=$LoggedUser['AuthKey']?>" />
  220. <input type="hidden" name="torrentid" value="<?=$TorrentID?>" />
  221. <input type="hidden" name="oldgroupid"
  222. value="<?=$Properties['GroupID']?>" />
  223. <input type="hidden" name="oldartistid"
  224. value="<?=$Properties['ArtistID']?>" />
  225. <input type="hidden" name="oldcategoryid"
  226. value="<?=$Properties['CategoryID']?>" />
  227. <table>
  228. <tr>
  229. <td class="label">Category</td>
  230. <td>
  231. <select id="newcategoryid" name="newcategoryid">
  232. <?php foreach ($Categories as $CatID => $CatName) { ?>
  233. <option value="<?=($CatID + 1)?>"
  234. <?Format::selected('CategoryID', $CatID + 1, 'selected', $Properties)?>><?=($CatName)?>
  235. </option>
  236. <?php } ?>
  237. </select>
  238. </td>
  239. </tr>
  240. <tr id="split_artist">
  241. <td class="label">Author</td>
  242. <td>
  243. <input type="text" name="artist"
  244. value="<?=$Properties['ArtistName']?>"
  245. size="50" />
  246. </td>
  247. </tr>
  248. <tr id="split_title">
  249. <td class="label">Torrent Title</td>
  250. <td>
  251. <input type="text" name="title"
  252. value="<?=$Properties['Title']?>"
  253. size="50" />
  254. </td>
  255. </tr>
  256. <tr id="split_year">
  257. <td class="label">Year</td>
  258. <td>
  259. <input type="text" name="year"
  260. value="<?=$Properties['Year']?>"
  261. size="10" />
  262. </td>
  263. </tr>
  264. <tr>
  265. <td colspan="2" class="center">
  266. <input type="submit" value="Change Category" />
  267. </td>
  268. </tr>
  269. </table>
  270. <script type="text/javascript">
  271. ChangeCategory($('#newcategoryid').raw().value);
  272. </script>
  273. </form>
  274. </div>
  275. <?php
  276. } ?>
  277. <?php
  278. } // if check_perms('torrents_edit')
  279. View::show_footer();