isLoggedIn()) { http_response_code(403); die('You must be logged in to view this page.'); } if(!$sUserInfo->canCreateTorrents()) { http_response_code(403); die('You are not allowed to view this page.'); } if(!empty($_FILES['torrent'])) { if(empty($_POST['boob']) || !hash_equals($sVerification, (string)filter_input(INPUT_POST, 'boob'))) { $cError = 'Request verification failed.'; } else { if(!isset($_FILES['torrent']['error']) || is_array($_FILES['torrent']['error'])) { $cError = 'Invalid parameters.'; } else { if($_FILES['torrent']['error'] !== UPLOAD_ERR_OK) { $cError = [ UPLOAD_ERR_NO_FILE => 'No file was sent.', UPLOAD_ERR_INI_SIZE => 'File size limit exceeded.', UPLOAD_ERR_FORM_SIZE => 'File size limit exceeded.', ][$_FILES['torrent']['error']] ?? 'An unexpected error occurred.'; } else { if(!is_uploaded_file($_FILES['torrent']['tmp_name'])) { $cError = 'File was not an uploaded file(?).'; } else { $torrentFile = fopen($_FILES['torrent']['tmp_name'], 'rb'); try { $cTorrentBuilder = SeriaTorrentBuilder::decode($torrentFile); $cTorrentBuilder->setUser($sUserInfo); $cTorrentInfo = $cTorrentBuilder->create($pdo); header('Location: /info.php?id=' . $cTorrentInfo->getId()); exit; } catch(Exception $ex) { $cError = $ex->getMessage(); if(empty($cError)) $cError = (string)$ex; } finally { fclose($torrentFile); } } } } } } $tPageTitle = 'Create Torrent'; $cTrackerUrl = 'https://' . $_SERVER['HTTP_HOST'] . '/announce.php/' . $sUserInfo->getPassKey(); require_once __DIR__ . '/_header.php'; echo '
'; echo '
'; echo '

Creating a torrent

'; echo '

Here you can submit a torrent for tracking.

'; echo '

You can use any client for submission. This page does not contain any of its own fields, the creator in your client should be sufficient.

'; echo '

Use as the tracker url so you\'re immediately seeding the torrent, the tracker will error but that\'s temporary since the torrent has not been submitted yet. This URL contains your private pass key, do not share it.

'; echo '

After your torrent has been submitted it will be queued for approval and won\'t immediately be available.

'; echo '
'; if(!empty($cError)) { echo '
'; echo '
Error
'; echo '
'; echo htmlspecialchars($cError); echo '
'; echo '
'; } echo '
'; echo '
'; echo ''; echo ''; echo ''; echo '
'; echo '
'; echo '
'; require_once __DIR__ . '/_footer.php';