mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 01:08:56 +00:00
Add admin SiteController
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
2018-04-17 DariusIII
|
||||
* Chg: Add admin SiteController
|
||||
* Chg: Add admin UserController
|
||||
* Chg: Add BookController and edit Blacklist/Anidb class
|
||||
* Chg: Add admin CategoryController
|
||||
|
||||
@@ -0,0 +1,232 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\BasePageController;
|
||||
use App\Models\Category;
|
||||
use App\Models\Release;
|
||||
use App\Models\Settings;
|
||||
use App\Models\User;
|
||||
use App\Models\UserRole;
|
||||
use Blacklight\SABnzbd;
|
||||
use Blacklight\Sites;
|
||||
use Blacklight\utility\Utility;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class SiteController extends BasePageController
|
||||
{
|
||||
/**
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function edit(Request $request)
|
||||
{
|
||||
$this->setAdminPrefs();
|
||||
|
||||
$sites = new Sites();
|
||||
|
||||
// set the current action
|
||||
$action = $request->input('action') ?? 'view';
|
||||
|
||||
switch ($action) {
|
||||
case 'submit':
|
||||
if (! $request->has('book_reqids')) {
|
||||
$request->merge(['book_reqids' => []]);
|
||||
}
|
||||
$error = '';
|
||||
$ret = Settings::settingsUpdate($request->all());
|
||||
if (\is_int($ret)) {
|
||||
if ($ret === Settings::ERR_BADUNRARPATH) {
|
||||
$error = 'The unrar path does not point to a valid binary';
|
||||
} elseif ($ret === Settings::ERR_BADFFMPEGPATH) {
|
||||
$error = 'The ffmpeg path does not point to a valid binary';
|
||||
} elseif ($ret === Settings::ERR_BADMEDIAINFOPATH) {
|
||||
$error = 'The mediainfo path does not point to a valid binary';
|
||||
} elseif ($ret === Settings::ERR_BADNZBPATH) {
|
||||
$error = 'The nzb path does not point to a valid directory';
|
||||
} elseif ($ret === Settings::ERR_DEEPNOUNRAR) {
|
||||
$error = 'Deep password check requires a valid path to unrar binary';
|
||||
} elseif ($ret === Settings::ERR_BADTMPUNRARPATH) {
|
||||
$error = 'The temp unrar path is not a valid directory';
|
||||
} elseif ($ret === Settings::ERR_BADLAMEPATH) {
|
||||
$error = 'The lame path is not a valid directory';
|
||||
} elseif ($ret === Settings::ERR_SABCOMPLETEPATH) {
|
||||
$error = 'The sab complete path is not a valid directory';
|
||||
}
|
||||
}
|
||||
|
||||
if ($error === '') {
|
||||
$site = $ret;
|
||||
$returnid = $site['id'];
|
||||
return redirect('site-edit.php?id='.$returnid);
|
||||
}
|
||||
|
||||
$this->smarty->assign('error', $error);
|
||||
$site = $sites->row2Object($request->all());
|
||||
$this->smarty->assign('site', $site);
|
||||
|
||||
break;
|
||||
case 'view':
|
||||
default:
|
||||
|
||||
$title = 'Site Edit';
|
||||
$site = $this->settings;
|
||||
$this->smarty->assign('site', $site);
|
||||
$this->smarty->assign('settings', Settings::toTree());
|
||||
break;
|
||||
}
|
||||
|
||||
$this->smarty->assign('yesno_ids', [1, 0]);
|
||||
$this->smarty->assign('yesno_names', ['Yes', 'No']);
|
||||
|
||||
$this->smarty->assign('passwd_ids', [1, 0]);
|
||||
$this->smarty->assign('passwd_names', ['Deep (requires unrar)', 'None']);
|
||||
|
||||
/*0 = English, 2 = Danish, 3 = French, 1 = German*/
|
||||
$this->smarty->assign('langlist_ids', [0, 2, 3, 1]);
|
||||
$this->smarty->assign('langlist_names', ['English', 'Danish', 'French', 'German']);
|
||||
|
||||
$this->smarty->assign(
|
||||
'imdblang_ids',
|
||||
[
|
||||
'en', 'da', 'nl', 'fi', 'fr', 'de', 'it', 'tlh', 'no', 'po', 'ru', 'es',
|
||||
'sv',
|
||||
]
|
||||
);
|
||||
$this->smarty->assign(
|
||||
'imdblang_names',
|
||||
[
|
||||
'English', 'Danish', 'Dutch', 'Finnish', 'French', 'German', 'Italian',
|
||||
'Klingon', 'Norwegian', 'Polish', 'Russian', 'Spanish', 'Swedish',
|
||||
]
|
||||
);
|
||||
|
||||
$this->smarty->assign('sabintegrationtype_ids', [SABnzbd::INTEGRATION_TYPE_USER, SABnzbd::INTEGRATION_TYPE_NONE]);
|
||||
$this->smarty->assign('sabintegrationtype_names', ['User', 'None (Off)']);
|
||||
|
||||
$this->smarty->assign('newgroupscan_names', ['Days', 'Posts']);
|
||||
|
||||
$this->smarty->assign('registerstatus_ids', [Settings::REGISTER_STATUS_OPEN, Settings::REGISTER_STATUS_INVITE, Settings::REGISTER_STATUS_CLOSED]);
|
||||
$this->smarty->assign('registerstatus_names', ['Open', 'Invite', 'Closed']);
|
||||
|
||||
$this->smarty->assign('passworded_ids', [0, 1, 2]);
|
||||
$this->smarty->assign('passworded_names', [
|
||||
'Hide passworded or potentially passworded (*yes)',
|
||||
'Hide passworded or potentially passworded (*no)',
|
||||
'Show non-passworded and potentially passworded (*no)',
|
||||
'Show everything (*no)',
|
||||
]);
|
||||
|
||||
$this->smarty->assign('lookuplanguage_iso', ['en', 'de', 'es', 'fr', 'it', 'nl', 'pt', 'sv']);
|
||||
$this->smarty->assign('lookuplanguage_names', ['English', 'Deutsch', 'Español', 'Français', 'Italiano', 'Nederlands', 'Português', 'Svenska']);
|
||||
|
||||
$this->smarty->assign('imdb_urls', [0, 1]);
|
||||
$this->smarty->assign('imdburl_names', ['imdb.com', 'akas.imdb.com']);
|
||||
|
||||
$this->smarty->assign('lookupbooks_ids', [0, 1, 2]);
|
||||
$this->smarty->assign('lookupbooks_names', ['Disabled', 'Lookup All Books', 'Lookup Renamed Books']);
|
||||
|
||||
$this->smarty->assign('lookupgames_ids', [0, 1, 2]);
|
||||
$this->smarty->assign('lookupgames_names', ['Disabled', 'Lookup All Consoles', 'Lookup Renamed Consoles']);
|
||||
|
||||
$this->smarty->assign('lookupmusic_ids', [0, 1, 2]);
|
||||
$this->smarty->assign('lookupmusic_names', ['Disabled', 'Lookup All Music', 'Lookup Renamed Music']);
|
||||
|
||||
$this->smarty->assign('lookupmovies_ids', [0, 1, 2]);
|
||||
$this->smarty->assign('lookupmovies_names', ['Disabled', 'Lookup All Movies', 'Lookup Renamed Movies']);
|
||||
|
||||
$this->smarty->assign('lookuptv_ids', [0, 1, 2]);
|
||||
$this->smarty->assign('lookuptv_names', ['Disabled', 'Lookup All TV', 'Lookup Renamed TV']);
|
||||
|
||||
$this->smarty->assign('lookup_reqids_ids', [0, 1, 2]);
|
||||
$this->smarty->assign('lookup_reqids_names', ['Disabled', 'Lookup Request IDs', 'Lookup Request IDs Threaded']);
|
||||
|
||||
$this->smarty->assign('coversPath', NN_COVERS);
|
||||
|
||||
// return a list of audiobooks, mags, ebooks, technical and foreign books
|
||||
$result = Category::query()->whereIn('id', [Category::MUSIC_AUDIOBOOK, Category::BOOKS_MAGAZINES, Category::BOOKS_TECHNICAL, Category::BOOKS_FOREIGN])->get(['id', 'title']);
|
||||
|
||||
// setup the display lists for these categories, this could have been static, but then if names changed they would be wrong
|
||||
$book_reqids_ids = [];
|
||||
$book_reqids_names = [];
|
||||
foreach ($result as $bookcategory) {
|
||||
$book_reqids_ids[] = $bookcategory['id'];
|
||||
$book_reqids_names[] = $bookcategory['title'];
|
||||
}
|
||||
|
||||
// convert from a string array to an int array as we want to use int
|
||||
$book_reqids_ids = array_map(function ($value) {
|
||||
return (int) $value;
|
||||
}, $book_reqids_ids);
|
||||
$this->smarty->assign('book_reqids_ids', $book_reqids_ids);
|
||||
$this->smarty->assign('book_reqids_names', $book_reqids_names);
|
||||
|
||||
// convert from a list to an array as we need to use an array, but teh Settings table only saves strings
|
||||
$books_selected = explode(',', Settings::settingValue('..book_reqids'));
|
||||
|
||||
// convert from a string array to an int array
|
||||
$books_selected = array_map(function ($value) {
|
||||
return (int) $value;
|
||||
}, $books_selected);
|
||||
$this->smarty->assign('book_reqids_selected', $books_selected);
|
||||
|
||||
$this->smarty->assign('themelist', Utility::getThemesList());
|
||||
|
||||
if (strpos(env('NNTP_SERVER'), 'astra') === false) {
|
||||
$this->smarty->assign('compress_headers_warning', 'compress_headers_warning');
|
||||
}
|
||||
|
||||
$content = $this->smarty->fetch('site-edit.tpl');
|
||||
|
||||
$this->smarty->assign(
|
||||
[
|
||||
'title' => $title,
|
||||
'content' => $content,
|
||||
]
|
||||
);
|
||||
|
||||
$this->adminrender();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function stats()
|
||||
{
|
||||
$this->setAdminPrefs();
|
||||
|
||||
$title = 'Site Stats';
|
||||
|
||||
$topgrabs = User::getTopGrabbers();
|
||||
$this->smarty->assign('topgrabs', $topgrabs);
|
||||
|
||||
$topdownloads = Release::getTopDownloads();
|
||||
$this->smarty->assign('topdownloads', $topdownloads);
|
||||
|
||||
$topcomments = Release::getTopComments();
|
||||
$this->smarty->assign('topcomments', $topcomments);
|
||||
|
||||
$recent = Category::getRecentlyAdded();
|
||||
$this->smarty->assign('recent', $recent);
|
||||
|
||||
$usersbymonth = User::getUsersByMonth();
|
||||
$this->smarty->assign('usersbymonth', $usersbymonth);
|
||||
|
||||
$usersbyrole = UserRole::getUsersByRole();
|
||||
$this->smarty->assign('usersbyrole', $usersbyrole);
|
||||
$this->smarty->assign('totusers', 0);
|
||||
$this->smarty->assign('totrusers', 0);
|
||||
|
||||
$content = $this->smarty->fetch('site-stats.tpl');
|
||||
|
||||
$this->smarty->assign(
|
||||
[
|
||||
'title' => $title,
|
||||
'content' => $content,
|
||||
]
|
||||
);
|
||||
|
||||
$this->adminrender();
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ class UserController extends BasePageController
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function index()
|
||||
public function index(Request $request)
|
||||
{
|
||||
$this->setAdminPrefs();
|
||||
|
||||
|
||||
@@ -215,4 +215,14 @@ Route::prefix('admin')->group(function () {
|
||||
Route::post('category-list', 'Admin\CategoryController@index');
|
||||
Route::get('category-edit', 'Admin\CategoryController@edit');
|
||||
Route::post('category-edit', 'Admin\CategoryController@edit');
|
||||
Route::get('user-list', 'Admin\UserController@index');
|
||||
Route::post('user-list', 'Admin\UserController@index');
|
||||
Route::get('user-edit', 'Admin\UserController@edit');
|
||||
Route::post('user-edit', 'Admin\UserController@edit');
|
||||
Route::get('user-delete', 'Admin\UserController@destroy');
|
||||
Route::post('user-delete', 'Admin\UserController@destroy');
|
||||
Route::get('site-edit', 'Admin\SiteController@edit');
|
||||
Route::post('site-edit', 'Admin\SiteController@edit');
|
||||
Route::get('site-stats', 'Admin\SiteController@stats');
|
||||
Route::post('site-stats', 'Admin\SiteController@stats');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user