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

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