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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. <?php
  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. {
  6. public $UploadForm = '';
  7. public $Categories = [];
  8. #var $Formats = [];
  9. #var $Bitrates = [];
  10. public $Media = [];
  11. public $MediaManga = [];
  12. public $Containers = [];
  13. #var $ContainersGames = [];
  14. public $Codecs = [];
  15. public $Resolutions = [];
  16. #var $AudioFormats = [];
  17. #var $Subbing = [];
  18. #var $Languages = [];
  19. #var $Platform = [];
  20. public $NewTorrent = false;
  21. public $Torrent = [];
  22. public $Error = false;
  23. public $TorrentID = false;
  24. public $Disabled = '';
  25. public $DisabledFlag = false;
  26. public function __construct($Torrent = false, $Error = false, $NewTorrent = true)
  27. {
  28. $this->NewTorrent = $NewTorrent;
  29. $this->Torrent = $Torrent;
  30. $this->Error = $Error;
  31. global $UploadForm, $Categories, $Media, $MediaManga, $TorrentID, $Containers, $Codecs, $Resolutions, $Archives;
  32. #global $UploadForm, $Categories, $Formats, $Bitrates, $Media, $MediaManga, $TorrentID, $Containers, $ContainersGames, $Codecs, $Resolutions, $AudioFormats, $Subbing, $Languages, $Platform, $Archives, $ArchivesManga;
  33. $this->UploadForm = $UploadForm;
  34. $this->Categories = $Categories;
  35. #$this->Formats = $Formats;
  36. #$this->Bitrates = $Bitrates;
  37. $this->Media = $Media;
  38. $this->MediaManga = $MediaManga;
  39. $this->Containers = $Containers;
  40. #$this->ContainersGames = $ContainersGames;
  41. $this->Codecs = $Codecs;
  42. $this->Resolutions = $Resolutions;
  43. #$this->AudioFormats = $AudioFormats;
  44. #$this->Subbing = $Subbing;
  45. #$this->Languages = $Languages;
  46. $this->TorrentID = $TorrentID;
  47. #$this->Platform = $Platform;
  48. $this->Archives = $Archives;
  49. #$this->ArchivesManga = $ArchivesManga;
  50. if ($this->Torrent && $this->Torrent['GroupID']) {
  51. $this->Disabled = ' readonly="readonly"';
  52. $this->DisabledFlag = true;
  53. }
  54. }
  55. public function head()
  56. {
  57. G::$DB->query("
  58. SELECT COUNT(ID)
  59. FROM torrents
  60. WHERE UserID = ?", G::$LoggedUser['ID']);
  61. list($Uploads) = G::$DB->next_record(); ?>
  62. <!-- Everything until the catalogue number field-->
  63. <div class="thin">
  64. <?php if ($this->NewTorrent) { ?>
  65. <p style="text-align: center;">
  66. If you would like to use your own torrent file, add the following to it.
  67. Otherwise, add none of it and redownload the torrent file after uploading it.
  68. All of the above data will be added to it by the site.
  69. <strong>If you never have before, be sure to read this list of <a href="wiki.php?action=article&name=uploadingpitfalls">uploading pitfalls</a></strong>.
  70. </p>
  71. <p style="text-align: center;">
  72. <?php
  73. $Announces = call_user_func_array('array_merge', ANNOUNCE_URLS);
  74. foreach ($Announces as $Announce) {
  75. # Loop through tracker URLs
  76. ?>
  77. <strong>Announce</strong>
  78. <input type="text" value="<?= $Announce . '/' . G::$LoggedUser['torrent_pass'] . '/announce' ?>"
  79. size="74" onclick="this.select();" readonly="readonly" /> <br />
  80. <?php
  81. } ?>
  82. <strong>Source</strong>
  83. <input type="text" value="<?= Users::get_upload_sources()[0] ?>" size="20"
  84. onclick="this.select();" readonly="readonly" />
  85. </p>
  86. <!-- Error display -->
  87. <p style="text-align: center;">
  88. <?php
  89. }
  90. if ($this->Error) {
  91. echo "\t".'<p style="color: red; text-align: center;">' . $this->Error . "</p>\n";
  92. } ?>
  93. </p>
  94. <!-- Torrent form hidden values -->
  95. <form class="create_form box pad" name="torrent" action="" enctype="multipart/form-data" method="post"
  96. onsubmit="$('#post').raw().disabled = 'disabled';">
  97. <div>
  98. <input type="hidden" name="submit" value="true" />
  99. <input type="hidden" name="auth"
  100. value="<?=G::$LoggedUser['AuthKey']?>" />
  101. <?php if (!$this->NewTorrent) { ?>
  102. <input type="hidden" name="action" value="takeedit" />
  103. <input type="hidden" name="torrentid"
  104. value="<?=display_str($this->TorrentID)?>" />
  105. <input type="hidden" name="type"
  106. value="<?=display_str($this->Torrent['CategoryID']-1)?>" />
  107. <?php
  108. } else {
  109. if ($this->Torrent && $this->Torrent['GroupID']) {
  110. # Find groups and requests
  111. ?>
  112. <input type="hidden" name="groupid"
  113. value="<?= display_str($this->Torrent['GroupID']) ?>" />
  114. <input type="hidden" name="type"
  115. value="<?= display_str($this->Torrent['CategoryID']-1) ?>" />
  116. <?php
  117. }
  118. if ($this->Torrent && ($this->Torrent['RequestID'] ?? false)) {
  119. ?>
  120. <input type="hidden" name="requestid"
  121. value="<?=display_str($this->Torrent['RequestID'])?>" />
  122. <?php
  123. }
  124. } ?>
  125. </div>
  126. <!-- New torrent options: file and category -->
  127. <?php if ($this->NewTorrent) { ?>
  128. <table cellpadding="3" cellspacing="1" border="0" class="layout" width="100%">
  129. <tr>
  130. <td class="label">Torrent File</td>
  131. <td><input id="file" type="file" name="file_input" size="50" /><br />
  132. Use the above announce URL and set the private flag in your BitTorrent client, e.g.,
  133. <pre>mktorrent -p -a &lt;announce&gt; &lt;target folder&gt;</pre>
  134. </td>
  135. </tr>
  136. <tr>
  137. <td class="label">Type</td>
  138. <td>
  139. <select id="categories" name="type" onchange="Categories()"
  140. <?= ($this->DisabledFlag) ? ' disabled="disabled"' : '' ?>>
  141. <?php
  142. foreach (Misc::display_array($this->Categories) as $Index => $Cat) {
  143. echo "\t\t\t\t\t\t<option value=\"$Index\"";
  144. if ($Cat == $this->Torrent['CategoryName']) {
  145. echo ' selected="selected"';
  146. }
  147. echo ">$Cat</option>\n";
  148. }
  149. ?>
  150. </select><br />
  151. What alphabet the sequence uses, n.b., plasmids fit in the Other category
  152. </td>
  153. </tr>
  154. </table>
  155. <!-- Start the dynamic form -->
  156. <?php } # if?>
  157. <div id="dynamic_form">
  158. <?php
  159. }
  160. public function foot()
  161. {
  162. $Torrent = $this->Torrent; ?>
  163. </div>
  164. <!-- Freeleech type -->
  165. <table cellpadding="3" cellspacing="1" border="0" class="layout slice" width="100%">
  166. <?php
  167. if (!$this->NewTorrent) {
  168. if (check_perms('torrents_freeleech')) {
  169. ?>
  170. <tr id="freetorrent">
  171. <td class="label">Freeleech</td>
  172. <td>
  173. <select name="freeleech">
  174. <?php
  175. $FL = array("Normal", "Free", "Neutral");
  176. foreach ($FL as $Key => $Name) {
  177. # Cycle types
  178. ?>
  179. <option value="<?= $Key ?>" <?= ($Key === $Torrent['FreeTorrent'] ? ' selected="selected"' : '') ?>><?= $Name ?>
  180. </option>
  181. <?php
  182. } ?>
  183. </select>
  184. because
  185. <select name="freeleechtype">
  186. <?php
  187. $FL = array("N/A", "Staff Pick", "Perma-FL", "Freeleechizer", "Site-Wide FL");
  188. foreach ($FL as $Key => $Name) {
  189. # Cycle reasons
  190. ?>
  191. <option value="<?=$Key?>" <?= ($Key === $Torrent['FreeLeechType'] ? ' selected="selected"' : '') ?>><?= $Name ?>
  192. </option>
  193. <?php
  194. } ?>
  195. </select>
  196. </td>
  197. </tr>
  198. <?php
  199. }
  200. } ?>
  201. <!-- Rules notice and submit button -->
  202. <tr>
  203. <td colspan="2" style="text-align: center;">
  204. <p>
  205. Be sure that your torrent is approved by the <a href="rules.php?p=upload" target="_blank">rules</a>.
  206. Not doing this will result in a <strong class="important_text">warning</strong> or <strong class="important_text">worse</strong>.
  207. </p>
  208. <?php if ($this->NewTorrent) { ?>
  209. <p>
  210. 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.
  211. Make use of this time wisely, and <a href="requests.php">search the list of requests</a>.
  212. </p>
  213. <?php } ?>
  214. <input id="post" type="submit"
  215. <?php
  216. if ($this->NewTorrent) {
  217. echo ' value="Upload"';
  218. } else {
  219. echo ' value="Edit"';
  220. } ?>
  221. />
  222. </td>
  223. </tr>
  224. </table>
  225. </form>
  226. </div>
  227. <!-- Okay, finally the real form -->
  228. <?php
  229. } # End
  230. public function upload_form()
  231. {
  232. $QueryID = G::$DB->get_query_id();
  233. $this->head();
  234. $Torrent = $this->Torrent; ?>
  235. <!-- Catalogue number field -->
  236. <table cellpadding="3" cellspacing="1" border="0" class="layout slice" width="100%">
  237. <?php if ($this->NewTorrent) { ?>
  238. <tr id="javdb_tr">
  239. <td class="label tooltip" title="">Accession Number</td>
  240. <td>
  241. <input type="text" id="catalogue" name="catalogue" size="10"
  242. value="<?= display_str($Torrent['CatalogueNumber']) ?>"
  243. <?= $this->Disabled ?>/>
  244. <?php if (!$this->DisabledFlag) { ?>
  245. <input type="button" autofill="jav" value="Autofill"
  246. style="background: lightgrey; pointer-events: none;">
  247. </input>
  248. Coming Soon!<br />
  249. RefSeq accession number, e.g., NM_001183340.1
  250. <?php } ?>
  251. </td>
  252. </tr>
  253. <!-- Other autofill options -->
  254. <tr id="anidb_tr" class="hidden">
  255. <td class="label">AniDB Autofill (optional)</td>
  256. <td>
  257. <input type="text" id="anidb" size="10" <?= $this->Disabled ?>/>
  258. <?php if (!$this->DisabledFlag) { ?>
  259. <input type="button" autofill="anime" value="Autofill" />
  260. <?php } ?>
  261. </td>
  262. </tr>
  263. <tr id="ehentai_tr" class="hidden">
  264. <td class="label">e-hentai URL (optional)</td>
  265. <td>
  266. <input type="text" id="catalogue" size="50" <?= $this->Disabled ?> />
  267. <?php if (!$this->DisabledFlag) { ?>
  268. <input type="button" autofill="douj" value="Autofill" />
  269. <?php } ?>
  270. </td>
  271. </tr>
  272. <!-- Three title fields -->
  273. <tr id="title_tr">
  274. <td class="label">Torrent Title</td>
  275. <td>
  276. <input type="text" id="title" name="title" size="60"
  277. value="<?= display_str($Torrent['Title']) ?>"
  278. <?= $this->Disabled ?>/><br />
  279. Definition line, e.g., Alcohol dehydrogenase ADH1
  280. </td>
  281. </tr>
  282. <tr id="title_rj_tr">
  283. <td class="label" title="">Organism</td>
  284. <td>
  285. <input type="text" id="title_rj" name="title_rj" size="60"
  286. value="<?= display_str($Torrent['TitleRJ']) ?>"
  287. <?= $this->Disabled ?>/><br />
  288. Organism line binomial, e.g., <em>Saccharomyces cerevisiae</em>
  289. </td>
  290. </tr>
  291. <tr id="title_jp_tr">
  292. <td class="label">Strain/Variety</td>
  293. <td>
  294. <input type="text" id="title_jp" name="title_jp" size="60"
  295. value="<?= display_str($Torrent['TitleJP']) ?>"
  296. <?= $this->Disabled ?>/><br />
  297. Organism line if any, e.g., S288C
  298. </td>
  299. </tr>
  300. <!-- Multiple artists -->
  301. <tr id="idols_tr">
  302. <td class="label tooltip" title="">Authors(s)</td>
  303. <td id="idolfields">
  304. One per field, e.g., Robert K. Mortimer [+] David Schild<br />
  305. <?php
  306. if (!empty($Torrent['Artists'])) {
  307. foreach ($Torrent['Artists'] as $Num => $Artist) {
  308. ?>
  309. <input type="text" id="idols_<?= $Num ?>" name="idols[]"
  310. size="45" value="<?= display_str($Artist['name']) ?>"
  311. <?= $this->Disabled ?>/>
  312. <?php if ($Num == 0) { ?>
  313. <a class="add_artist_button brackets">+</a>
  314. <a class="remove_artist_button brackets">&minus;</a>
  315. <?php
  316. }
  317. }
  318. } else {
  319. ?>
  320. <input type="text" id="idols_0" name="idols[]" size="45" value="" <?= $this->Disabled ?> />
  321. <a class="add_artist_button brackets">+</a>
  322. <a class="remove_artist_button brackets">&minus;</a>
  323. <?php
  324. } ?>
  325. </td>
  326. </tr>
  327. <!-- Production studio -->
  328. <tr id="studio_tr">
  329. <td class="label">Department/Lab</td>
  330. <td>
  331. <input type="text" id="studio" name="studio" size="60"
  332. value="<?= display_str($Torrent['Studio']) ?>"
  333. <?= $this->Disabled ?>/><br />
  334. First author's institution, e.g., Lawrence Berkeley Laboratory
  335. </td>
  336. </tr>
  337. <!-- Location -->
  338. <tr id="series_tr">
  339. <td class="label">Location</td>
  340. <td>
  341. <input type="text" id="series" name="series" size="60"
  342. value="<?= display_str($Torrent['Series']) ?>"
  343. <?= $this->Disabled ?>/><br />
  344. Physical location, e.g., Berkeley, CA
  345. </td>
  346. </tr>
  347. <!-- Year -->
  348. <tr id="year_tr">
  349. <td class="label">Year</td>
  350. <td>
  351. <input type="text" id="year" name="year" maxlength="4" size="5"
  352. value="<?= display_str($Torrent['Year']) ?>"
  353. <?= $this->Disabled ?>/><br />
  354. Original publication year
  355. </td>
  356. </tr>
  357. <!-- Media type -->
  358. <?php } # Ends if NewTorrent line 256?>
  359. <tr id="media_tr">
  360. <td class="label">Platform</td>
  361. <td>
  362. <select name="media">
  363. <option>---</option>
  364. <?php
  365. foreach ($this->Media as $Media) {
  366. echo "\t\t\t\t\t\t<option value=\"$Media\"";
  367. if ($Media == ($Torrent['Media'] ?? false)) {
  368. echo " selected";
  369. }
  370. echo ">$Media</option>\n";
  371. } ?>
  372. </select><br />
  373. Class of sequencing technology used
  374. </td>
  375. </tr>
  376. <!-- Container -->
  377. <tr id="container_tr">
  378. <td class="label">Format</td>
  379. <td>
  380. <select name="container">
  381. <option>---</option>
  382. <?php
  383. foreach ($this->Containers as $Cont) {
  384. echo "\t\t\t\t\t\t<option value=\"$Cont\"";
  385. if ($Cont === ($Torrent['Container'] ?? false)) {
  386. echo " selected";
  387. }
  388. echo ">$Cont</option>\n";
  389. } ?>
  390. </select><br />
  391. Data file format
  392. </td>
  393. </tr>
  394. <!-- Resolution -->
  395. <tr id="resolution_tr">
  396. <td class="label">Assembly Level</td>
  397. <td>
  398. <select id="ressel" name="ressel" onchange="SetResolution()">
  399. <option value="">---</option>
  400. <?php
  401. foreach ($this->Resolutions as $Res) {
  402. echo "\t\t\t\t\t\t<option value=\"$Res\"";
  403. if ($Res === ($Torrent['Resolution'] ?? false)
  404. || (!isset($FoundRes) && ($Torrent['Resolution'] ?? false)
  405. && $Res === 'Other')) {
  406. echo " selected";
  407. $FoundRes = true;
  408. }
  409. echo ">$Res</option>\n";
  410. } ?>
  411. </select>
  412. <input type="text" id="resolution" name="resolution" size="10" class="hidden"
  413. value="<?= ($Torrent['Resolution']??'') ?>"
  414. readonly>
  415. </input>
  416. <script>
  417. if ($('#ressel').raw().value == "Other") {
  418. $('#resolution').raw().readOnly = false
  419. $('#resolution').gshow()
  420. }
  421. </script><br />
  422. How complete the data is
  423. </td>
  424. </tr>
  425. <!-- Compression -->
  426. <tr id="archive_tr">
  427. <td class="label">Archive</td>
  428. <td>
  429. <select name='archive'>
  430. <option>---</option>
  431. <?php
  432. foreach ($this->Archives as $Archive) {
  433. echo "\t\t\t\t\t\t<option value=\"$Archive\"";
  434. if ($Archive === ($Torrent['Archive'] ?? false)) {
  435. echo ' selected';
  436. }
  437. echo ">$Archive</option>\n";
  438. } ?>
  439. </select><br />
  440. Compression algorithm
  441. </td>
  442. </tr>
  443. <!-- Encoding -->
  444. <tr id="codec_tr">
  445. <td class="label">License</td>
  446. <td>
  447. <select name="codec">
  448. <option>---</option>
  449. <?php
  450. foreach ($this->Codecs as $Codec) {
  451. echo "\t\t\t\t\t\t<option value=\"$Codec\"";
  452. if ($Codec === ($Torrent['Codec'] ?? false)) {
  453. echo " selected";
  454. }
  455. echo ">$Codec</option>\n";
  456. } ?>
  457. </select><br />
  458. Please see <a href="http://www.dcc.ac.uk/resources/how-guides/license-research-data" target="_blank">How to License Research Data</a>
  459. </td>
  460. </tr>
  461. <!-- Tags -->
  462. <?php if ($this->NewTorrent) { ?>
  463. <tr id="tags_tr">
  464. <td class="label">Tags</td>
  465. <td>
  466. <?php
  467. $GenreTags = G::$Cache->get_value('genre_tags');
  468. if (!$GenreTags) {
  469. $DB->query("
  470. SELECT Name
  471. FROM tags
  472. WHERE TagType = 'genre'
  473. ORDER BY Name");
  474. $GenreTags = $DB->collect('Name');
  475. G::$Cache->cache_value('genre_tags', $GenreTags, 3600*6);
  476. }
  477. ?>
  478. <select id="genre_tags" name="genre_tags" onchange="add_tag(); return false;" <?= ($this->DisabledFlag) ? ' disabled="disabled"' : '' ?>>
  479. <option>---</option>
  480. <?php foreach (Misc::display_array($GenreTags) as $Genre) { ?>
  481. <option value="<?= $Genre ?>"><?= $Genre ?>
  482. </option>
  483. <?php } ?>
  484. </select>
  485. <input type="text" id="tags" name="tags" size="60"
  486. value="<?= display_str(implode(', ', explode(',', $Torrent['TagList']))) ?>"
  487. <?php Users::has_autocomplete_enabled('other'); ?> /><br />
  488. Comma-seperated list of tags, n.b., use <strong class="important_text_alt">vanity.house</strong> for data you produced
  489. </td>
  490. </tr>
  491. <!-- Picture -->
  492. <tr id="cover_tr">
  493. <td class="label">Picture</td>
  494. <td>
  495. <input type="text" id="image" name="image" size="60"
  496. value="<?= display_str($Torrent['Image']) ?>"
  497. <?= $this->Disabled ?> /><br />
  498. A meaningful picture, e.g., the specimen or a thumbnail
  499. </td>
  500. </tr>
  501. <!-- Sample pictures/links -->
  502. <?php if (!$this->DisabledFlag && $this->NewTorrent) { ?>
  503. <tr id="screenshots_tr">
  504. <td class="label">Publications</td>
  505. <td>
  506. <textarea rows="8" cols="60" name="screenshots"
  507. id="screenshots"><?= display_str($Torrent['Screenshots'])?></textarea>
  508. Up to ten DOI numbers relevant to the torrent, one per line
  509. </tr>
  510. <?php } ?>
  511. <!-- Artist description -->
  512. <tr id="group_desc_tr">
  513. <td class="label">Torrent Group Description</td>
  514. <td>
  515. <?php
  516. new TEXTAREA_PREVIEW(
  517. 'album_desc',
  518. 'album_desc',
  519. display_str($Torrent['GroupDescription']),
  520. 60,
  521. 8,
  522. !$this->DisabledFlag,
  523. !$this->DisabledFlag,
  524. false,
  525. array($this->Disabled)
  526. );
  527. ?><br />
  528. General info about the gene or protein's function or significance
  529. </td>
  530. </tr>
  531. <?php } # Ends if NewTorrent line 499?>
  532. <!-- Torrent description -->
  533. <tr id="release_desc_tr">
  534. <td class="label">Torrent Description</td>
  535. <td>
  536. <?php
  537. new TEXTAREA_PREVIEW(
  538. 'release_desc',
  539. 'release_desc',
  540. display_str($Torrent['TorrentDescription'] ?? ''),
  541. 60,
  542. ); ?><br />
  543. Specific info about the protocols and equipment relevant to this data
  544. </td>
  545. </tr>
  546. <!-- Boolean options -->
  547. <tr id="censored_tr">
  548. <td class="label">Aligned Sequence</td>
  549. <td>
  550. <input type="checkbox" name="censored" value="1"
  551. <?= (($Torrent['Censored'] ?? 0) ? 'checked ' : '') ?>/>
  552. Whether the torrent contains raw reads or alignment data
  553. </td>
  554. </tr>
  555. <tr id="anon_tr">
  556. <td class="label">Upload Anonymously</td>
  557. <td>
  558. <input type="checkbox" name="anonymous" value="1"
  559. <?= (($Torrent['Anonymous'] ?? false) ? 'checked ' : '') ?>/>
  560. Hide your username from other users on the torrent details page
  561. </td>
  562. </tr>
  563. </table>
  564. <?php
  565. # Phew
  566. $this->foot();
  567. G::$DB->set_query_id($QueryID);
  568. }
  569. }