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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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. $TitleJP = $Request['TitleJP'];
  28. $CatalogueNumber = $Request['CatalogueNumber'];
  29. $DLsiteID = $Request['DLsiteID'];
  30. $Image = $Request['Image'];
  31. $GroupID = $Request['GroupID'];
  32. $VoteArray = Requests::get_votes_array($RequestID);
  33. $VoteCount = count($VoteArray['Voters']);
  34. $IsFilled = !empty($Request['TorrentID']);
  35. $CategoryName = $Categories[$CategoryID - 1];
  36. $ProjectCanEdit = (check_perms('project_team') && !$IsFilled && $CategoryID === '0');
  37. $CanEdit = ((!$IsFilled && $LoggedUser['ID'] === $Request['UserID'] && $VoteCount < 2) || $ProjectCanEdit || check_perms('site_moderate_requests'));
  38. if (!$CanEdit) {
  39. error(403);
  40. }
  41. if ($CategoryName != 'Other') {
  42. $ArtistForm = Requests::get_artists($RequestID);
  43. }
  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.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, $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'), '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. <? if (!$NewRequest) { ?>
  91. <input type="hidden" name="requestid" value="<?=$RequestID?>" />
  92. <? } ?>
  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. <? if ($NewRequest || $CanEdit) { ?>
  101. <tr>
  102. <td class="label">
  103. Type
  104. </td>
  105. <td>
  106. <? if (!empty($Disabled)) { ?>
  107. <input type="hidden" name="type" value="<?=$CategoryName?>" />
  108. <select id="categories" name="type" onchange="Categories();" disabled="disabled">
  109. <? } else { ?>
  110. <select id="categories" name="type" onchange="Categories();">
  111. <? } ?>
  112. <? foreach (Misc::display_array($Categories) as $Cat) { ?>
  113. <option value="<?=$Cat?>"<?=(!empty($CategoryName) && ($CategoryName === $Cat) ? ' selected="selected"' : '')?>><?=$Cat?></option>
  114. <? } ?>
  115. </select>
  116. </td>
  117. </tr>
  118. <tr id="cataloguenumber_tr">
  119. <td class="label">Catalogue Number</td>
  120. <td>
  121. <input type="text" id="catalogue" name="cataloguenumber" size="15" value="<?=(isset($CatalogueNumber)?$CatalogueNumber:'') ?>" <?=$Disabled?>/>
  122. <? if (empty($Disabled)) { ?>
  123. ( <input type="button" autofill="jav" value="Autofill" style="font-size:0.8em;"></input> )
  124. <? } ?>
  125. </td>
  126. </tr>
  127. <tr id="artist_tr">
  128. <td class="label">Artist(s)</td>
  129. <td id="artistfields">
  130. <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>
  131. <?
  132. if (!empty($ArtistForm)) {
  133. $First = true;
  134. foreach ($ArtistForm as $Artist) {
  135. ?>
  136. <input type="text" id="artist_0" name="artists[]"<? Users::has_autocomplete_enabled('other'); ?> size="45" value="<?=display_str($Artist['name']) ?>" <?=$Disabled?>/>
  137. <? 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; } ?>
  138. <br />
  139. <?
  140. }
  141. } else {
  142. ?> <input type="text" id="artist_0" name="artists[]"<? Users::has_autocomplete_enabled('other'); ?> size="45" onblur="CheckVA();" <?=$Disabled?>/>
  143. <? if (empty($Disabled)) { ?>
  144. <a href="#" onclick="AddArtistField(); return false;" class="brackets">+</a> <a href="#" onclick="RemoveArtistField(); return false;" class="brackets">&minus;</a>
  145. <? } ?>
  146. <?
  147. }
  148. ?>
  149. </td>
  150. </tr>
  151. <tr>
  152. <td class="label">Title</td>
  153. <td>
  154. <input type="text" id="title" name="title" size="45" value="<?=(!empty($Title) ? $Title : '')?>" <?=$Disabled?>/>
  155. </td>
  156. </tr>
  157. <tr>
  158. <td class="label">Japanese Title</td>
  159. <td>
  160. <input type="text" id="title_jp" name="title_jp" size="45" value="<?=isset($TitleJP)?$TitleJP:''?>" <?=$Disabled?>/>
  161. </td>
  162. </tr>
  163. <tr id="dlsiteid_tr">
  164. <td class="label">DLSite ID</td>
  165. <td>
  166. <input type="text" id="dlsiteid" name="dlsiteid" size="15" value="<?=isset($DLsiteID)?$DLsiteID:''?>" <?=$Disabled?>/>
  167. </td>
  168. </tr>
  169. <? } ?>
  170. <? if ($NewRequest || $CanEdit) { ?>
  171. <tr id="image_tr">
  172. <td class="label">Image</td>
  173. <td>
  174. <input type="text" id="image" name="image" size="45" value="<?=(!empty($Image) ? $Image : '')?>" <?=$Disabled?>/>
  175. </td>
  176. </tr>
  177. <? } ?>
  178. <tr>
  179. <td class="label">Tags</td>
  180. <td>
  181. <?
  182. $GenreTags = $Cache->get_value('genre_tags');
  183. if (!$GenreTags) {
  184. $DB->query('
  185. SELECT Name
  186. FROM tags
  187. WHERE TagType = \'genre\'
  188. ORDER BY Name');
  189. $GenreTags = $DB->collect('Name');
  190. $Cache->cache_value('genre_tags', $GenreTags, 3600 * 6);
  191. }
  192. if (!empty($Disabled)) {
  193. ?>
  194. <select id="genre_tags" name="genre_tags" onchange="add_tag(); return false;" disabled="disabled">
  195. <? } else { ?>
  196. <select id="genre_tags" name="genre_tags" onchange="add_tag(); return false;" >
  197. <? } ?>
  198. <option>---</option>
  199. <? foreach (Misc::display_array($GenreTags) as $Genre) { ?>
  200. <option value="<?=$Genre?>"><?=$Genre?></option>
  201. <? } ?>
  202. </select>
  203. <input type="text" id="tags" name="tags" size="45" value="<?=(!empty($Tags) ? display_str($Tags) : '')?>"<? Users::has_autocomplete_enabled('other'); ?> <?=$Disabled?>/>
  204. <br />
  205. 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>".
  206. <br /><br />
  207. 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.).
  208. </td>
  209. </tr>
  210. <? if ($NewRequest || $CanEdit) { ?>
  211. <? } ?>
  212. <tr>
  213. <td class="label">Description</td>
  214. <td>
  215. <textarea id="req_desc" name="description" cols="70" rows="7"><?=(!empty($Request['Description']) ? $Request['Description'] : '')?></textarea> <br />
  216. </td>
  217. </tr>
  218. <? if (check_perms('site_moderate_requests')) { ?>
  219. <tr>
  220. <td class="label">Torrent group</td>
  221. <td>
  222. <?=site_url()?>torrents.php?id=<input type="text" name="groupid" value="<?=isset($GroupID)?$GroupID:''?>" size="15"/><br />
  223. If this request matches a torrent group <span style="font-weight: bold;">already existing</span> on the site, please indicate that here.
  224. </td>
  225. </tr>
  226. <? } elseif (!empty($GroupID) && ($CategoryID != 5) && ($CategoryID != 0)) { ?>
  227. <tr>
  228. <td class="label">Torrent group</td>
  229. <td>
  230. <a href="torrents.php?id=<?=$GroupID?>"><?=site_url()?>torrents.php?id=<?=$GroupID?></a><br />
  231. This request <?=($NewRequest ? 'will be' : 'is')?> associated with the above torrent group.
  232. <? if (!$NewRequest) { ?>
  233. 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.
  234. <? } ?>
  235. <input type="hidden" name="groupid" value="<?=$GroupID?>" />
  236. </td>
  237. </tr>
  238. <? }
  239. if ($NewRequest) { ?>
  240. <tr id="voting">
  241. <td class="label">Bounty (MB)</td>
  242. <td>
  243. <input type="text" id="amount_box" size="8" value="<?=(!empty($Bounty) ? $Bounty : '100')?>" onchange="Calculate();" />
  244. <select id="unit" name="unit" onchange="Calculate();">
  245. <option value="mb"<?=(!empty($_POST['unit']) && $_POST['unit'] === 'mb' ? ' selected="selected"' : '') ?>>MB</option>
  246. <option value="gb"<?=(!empty($_POST['unit']) && $_POST['unit'] === 'gb' ? ' selected="selected"' : '') ?>>GB</option>
  247. </select>
  248. <input type="button" value="Preview" onclick="Calculate();" />
  249. <strong><?=($RequestTax * 100)?>% of this is deducted as tax by the system.</strong>
  250. </td>
  251. </tr>
  252. <tr>
  253. <td class="label">Post request information</td>
  254. <td>
  255. <input type="hidden" id="amount" name="amount" value="<?=(!empty($Bounty) ? $Bounty : '100')?>" />
  256. <input type="hidden" id="current_uploaded" value="<?=$LoggedUser['BytesUploaded']?>" />
  257. <input type="hidden" id="current_downloaded" value="<?=$LoggedUser['BytesDownloaded']?>" />
  258. Bounty after tax: <strong><span id="bounty_after_tax">90.00 MB</span></strong><br />
  259. If you add the entered <strong><span id="new_bounty">100.00 MB</span></strong> of bounty, your new stats will be: <br />
  260. Uploaded: <span id="new_uploaded"><?=Format::get_size($LoggedUser['BytesUploaded'])?></span><br />
  261. Ratio: <span id="new_ratio"><?=Format::get_ratio_html($LoggedUser['BytesUploaded'], $LoggedUser['BytesDownloaded'])?></span>
  262. </td>
  263. </tr>
  264. <tr>
  265. <td colspan="2" class="center">
  266. <input type="submit" id="button" value="Create request" disabled="disabled" />
  267. </td>
  268. </tr>
  269. <? } else { ?>
  270. <tr>
  271. <td colspan="2" class="center">
  272. <input type="submit" id="button" value="Edit request" />
  273. </td>
  274. </tr>
  275. <? } ?>
  276. </table>
  277. </form>
  278. <script type="text/javascript"><?=$NewRequest ? " Calculate();" : '' ?></script>
  279. <script type="text/javascript">Categories();</script>
  280. </div>
  281. </div>
  282. <?
  283. View::show_footer();
  284. ?>