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 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <?php
  2. /*
  3. * Yeah, that's right, edit and new are the same place again.
  4. * It makes the page uglier to read but ultimately better as the alternative means
  5. * maintaining 2 copies of almost identical files.
  6. */
  7. $NewRequest = $_GET['action'] === 'new';
  8. if (!$NewRequest) {
  9. $RequestID = $_GET['id'];
  10. if (!is_number($RequestID)) {
  11. error(404);
  12. }
  13. }
  14. $Disabled = "";
  15. if ($NewRequest && ($LoggedUser['BytesUploaded'] < 250 * 1024 * 1024 || !check_perms('site_submit_requests'))) {
  16. error('You do not have enough uploaded to make a request.');
  17. }
  18. if (!$NewRequest) {
  19. if (empty($ReturnEdit)) {
  20. $Request = Requests::get_request($RequestID);
  21. if ($Request === false) {
  22. error(404);
  23. }
  24. // Define these variables to simplify _GET['groupid'] requests later on
  25. $CategoryID = $Request['CategoryID'];
  26. $Title = $Request['Title'];
  27. $TitleRJ = $Request['TitleRJ'];
  28. $TitleJP = $Request['TitleJP'];
  29. $CatalogueNumber = $Request['CatalogueNumber'];
  30. $DLsiteID = $Request['DLsiteID'];
  31. $Image = $Request['Image'];
  32. $GroupID = $Request['GroupID'];
  33. $VoteArray = Requests::get_votes_array($RequestID);
  34. $VoteCount = count($VoteArray['Voters']);
  35. $IsFilled = !empty($Request['TorrentID']);
  36. $CategoryName = $Categories[$CategoryID - 1];
  37. $ProjectCanEdit = (check_perms('project_team') && !$IsFilled && $CategoryID === '0');
  38. $CanEdit = ((!$IsFilled && $LoggedUser['ID'] === $Request['UserID'] && $VoteCount < 2) || $ProjectCanEdit || check_perms('site_moderate_requests'));
  39. if (!$CanEdit) {
  40. error(403);
  41. }
  42. $ArtistForm = Requests::get_artists($RequestID);
  43. $Tags = implode(', ', $Request['Tags']);
  44. }
  45. }
  46. if ($NewRequest && !empty($_GET['artistid']) && is_number($_GET['artistid'])) {
  47. $DB->query("
  48. SELECT Name
  49. FROM artists_group
  50. WHERE artistid = ".$_GET['artistid']."
  51. LIMIT 1");
  52. list($ArtistName) = $DB->next_record();
  53. $ArtistForm = array(
  54. 1 => array(array('name' => trim($ArtistName))),
  55. );
  56. } elseif ($NewRequest && !empty($_GET['groupid']) && is_number($_GET['groupid'])) {
  57. $ArtistForm = Artists::get_artist($_GET['groupid']);
  58. $DB->query("
  59. SELECT
  60. tg.Name,
  61. tg.NameRJ,
  62. tg.NameJP,
  63. tg.Year,
  64. tg.Studio,
  65. tg.Series,
  66. tg.CatalogueNumber,
  67. tg.DLsiteID,
  68. tg.WikiImage,
  69. GROUP_CONCAT(t.Name SEPARATOR ', '),
  70. tg.CategoryID
  71. FROM torrents_group AS tg
  72. JOIN torrents_tags AS tt ON tt.GroupID = tg.ID
  73. JOIN tags AS t ON t.ID = tt.TagID
  74. WHERE tg.ID = ".$_GET['groupid']);
  75. if (list($Title, $TitleRJ, $TitleJP, $Year, $Studio, $Series, $CatalogueNumber, $DLsiteID, $Image, $Tags, $CategoryID) = $DB->next_record()) {
  76. $GroupID = trim($_REQUEST['groupid']);
  77. $CategoryName = $Categories[$CategoryID - 1];
  78. $Disabled = 'readonly="readonly"';
  79. }
  80. }
  81. View::show_header(($NewRequest ? 'Create a request' : 'Edit a request'), 'bbcode,requests,form_validate');
  82. ?>
  83. <div class="thin">
  84. <div class="header">
  85. <h2><?=($NewRequest ? 'Create a request' : 'Edit a request')?></h2>
  86. </div>
  87. <div class="box pad">
  88. <form action="" method="post" id="request_form" onsubmit="Calculate();">
  89. <div>
  90. <?php if (!$NewRequest) { ?>
  91. <input type="hidden" name="requestid" value="<?=$RequestID?>" />
  92. <?php } ?>
  93. <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
  94. <input type="hidden" name="action" value="<?=($NewRequest ? 'takenew' : 'takeedit')?>" />
  95. </div>
  96. <table class="layout">
  97. <tr>
  98. <td colspan="2" class="center">Please make sure your request follows <a href="rules.php?p=requests">the request rules</a>!</td>
  99. </tr>
  100. <?php if ($NewRequest || $CanEdit) { ?>
  101. <tr>
  102. <td class="label tooltip" title="What alphabet the sequence uses, n.b., plasmids fit in the Other category">Type</td>
  103. <td>
  104. <?php if (!empty($Disabled)) { ?>
  105. <input type="hidden" name="type" value="<?=$CategoryName?>" />
  106. <select id="categories" name="type" onchange="Categories();" disabled="disabled">
  107. <?php } else { ?>
  108. <select id="categories" name="type" onchange="Categories();">
  109. <?php } ?>
  110. <?php foreach (Misc::display_array($Categories) as $Cat) { ?>
  111. <option value="<?=$Cat?>"<?=(!empty($CategoryName) && ($CategoryName === $Cat) ? ' selected="selected"' : '')?>><?=$Cat?></option>
  112. <?php } ?>
  113. </select>
  114. </td>
  115. </tr>
  116. <tr id="cataloguenumber_tr">
  117. <td class="label">Accession Number</td>
  118. <td>
  119. <input type="text" id="catalogue" name="cataloguenumber" size="15" value="<?=(isset($CatalogueNumber)?$CatalogueNumber:'') ?>" <?=$Disabled?>/>
  120. <?php if (empty($Disabled)) { ?>
  121. <input type="button" autofill="jav" value="Autofill"></input>
  122. <?php } ?>
  123. </td>
  124. </tr>
  125. <tr id="artist_tr">
  126. <td class="label">Collaborator(s)</td>
  127. <td id="artistfields">
  128. <p id="vawarning" class="hidden">Please use the multiple artists feature rather than adding "Various Artists" as an artist; read <a href="wiki.php?action=article&amp;id=369">this</a> for more information.</p>
  129. <?php
  130. if (!empty($ArtistForm)) {
  131. $First = true;
  132. foreach ($ArtistForm as $Artist) {
  133. ?>
  134. <input type="text" id="artist_0" name="artists[]"<?php Users::has_autocomplete_enabled('other'); ?> size="45" value="<?=display_str($Artist['name']) ?>" <?=$Disabled?>/>
  135. <?php if (empty($Disabled)) {
  136. if ($First) { ?><a class="add_artist_button brackets">+</a> <a class="remove_artist_button brackets">&minus;</a><?php }
  137. $First = false;
  138. } ?>
  139. <br />
  140. <?php
  141. }
  142. } else {
  143. ?> <input type="text" id="artist_0" name="artists[]"<?php Users::has_autocomplete_enabled('other'); ?> size="45" <?=$Disabled?>/>
  144. <?php if (empty($Disabled)) { ?>
  145. <a class="add_artist_button brackets">+</a> <a class="remove_artist_button brackets">&minus;</a>
  146. <?php } ?>
  147. <?php
  148. }
  149. ?>
  150. </td>
  151. </tr>
  152. <tr>
  153. <td class="label tooltip" title="FASTA definition line, e.g., Alcohol dehydrogenase ADH1">Sequence Name</td>
  154. <td>
  155. <input type="text" id="title" name="title" size="45" value="<?=(!empty($Title) ? $Title : '')?>" <?=$Disabled?>/>
  156. </td>
  157. </tr>
  158. <tr>
  159. <td class="label tooltip" title="FASTA organism line binomial nomenclature, e.g., Saccharomyces cerevisiae">Organism</td>
  160. <td>
  161. <input type="text" id="title_rj" name="title_rj" size="45" value="<?=(!empty($TitleRJ) ? $TitleRJ : '')?>" <?=$Disabled?>/>
  162. </td>
  163. </tr>
  164. <tr>
  165. <td class="label tooltip" title="FASTA organism line if applicable, e.g., S288C">Strain/Variety</td>
  166. <td>
  167. <input type="text" id="title_jp" name="title_jp" size="45" value="<?=!empty($TitleJP)?$TitleJP:''?>" <?=$Disabled?>/>
  168. </td>
  169. </tr>
  170. <?php } ?>
  171. <?php if ($NewRequest || $CanEdit) { ?>
  172. <tr id="image_tr">
  173. <td class="label tooltip" title="A meaningful picture, e.g., of the specimen">Picture</td>
  174. <td>
  175. <input type="text" id="image" name="image" size="45" value="<?=(!empty($Image) ? $Image : '')?>" <?=$Disabled?>/>
  176. </td>
  177. </tr>
  178. <?php } ?>
  179. <tr>
  180. <td class="label tooltip" title="Comma-seperated list of tags, n.b., use vanity.house for data you produced">Tags</td>
  181. <td>
  182. <?php
  183. $GenreTags = $Cache->get_value('genre_tags');
  184. if (!$GenreTags) {
  185. $DB->query('
  186. SELECT Name
  187. FROM tags
  188. WHERE TagType = \'genre\'
  189. ORDER BY Name');
  190. $GenreTags = $DB->collect('Name');
  191. $Cache->cache_value('genre_tags', $GenreTags, 3600 * 6);
  192. }
  193. if (!empty($Disabled)) {
  194. ?>
  195. <select id="genre_tags" name="genre_tags" onchange="add_tag(); return false;" disabled="disabled">
  196. <?php
  197. } else { ?>
  198. <select id="genre_tags" name="genre_tags" onchange="add_tag(); return false;" >
  199. <?php } ?>
  200. <option>---</option>
  201. <?php foreach (Misc::display_array($GenreTags) as $Genre) { ?>
  202. <option value="<?=$Genre?>"><?=$Genre?></option>
  203. <?php } ?>
  204. </select>
  205. <input type="text" id="tags" name="tags" size="45" value="<?=(!empty($Tags) ? display_str($Tags) : '')?>"<?php Users::has_autocomplete_enabled('other'); ?> <?=$Disabled?>/>
  206. </td>
  207. </tr>
  208. <?php if ($NewRequest || $CanEdit) { ?>
  209. <?php } ?>
  210. <tr>
  211. <td class="label">Description</td>
  212. <td>
  213. <?php new TEXTAREA_PREVIEW('description', 'req_desc', $Request['Description']??''); ?>
  214. </td>
  215. </tr>
  216. <?php if (check_perms('site_moderate_requests')) { ?>
  217. <tr>
  218. <td class="label">Torrent Group</td>
  219. <td>
  220. <?=site_url()?>torrents.php?id=<input type="text" name="groupid" value="<?=isset($GroupID)?$GroupID:''?>" size="15"/><br />
  221. If this request matches a torrent group <strong>already existing</strong> on the site, please indicate that here.
  222. </td>
  223. </tr>
  224. <?php } elseif (!empty($GroupID) && ($CategoryID !== 5) && ($CategoryID !== 0)) { ?>
  225. <tr>
  226. <td class="label">Torrent Group</td>
  227. <td>
  228. <a href="torrents.php?id=<?=$GroupID?>"><?=site_url()?>torrents.php?id=<?=$GroupID?></a><br />
  229. This request <?=($NewRequest ? 'will be' : 'is')?> associated with the above torrent group.
  230. <?php if (!$NewRequest) { ?>
  231. If this is incorrect, please <a href="reports.php?action=report&amp;type=request&amp;id=<?=$RequestID?>">report this request</a> so that staff can fix it.
  232. <?php } ?>
  233. <input type="hidden" name="groupid" value="<?=$GroupID?>" />
  234. </td>
  235. </tr>
  236. <?php }
  237. if ($NewRequest) { ?>
  238. <tr id="voting">
  239. <td class="label tooltip" title="How much upload credit the fulfiller wins">Bounty</td>
  240. <td>
  241. <input type="text" id="amount_box" size="8" value="<?=(!empty($Bounty) ? $Bounty : '100')?>" onchange="Calculate();" />
  242. <select id="unit" name="unit" onchange="Calculate();">
  243. <option value="mb"<?=(!empty($_POST['unit']) && $_POST['unit'] === 'mb' ? ' selected="selected"' : '') ?>>MB</option>
  244. <option value="gb"<?=(!empty($_POST['unit']) && $_POST['unit'] === 'gb' ? ' selected="selected"' : '') ?>>GB</option>
  245. </select>
  246. <input type="button" value="Preview" onclick="Calculate();" />
  247. <strong><?=($RequestTax * 100)?>% of this is deducted as tax by the system.</strong>
  248. </td>
  249. </tr>
  250. <tr>
  251. <td class="label">Post-Request Information</td>
  252. <td>
  253. <input type="hidden" id="amount" name="amount" value="<?=(!empty($Bounty) ? $Bounty : '100')?>" />
  254. <input type="hidden" id="current_uploaded" value="<?=$LoggedUser['BytesUploaded']?>" />
  255. <input type="hidden" id="current_downloaded" value="<?=$LoggedUser['BytesDownloaded']?>" />
  256. Bounty after tax: <strong><span id="bounty_after_tax">90.00 MB</span></strong><br />
  257. If you add the entered <strong><span id="new_bounty">100.00 MB</span></strong> of bounty, your new stats will be: <br />
  258. Uploaded: <span id="new_uploaded"><?=Format::get_size($LoggedUser['BytesUploaded'])?></span><br />
  259. Ratio: <span id="new_ratio"><?=Format::get_ratio_html($LoggedUser['BytesUploaded'], $LoggedUser['BytesDownloaded'])?></span>
  260. </td>
  261. </tr>
  262. <tr>
  263. <td colspan="2" class="center">
  264. <input type="submit" id="button" value="Create request" disabled="disabled" />
  265. </td>
  266. </tr>
  267. <?php } else { ?>
  268. <tr>
  269. <td colspan="2" class="center">
  270. <input type="submit" id="button" value="Edit request" />
  271. </td>
  272. </tr>
  273. <?php } ?>
  274. </table>
  275. </form>
  276. </div>
  277. </div>
  278. <?php
  279. View::show_footer();