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.

new_edit.php 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. <?php
  2. # todo: Fix multiple authors and bounty preview
  3. /*
  4. * Yeah, that's right, edit and new are the same place again.
  5. * It makes the page uglier to read but ultimately better as the alternative means
  6. * maintaining 2 copies of almost identical files.
  7. */
  8. $NewRequest = $_GET['action'] === 'new';
  9. if (!$NewRequest) {
  10. $RequestID = $_GET['id'];
  11. if (!is_number($RequestID)) {
  12. error(404);
  13. }
  14. }
  15. $Disabled = "";
  16. if ($NewRequest && ($LoggedUser['BytesUploaded'] < 250 * 1024 * 1024 || !check_perms('site_submit_requests'))) {
  17. error('You do not have enough uploaded to make a request');
  18. }
  19. if (!$NewRequest) {
  20. if (empty($ReturnEdit)) {
  21. $Request = Requests::get_request($RequestID);
  22. if ($Request === false) {
  23. error(404);
  24. }
  25. // Define these variables to simplify _GET['groupid'] requests later on
  26. $CategoryID = $Request['CategoryID'];
  27. $Title = $Request['Title'];
  28. $TitleRJ = $Request['TitleRJ'];
  29. $TitleJP = $Request['TitleJP'];
  30. $CatalogueNumber = $Request['CatalogueNumber'];
  31. $DLsiteID = $Request['DLsiteID'];
  32. $Image = $Request['Image'];
  33. $GroupID = $Request['GroupID'];
  34. $VoteArray = Requests::get_votes_array($RequestID);
  35. $VoteCount = count($VoteArray['Voters']);
  36. $IsFilled = !empty($Request['TorrentID']);
  37. $CategoryName = $Categories[$CategoryID - 1];
  38. $ProjectCanEdit = (check_perms('project_team') && !$IsFilled && $CategoryID === '0');
  39. $CanEdit = ((!$IsFilled && $LoggedUser['ID'] === $Request['UserID'] && $VoteCount < 2) || $ProjectCanEdit || check_perms('site_moderate_requests'));
  40. if (!$CanEdit) {
  41. error(403);
  42. }
  43. $ArtistForm = Requests::get_artists($RequestID);
  44. $Tags = implode(', ', $Request['Tags']);
  45. }
  46. }
  47. if ($NewRequest && !empty($_GET['artistid']) && is_number($_GET['artistid'])) {
  48. $DB->query("
  49. SELECT Name
  50. FROM artists_group
  51. WHERE artistid = ".$_GET['artistid']."
  52. LIMIT 1");
  53. list($ArtistName) = $DB->next_record();
  54. $ArtistForm = array(
  55. 1 => array(array('name' => trim($ArtistName))),
  56. );
  57. } elseif ($NewRequest && !empty($_GET['groupid']) && is_number($_GET['groupid'])) {
  58. $ArtistForm = Artists::get_artist($_GET['groupid']);
  59. $DB->query("
  60. SELECT
  61. tg.Name,
  62. tg.NameRJ,
  63. tg.NameJP,
  64. tg.Year,
  65. tg.Studio,
  66. tg.Series,
  67. tg.CatalogueNumber,
  68. tg.DLsiteID,
  69. tg.WikiImage,
  70. GROUP_CONCAT(t.Name SEPARATOR ', '),
  71. tg.CategoryID
  72. FROM torrents_group AS tg
  73. JOIN torrents_tags AS tt ON tt.GroupID = tg.ID
  74. JOIN tags AS t ON t.ID = tt.TagID
  75. WHERE tg.ID = ".$_GET['groupid']);
  76. if (list($Title, $TitleRJ, $TitleJP, $Year, $Studio, $Series, $CatalogueNumber, $DLsiteID, $Image, $Tags, $CategoryID) = $DB->next_record()) {
  77. $GroupID = trim($_REQUEST['groupid']);
  78. $CategoryName = $Categories[$CategoryID - 1];
  79. $Disabled = 'readonly="readonly"';
  80. }
  81. }
  82. View::show_header(($NewRequest ? 'Create Request' : 'Edit Request'), 'bbcode,requests,form_validate');
  83. ?>
  84. <!-- HTML title -->
  85. <div class="thin">
  86. <div class="header">
  87. <h2><?= ($NewRequest ? 'Create Request' : 'Edit Request') ?>
  88. </h2>
  89. </div>
  90. <!-- New request hidden fields -->
  91. <div class="box pad">
  92. <form action="" method="post" id="request_form" onsubmit="Calculate();">
  93. <div>
  94. <?php if (!$NewRequest) { ?>
  95. <input type="hidden" name="requestid"
  96. value="<?= $RequestID ?>" />
  97. <?php } ?>
  98. <input type="hidden" name="auth"
  99. value="<?= $LoggedUser['AuthKey'] ?>" />
  100. <input type="hidden" name="action"
  101. value="<?= ($NewRequest ? 'takenew' : 'takeedit') ?>" />
  102. </div>
  103. <!-- Main table -->
  104. <table class="layout">
  105. <tr>
  106. <td colspan="2" class="center">Please make sure your request follows the
  107. <a href="rules.php?p=requests">request rules</a>!</td>
  108. </tr>
  109. <?php if ($NewRequest || $CanEdit) { ?>
  110. <!-- Category -->
  111. <tr>
  112. <td class="label">
  113. Category
  114. <strong class="important_text">*</strong>
  115. </td>
  116. <td>
  117. <?php if (!empty($Disabled)) { ?>
  118. <input type="hidden" name="type"
  119. value="<?= $CategoryName ?>" />
  120. <select id="categories" name="type" onchange="Categories();" disabled="disabled">
  121. <?php } else { ?>
  122. <select id="categories" name="type" onchange="Categories();">
  123. <?php } ?>
  124. <?php foreach (Misc::display_array($Categories) as $Cat) { ?>
  125. <option value="<?= $Cat ?>" <?= (!empty($CategoryName) && ($CategoryName === $Cat) ? ' selected="selected"' : '') ?>><?=$Cat?>
  126. </option>
  127. <?php } ?>
  128. </select>
  129. </td>
  130. </tr>
  131. <!-- Catalogue number -->
  132. <tr id="cataloguenumber_tr">
  133. <td class="label">Accession Number</td>
  134. <td>
  135. <input type="text" id="catalogue" name="cataloguenumber" size="15"
  136. value="<?= (isset($CatalogueNumber)?$CatalogueNumber:'') ?>"
  137. <?= $Disabled ?>/>
  138. <?php if (empty($Disabled)) { ?>
  139. <input type="button" autofill="jav" value="Autofill" style="pointer-events: none; opacity: 0.5;"></input>
  140. <?php } ?>
  141. </td>
  142. </tr>
  143. <!-- Three title fields -->
  144. <tr>
  145. <td class="label">
  146. Torrent Title
  147. <strong class="important_text">*</strong>
  148. </td>
  149. <td>
  150. <input type="text" id="title" name="title" size="45"
  151. value="<?= (!empty($Title) ? $Title : '') ?>"
  152. <?= $Disabled ?>/>
  153. </td>
  154. </tr>
  155. <!-- 2 -->
  156. <tr>
  157. <td class="label">Organism</td>
  158. <td>
  159. <input type="text" id="title_rj" name="title_rj" size="45"
  160. value="<?= (!empty($TitleRJ) ? $TitleRJ : '') ?>"
  161. <?= $Disabled ?>/>
  162. </td>
  163. </tr>
  164. <!-- 3 -->
  165. <tr>
  166. <td class="label">Strain/Variety</td>
  167. <td>
  168. <input type="text" id="title_jp" name="title_jp" size="45"
  169. value="<?= !empty($TitleJP)?$TitleJP:'' ?>"
  170. <?= $Disabled ?>/>
  171. </td>
  172. </tr>
  173. <?php } # Ends if NewRequest line 123?>
  174. <!-- Multiple artists -->
  175. <tr id="artist_tr">
  176. <td class="label">
  177. Authors(s)
  178. <strong class="important_text">*</strong>
  179. </td>
  180. <td id="artistfields">
  181. <p id="vawarning" class="hidden">
  182. Please use the multiple artists feature rather than using "Various Artists."
  183. </p>
  184. <?php
  185. if (!empty($ArtistForm)) {
  186. $First = true;
  187. foreach ($ArtistForm as $Artist) {
  188. ?>
  189. <input type="text" id="artist_0" name="artists[]" <?php Users::has_autocomplete_enabled('other'); ?>
  190. size="45" value="<?=display_str($Artist['name']) ?>" <?=$Disabled?>/>
  191. <?php if (empty($Disabled)) {
  192. if ($First) { ?><a class="add_artist_button brackets">+</a> <a
  193. class="remove_artist_button brackets">&minus;</a><?php }
  194. $First = false;
  195. } ?>
  196. <br />
  197. <?php
  198. }
  199. } else {
  200. ?> <input type="text" id="artist_0" name="artists[]" <?php Users::has_autocomplete_enabled('other'); ?>
  201. size="45" <?=$Disabled?>/>
  202. <?php if (empty($Disabled)) { ?>
  203. <a class="add_artist_button brackets">+</a> <a class="remove_artist_button brackets">&minus;</a>
  204. <?php } ?>
  205. <?php
  206. }
  207. ?>
  208. </td>
  209. </tr>
  210. <!-- Picture -->
  211. <?php if ($NewRequest || $CanEdit) { ?>
  212. <tr id="image_tr">
  213. <td class="label">Picture</td>
  214. <td>
  215. <input type="text" id="image" name="image" size="45"
  216. value="<?= (!empty($Image) ? $Image : '') ?>"
  217. <?= $Disabled ?>/>
  218. </td>
  219. </tr>
  220. <?php } ?>
  221. <!-- Tags -->
  222. <tr>
  223. <td class="label">
  224. Tags
  225. <strong class="important_text">*</strong>
  226. </td>
  227. <td>
  228. <?php
  229. $GenreTags = $Cache->get_value('genre_tags');
  230. if (!$GenreTags) {
  231. $DB->query('
  232. SELECT Name
  233. FROM tags
  234. WHERE TagType = \'genre\'
  235. ORDER BY Name');
  236. $GenreTags = $DB->collect('Name');
  237. $Cache->cache_value('genre_tags', $GenreTags, 3600 * 6);
  238. }
  239. if (!empty($Disabled)) {
  240. ?>
  241. <select id="genre_tags" name="genre_tags" onchange="add_tag(); return false;" disabled="disabled">
  242. <?php
  243. } else { ?>
  244. <select id="genre_tags" name="genre_tags" onchange="add_tag(); return false;">
  245. <?php } ?>
  246. <option>---</option>
  247. <?php foreach (Misc::display_array($GenreTags) as $Genre) { ?>
  248. <option value="<?= $Genre ?>"><?= $Genre ?>
  249. </option>
  250. <?php } ?>
  251. </select>
  252. <input type="text" id="tags" name="tags" size="45"
  253. value="<?= (!empty($Tags) ? display_str($Tags) : '') ?>"
  254. <?php Users::has_autocomplete_enabled('other'); ?>
  255. <?= $Disabled ?>/>
  256. </td>
  257. </tr>
  258. <!-- Description -->
  259. <tr>
  260. <td class="label">
  261. Request Description
  262. <strong class="important_text">*</strong>
  263. </td>
  264. <td>
  265. <?php new TEXTAREA_PREVIEW('description', 'req_desc', $Request['Description']??''); ?>
  266. </td>
  267. </tr>
  268. <!-- Existing torrent groups -->
  269. <?php if (check_perms('site_moderate_requests')) { ?>
  270. <tr>
  271. <td class="label">Torrent Group</td>
  272. <td>
  273. If this request matches a torrent group <strong>already existing</strong> on the site, please indicate that
  274. here.<br />
  275. <?= site_url() ?>torrents.php?id=<input type="text"
  276. name="groupid"
  277. value="<?= isset($GroupID)?$GroupID:'' ?>"
  278. size="15" />
  279. </td>
  280. </tr>
  281. <?php
  282. } elseif (!empty($GroupID)
  283. #&& ($CategoryID !== 5) # ?
  284. #&& ($CategoryID !== 0) # ?
  285. ) {
  286. ?>
  287. <!-- Torrent group admin -->
  288. <tr>
  289. <td class="label">Torrent Group</td>
  290. <td>
  291. <a href="torrents.php?id=<?= $GroupID ?>"><?= site_url() ?>torrents.php?id=<?= $GroupID ?></a><br />
  292. This request <?= ($NewRequest ? 'will be' : 'is') ?>
  293. associated with the above torrent group.
  294. <?php if (!$NewRequest) { ?>
  295. If this is incorrect, please
  296. <a
  297. href="reports.php?action=report&amp;type=request&amp;id=<?= $RequestID ?>">report
  298. this request</a>
  299. so that staff can fix it.
  300. <?php } ?>
  301. <input type="hidden" name="groupid"
  302. value="<?= $GroupID ?>" />
  303. </td>
  304. </tr>
  305. <!-- Bounty -->
  306. <?php
  307. } if ($NewRequest) { ?>
  308. <tr id="voting">
  309. <td class="label">Bounty</td>
  310. <td>
  311. <input type="text" id="amount_box" size="8"
  312. value="<?= (!empty($Bounty) ? $Bounty : '100') ?>"
  313. onchange="Calculate();" />
  314. <select id="unit" name="unit" onchange="Calculate();">
  315. <option value="mb" <?= (!empty($_POST['unit']) && $_POST['unit'] === 'mb' ? ' selected="selected"' : '') ?>>MB
  316. </option>
  317. <option value="gb" <?= (!empty($_POST['unit']) && $_POST['unit'] === 'gb' ? ' selected="selected"' : '') ?>>GB
  318. </option>
  319. </select>
  320. <input type="button" value="Preview" onclick="Calculate();" />
  321. <strong>The system deducts <?= ($RequestTax * 100) ?>% as
  322. tax</strong>
  323. </td>
  324. </tr>
  325. <!-- New stats -->
  326. <tr>
  327. <td class="label">New Stats</td>
  328. <td>
  329. <input type="hidden" id="amount" name="amount"
  330. value="<?= (!empty($Bounty) ? $Bounty : '100') ?>" />
  331. <input type="hidden" id="current_uploaded"
  332. value="<?= $LoggedUser['BytesUploaded'] ?>" />
  333. <input type="hidden" id="current_downloaded"
  334. value="<?= $LoggedUser['BytesDownloaded'] ?>" />
  335. <ul>
  336. <!-- todo: Return this feature
  337. <li><strong>Bounty:</strong> <span id="bounty_after_tax">90.00 MB</span></li> -->
  338. <li><strong>Uploaded:</strong> <span id="new_uploaded"><?= Format::get_size($LoggedUser['BytesUploaded']) ?></span>
  339. </li>
  340. <li><strong>Ratio:</strong> <span id="new_ratio"><?= Format::get_ratio_html($LoggedUser['BytesUploaded'], $LoggedUser['BytesDownloaded']) ?></span>
  341. </li>
  342. </ul>
  343. </td>
  344. </tr>
  345. <!-- Submit -->
  346. <tr>
  347. <td colspan="2" class="center">
  348. <input type="submit" id="button" value="Create" disabled="disabled" />
  349. </td>
  350. </tr>
  351. <?php } else { ?>
  352. <tr>
  353. <td colspan="2" class="center">
  354. <input type="submit" id="button" value="Edit" />
  355. </td>
  356. </tr>
  357. <?php } ?>
  358. </table>
  359. </form>
  360. </div>
  361. </div>
  362. <?php
  363. View::show_footer();