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.
56 lines
1.7 KiB
56 lines
1.7 KiB
<?php
|
|
|
|
use nzedb\NZBImport;
|
|
|
|
// Check if the user is running from CLI.
|
|
if (PHP_SAPI === 'cli') {
|
|
exit('This is a web only script, run misc/testing/nzb-import.php instead.');
|
|
}
|
|
|
|
require_once './config.php';
|
|
$page = new AdminPage();
|
|
|
|
$filesToProcess = [];
|
|
$output = '';
|
|
if ($page->isPostBack()) {
|
|
|
|
$useNzbName = false;
|
|
$deleteNZB = true;
|
|
// Get the list of NZB files from php /tmp folder if nzb files were uploaded.
|
|
if (isset($_FILES["uploadedfiles"])) {
|
|
foreach ($_FILES["uploadedfiles"]["error"] as $key => $error) {
|
|
if ($error == UPLOAD_ERR_OK) {
|
|
$tmp_name = $_FILES["uploadedfiles"]["tmp_name"][$key];
|
|
$name = $_FILES["uploadedfiles"]["name"][$key];
|
|
$filesToProcess[] = $tmp_name;
|
|
}
|
|
}
|
|
} else {
|
|
|
|
// Check if the user wants to use the file name as the release name.
|
|
$useNzbName = (isset($_POST['usefilename']) && $_POST["usefilename"] == 'on') ? true : false;
|
|
|
|
// Check if the user wants to delete the NZB file when done importing.
|
|
$deleteNZB = (isset($_POST['deleteNZB']) && $_POST["deleteNZB"] == 'on') ? true : false;
|
|
|
|
// Get the path the user set in the browser if he put one.
|
|
$path = (isset($_POST["folder"]) ? $_POST["folder"] : "");
|
|
if (substr($path, strlen($path) - 1) !== DS) {
|
|
$path .= DS;
|
|
}
|
|
|
|
// Get the files from the user specified path.
|
|
$filesToProcess = glob($path . "*.nzb");
|
|
}
|
|
|
|
if (count($filesToProcess) > 0) {
|
|
// Create a new instance of NZBImport and send it the file locations.
|
|
$output = (new NZBImport(['Browser' => true, 'Settings' => $page->settings]))->beginImport(
|
|
$filesToProcess, $useNzbName, $deleteNZB
|
|
);
|
|
}
|
|
}
|
|
$page->smarty->assign('output', $output);
|
|
$page->title = "Import Nzbs";
|
|
$page->content = $page->smarty->fetch('nzb-import.tpl');
|
|
$page->render();
|
|
|