123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330 |
- <?php
- #declare(strict_types = 1);
-
- /**
- * Edit form
- *
- * This page relies on the TorrentForm class.
- * All it does is call the necessary functions.
- * At the bottom, there are grouping functions,
- * which are off limits to most members.
- */
-
- require_once SERVER_ROOT.'/classes/torrent_form.class.php';
- if (!is_number($_GET['id']) || !$_GET['id']) {
- error(400);
- }
-
- # DB query for the main torrent parameters
- # todo: Simplify based on unused tables
- $TorrentID = $_GET['id'];
- $DB->query("
- SELECT
- t.`Media`,
- t.`Container`,
- t.`Codec`,
- t.`Resolution`,
- t.`Version`,
- t.`Censored`,
- t.`Anonymous`,
- t.`Archive`,
- t.`FreeTorrent`,
- t.`FreeLeechType`,
- t.`Description` AS TorrentDescription,
- t.`FileList`,
- tg.`category_id`,
- tg.`title` AS title,
- tg.`subject` AS subject,
- tg.`object` AS object,
- tg.`published`,
- tg.`workgroup`,
- tg.`location`,
- tg.`identifier`,
- ag.`Name` AS ArtistName,
- t.`GroupID`,
- t.`UserID`,
- bt.`TorrentID` AS BadTags,
- bf.`TorrentID` AS BadFolders,
- bfi.`TorrentID` AS BadFiles
- FROM
- `torrents` AS t
- LEFT JOIN `torrents_group` AS tg
- ON
- tg.`id` = t.`GroupID`
- LEFT JOIN `torrents_artists` AS ta
- ON
- tg.`id` = ta.`GroupID`
- LEFT JOIN `artists_group` AS ag
- ON
- ag.`ArtistID` = ta.`ArtistID`
- LEFT JOIN `torrents_bad_tags` AS bt
- ON
- bt.`TorrentID` = t.`ID`
- LEFT JOIN `torrents_bad_folders` AS bf
- ON
- bf.`TorrentID` = t.`ID`
- LEFT JOIN `torrents_bad_files` AS bfi
- ON
- bfi.`TorrentID` = t.`ID`
- WHERE
- t.`ID` = '$TorrentID'
- ");
-
- # Error on no results
- list($Properties) = $DB->to_array(false, MYSQLI_BOTH);
- if (!$Properties) {
- error(404);
- }
-
- # Error on bad permissions
- $UploadForm = $Categories[$Properties['CategoryID'] - 1];
- if (($LoggedUser['ID'] !== $Properties['UserID']
- && !check_perms('torrents_edit'))
- || $LoggedUser['DisableWiki']) {
- error(403);
- }
-
-
- /**
- * Torrent Form
- *
- * This is the actual edit form.
- * Commenting only to see it better.
- */
-
- View::show_header('Edit torrent', 'upload,torrent,bbcode');
- $TorrentForm = new TorrentForm(
- $Torrent = $Properties,
- $Error = $Err,
- $NewTorrent = false
- );
- $TorrentForm->upload_form();
-
-
- /**
- * Moderator tools
- *
- * Various inlined tools to manage torrent grouping, etc.
- */
- if (check_perms('torrents_edit') || check_perms('users_mod')) { ?>
- <!-- Start HTML -->
-
-
- <!--
- Change Group
- -->
- <div class="header">
- <h2>Change Group</h2>
- </div>
-
- <div class="box pad">
- <form class="edit_form" name="torrent_group" action="torrents.php" method="post">
-
- <!-- Hidden values -->
- <input type="hidden" name="action" value="editgroupid" />
-
- <input type="hidden" name="auth"
- value="<?=$LoggedUser['AuthKey']?>" />
-
- <input type="hidden" name="torrentid" value="<?=$TorrentID?>" />
-
- <input type="hidden" name="oldgroupid"
- value="<?=$Properties['GroupID']?>" />
-
- <!-- Formlet table -->
- <table class="layout">
- <tr>
- <td class="label">
- Group ID
- </td>
-
- <td>
- <input type="text" name="groupid"
- value="<?=$Properties['GroupID']?>"
- size="10" />
- </td>
- </tr>
-
- <tr>
- <td colspan="2" class="center">
- <input type="submit" value="Change Group ID" />
- </td>
- </tr>
- </table>
- </form>
- </div> <!-- box pad -->
-
-
- <!--
- Split off into new group
- -->
-
- <h2 class="header">
- Split off into new group
- </h2>
-
- <div class="box pad">
- <form class="split_form" name="torrent_group" action="torrents.php" method="post">
-
- <!-- Hidden values -->
- <input type="hidden" name="action" value="newgroup" />
-
- <input type="hidden" name="auth"
- value="<?=$LoggedUser['AuthKey']?>" />
-
- <input type="hidden" name="torrentid" value="<?=$TorrentID?>" />
-
- <input type="hidden" name="oldgroupid"
- value="<?=$Properties['GroupID']?>" />
-
- <!-- Formlet table -->
- <table class="layout">
- <tr>
- <td class="label">
- Author
- </td>
-
- <td>
- <input type="text" name="artist"
- value="<?=$Properties['ArtistName']?>"
- size="50" />
- </td>
- </tr>
-
-
- <tr>
- <td class="label">
- Torrent Title
- </td>
-
- <td>
- <input type="text" name="title"
- value="<?=$Properties['Title']?>"
- size="50" />
- </td>
- </tr>
-
-
- <tr>
- <td class="label">
- Organism
- </td>
-
- <td>
- <input type="test" name="title_rj"
- value="<?=$Properties['Title2']?>"
- size=50" />
- </td>
- </tr>
-
-
- <tr>
- <td class="label">
- Strain/Variety
- </td>
-
- <td>
- <input type="test" name="title_jp"
- value="<?=$Properties['TitleJP']?>"
- size=50" />
- </td>
- </tr>
-
-
- <tr>
- <td class="label">
- Year
- </td>
-
- <td>
- <input type="text" name="year"
- value="<?=$Properties['Year']?>"
- size="10" />
- </td>
- </tr>
-
-
- <tr>
- <td colspan="2" class="center">
- <input type="submit" value="Split into new group" />
- </td>
- </tr>
- </table>
- </form>
- </div> <!-- box pad -->
-
- <?php
- if (check_perms('users_mod')) { ?>
-
- <!-- Change Category -->
- <h2>Change Category</h2>
- <div class="box pad">
- <form action="torrents.php" method="post">
- <input type="hidden" name="action" value="changecategory" />
- <input type="hidden" name="auth"
- value="<?=$LoggedUser['AuthKey']?>" />
- <input type="hidden" name="torrentid" value="<?=$TorrentID?>" />
- <input type="hidden" name="oldgroupid"
- value="<?=$Properties['GroupID']?>" />
- <input type="hidden" name="oldartistid"
- value="<?=$Properties['ArtistID']?>" />
- <input type="hidden" name="oldcategoryid"
- value="<?=$Properties['CategoryID']?>" />
-
- <table>
- <tr>
- <td class="label">Category</td>
- <td>
- <select id="newcategoryid" name="newcategoryid">
- <?php foreach ($Categories as $CatID => $CatName) { ?>
- <option value="<?=($CatID + 1)?>"
- <?Format::selected('CategoryID', $CatID + 1, 'selected', $Properties)?>><?=($CatName)?>
- </option>
- <?php } ?>
- </select>
- </td>
- </tr>
-
- <tr id="split_artist">
- <td class="label">Author</td>
- <td>
- <input type="text" name="artist"
- value="<?=$Properties['ArtistName']?>"
- size="50" />
- </td>
- </tr>
-
- <tr id="split_title">
- <td class="label">Torrent Title</td>
- <td>
- <input type="text" name="title"
- value="<?=$Properties['Title']?>"
- size="50" />
- </td>
- </tr>
-
- <tr id="split_year">
- <td class="label">Year</td>
- <td>
- <input type="text" name="year"
- value="<?=$Properties['Year']?>"
- size="10" />
- </td>
- </tr>
-
- <tr>
- <td colspan="2" class="center">
- <input type="submit" value="Change Category" />
- </td>
- </tr>
- </table>
- <script type="text/javascript">
- ChangeCategory($('#newcategoryid').raw().value);
- </script>
- </form>
- </div>
- <?php
- } ?>
- <?php
- } // if check_perms('torrents_edit')
- View::show_footer();
|