mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 01:08:56 +00:00
Add FileListController and routes
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Release;
|
||||
use Blacklight\NZB;
|
||||
|
||||
class FileListController extends BasePageController
|
||||
{
|
||||
/**
|
||||
* @param $guid
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function show($guid)
|
||||
{
|
||||
$this->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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Release;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
// Page is accessible only by the rss token, or logged in users.
|
||||
if (Auth::check()) {
|
||||
$uid = Auth::id();
|
||||
$rssToken = $page->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);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -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');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user