From ff3ca584afff861965ede2245c628064fddcbbe9 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Sun, 8 Apr 2018 22:48:44 +0200 Subject: [PATCH] Add FileListController and routes --- Changelog | 1 + app/Http/Controllers/FileListController.php | 61 +++++++++++++++++++++ public/pages/failed.php | 38 ------------- routes/web.php | 6 +- 4 files changed, 65 insertions(+), 41 deletions(-) create mode 100644 app/Http/Controllers/FileListController.php delete mode 100644 public/pages/failed.php diff --git a/Changelog b/Changelog index 80f9874f4..574836e54 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2018-04-08 DariusIII + * Chg: Add FileListController and routes * Chg: Add FailedReleasesController and routes * Chg: Add ContentController and route 2018-04-07 DariusIII diff --git a/app/Http/Controllers/FileListController.php b/app/Http/Controllers/FileListController.php new file mode 100644 index 000000000..ab3106b54 --- /dev/null +++ b/app/Http/Controllers/FileListController.php @@ -0,0 +1,61 @@ +setPrefs(); + $nzb = new NZB(); + + if ($guid !== null) { + $rel = Release::getByGuid($guid); + if (! $rel) { + $this->show404(); + } + + $nzbpath = $nzb->NZBPath($guid); + + if (! file_exists($nzbpath)) { + $this->show404(); + } + + ob_start(); + @readgzfile($nzbpath); + $nzbfile = ob_get_contents(); + ob_end_clean(); + + $ret = $nzb->nzbFileList($nzbfile); + + $this->smarty->assign('rel', $rel); + $this->smarty->assign('files', $ret); + + $title = 'File List'; + $meta_title = 'View Nzb file list'; + $meta_keywords = 'view,nzb,file,list,description,details'; + $meta_description = 'View Nzb File List'; + + $content = $this->smarty->fetch('viewfilelist.tpl'); + + + $this->smarty->assign( + [ + 'title' => $title, + 'content' => $content, + 'meta_title' => $meta_title, + 'meta_keywords' => $meta_keywords, + 'meta_description' => $meta_description, + ] + ); + $this->pagerender(); + } + } +} diff --git a/public/pages/failed.php b/public/pages/failed.php deleted file mode 100644 index cf0b363d4..000000000 --- a/public/pages/failed.php +++ /dev/null @@ -1,38 +0,0 @@ -userdata['rsstoken']; -} else { - if (! request()->has('userid') || ! request()->has('rsstoken')) { - header('X-DNZB-RCode: 400'); - header('X-DNZB-RText: Bad request, please supply all parameters!'); - $page->show403(); - } else { - $res = User::getByIdAndRssToken(request()->input('userid'), request()->input('rsstoken')); - } - if (! isset($res)) { - header('X-DNZB-RCode: 401'); - header('X-DNZB-RText: Unauthorised, wrong user ID or rss key!'); - $page->show403(); - } else { - $uid = $res['id']; - $rssToken = $res['rsstoken']; - } -} - -if (isset($uid, $rssToken) && is_numeric($uid) && request()->has('guid')) { - $alt = Release::getAlternate(request()->input('guid'), $uid); - if ($alt === null) { - header('X-DNZB-RCode: 404'); - header('X-DNZB-RText: No NZB found for alternate match.'); - $page->show404(); - } else { - header('Location: '.$page->serverurl.'getnzb?id='.$alt['guid'].'&i='.$uid.'&r='.$rssToken); - } -} diff --git a/routes/web.php b/routes/web.php index 28e6c6c5b..9930acb55 100644 --- a/routes/web.php +++ b/routes/web.php @@ -143,9 +143,9 @@ Route::post('/search/{id}', function () { redirect('/search'); })->middleware('auth', 'api'); -Route::get('/filelist/{id}', function () { - redirect('/filelist'); -})->middleware('auth'); +Route::get('filelist/{guid}', 'FileListController@show'); + +Route::post('filelist/{guid}', 'FileListController@show'); Route::get('btc_payment', 'BtcPaymentController@show');