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.

editgroup.php 8.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. <?php
  2. #declare(strict_types = 1);
  3. /************************************************************************
  4. ||------------|| Edit torrent group wiki page ||-----------------------||
  5. This page is the page that is displayed when someone feels like editing
  6. a torrent group's wiki page.
  7. It is called when $_GET['action'] === 'edit'. $_GET['groupid'] is the
  8. ID of the torrent group and must be set.
  9. The page inserts a new revision into the wiki_torrents table, and clears
  10. the cache for the torrent group page.
  11. ************************************************************************/
  12. $GroupID = $_GET['groupid'];
  13. if (!is_number($GroupID) || !$GroupID) {
  14. error(0);
  15. }
  16. // Get the torrent group name and the body of the last revision
  17. $DB->query("
  18. SELECT
  19. tg.`Name`,
  20. tg.`Title2`,
  21. tg.`NameJP`,
  22. wt.`Image`,
  23. wt.`Body`,
  24. tg.`WikiImage`,
  25. tg.`WikiBody`,
  26. tg.`Year`,
  27. tg.`Studio`,
  28. tg.`Series`,
  29. tg.`CatalogueNumber`,
  30. tg.`CategoryID`
  31. FROM
  32. `torrents_group` AS tg
  33. LEFT JOIN `wiki_torrents` AS wt
  34. ON
  35. wt.`RevisionID` = tg.`RevisionID`
  36. WHERE
  37. tg.`ID` = '".db_string($GroupID)."'
  38. ");
  39. if (!$DB->has_results()) {
  40. error(404);
  41. }
  42. list($Name, $Title2, $NameJP, $Image, $Body, $WikiImage, $WikiBody, $Year, $Studio, $Series, $CatalogueNumber, $CategoryID) = $DB->next_record();
  43. $DB->query("
  44. SELECT
  45. `ID`,
  46. `UserID`,
  47. `Time`,
  48. `URI`
  49. FROM
  50. `torrents_screenshots`
  51. WHERE
  52. TorrentID = '".db_string($TorrentID)."'
  53. ");
  54. if ($DB->has_results()) {
  55. $Screenshots = [];
  56. while ($S = $DB->next_record(MYSQLI_ASSOC, true)) {
  57. $Screenshots[] = $S;
  58. }
  59. }
  60. $Artists = Artists::get_artists(array($GroupID))[$GroupID];
  61. if (!$Body) {
  62. $Body = $WikiBody;
  63. $Image = $WikiImage;
  64. }
  65. View::show_header(
  66. 'Edit torrent group',
  67. 'upload,bbcode,vendor/easymde.min',
  68. 'vendor/easymde.min'
  69. );
  70. // Start printing form
  71. ?>
  72. <h2 class="header">
  73. Edit
  74. <a href="torrents.php?id=<?=$GroupID?>"><?=($Name ? $Name : ($Title2 ? $Title2 : $NameJP))?></a>
  75. </h2>
  76. <div class="box pad">
  77. <form class="edit_form" name="torrent_group" action="torrents.php" method="post">
  78. <input type="hidden" name="action" value="takegroupedit" />
  79. <input type="hidden" name="auth"
  80. value="<?=$LoggedUser['AuthKey']?>" />
  81. <input type="hidden" name="groupid" value="<?=$GroupID?>" />
  82. <h3>
  83. Picture
  84. </h3>
  85. <input type="text" name="image" size="92" value="<?=$Image?>" />
  86. <br /><br />
  87. <h3>
  88. Torrent Group Description
  89. </h3>
  90. <?php
  91. new TEXTAREA_PREVIEW(
  92. 'body', # $Name breaks "Rename (will not merge)"
  93. $ID = 'body',
  94. $Value = display_str($Body) ?? '',
  95. );
  96. $DB->query("
  97. SELECT
  98. `UserID`
  99. FROM
  100. `torrents`
  101. WHERE
  102. `GroupID` = '$GroupID'
  103. ");
  104. $Contributed = in_array($LoggedUser['ID'], $DB->collect('UserID'));
  105. ?>
  106. <h3>
  107. Edit Summary
  108. </h3>
  109. <input type="text" name="summary" size="92" />
  110. <br />
  111. <div class="center pad">
  112. <input type="submit" value="Submit" />
  113. </div>
  114. </form>
  115. </div>
  116. <?php
  117. if ($Contributed
  118. || check_perms('torrents_edit')
  119. || check_perms('screenshots_delete')
  120. || check_perms('screenshots_add')) { ?>
  121. <h2 id="screenshots_section">
  122. Publications
  123. </h2>
  124. <div class="box pad">
  125. <form class="edit_form" name="screenshots_form" action="torrents.php" method="post">
  126. <input type="hidden" name="action" value="screenshotedit" />
  127. <input type="hidden" name="auth"
  128. value="<?=$LoggedUser['AuthKey']?>" />
  129. <input type="hidden" name="groupid" value="<?=$GroupID?>" />
  130. <table cellpadding="3" cellspacing="1" border="0" class="layout" width="100%">
  131. <tr>
  132. <td class="label">
  133. Publications
  134. </td>
  135. <td id="screenshots">
  136. <?php
  137. if ($Contributed || check_perms('screenshots_add') || check_perms('torrents_edit')) { ?>
  138. <a class="float_right brackets" onclick="AddScreenshotField()">+</a>
  139. <?php } ?>
  140. </td>
  141. </tr>
  142. </table>
  143. <div class="center pad">
  144. <input type="submit" value="Submit" />
  145. </div>
  146. </form>
  147. </div>
  148. <?php
  149. }
  150. // Users can edit the group info if they've uploaded a torrent to the group or have torrents_edit
  151. if ($Contributed || check_perms('torrents_edit')) { ?>
  152. <h2>
  153. Non-wiki torrent group editing
  154. </h2>
  155. <div class="box pad">
  156. <form class="edit_form" name="torrent_group" action="torrents.php" method="post">
  157. <input type="hidden" name="action" value="nonwikiedit" />
  158. <input type="hidden" name="auth"
  159. value="<?=$LoggedUser['AuthKey']?>" />
  160. <input type="hidden" name="groupid" value="<?=$GroupID?>" />
  161. <table cellpadding="3" cellspacing="1" border="0" class="layout" width="100%">
  162. <tr>
  163. <td class="label">
  164. Author(s)
  165. </td>
  166. <td id="idolfields">
  167. <input type="text" id="idols_0" name="idols[]" size="45"
  168. value="<?=$Artists[0]['name']?>"
  169. <?php Users::has_autocomplete_enabled('other'); ?>/>
  170. <a class="add_artist_button brackets">+</a> <a class="remove_artist_button brackets">&minus;</a>
  171. <?php
  172. for ($i = 1; $i < count($Artists); $i++) {
  173. echo '<br /><input type="text" id="idol_'.$i.'" name="idols[]" size="45" value="'.$Artists[$i]['name'].'"/>';
  174. } ?>
  175. </td>
  176. </tr>
  177. <tr>
  178. <td class="label">
  179. Department/Lab
  180. </td>
  181. <td>
  182. <input type="text" id="studio" name="studio" size="60"
  183. value="<?=$Studio?>" />
  184. </td>
  185. </tr>
  186. <tr>
  187. <td class="label">
  188. Location
  189. </td>
  190. <td>
  191. <input type="text" id="series" name="series" size="60"
  192. value="<?=$Series?>" />
  193. </td>
  194. </tr>
  195. <tr>
  196. <td class="label">
  197. Year
  198. </td>
  199. <td>
  200. <input type="text" name="year" size="10"
  201. value="<?=$Year?>" />
  202. </td>
  203. </tr>
  204. <tr>
  205. <td class="label">
  206. Accession Number
  207. </td>
  208. <td>
  209. <input type="text" name="catalogue" size="40"
  210. value="<?=$CatalogueNumber?>" />
  211. </td>
  212. </tr>
  213. <?php if (check_perms('torrents_freeleech')) { ?>
  214. <tr>
  215. <td class="label">
  216. Torrent <strong>group</strong> leech status
  217. </td>
  218. <td>
  219. <input type="checkbox" id="unfreeleech" name="unfreeleech" /><label for="unfreeleech"> Reset</label>
  220. <input type="checkbox" id="freeleech" name="freeleech" /><label for="freeleech"> Freeleech</label>
  221. <input type="checkbox" id="neutralleech" name="neutralleech" /><label for="neutralleech"> Neutral
  222. Leech</label>
  223. because
  224. <select name="freeleechtype">
  225. <?php $FL = array('N/A', 'Staff Pick', 'Perma-FL', 'Freeleechizer', 'Site-Wide FL');
  226. foreach ($FL as $Key => $FLType) { ?>
  227. <option value="<?=$Key?>" <?=($Key == $Torrent['FreeLeechType'] ? ' selected="selected"' : '')?>><?=$FLType?>
  228. </option>
  229. <?php } ?>
  230. </select>
  231. </td>
  232. </tr>
  233. <?php } ?>
  234. </table>
  235. <div class="center pad">
  236. <input type="submit" value="Edit" />
  237. </div>
  238. </form>
  239. </div>
  240. <?php
  241. }
  242. if ($Contributed || check_perms('torrents_edit')) { ?>
  243. <h2>
  244. Rename (will not merge)
  245. </h2>
  246. <div class="box pad">
  247. <form class="rename_form" name="torrent_group" action="torrents.php" method="post">
  248. <table cellpadding="3" cellspacing="1" border="0" class="layout" width="100%">
  249. <input type="hidden" name="action" value="rename" />
  250. <input type="hidden" name="auth"
  251. value="<?=$LoggedUser['AuthKey']?>" />
  252. <input type="hidden" name="groupid" value="<?=$GroupID?>" />
  253. <tr>
  254. <td class="label">
  255. Torrent Title
  256. </td>
  257. <td>
  258. <input type="text" name="name" size="70"
  259. value="<?=$Name?>" />
  260. </td>
  261. </tr>
  262. <tr>
  263. <td class="label">
  264. Organism
  265. </td>
  266. <td>
  267. <input type="text" name="Title2" size="70"
  268. value="<?=$Title2?>" />
  269. </td>
  270. </tr>
  271. <tr>
  272. <td class="label">
  273. Strain/Variety
  274. </td>
  275. <td>
  276. <input type="text" name="namejp" size="70"
  277. value="<?=$NameJP?>" />
  278. </td>
  279. </tr>
  280. </table>
  281. <div class="center pad">
  282. <input type="submit" value="Rename" />
  283. </div>
  284. </form>
  285. </div>
  286. <?php
  287. }
  288. if (check_perms('torrents_edit')) { ?>
  289. <h2>
  290. Merge with another group
  291. </h2>
  292. <div class="box pad">
  293. <form class="merge_form" name="torrent_group" action="torrents.php" method="post">
  294. <input type="hidden" name="action" value="merge" />
  295. <input type="hidden" name="auth"
  296. value="<?=$LoggedUser['AuthKey']?>" />
  297. <input type="hidden" name="groupid" value="<?=$GroupID?>" />
  298. <h3>
  299. Target torrent group ID
  300. <input type="text" name="targetgroupid" size="10" />
  301. </h3>
  302. <div class="center pad">
  303. <input type="submit" value="Merge" />
  304. </div>
  305. </form>
  306. </div>
  307. <?php } ?>
  308. <?php View::show_footer();