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.

new_edit.php 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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. if ($CategoryName != 'Other') {
  43. $ArtistForm = Requests::get_artists($RequestID);
  44. }
  45. $Tags = implode(', ', $Request['Tags']);
  46. }
  47. }
  48. if ($NewRequest && !empty($_GET['artistid']) && is_number($_GET['artistid'])) {
  49. $DB->query("
  50. SELECT Name
  51. FROM artists_group
  52. WHERE artistid = ".$_GET['artistid']."
  53. LIMIT 1");
  54. list($ArtistName) = $DB->next_record();
  55. $ArtistForm = array(
  56. 1 => array(array('name' => trim($ArtistName))),
  57. );
  58. } elseif ($NewRequest && !empty($_GET['groupid']) && is_number($_GET['groupid'])) {
  59. $ArtistForm = Artists::get_artist($_GET['groupid']);
  60. $DB->query("
  61. SELECT
  62. tg.Name,
  63. tg.NameRJ,
  64. tg.NameJP,
  65. tg.Year,
  66. tg.Studio,
  67. tg.Series,
  68. tg.CatalogueNumber,
  69. tg.DLsiteID,
  70. tg.WikiImage,
  71. GROUP_CONCAT(t.Name SEPARATOR ', '),
  72. tg.CategoryID
  73. FROM torrents_group AS tg
  74. JOIN torrents_tags AS tt ON tt.GroupID = tg.ID
  75. JOIN tags AS t ON t.ID = tt.TagID
  76. WHERE tg.ID = ".$_GET['groupid']);
  77. if (list($Title, $TitleRJ, $TitleJP, $Year, $Studio, $Series, $CatalogueNumber, $DLsiteID, $Image, $Tags, $CategoryID) = $DB->next_record()) {
  78. $GroupID = trim($_REQUEST['groupid']);
  79. $CategoryName = $Categories[$CategoryID - 1];
  80. $Disabled = 'readonly="readonly"';
  81. }
  82. }
  83. View::show_header(($NewRequest ? 'Create a request' : 'Edit a request'), 'requests,form_validate');
  84. ?>
  85. <div class="thin">
  86. <div class="header">
  87. <h2><?=($NewRequest ? 'Create a request' : 'Edit a request')?></h2>
  88. </div>
  89. <div class="box pad">
  90. <form action="" method="post" id="request_form" onsubmit="Calculate();">
  91. <div>
  92. <? if (!$NewRequest) { ?>
  93. <input type="hidden" name="requestid" value="<?=$RequestID?>" />
  94. <? } ?>
  95. <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
  96. <input type="hidden" name="action" value="<?=($NewRequest ? 'takenew' : 'takeedit')?>" />
  97. </div>
  98. <table class="layout">
  99. <tr>
  100. <td colspan="2" class="center">Please make sure your request follows <a href="rules.php?p=requests">the request rules</a>!</td>
  101. </tr>
  102. <? if ($NewRequest || $CanEdit) { ?>
  103. <tr>
  104. <td class="label">
  105. Type
  106. </td>
  107. <td>
  108. <? if (!empty($Disabled)) { ?>
  109. <input type="hidden" name="type" value="<?=$CategoryName?>" />
  110. <select id="categories" name="type" onchange="Categories();" disabled="disabled">
  111. <? } else { ?>
  112. <select id="categories" name="type" onchange="Categories();">
  113. <? } ?>
  114. <? foreach (Misc::display_array($Categories) as $Cat) { ?>
  115. <option value="<?=$Cat?>"<?=(!empty($CategoryName) && ($CategoryName === $Cat) ? ' selected="selected"' : '')?>><?=$Cat?></option>
  116. <? } ?>
  117. </select>
  118. </td>
  119. </tr>
  120. <tr id="cataloguenumber_tr">
  121. <td class="label">Catalogue Number</td>
  122. <td>
  123. <input type="text" id="catalogue" name="cataloguenumber" size="15" value="<?=(isset($CatalogueNumber)?$CatalogueNumber:'') ?>" <?=$Disabled?>/>
  124. <? if (empty($Disabled)) { ?>
  125. ( <input type="button" autofill="jav" value="Autofill" style="font-size:0.8em;"></input> )
  126. <? } ?>
  127. </td>
  128. </tr>
  129. <tr id="artist_tr">
  130. <td class="label">Artist(s)</td>
  131. <td id="artistfields">
  132. <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>
  133. <?
  134. if (!empty($ArtistForm)) {
  135. $First = true;
  136. foreach ($ArtistForm as $Artist) {
  137. ?>
  138. <input type="text" id="artist_0" name="artists[]"<? Users::has_autocomplete_enabled('other'); ?> size="45" value="<?=display_str($Artist['name']) ?>" <?=$Disabled?>/>
  139. <? if (empty($Disabled)) { if ($First) { ?><a href="#" onclick="AddArtistField(); return false;" class="brackets">+</a> <a href="#" onclick="RemoveArtistField(); return false;" class="brackets">&minus;</a><? } $First = false; } ?>
  140. <br />
  141. <?
  142. }
  143. } else {
  144. ?> <input type="text" id="artist_0" name="artists[]"<? Users::has_autocomplete_enabled('other'); ?> size="45" onblur="CheckVA();" <?=$Disabled?>/>
  145. <? if (empty($Disabled)) { ?>
  146. <a href="#" onclick="AddArtistField(); return false;" class="brackets">+</a> <a href="#" onclick="RemoveArtistField(); return false;" class="brackets">&minus;</a>
  147. <? } ?>
  148. <?
  149. }
  150. ?>
  151. </td>
  152. </tr>
  153. <tr>
  154. <td class="label">Title</td>
  155. <td>
  156. <input type="text" id="title" name="title" size="45" value="<?=(!empty($Title) ? $Title : '')?>" <?=$Disabled?>/>
  157. </td>
  158. </tr>
  159. <tr>
  160. <td class="label">Romaji Title</td>
  161. <td>
  162. <input type="text" id="title_rj" name="title_rj" size="45" value="<?=(!empty($TitleRJ) ? $TitleRJ : '')?>" <?=$Disabled?>/>
  163. </td>
  164. </tr>
  165. <tr>
  166. <td class="label">Japanese Title</td>
  167. <td>
  168. <input type="text" id="title_jp" name="title_jp" size="45" value="<?=!empty($TitleJP)?$TitleJP:''?>" <?=$Disabled?>/>
  169. </td>
  170. </tr>
  171. <tr id="dlsiteid_tr">
  172. <td class="label">DLSite ID</td>
  173. <td>
  174. <input type="text" id="dlsiteid" name="dlsiteid" size="15" value="<?=isset($DLsiteID)?$DLsiteID:''?>" <?=$Disabled?>/>
  175. </td>
  176. </tr>
  177. <? } ?>
  178. <? if ($NewRequest || $CanEdit) { ?>
  179. <tr id="image_tr">
  180. <td class="label">Image</td>
  181. <td>
  182. <input type="text" id="image" name="image" size="45" value="<?=(!empty($Image) ? $Image : '')?>" <?=$Disabled?>/>
  183. </td>
  184. </tr>
  185. <? } ?>
  186. <tr>
  187. <td class="label">Tags</td>
  188. <td>
  189. <?
  190. $GenreTags = $Cache->get_value('genre_tags');
  191. if (!$GenreTags) {
  192. $DB->query('
  193. SELECT Name
  194. FROM tags
  195. WHERE TagType = \'genre\'
  196. ORDER BY Name');
  197. $GenreTags = $DB->collect('Name');
  198. $Cache->cache_value('genre_tags', $GenreTags, 3600 * 6);
  199. }
  200. if (!empty($Disabled)) {
  201. ?>
  202. <select id="genre_tags" name="genre_tags" onchange="add_tag(); return false;" disabled="disabled">
  203. <? } else { ?>
  204. <select id="genre_tags" name="genre_tags" onchange="add_tag(); return false;" >
  205. <? } ?>
  206. <option>---</option>
  207. <? foreach (Misc::display_array($GenreTags) as $Genre) { ?>
  208. <option value="<?=$Genre?>"><?=$Genre?></option>
  209. <? } ?>
  210. </select>
  211. <input type="text" id="tags" name="tags" size="45" value="<?=(!empty($Tags) ? display_str($Tags) : '')?>"<? Users::has_autocomplete_enabled('other'); ?> <?=$Disabled?>/>
  212. <br />
  213. Tags should be comma-separated, and you should use a period (".") to separate words inside a tag&#8202;&mdash;&#8202;e.g. "<strong class="important_text_alt">big.breasts</strong>".
  214. <br /><br />
  215. There is a list of official tags to the left of the text box. Please use these tags instead of "unofficial" tags (e.g. use the official "<strong class="important_text_alt">nakadashi</strong>" tag, instead of an unofficial "<strong class="important_text">creampie</strong>" tag.).
  216. </td>
  217. </tr>
  218. <? if ($NewRequest || $CanEdit) { ?>
  219. <? } ?>
  220. <tr>
  221. <td class="label">Description</td>
  222. <td>
  223. <textarea id="req_desc" name="description" cols="70" rows="7"><?=(!empty($Request['Description']) ? $Request['Description'] : '')?></textarea> <br />
  224. </td>
  225. </tr>
  226. <? if (check_perms('site_moderate_requests')) { ?>
  227. <tr>
  228. <td class="label">Torrent group</td>
  229. <td>
  230. <?=site_url()?>torrents.php?id=<input type="text" name="groupid" value="<?=isset($GroupID)?$GroupID:''?>" size="15"/><br />
  231. If this request matches a torrent group <span style="font-weight: bold;">already existing</span> on the site, please indicate that here.
  232. </td>
  233. </tr>
  234. <? } elseif (!empty($GroupID) && ($CategoryID != 5) && ($CategoryID != 0)) { ?>
  235. <tr>
  236. <td class="label">Torrent group</td>
  237. <td>
  238. <a href="torrents.php?id=<?=$GroupID?>"><?=site_url()?>torrents.php?id=<?=$GroupID?></a><br />
  239. This request <?=($NewRequest ? 'will be' : 'is')?> associated with the above torrent group.
  240. <? if (!$NewRequest) { ?>
  241. 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.
  242. <? } ?>
  243. <input type="hidden" name="groupid" value="<?=$GroupID?>" />
  244. </td>
  245. </tr>
  246. <? }
  247. if ($NewRequest) { ?>
  248. <tr id="voting">
  249. <td class="label">Bounty (MB)</td>
  250. <td>
  251. <input type="text" id="amount_box" size="8" value="<?=(!empty($Bounty) ? $Bounty : '100')?>" onchange="Calculate();" />
  252. <select id="unit" name="unit" onchange="Calculate();">
  253. <option value="mb"<?=(!empty($_POST['unit']) && $_POST['unit'] === 'mb' ? ' selected="selected"' : '') ?>>MB</option>
  254. <option value="gb"<?=(!empty($_POST['unit']) && $_POST['unit'] === 'gb' ? ' selected="selected"' : '') ?>>GB</option>
  255. </select>
  256. <input type="button" value="Preview" onclick="Calculate();" />
  257. <strong><?=($RequestTax * 100)?>% of this is deducted as tax by the system.</strong>
  258. </td>
  259. </tr>
  260. <tr>
  261. <td class="label">Post request information</td>
  262. <td>
  263. <input type="hidden" id="amount" name="amount" value="<?=(!empty($Bounty) ? $Bounty : '100')?>" />
  264. <input type="hidden" id="current_uploaded" value="<?=$LoggedUser['BytesUploaded']?>" />
  265. <input type="hidden" id="current_downloaded" value="<?=$LoggedUser['BytesDownloaded']?>" />
  266. Bounty after tax: <strong><span id="bounty_after_tax">90.00 MB</span></strong><br />
  267. If you add the entered <strong><span id="new_bounty">100.00 MB</span></strong> of bounty, your new stats will be: <br />
  268. Uploaded: <span id="new_uploaded"><?=Format::get_size($LoggedUser['BytesUploaded'])?></span><br />
  269. Ratio: <span id="new_ratio"><?=Format::get_ratio_html($LoggedUser['BytesUploaded'], $LoggedUser['BytesDownloaded'])?></span>
  270. </td>
  271. </tr>
  272. <tr>
  273. <td colspan="2" class="center">
  274. <input type="submit" id="button" value="Create request" disabled="disabled" />
  275. </td>
  276. </tr>
  277. <? } else { ?>
  278. <tr>
  279. <td colspan="2" class="center">
  280. <input type="submit" id="button" value="Edit request" />
  281. </td>
  282. </tr>
  283. <? } ?>
  284. </table>
  285. </form>
  286. <script type="text/javascript"><?=$NewRequest ? " Calculate();" : '' ?></script>
  287. <script type="text/javascript">Categories();</script>
  288. </div>
  289. </div>
  290. <?
  291. View::show_footer();
  292. ?>