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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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. if ($NewRequest && ($LoggedUser['BytesUploaded'] < 250 * 1024 * 1024 || !check_perms('site_submit_requests'))) {
  15. error('You do not have enough uploaded to make a request.');
  16. }
  17. if (!$NewRequest) {
  18. if (empty($ReturnEdit)) {
  19. $Request = Requests::get_request($RequestID);
  20. if ($Request === false) {
  21. error(404);
  22. }
  23. // Define these variables to simplify _GET['groupid'] requests later on
  24. $CategoryID = $Request['CategoryID'];
  25. $Title = $Request['Title'];
  26. $TitleJP = $Request['TitleJP'];
  27. $CatalogueNumber = $Request['CatalogueNumber'];
  28. $DLsiteID = $Request['DLsiteID'];
  29. $Image = $Request['Image'];
  30. $GroupID = $Request['GroupID'];
  31. $VoteArray = Requests::get_votes_array($RequestID);
  32. $VoteCount = count($VoteArray['Voters']);
  33. $IsFilled = !empty($Request['TorrentID']);
  34. $CategoryName = $Categories[$CategoryID - 1];
  35. $ProjectCanEdit = (check_perms('project_team') && !$IsFilled && $CategoryID === '0');
  36. $CanEdit = ((!$IsFilled && $LoggedUser['ID'] === $Request['UserID'] && $VoteCount < 2) || $ProjectCanEdit || check_perms('site_moderate_requests'));
  37. if (!$CanEdit) {
  38. error(403);
  39. }
  40. if ($CategoryName != 'Other') {
  41. $ArtistForm = Requests::get_artists($RequestID);
  42. }
  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.NameJP,
  62. tg.Year,
  63. tg.Studio,
  64. tg.Series,
  65. tg.CatalogueNumber,
  66. tg.DLsiteID,
  67. tg.WikiImage,
  68. GROUP_CONCAT(t.Name SEPARATOR ', '),
  69. tg.CategoryID
  70. FROM torrents_group AS tg
  71. JOIN torrents_tags AS tt ON tt.GroupID = tg.ID
  72. JOIN tags AS t ON t.ID = tt.TagID
  73. WHERE tg.ID = ".$_GET['groupid']);
  74. if (list($Title, $TitleJP, $Year, $Studio, $Series, $CatalogueNumber, $DLsiteID, $Image, $Tags, $CategoryID) = $DB->next_record()) {
  75. $GroupID = trim($_REQUEST['groupid']);
  76. }
  77. }
  78. View::show_header(($NewRequest ? 'Create a request' : 'Edit a request'), 'requests,form_validate');
  79. ?>
  80. <div class="thin">
  81. <div class="header">
  82. <h2><?=($NewRequest ? 'Create a request' : 'Edit a request')?></h2>
  83. </div>
  84. <div class="box pad">
  85. <form action="" method="post" id="request_form" onsubmit="Calculate();">
  86. <div>
  87. <? if (!$NewRequest) { ?>
  88. <input type="hidden" name="requestid" value="<?=$RequestID?>" />
  89. <? } ?>
  90. <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
  91. <input type="hidden" name="action" value="<?=($NewRequest ? 'takenew' : 'takeedit')?>" />
  92. </div>
  93. <table class="layout">
  94. <tr>
  95. <td colspan="2" class="center">Please make sure your request follows <a href="rules.php?p=requests">the request rules</a>!</td>
  96. </tr>
  97. <? if ($NewRequest || $CanEdit) { ?>
  98. <tr>
  99. <td class="label">
  100. Type
  101. </td>
  102. <td>
  103. <select id="categories" name="type" onchange="Categories();">
  104. <? foreach (Misc::display_array($Categories) as $Cat) { ?>
  105. <option value="<?=$Cat?>"<?=(!empty($CategoryName) && ($CategoryName === $Cat) ? ' selected="selected"' : '')?>><?=$Cat?></option>
  106. <? } ?>
  107. </select>
  108. </td>
  109. </tr>
  110. <tr id="cataloguenumber_tr">
  111. <td class="label">Catalogue Number</td>
  112. <td>
  113. <input type="text" id="catalogue" name="cataloguenumber" size="15" value="<?=(isset($CatalogueNumber)?$CatalogueNumber:'') ?>" />
  114. ( <input type="button" onclick="JavAutofill()" value="Autofill" style="font-size:0.8em;"></input> )
  115. </td>
  116. </tr>
  117. <tr id="artist_tr">
  118. <td class="label">Artist(s)</td>
  119. <td id="artistfields">
  120. <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>
  121. <?
  122. if (!empty($ArtistForm)) {
  123. $First = true;
  124. foreach ($ArtistForm as $Artist) {
  125. ?>
  126. <input type="text" id="artist_0" name="artists[]"<? Users::has_autocomplete_enabled('other'); ?> size="45" value="<?=display_str($Artist['name']) ?>" />
  127. <? if ($First) { ?><a href="#" onclick="AddArtistField(); return false;" class="brackets">+</a> <a href="#" onclick="RemoveArtistField(); return false;" class="brackets">&minus;</a><? } $First = false; ?>
  128. <br />
  129. <?
  130. }
  131. } else {
  132. ?> <input type="text" id="artist_0" name="artists[]"<? Users::has_autocomplete_enabled('other'); ?> size="45" onblur="CheckVA();" />
  133. <a href="#" onclick="AddArtistField(); return false;" class="brackets">+</a> <a href="#" onclick="RemoveArtistField(); return false;" class="brackets">&minus;</a>
  134. <?
  135. }
  136. ?>
  137. </td>
  138. </tr>
  139. <tr>
  140. <td class="label">Title</td>
  141. <td>
  142. <input type="text" id="title" name="title" size="45" value="<?=(!empty($Title) ? $Title : '')?>" />
  143. </td>
  144. </tr>
  145. <tr>
  146. <td class="label">Japanese Title</td>
  147. <td>
  148. <input type="text" id="title_jp" name="title_jp" size="45" value="<?=isset($TitleJP)?$TitleJP:''?>" />
  149. </td>
  150. </tr>
  151. <tr id="dlsiteid_tr">
  152. <td class="label">DLSite ID</td>
  153. <td>
  154. <input type="text" id="dlsiteid" name="dlsiteid" size="15" value="<?=isset($DLsiteID)?$DLsiteID:''?>" />
  155. </td>
  156. </tr>
  157. <? } ?>
  158. <? if ($NewRequest || $CanEdit) { ?>
  159. <tr id="image_tr">
  160. <td class="label">Image</td>
  161. <td>
  162. <input type="text" id="image" name="image" size="45" value="<?=(!empty($Image) ? $Image : '')?>" />
  163. </td>
  164. </tr>
  165. <? } ?>
  166. <tr>
  167. <td class="label">Tags</td>
  168. <td>
  169. <?
  170. $GenreTags = $Cache->get_value('genre_tags');
  171. if (!$GenreTags) {
  172. $DB->query('
  173. SELECT Name
  174. FROM tags
  175. WHERE TagType = \'genre\'
  176. ORDER BY Name');
  177. $GenreTags = $DB->collect('Name');
  178. $Cache->cache_value('genre_tags', $GenreTags, 3600 * 6);
  179. }
  180. ?>
  181. <select id="genre_tags" name="genre_tags" onchange="add_tag(); return false;">
  182. <option>---</option>
  183. <? foreach (Misc::display_array($GenreTags) as $Genre) { ?>
  184. <option value="<?=$Genre?>"><?=$Genre?></option>
  185. <? } ?>
  186. </select>
  187. <input type="text" id="tags" name="tags" size="45" value="<?=(!empty($Tags) ? display_str($Tags) : '')?>"<? Users::has_autocomplete_enabled('other'); ?> />
  188. <br />
  189. 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>".
  190. <br /><br />
  191. 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.).
  192. </td>
  193. </tr>
  194. <? if ($NewRequest || $CanEdit) { ?>
  195. <? } ?>
  196. <tr>
  197. <td class="label">Description</td>
  198. <td>
  199. <textarea id="req_desc" name="description" cols="70" rows="7"><?=(!empty($Request['Description']) ? $Request['Description'] : '')?></textarea> <br />
  200. </td>
  201. </tr>
  202. <? if (check_perms('site_moderate_requests')) { ?>
  203. <tr>
  204. <td class="label">Torrent group</td>
  205. <td>
  206. <?=site_url()?>torrents.php?id=<input type="text" name="groupid" value="<?=isset($GroupID)?$GroupID:''?>" size="15" /><br />
  207. If this request matches a torrent group <span style="font-weight: bold;">already existing</span> on the site, please indicate that here.
  208. </td>
  209. </tr>
  210. <? } elseif (!empty($GroupID) && ($CategoryID != 5) && ($CategoryID != 0)) { ?>
  211. <tr>
  212. <td class="label">Torrent group</td>
  213. <td>
  214. <a href="torrents.php?id=<?=$GroupID?>"><?=site_url()?>torrents.php?id=<?=$GroupID?></a><br />
  215. This request <?=($NewRequest ? 'will be' : 'is')?> associated with the above torrent group.
  216. <? if (!$NewRequest) { ?>
  217. 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.
  218. <? } ?>
  219. <input type="hidden" name="groupid" value="<?=$GroupID?>" />
  220. </td>
  221. </tr>
  222. <? }
  223. if ($NewRequest) { ?>
  224. <tr id="voting">
  225. <td class="label">Bounty (MB)</td>
  226. <td>
  227. <input type="text" id="amount_box" size="8" value="<?=(!empty($Bounty) ? $Bounty : '100')?>" onchange="Calculate();" />
  228. <select id="unit" name="unit" onchange="Calculate();">
  229. <option value="mb"<?=(!empty($_POST['unit']) && $_POST['unit'] === 'mb' ? ' selected="selected"' : '') ?>>MB</option>
  230. <option value="gb"<?=(!empty($_POST['unit']) && $_POST['unit'] === 'gb' ? ' selected="selected"' : '') ?>>GB</option>
  231. </select>
  232. <input type="button" value="Preview" onclick="Calculate();" />
  233. <strong><?=($RequestTax * 100)?>% of this is deducted as tax by the system.</strong>
  234. </td>
  235. </tr>
  236. <tr>
  237. <td class="label">Post request information</td>
  238. <td>
  239. <input type="hidden" id="amount" name="amount" value="<?=(!empty($Bounty) ? $Bounty : '100')?>" />
  240. <input type="hidden" id="current_uploaded" value="<?=$LoggedUser['BytesUploaded']?>" />
  241. <input type="hidden" id="current_downloaded" value="<?=$LoggedUser['BytesDownloaded']?>" />
  242. Bounty after tax: <strong><span id="bounty_after_tax">90.00 MB</span></strong><br />
  243. If you add the entered <strong><span id="new_bounty">100.00 MB</span></strong> of bounty, your new stats will be: <br />
  244. Uploaded: <span id="new_uploaded"><?=Format::get_size($LoggedUser['BytesUploaded'])?></span><br />
  245. Ratio: <span id="new_ratio"><?=Format::get_ratio_html($LoggedUser['BytesUploaded'], $LoggedUser['BytesDownloaded'])?></span>
  246. </td>
  247. </tr>
  248. <tr>
  249. <td colspan="2" class="center">
  250. <input type="submit" id="button" value="Create request" disabled="disabled" />
  251. </td>
  252. </tr>
  253. <? } else { ?>
  254. <tr>
  255. <td colspan="2" class="center">
  256. <input type="submit" id="button" value="Edit request" />
  257. </td>
  258. </tr>
  259. <? } ?>
  260. </table>
  261. </form>
  262. <script type="text/javascript"><?=$NewRequest ? " Calculate();" : '' ?></script>
  263. <script type="text/javascript">Categories();</script>
  264. </div>
  265. </div>
  266. <?
  267. View::show_footer();
  268. ?>