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.

torrent_form.class.php 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. <?
  2. // This class is used in upload.php to display the upload form, and the edit
  3. // section of torrents.php to display a shortened version of the same form
  4. class TorrentForm {
  5. var $UploadForm = '';
  6. var $Categories = [];
  7. #var $Formats = [];
  8. #var $Bitrates = [];
  9. var $Media = [];
  10. #var $MediaManga = [];
  11. var $Containers = [];
  12. #var $ContainersGames = [];
  13. var $Codecs = [];
  14. var $Resolutions = [];
  15. #var $AudioFormats = [];
  16. #var $Subbing = [];
  17. #var $Languages = [];
  18. #var $Platform = [];
  19. var $NewTorrent = false;
  20. var $Torrent = [];
  21. var $Error = false;
  22. var $TorrentID = false;
  23. var $Disabled = '';
  24. var $DisabledFlag = false;
  25. function __construct($Torrent = false, $Error = false, $NewTorrent = true) {
  26. $this->NewTorrent = $NewTorrent;
  27. $this->Torrent = $Torrent;
  28. $this->Error = $Error;
  29. global $UploadForm, $Categories, $Media, $TorrentID, $Containers, $Codecs, $Resolutions, $Archives;
  30. #global $UploadForm, $Categories, $Formats, $Bitrates, $Media, $MediaManga, $TorrentID, $Containers, $ContainersGames, $Codecs, $Resolutions, $AudioFormats, $Subbing, $Languages, $Platform, $Archives, $ArchivesManga;
  31. $this->UploadForm = $UploadForm;
  32. $this->Categories = $Categories;
  33. #$this->Formats = $Formats;
  34. #$this->Bitrates = $Bitrates;
  35. $this->Media = $Media;
  36. #$this->MediaManga = $MediaManga;
  37. $this->Containers = $Containers;
  38. #$this->ContainersGames = $ContainersGames;
  39. $this->Codecs = $Codecs;
  40. $this->Resolutions = $Resolutions;
  41. #$this->AudioFormats = $AudioFormats;
  42. #$this->Subbing = $Subbing;
  43. #$this->Languages = $Languages;
  44. $this->TorrentID = $TorrentID;
  45. #$this->Platform = $Platform;
  46. $this->Archives = $Archives;
  47. #$this->ArchivesManga = $ArchivesManga;
  48. if ($this->Torrent && $this->Torrent['GroupID']) {
  49. $this->Disabled = ' readonly="readonly"';
  50. $this->DisabledFlag = true;
  51. }
  52. }
  53. function head() {
  54. G::$DB->query("
  55. SELECT COUNT(ID)
  56. FROM torrents
  57. WHERE UserID = ?", G::$LoggedUser['ID']);
  58. list($Uploads) = G::$DB->next_record();
  59. ?>
  60. <div class="thin">
  61. <? if ($this->NewTorrent) { ?>
  62. <p style="text-align: center;">
  63. If you would like to use your own torrent file, add the following to it:<br />
  64. <? $Announces = call_user_func_array('array_merge', ANNOUNCE_URLS);
  65. foreach ($Announces as $Announce) {
  66. ?>
  67. Announce: <input type="text" value="<?=$Announce . '/' . G::$LoggedUser['torrent_pass'] . '/announce'?>" size="74" onclick="this.select();" readonly="readonly" /> <br />
  68. <? } ?>
  69. Source: <input type="text" value="<?=Users::get_upload_sources()[0]?>" size="20" onclick="this.select();" readonly="readonly" />
  70. <p style="text-align: center;">
  71. Otherwise, add none of it and simply redownload the torrent file after uploading it. All of the above data will be added to it by the site.<br /><br />
  72. <strong<?=((!$Uploads)?' class="important_text"':'')?>>
  73. If you never have before, be sure to read this list of <a href="wiki.php?action=article&name=uploadingpitfalls">uploading pitfalls</a>
  74. </strong>
  75. </p>
  76. </p>
  77. <? }
  78. if ($this->Error) {
  79. echo "\t".'<p style="color: red; text-align: center;">'.$this->Error."</p>\n";
  80. }
  81. ?>
  82. <form class="create_form box pad" name="torrent" action="" enctype="multipart/form-data" method="post" onsubmit="$('#post').raw().disabled = 'disabled';">
  83. <div>
  84. <input type="hidden" name="submit" value="true" />
  85. <input type="hidden" name="auth" value="<?=G::$LoggedUser['AuthKey']?>" />
  86. <? if (!$this->NewTorrent) { ?>
  87. <input type="hidden" name="action" value="takeedit" />
  88. <input type="hidden" name="torrentid" value="<?=display_str($this->TorrentID)?>" />
  89. <input type="hidden" name="type" value="<?=display_str($this->Torrent['CategoryID']-1)?>" />
  90. <?
  91. } else {
  92. if ($this->Torrent && $this->Torrent['GroupID']) {
  93. ?>
  94. <input type="hidden" name="groupid" value="<?=display_str($this->Torrent['GroupID'])?>" />
  95. <input type="hidden" name="type" value="<?=display_str($this->Torrent['CategoryID']-1)?>" />
  96. <?
  97. }
  98. if ($this->Torrent && ($this->Torrent['RequestID'] ?? false)) {
  99. ?>
  100. <input type="hidden" name="requestid" value="<?=display_str($this->Torrent['RequestID'])?>" />
  101. <?
  102. }
  103. }
  104. ?>
  105. </div>
  106. <? if ($this->NewTorrent) { ?>
  107. <table cellpadding="3" cellspacing="1" border="0" class="layout" width="100%">
  108. <tr>
  109. <td class="label tooltip" title="Use the above announce URL and set the private flag in your BitTorrent client">Torrent File</td>
  110. <td><input id="file" type="file" name="file_input" size="50" /></td>
  111. </tr>
  112. <tr>
  113. <td class="label tooltip" title="What alphabet the sequence uses, n.b., plasmids fit in the Other category">Type</td>
  114. <td>
  115. <select id="categories" name="type" onchange="Categories()"<?=($this->DisabledFlag) ? ' disabled="disabled"' : ''?>>
  116. <?
  117. foreach (Misc::display_array($this->Categories) as $Index => $Cat) {
  118. echo "\t\t\t\t\t\t<option value=\"$Index\"";
  119. if ($Cat == $this->Torrent['CategoryName']) {
  120. echo ' selected="selected"';
  121. }
  122. echo ">$Cat</option>\n";
  123. }
  124. ?>
  125. </select>
  126. </td>
  127. </tr>
  128. </table>
  129. <? }//if ?>
  130. <div id="dynamic_form">
  131. <?
  132. }
  133. function foot() {
  134. $Torrent = $this->Torrent;
  135. ?>
  136. </div>
  137. <table cellpadding="3" cellspacing="1" border="0" class="layout slice" width="100%">
  138. <?
  139. if (!$this->NewTorrent) {
  140. if (check_perms('torrents_freeleech')) {
  141. ?>
  142. <tr id="freetorrent">
  143. <td class="label">Freeleech</td>
  144. <td>
  145. <select name="freeleech">
  146. <?
  147. $FL = array("Normal", "Free", "Neutral");
  148. foreach ($FL as $Key => $Name) {
  149. ?>
  150. <option value="<?=$Key?>"<?=($Key == $Torrent['FreeTorrent'] ? ' selected="selected"' : '')?>><?=$Name?></option>
  151. <? } ?>
  152. </select>
  153. because
  154. <select name="freeleechtype">
  155. <?
  156. $FL = array("N/A", "Staff Pick", "Perma-FL", "Freeleechizer", "Site-Wide FL");
  157. foreach ($FL as $Key => $Name) {
  158. ?>
  159. <option value="<?=$Key?>"<?=($Key == $Torrent['FreeLeechType'] ? ' selected="selected"' : '')?>><?=$Name?></option>
  160. <? } ?>
  161. </select>
  162. </td>
  163. </tr>
  164. <?
  165. }
  166. }
  167. ?>
  168. <tr>
  169. <td colspan="2" style="text-align: center;">
  170. <p>Be sure that your torrent is approved by the <a href="rules.php?p=upload" target="_blank">rules</a>. Not doing this will result in a <strong class="important_text">warning</strong> or <strong class="important_text">worse</strong>.</p>
  171. <? if ($this->NewTorrent) { ?>
  172. <p>After uploading the torrent, you will have a one hour grace period during which no one other than you can fill requests with this torrent. Make use of this time wisely, and <a href="requests.php">search the list of requests</a>.</p>
  173. <? } ?>
  174. <input id="post" type="submit"<? if ($this->NewTorrent) { echo ' value="Upload torrent"'; } else { echo ' value="Edit torrent"';} ?> />
  175. </td>
  176. </tr>
  177. </table>
  178. </form>
  179. </div>
  180. <?
  181. }
  182. function upload_form() {
  183. $QueryID = G::$DB->get_query_id();
  184. $this->head();
  185. $Torrent = $this->Torrent;
  186. ?>
  187. <table cellpadding="3" cellspacing="1" border="0" class="layout slice" width="100%">
  188. <? if ($this->NewTorrent) { ?>
  189. <tr id="javdb_tr">
  190. <td class="label tooltip" title="RefSeq accession number, e.g., NM_001183340.1">Accession Number</td>
  191. <td>
  192. <input type="text" id="catalogue" name="catalogue" size="10" value="<?=display_str($Torrent['CatalogueNumber']) ?>" <?=$this->Disabled?>/>
  193. <? if (!$this->DisabledFlag) { ?>
  194. <input type="button" autofill="jav" value="Autofill" style="background: lightgrey; pointer-events: none;"></input>
  195. <? } ?>
  196. </td>
  197. </tr>
  198. <tr id="anidb_tr" class="hidden">
  199. <td class="label">AniDB Autofill (optional)</td>
  200. <td>
  201. <input type="text" id="anidb" size="10" <?=$this->Disabled?>/>
  202. <? if (!$this->DisabledFlag) { ?>
  203. <input type="button" autofill="anime" value="Autofill"/>
  204. <? } ?>
  205. </td>
  206. </tr>
  207. <tr id="ehentai_tr" class="hidden">
  208. <td class="label">e-hentai URL (optional)</td>
  209. <td>
  210. <input type="text" id="catalogue" size="50" <?=$this->Disabled?> />
  211. <? if (!$this->DisabledFlag) { ?>
  212. <input type="button" autofill="douj" value="Autofill"/>
  213. <? } ?>
  214. </td>
  215. </tr>
  216. <tr id="title_tr">
  217. <td class="label tooltip" title="FASTA definition line, e.g., Alcohol dehydrogenase ADH1">Sequence Name</td>
  218. <td><input type="text" id="title" name="title" size="60" value="<?=display_str($Torrent['Title']) ?>" <?=$this->Disabled?>/></td>
  219. </tr>
  220. <tr id="title_rj_tr">
  221. <td class="label tooltip" title="FASTA organism line binomial nomenclature, e.g., Saccharomyces cerevisiae">Organism</td>
  222. <td><input type="text" id="title_rj" name="title_rj" size="60" value="<?=display_str($Torrent['TitleRJ']) ?>" <?=$this->Disabled?>/></td>
  223. </tr>
  224. <tr id="title_jp_tr">
  225. <td class="label tooltip" title="FASTA organism line if applicable, e.g., S288C">Strain/Variety</td>
  226. <td><input type="text" id="title_jp" name="title_jp" size="60" value="<?=display_str($Torrent['TitleJP']) ?>" <?=$this->Disabled?>/></td>
  227. </tr>
  228. <tr id="idols_tr">
  229. <td class="label tooltip" title="FASTA authors line, e.g., Robert K. Mortimer and David Schild">Collaborator(s)</td>
  230. <td id="idolfields">
  231. <? if (!empty($Torrent['Artists'])) {
  232. foreach ($Torrent['Artists'] as $Num => $Artist) { ?>
  233. <input type="text" id="idols_<?=$Num?>" name="idols[]" size="45" value="<?=display_str($Artist['name'])?>" <?=$this->Disabled?>/>
  234. <? if ($Num == 0) { ?>
  235. <a class="add_artist_button brackets">+</a> <a class="remove_artist_button brackets">&minus;</a>
  236. <? }
  237. }
  238. } else { ?>
  239. <input type="text" id="idols_0" name="idols[]" size="45" value="" <?=$this->Disabled?> />
  240. <a class="add_artist_button brackets">+</a> <a class="remove_artist_button brackets">&minus;</a>
  241. <? } ?>
  242. </td>
  243. </tr>
  244. <tr id="studio_tr">
  245. <td class="label tooltip" title="Who produced the sequence, e.g., Lawrence Berkeley Laboratory">Department/Lab</td>
  246. <td><input type="text" id="studio" name="studio" size="60" value="<?=display_str($Torrent['Studio']) ?>" <?=$this->Disabled?>/></td>
  247. </tr>
  248. <tr id="series_tr">
  249. <td class="label tooltip" title="Their physical location, e.g., Berkeley, CA">Location</td>
  250. <td><input type="text" id="series" name="series" size="60" value="<?=display_str($Torrent['Series']) ?>" <?=$this->Disabled?>/></td>
  251. </tr>
  252. <tr id="year_tr">
  253. <td class="label tooltip" title="What year they published the sequence in">Year</td>
  254. <td><input type="text" id="year" name="year" maxlength="4" size="5" value="<?=display_str($Torrent['Year']) ?>" <?=$this->Disabled?>/></td>
  255. </tr>
  256. <? } ?>
  257. <tr id="media_tr">
  258. <td class="label tooltip" title="What class of sequencing technology they used">Platform</td>
  259. <td>
  260. <select name="media">
  261. <option>---</option>
  262. <?
  263. foreach($this->Media as $Media) {
  264. echo "\t\t\t\t\t\t<option value=\"$Media\"";
  265. if ($Media == ($Torrent['Media'] ?? false)) {
  266. echo " selected";
  267. }
  268. echo ">$Media</option>\n";
  269. }
  270. ?>
  271. </select>
  272. </td>
  273. </tr>
  274. <tr id="archive_tr">
  275. <td class="label tooltip" title="How the data is archived and compressed">Archive</td>
  276. <td>
  277. <select name='archive'>
  278. <option>---</option>
  279. <?
  280. foreach($this->Archives as $Archive) {
  281. echo "\t\t\t\t\t\t<option value=\"$Archive\"";
  282. if ($Archive == ($Torrent['Archive'] ?? false)) {
  283. echo ' selected';
  284. }
  285. echo ">$Archive</option>\n";
  286. }
  287. ?>
  288. </select>
  289. </td>
  290. </tr>
  291. <tr id="container_tr">
  292. <td class="label tooltip" title="What file format the sequence is in">Format</td>
  293. <td>
  294. <select name="container">
  295. <option>---</option>
  296. <?
  297. foreach($this->Containers as $Cont) {
  298. echo "\t\t\t\t\t\t<option value=\"$Cont\"";
  299. if ($Cont == ($Torrent['Container'] ?? false)) {
  300. echo " selected";
  301. }
  302. echo ">$Cont</option>\n";
  303. }
  304. ?>
  305. </select>
  306. </td>
  307. </tr>
  308. <tr id="codec_tr">
  309. <td class="label tooltip" title="What license the collaborators released the data under">License</td>
  310. <td>
  311. <select name="codec">
  312. <option>---</option>
  313. <?
  314. foreach($this->Codecs as $Codec) {
  315. echo "\t\t\t\t\t\t<option value=\"$Codec\"";
  316. if ($Codec == ($Torrent['Codec'] ?? false)) {
  317. echo " selected";
  318. }
  319. echo ">$Codec</option>\n";
  320. }
  321. ?>
  322. </select>
  323. </td>
  324. </tr>
  325. <tr id="resolution_tr">
  326. <td class="label tooltip" title="How complete the sequence data is">Assembly Level</td>
  327. <td>
  328. <select id="ressel" name="ressel" onchange="SetResolution()">
  329. <option value="">---</option>
  330. <?
  331. foreach($this->Resolutions as $Res) {
  332. echo "\t\t\t\t\t\t<option value=\"$Res\"";
  333. if ($Res == ($Torrent['Resolution'] ?? false) || (!isset($FoundRes) && ($Torrent['Resolution'] ?? false) && $Res == "Other")) {
  334. echo " selected";
  335. $FoundRes = true;
  336. }
  337. echo ">$Res</option>\n";
  338. }
  339. ?>
  340. </select>
  341. <input type="text" id="resolution" name="resolution" size="10" class="hidden tooltip" pattern="[0-9]+x[0-9]+" title='Enter "Other" resolutions in the form ###x###' value="<?=($Torrent['Resolution']??'')?>" readonly></input>
  342. <script>
  343. if ($('#ressel').raw().value == "Other") {
  344. $('#resolution').raw().readOnly = false
  345. $('#resolution').gshow()
  346. }
  347. </script>
  348. </td>
  349. </tr>
  350. <? if ($this->NewTorrent) { ?>
  351. <tr id="tags_tr">
  352. <td class="label tooltip" title="Comma-seperated list of tags, n.b., use vanity.house for data you produced">Tags</td>
  353. <td>
  354. <?
  355. $GenreTags = G::$Cache->get_value('genre_tags');
  356. if (!$GenreTags) {
  357. $DB->query("
  358. SELECT Name
  359. FROM tags
  360. WHERE TagType = 'genre'
  361. ORDER BY Name");
  362. $GenreTags = $DB->collect('Name');
  363. G::$Cache->cache_value('genre_tags', $GenreTags, 3600*6);
  364. }
  365. ?>
  366. <select id="genre_tags" name="genre_tags" onchange="add_tag(); return false;" <?=($this->DisabledFlag) ? ' disabled="disabled"' : ''?>>
  367. <option>---</option>
  368. <? foreach (Misc::display_array($GenreTags) as $Genre) { ?>
  369. <option value="<?=$Genre?>"><?=$Genre?></option>
  370. <? } ?>
  371. </select>
  372. <input type="text" id="tags" name="tags" size="60" value="<?=display_str(implode(', ', explode(',', $Torrent['TagList']))) ?>"<? Users::has_autocomplete_enabled('other'); ?> />
  373. <p class="min_padding notes"></p>
  374. </td>
  375. </tr>
  376. <tr id="cover_tr">
  377. <td class="label tooltip" title="A meaningful picture, e.g., of the specimen">Picture</td>
  378. <td><input type="text" id="image" name="image" size="60" value="<?=display_str($Torrent['Image']) ?>"<?=$this->Disabled?> /></td>
  379. </tr>
  380. <? if (!$this->DisabledFlag && $this->NewTorrent) { ?>
  381. <tr id="screenshots_tr">
  382. <td class="label tooltip" title="Relevant publications that use the data">Publications</td>
  383. <td>
  384. <textarea rows="8" cols="60" name="screenshots" id="screenshots"><?=display_str($Torrent['Screenshots'])?></textarea>
  385. <p>Enter up to 10 links to studies for the torrent, one per line. The system will automatically remove malformed or invalid links, as well as any links after the 10th. Remember to consult the <a href="/rules.php?p=upload#h1.4">rules for adding publications</a>.</p>
  386. <p class="min_padding notes"></p>
  387. </tr>
  388. <? } ?>
  389. <tr id="group_desc_tr">
  390. <td class="label tooltip" title="General info about the gene or protein's function or significance">Torrent Group Description</td>
  391. <td>
  392. <p class="min_padding notes"></p>
  393. <?php new TEXTAREA_PREVIEW('album_desc', 'album_desc', display_str($Torrent['GroupDescription']), 60, 8, !$this->DisabledFlag, !$this->DisabledFlag, false, array($this->Disabled)); ?>
  394. </td>
  395. </tr>
  396. <? } ?>
  397. <tr id="release_desc_tr">
  398. <td class="label tooltip" title="Specific info about what protocols and equipment helped generate the data">Torrent Description (optional)</td>
  399. <td>
  400. <p class="min_padding notes"></p>
  401. <?php new TEXTAREA_PREVIEW('release_desc', 'release_desc', display_str($Torrent['TorrentDescription']??''), 60, 8); ?>
  402. </td>
  403. </tr>
  404. <tr id="censored_tr">
  405. <td class="label tooltip" title="Whether the torrent contains raw reads or alignment data">Aligned Sequence?</td>
  406. <td>
  407. <input type="checkbox" name="censored" value="1" <?=(($Torrent['Censored'] ?? 0) ? 'checked ' : '')?>/>
  408. </td>
  409. </tr>
  410. <tr id="anon_tr">
  411. <td class="label tooltip" title="Hide your username from other users on the torrent details page">Upload Anonymously?</td>
  412. <td><input type="checkbox" name="anonymous" value="1" <?=(($Torrent['Anonymous'] ?? false) ? 'checked ' : '')?>/></td>
  413. </tr>
  414. </table>
  415. <?
  416. $this->foot();
  417. G::$DB->set_query_id($QueryID);
  418. }
  419. }
  420. ?>