Use config where possible

This commit is contained in:
DariusIII
2024-10-28 11:29:09 +01:00
parent 2057bf906c
commit 05ebaf4442
36 changed files with 144 additions and 130 deletions
+23 -3
View File
@@ -20,6 +20,9 @@ ELASTICSEARCH_PASS=
ELASTICSEARCH_LOGGING=false ELASTICSEARCH_LOGGING=false
ELASTICSEARCH_ENABLED=false ELASTICSEARCH_ENABLED=false
NNTP_COMPRESSED_HEADERS=false
USE_ALTERNATE_NNTP_SERVER=false
NNTP_USERNAME= NNTP_USERNAME=
NNTP_PASSWORD= NNTP_PASSWORD=
NNTP_SERVER= NNTP_SERVER=
@@ -110,7 +113,8 @@ ITEMS_PER_PAGE=50
ITEMS_PER_COVER_PAGE=25 ITEMS_PER_COVER_PAGE=25
MAX_PAGER_RESULTS=125000 MAX_PAGER_RESULTS=125000
ECHOCLI=true ECHOCLI=true
RENAME_PAR2 = false RENAME_PAR2=false
ADD_PAR2=false
RENAME_MUSIC_MEDIAINFO=true RENAME_MUSIC_MEDIAINFO=true
CACHE_EXPIRY_SHORT=5 CACHE_EXPIRY_SHORT=5
CACHE_EXPIRY_MEDIUM=10 CACHE_EXPIRY_MEDIUM=10
@@ -149,8 +153,8 @@ FANARTTV_APIKEY=
OMDB_APIKEY= OMDB_APIKEY=
TRAKTTV_APIKEY= TRAKTTV_APIKEY=
TEMP_UNRAR_PATH= TEMP_UNRAR_PATH='/var/www/nntmux/resources/tmp/unrar/'
TEMP_UNZIP_PATH= TEMP_UNZIP_PATH='/var/www/nntmux/resources/tmp/unzip/'
VIEW_COMPILED_PATH=/var/www/NNTmux/storage/framework/views VIEW_COMPILED_PATH=/var/www/NNTmux/storage/framework/views
ASSET_URL= ASSET_URL=
@@ -184,3 +188,19 @@ PURGE_INACTIVE_USERS=false
OTP_ENABLED=false OTP_ENABLED=false
FLARE_KEY= FLARE_KEY=
UNRAR_PATH=
UNZIP_PATH=
CHECK_PASSWORDED_RARS=false
DELETE_PASSWORDED_RELEASES=false
DELETE_POSSIBLE_PASSWORDED_RELEASES=false
EXTRACT_USING_RARINFO=false
PATH_TO_NZBS='/var/www/NNTmux/storage/nzb'
PRIVATE_PROFILES=true
STORE_USER_IP=false
FFMPEG_PATH=
LAME_PATH=
MEDIAINFO_PATH=
TIIMEOUT_PATH=
MAGIC_FILE_PATH=
COVERS_PATH='/var/www/nntmux/storage/covers/'
+1 -1
View File
@@ -54,7 +54,7 @@ class Backfill
$this->colorCli = new ColorCLI; $this->colorCli = new ColorCLI;
$this->_compressedHeaders = (int) Settings::settingValue('..compressedheaders') === 1; $this->_compressedHeaders = config('nntmux_nntp.compressed_headers');
$this->_safeBackFillDate = Settings::settingValue('..safebackfilldate') !== '' ? (string) Settings::settingValue('safebackfilldate') : '2012-08-14'; $this->_safeBackFillDate = Settings::settingValue('..safebackfilldate') !== '' ? (string) Settings::settingValue('safebackfilldate') : '2012-08-14';
$this->_safePartRepair = (int) Settings::settingValue('..safepartrepair') === 1 ? 'update' : 'backfill'; $this->_safePartRepair = (int) Settings::settingValue('..safepartrepair') === 1 ? 'update' : 'backfill';
$this->_disableBackfillGroup = (int) Settings::settingValue('..disablebackfillgroup') === 1; $this->_disableBackfillGroup = (int) Settings::settingValue('..disablebackfillgroup') === 1;
+1 -1
View File
@@ -182,7 +182,7 @@ class Binaries
$this->messageBuffer = Settings::settingValue('..maxmssgs') !== '' ? $this->messageBuffer = Settings::settingValue('..maxmssgs') !== '' ?
(int) Settings::settingValue('..maxmssgs') : 20000; (int) Settings::settingValue('..maxmssgs') : 20000;
$this->_compressedHeaders = (int) Settings::settingValue('..compressedheaders') === 1; $this->_compressedHeaders = config('nntmux_nntp.compressed_headers');
$this->_partRepair = (int) Settings::settingValue('..partrepair') === 1; $this->_partRepair = (int) Settings::settingValue('..partrepair') === 1;
$this->_newGroupScanByDays = (int) Settings::settingValue('..newgroupscanmethod') === 1; $this->_newGroupScanByDays = (int) Settings::settingValue('..newgroupscanmethod') === 1;
$this->_newGroupMessagesToScan = Settings::settingValue('..newgroupmsgstoscan') !== '' ? (int) Settings::settingValue('..newgroupmsgstoscan') : 50000; $this->_newGroupMessagesToScan = Settings::settingValue('..newgroupmsgstoscan') !== '' ? (int) Settings::settingValue('..newgroupmsgstoscan') : 50000;
+2 -2
View File
@@ -69,8 +69,8 @@ class Books
$this->bookqty = Settings::settingValue('..maxbooksprocessed') !== '' ? (int) Settings::settingValue('..maxbooksprocessed') : 300; $this->bookqty = Settings::settingValue('..maxbooksprocessed') !== '' ? (int) Settings::settingValue('..maxbooksprocessed') : 300;
$this->sleeptime = Settings::settingValue('..amazonsleep') !== '' ? (int) Settings::settingValue('..amazonsleep') : 1000; $this->sleeptime = Settings::settingValue('..amazonsleep') !== '' ? (int) Settings::settingValue('..amazonsleep') : 1000;
$this->imgSavePath = storage_path('covers/book/'); $this->imgSavePath = storage_path('covers/book/');
$result = Settings::settingValue('..book_reqids');
$this->bookreqids = $result ?? Category::BOOKS_EBOOK; $this->bookreqids = Category::BOOKS_EBOOK;
$this->renamed = (int) Settings::settingValue('..lookupbooks') === 2 ? 'AND isrenamed = 1' : ''; $this->renamed = (int) Settings::settingValue('..lookupbooks') === 2 ? 'AND isrenamed = 1' : '';
$this->failCache = []; $this->failCache = [];
+6 -4
View File
@@ -261,7 +261,7 @@ class NNTP extends \Net_NNTP_Client
// If we are connected and authenticated, try enabling compression if we have it enabled. // If we are connected and authenticated, try enabling compression if we have it enabled.
if ($connected && $authenticated) { if ($connected && $authenticated) {
// Check if we should use compression on the connection. // Check if we should use compression on the connection.
if (! $compression || (int) Settings::settingValue('..compressedheaders') === 0) { if (! $compression || config('nntmux_nntp.compressed_headers') === false) {
$this->_compressionSupported = false; $this->_compressionSupported = false;
} }
@@ -325,7 +325,7 @@ class NNTP extends \Net_NNTP_Client
*/ */
public function enableCompression(): void public function enableCompression(): void
{ {
if ((int) Settings::settingValue('..compressedheaders') !== 1) { if (config('nntmux_nntp.compressed_headers') === false) {
return; return;
} }
$this->_enableCompression(); $this->_enableCompression();
@@ -554,8 +554,9 @@ class NNTP extends \Net_NNTP_Client
// If there is an error try the alternate provider or return the PEAR error. // If there is an error try the alternate provider or return the PEAR error.
} elseif ($alternate) { } elseif ($alternate) {
if (! $aConnected) { if (! $aConnected) {
$compressedHeaders = config('nntmux_nntp.compressed_headers');
// Check if the current connected server is the alternate or not. // Check if the current connected server is the alternate or not.
$aConnected = $this->_currentServer === config('nntmux_nntp.server') ? $nntp->doConnect(true, true) : $nntp->doConnect(); $aConnected = $this->_currentServer === config('nntmux_nntp.server') ? $nntp->doConnect($compressedHeaders, true) : $nntp->doConnect();
} }
// If we connected successfully to usenet try to download the article body. // If we connected successfully to usenet try to download the article body.
if ($aConnected === true) { if ($aConnected === true) {
@@ -590,7 +591,8 @@ class NNTP extends \Net_NNTP_Client
} elseif (\is_string($identifiers) || is_numeric($identifiers)) { } elseif (\is_string($identifiers) || is_numeric($identifiers)) {
$body = $this->_getMessage($groupName, $identifiers); $body = $this->_getMessage($groupName, $identifiers);
if ($alternate && self::isError($body)) { if ($alternate && self::isError($body)) {
$nntp->doConnect(true, true); $compressedHeaders = config('nntmux_nntp.compressed_headers');
$nntp->doConnect($compressedHeaders, true);
$body = $nntp->_getMessage($groupName, $identifiers); $body = $nntp->_getMessage($groupName, $identifiers);
$aConnected = true; $aConnected = true;
} }
+1 -1
View File
@@ -65,7 +65,7 @@ class NZB
{ {
$nzbSplitLevel = (int) Settings::settingValue('..nzbsplitlevel'); $nzbSplitLevel = (int) Settings::settingValue('..nzbsplitlevel');
$this->nzbSplitLevel = $nzbSplitLevel ?? 1; $this->nzbSplitLevel = $nzbSplitLevel ?? 1;
$this->siteNzbPath = (string) Settings::settingValue('..nzbpath'); $this->siteNzbPath = config('nntmux_settings.path_to_nzbs');
if (! Str::endsWith($this->siteNzbPath, '/')) { if (! Str::endsWith($this->siteNzbPath, '/')) {
$this->siteNzbPath .= '/'; $this->siteNzbPath .= '/';
} }
+1 -1
View File
@@ -41,7 +41,7 @@ class NZBContents
$this->pp = new PostProcess; $this->pp = new PostProcess;
$this->nzb = new NZB; $this->nzb = new NZB;
$this->lookuppar2 = (int) Settings::settingValue('..lookuppar2') === 1; $this->lookuppar2 = (int) Settings::settingValue('..lookuppar2') === 1;
$this->alternateNNTP = (int) Settings::settingValue('..alternate_nntp') === 1; $this->alternateNNTP = config('nntmux_nntp.use_alternate_nntp_server');
} }
/** /**
-25
View File
@@ -187,10 +187,6 @@ class Forking
$this->postProcessNfo(); $this->postProcessNfo();
break; break;
case 'postProcess_sha':
$this->processSharing();
break;
case 'postProcess_tv': case 'postProcess_tv':
$this->ppRenamedOnly = (isset($this->workTypeOptions[0]) && $this->workTypeOptions[0] === true); $this->ppRenamedOnly = (isset($this->workTypeOptions[0]) && $this->workTypeOptions[0] === true);
$this->postProcessTv(); $this->postProcessTv();
@@ -841,27 +837,6 @@ class Forking
$this->postProcess($this->work, $this->maxProcesses); $this->postProcess($this->work, $this->maxProcesses);
} }
/**
* Process sharing.
*
*
* @throws \Exception
*/
private function processSharing(): bool
{
$sharing = DB::select('SELECT enabled FROM sharing');
if ($sharing > 0 && (int) $sharing[0]->enabled === 1) {
$nntp = new NNTP;
if ((int) (Settings::settingValue('..alternate_nntp') === 1 ? $nntp->doConnect(true, true) : $nntp->doConnect()) === true) {
(new PostProcess(['ColorCLI' => $this->colorCli]))->processSharing($nntp);
}
return true;
}
return false;
}
/** /**
* Process all that require a single thread. * Process all that require a single thread.
* *
+2 -2
View File
@@ -59,8 +59,8 @@ class PostProcess
$this->Nfo = new Nfo; $this->Nfo = new Nfo;
// Site settings. // Site settings.
$this->addpar2 = (int) Settings::settingValue('..addpar2') !== 0; $this->addpar2 = config('nntmux:settings.add_par2');
$this->alternateNNTP = (int) Settings::settingValue('..alternate_nntp') === 1; $this->alternateNNTP = config('nntmux_nntp.use_alternate_nntp_server');
} }
/** /**
@@ -285,17 +285,15 @@ class ProcessAdditional
// Pass the binary extractors to ArchiveInfo. // Pass the binary extractors to ArchiveInfo.
$clients = []; $clients = [];
if (! empty(Settings::settingValue('apps..unrarpath'))) { $this->_unrarPath = config('nntmux_settings.unrar_path');
$this->_unrarPath = Settings::settingValue('apps..unrarpath'); $clients += [ArchiveInfo::TYPE_RAR => $this->_unrarPath];
$clients += [ArchiveInfo::TYPE_RAR => $this->_unrarPath];
}
$this->_archiveInfo->setExternalClients($clients); $this->_archiveInfo->setExternalClients($clients);
$this->_killString = '"'; $this->_killString = '"';
if (! empty(Settings::settingValue('apps..timeoutpath')) && (int) Settings::settingValue('..timeoutseconds') > 0) { if (config('nntmux_settings.timeout_path') && (int) Settings::settingValue('..timeoutseconds') > 0) {
$this->_killString = ( $this->_killString = (
'"'.Settings::settingValue('apps..timeoutpath'). '"'.config('nntmux_settings.timeout_path').
'" --foreground --signal=KILL '. '" --foreground --signal=KILL '.
Settings::settingValue('..timeoutseconds').' "' Settings::settingValue('..timeoutseconds').' "'
); );
@@ -327,13 +325,13 @@ class ProcessAdditional
$this->_minSize = (Settings::settingValue('..minsizetopostprocess') !== '') ? (int) Settings::settingValue('..minsizetopostprocess') : 100; $this->_minSize = (Settings::settingValue('..minsizetopostprocess') !== '') ? (int) Settings::settingValue('..minsizetopostprocess') : 100;
// Use the alternate NNTP provider for downloading Message-ID's ? // Use the alternate NNTP provider for downloading Message-ID's ?
$this->_alternateNNTP = (int) Settings::settingValue('..alternate_nntp') === 1; $this->_alternateNNTP = config('nntmux_nntp.use_alternate_nntp_server');
$this->_ffMPEGDuration = Settings::settingValue('..ffmpeg_duration') !== '' ? (int) Settings::settingValue('..ffmpeg_duration') : 5; $this->_ffMPEGDuration = Settings::settingValue('..ffmpeg_duration') !== '' ? (int) Settings::settingValue('..ffmpeg_duration') : 5;
$this->_addPAR2Files = (int) Settings::settingValue('..addpar2') !== 0; $this->_addPAR2Files = config('nntmux:settings.add_par2');
if (! Settings::settingValue('apps..ffmpegpath')) { if (! config('nntmux_settings.ffmpeg_path')) {
$this->_processAudioSample = $this->_processThumbnails = $this->_processVideo = false; $this->_processAudioSample = $this->_processThumbnails = $this->_processVideo = false;
} else { } else {
$this->_processAudioSample = (int) Settings::settingValue('..saveaudiopreview') !== 0; $this->_processAudioSample = (int) Settings::settingValue('..saveaudiopreview') !== 0;
@@ -342,11 +340,11 @@ class ProcessAdditional
} }
$this->_processJPGSample = (int) Settings::settingValue('..processjpg') !== 0; $this->_processJPGSample = (int) Settings::settingValue('..processjpg') !== 0;
$this->_processMediaInfo = Settings::settingValue('apps..mediainfopath') !== ''; $this->_processMediaInfo = config('nntmux_settings.mediainfo_path');
$this->_processAudioInfo = $this->_processMediaInfo; $this->_processAudioInfo = $this->_processMediaInfo;
$this->_processPasswords = ! empty(Settings::settingValue('..checkpasswordedrar')) && ! empty(Settings::settingValue('apps..unrarpath')); $this->_processPasswords = config('nntmux_settings.check_passworded_rars') === true && ! empty(config('nntmux_settings.unrar_path'));
$this->_audioSavePath = storage_path('covers/audiosample/'); $this->_audioSavePath = config('nntmux_settings.covers_path').'/audiosample/';
$this->_audioFileRegex = '\.(AAC|AIFF|APE|AC3|ASF|DTS|FLAC|MKA|MKS|MP2|MP3|RA|OGG|OGM|W64|WAV|WMA)'; $this->_audioFileRegex = '\.(AAC|AIFF|APE|AC3|ASF|DTS|FLAC|MKA|MKS|MP2|MP3|RA|OGG|OGM|W64|WAV|WMA)';
$this->_ignoreBookRegex = '/\b(epub|lit|mobi|pdf|sipdf|html)\b.*\.rar(?!.{20,})/i'; $this->_ignoreBookRegex = '/\b(epub|lit|mobi|pdf|sipdf|html)\b.*\.rar(?!.{20,})/i';
+1 -1
View File
@@ -127,7 +127,7 @@ class Utility
*/ */
public static function fileInfo(string $path): string public static function fileInfo(string $path): string
{ {
$magicPath = Settings::settingValue('apps.indexer.magic_file_path'); $magicPath = config('nntmux_settings.magic_file_path');
if ($magicPath !== null && Process::run('which file')->successful()) { if ($magicPath !== null && Process::run('which file')->successful()) {
$magicSwitch = " -m $magicPath"; $magicSwitch = " -m $magicPath";
$output = runCmd('file'.$magicSwitch.' -b "'.$path.'"'); $output = runCmd('file'.$magicSwitch.' -b "'.$path.'"');
+1 -1
View File
@@ -55,7 +55,7 @@ class CleanNZB extends Command
$releases = new Release; $releases = new Release;
$checked = $deleted = 0; $checked = $deleted = 0;
// Get the list of NZBs in the NZB folder // Get the list of NZBs in the NZB folder
$dirItr = new \RecursiveDirectoryIterator(Settings::settingValue('..nzbpath')); $dirItr = new \RecursiveDirectoryIterator(config('nntmux_settings.path_to_nzbs'));
$itr = new \RecursiveIteratorIterator($dirItr, \RecursiveIteratorIterator::LEAVES_ONLY); $itr = new \RecursiveIteratorIterator($dirItr, \RecursiveIteratorIterator::LEAVES_ONLY);
// Checking filename GUIDs against the releases table // Checking filename GUIDs against the releases table
+13 -12
View File
@@ -60,14 +60,7 @@ class InstallNntmux extends Command
$paths = $this->updatePaths(); $paths = $this->updatePaths();
if ($paths !== false) { if ($paths !== false) {
$sql1 = Settings::query()->where('setting', '=', 'nzbpath')->update(['value' => $paths['nzb_path']]); $this->info('Paths checked successfully');
$sql2 = Settings::query()->where('setting', '=', 'tmpunrarpath')->update(['value' => config('nntmux.tmp_path')]);
$sql3 = Settings::query()->where('setting', '=', 'coverspath')->update(['value' => $paths['covers_path']]);
if ($sql1 === null || $sql2 === null || $sql3 === null) {
$error = true;
} else {
$this->info('Settings table updated successfully');
}
} }
if (! $error && $this->addAdminUser()) { if (! $error && $this->addAdminUser()) {
@@ -93,10 +86,10 @@ class InstallNntmux extends Command
*/ */
private function updatePaths() private function updatePaths()
{ {
$covers_path = storage_path('covers'); $covers_path = config('nntmux_settings.covers_path');
$nzb_path = storage_path('nzb'); $nzb_path = config('nntmux_settings.path_to_nzbs');
$tmp_path = resource_path('tmp'); $tmp_path = config('nntmux.tmp_path');
$unrar_path = $tmp_path.'unrar/'; $unrar_path = config('nntmux_settings.unrar_path');
$nzbPathCheck = File::isWritable($nzb_path); $nzbPathCheck = File::isWritable($nzb_path);
if (! $nzbPathCheck) { if (! $nzbPathCheck) {
@@ -126,10 +119,18 @@ class InstallNntmux extends Command
return false; return false;
} }
$tmpPathCheck = File::isWritable($tmp_path);
if (! $tmpPathCheck) {
$this->warn($tmp_path.' is not writable. Please fix folder permissions');
return false;
}
return [ return [
'nzb_path' => Str::finish($nzb_path, '/'), 'nzb_path' => Str::finish($nzb_path, '/'),
'covers_path' => Str::finish($covers_path, '/'), 'covers_path' => Str::finish($covers_path, '/'),
'unrar_path' => Str::finish($unrar_path, '/'), 'unrar_path' => Str::finish($unrar_path, '/'),
'tmp_path' => Str::finish($tmp_path, '/'),
]; ];
} }
+1 -1
View File
@@ -176,7 +176,7 @@ class NntmuxResetDb extends Command
} }
$this->info('Deleting nzbfiles subfolders.'); $this->info('Deleting nzbfiles subfolders.');
$files = File::allFiles(Settings::settingValue('..nzbpath')); $files = File::allFiles(config('nntmux_settings.path_to_nzbs'));
File::delete($files); File::delete($files);
$this->info('Deleting all images, previews and samples that still remain.'); $this->info('Deleting all images, previews and samples that still remain.');
@@ -73,7 +73,7 @@ class ForgotPasswordController extends Controller
} }
} }
$theme = Settings::settingValue('site.main.style'); $theme = 'Gentele';
$title = 'Forgotten Password'; $title = 'Forgotten Password';
$meta_title = 'Forgotten Password'; $meta_title = 'Forgotten Password';
@@ -81,7 +81,7 @@ class LoginController extends Controller
} }
if (Auth::attempt($request->only($login_type, 'password'), $rememberMe)) { if (Auth::attempt($request->only($login_type, 'password'), $rememberMe)) {
$userIp = (int) Settings::settingValue('..storeuserips') === 1 ? ($request->ip() ?? $request->getClientIp()) : ''; $userIp = config('nntmux:settings.store_user_ip') ? ($request->ip() ?? $request->getClientIp()) : '';
event(new UserLoggedIn($user, $userIp)); event(new UserLoggedIn($user, $userIp));
Auth::logoutOtherDevices($request->input('password')); Auth::logoutOtherDevices($request->input('password'));
@@ -108,7 +108,7 @@ class LoginController extends Controller
public function showLoginForm() public function showLoginForm()
{ {
$theme = Settings::settingValue('site.main.style'); $theme = 'Gentele';
$meta_title = 'Login'; $meta_title = 'Login';
$meta_keywords = 'Login'; $meta_keywords = 'Login';
@@ -227,7 +227,7 @@ class RegisterController extends Controller
app('smarty.view')->assign('showregister', $showRegister); app('smarty.view')->assign('showregister', $showRegister);
app('smarty.view')->assign('error', $error); app('smarty.view')->assign('error', $error);
app('smarty.view')->assign('invite_code_query', $this->inviteCodeQuery); app('smarty.view')->assign('invite_code_query', $this->inviteCodeQuery);
$theme = Settings::settingValue('site.main.style'); $theme = 'Gentele';
$nocaptcha = config('settings.nocaptcha_enabled'); $nocaptcha = config('settings.nocaptcha_enabled');
@@ -69,7 +69,7 @@ class ResetPasswordController extends Controller
} }
} }
$theme = Settings::settingValue('site.main.style'); $theme = 'Gentele';
$title = 'Forgotten Password'; $title = 'Forgotten Password';
$meta_title = 'Forgotten Password'; $meta_title = 'Forgotten Password';
+3 -21
View File
@@ -79,14 +79,10 @@ class BasePageController extends Controller
if (Auth::check()) { if (Auth::check()) {
$this->userdata = User::find(Auth::id()); $this->userdata = User::find(Auth::id());
$this->setUserPreferences(); $this->setUserPreferences();
if ($this->theme === 'None') {
$this->theme = Settings::settingValue('site.main.style');
}
} else { } else {
$this->theme = Settings::settingValue('site.main.style');
// Tell Smarty which directories to use for templates // Tell Smarty which directories to use for templates
$this->smarty->setTemplateDir([ $this->smarty->setTemplateDir([
'user' => config('ytake-laravel-smarty.template_path').DIRECTORY_SEPARATOR.$this->theme, 'user' => config('ytake-laravel-smarty.template_path').'/Gentele',
'shared' => config('ytake-laravel-smarty.template_path').'/shared', 'shared' => config('ytake-laravel-smarty.template_path').'/shared',
'default' => config('ytake-laravel-smarty.template_path').'/Gentele', 'default' => config('ytake-laravel-smarty.template_path').'/Gentele',
]); ]);
@@ -102,7 +98,7 @@ class BasePageController extends Controller
$this->smarty->assign( $this->smarty->assign(
[ [
'theme' => $this->theme, 'theme' => 'Gentele',
'site' => $this->settings, 'site' => $this->settings,
] ]
); );
@@ -139,16 +135,6 @@ class BasePageController extends Controller
{ {
$this->userdata->categoryexclusions = User::getCategoryExclusionById(Auth::id()); $this->userdata->categoryexclusions = User::getCategoryExclusionById(Auth::id());
// Change the theme to user's selected theme if they selected one, else use the admin one.
if ((int) Settings::settingValue('site.main.userselstyle') === 1) {
$this->theme = $this->userdata->style ?? 'None';
if ($this->theme === 'None') {
$this->theme = Settings::settingValue('site.main.style');
}
} else {
$this->theme = Settings::settingValue('site.main.style');
}
// Update last login every 15 mins. // Update last login every 15 mins.
if (now()->subHours(3) > $this->userdata->lastlogin) { if (now()->subHours(3) > $this->userdata->lastlogin) {
event(new UserLoggedIn($this->userdata)); event(new UserLoggedIn($this->userdata));
@@ -167,7 +153,7 @@ class BasePageController extends Controller
// Tell Smarty which directories to use for templates // Tell Smarty which directories to use for templates
$this->smarty->setTemplateDir([ $this->smarty->setTemplateDir([
'user' => config('ytake-laravel-smarty.template_path').DIRECTORY_SEPARATOR.$this->theme, 'user' => config('ytake-laravel-smarty.template_path').'/Gentele',
'shared' => config('ytake-laravel-smarty.template_path').'/shared', 'shared' => config('ytake-laravel-smarty.template_path').'/shared',
'default' => config('ytake-laravel-smarty.template_path').'/Gentele', 'default' => config('ytake-laravel-smarty.template_path').'/Gentele',
]); ]);
@@ -178,10 +164,6 @@ class BasePageController extends Controller
} }
$content = new Contents; $content = new Contents;
if ($this->userdata !== null) {
$this->smarty->assign('recentforumpostslist', Forumpost::getPosts(Settings::settingValue('..showrecentforumposts')));
}
$parentcatlist = Category::getForMenu($this->userdata->categoryexclusions); $parentcatlist = Category::getForMenu($this->userdata->categoryexclusions);
$this->smarty->assign('parentcatlist', $parentcatlist); $this->smarty->assign('parentcatlist', $parentcatlist);
+1 -1
View File
@@ -151,7 +151,7 @@ class DetailsController extends BasePageController
$this->smarty->assign('comments', $comments); $this->smarty->assign('comments', $comments);
$this->smarty->assign('searchname', getSimilarName($data['searchname'])); $this->smarty->assign('searchname', getSimilarName($data['searchname']));
$this->smarty->assign('similars', $similars !== false ? $similars : ''); $this->smarty->assign('similars', $similars !== false ? $similars : '');
$this->smarty->assign('privateprofiles', (int) Settings::settingValue('..privateprofiles') === 1); $this->smarty->assign('privateprofiles', config('nntmux_settings.private_profiles'));
$this->smarty->assign('failed', $failed); $this->smarty->assign('failed', $failed);
$this->smarty->assign('cpapi', $cpapi); $this->smarty->assign('cpapi', $cpapi);
$this->smarty->assign('cpurl', $cpurl); $this->smarty->assign('cpurl', $cpurl);
+2 -2
View File
@@ -48,7 +48,7 @@ class ForumController extends BasePageController
$results = Forumpost::getBrowseRange(); $results = Forumpost::getBrowseRange();
$this->smarty->assign('privateprofiles', (int) Settings::settingValue('..privateprofiles') === 1); $this->smarty->assign('privateprofiles', config('nntmux_settings.private_profiles'));
$this->smarty->assign('results', $results); $this->smarty->assign('results', $results);
@@ -89,7 +89,7 @@ class ForumController extends BasePageController
$meta_description = 'View forum post'; $meta_description = 'View forum post';
$this->smarty->assign('results', $results); $this->smarty->assign('results', $results);
$this->smarty->assign('privateprofiles', (int) Settings::settingValue('..privateprofiles') === 1); $this->smarty->assign('privateprofiles', config('nntmux_settings.private_profiles'));
$content = $this->smarty->fetch('forumpost.tpl'); $content = $this->smarty->fetch('forumpost.tpl');
+2 -6
View File
@@ -30,7 +30,7 @@ class ProfileController extends BasePageController
$userID = $this->userdata->id; $userID = $this->userdata->id;
$privileged = $this->userdata->hasRole('Admin') || $this->userdata->hasRole('Moderator'); $privileged = $this->userdata->hasRole('Admin') || $this->userdata->hasRole('Moderator');
$privateProfiles = (int) Settings::settingValue('..privateprofiles') === 1; $privateProfiles = config('nntmux_settings.private_profiles');
$publicView = false; $publicView = false;
if ($privileged || ! $privateProfiles) { if ($privileged || ! $privateProfiles) {
@@ -150,7 +150,7 @@ class ProfileController extends BasePageController
$request->has('xxxview') ? 1 : 0, $request->has('xxxview') ? 1 : 0,
$request->has('consoleview') ? 1 : 0, $request->has('consoleview') ? 1 : 0,
$request->has('bookview') ? 1 : 0, $request->has('bookview') ? 1 : 0,
(int) Settings::settingValue('site.main.userselstyle') === 1 ? $request->input('style') : 'None' 'None',
); );
if ((int) $request->input('viewconsole') === 1 && $this->userdata->can('view console') && ! $this->userdata->hasDirectPermission('view console')) { if ((int) $request->input('viewconsole') === 1 && $this->userdata->can('view console') && ! $this->userdata->hasDirectPermission('view console')) {
@@ -245,10 +245,6 @@ class ProfileController extends BasePageController
default: default:
break; break;
} }
if ((int) Settings::settingValue('site.main.userselstyle') === 1) {
// Get the list of themes.
$this->smarty->assign('themelist', Utility::getThemesList());
}
$this->smarty->assign('error', $errorStr); $this->smarty->assign('error', $errorStr);
$this->smarty->assign('user', $this->userdata); $this->smarty->assign('user', $this->userdata);
+1 -1
View File
@@ -235,7 +235,7 @@ class Release extends Model
*/ */
public static function insertRelease(array $parameters = []) public static function insertRelease(array $parameters = [])
{ {
$passwordStatus = ((int) Settings::settingValue('..checkpasswordedrar') === 1 ? -1 : 0); $passwordStatus = config('nntmux_settings.check_passworded_rars') === true ? -1 : 0;
$parameters['id'] = self::query() $parameters['id'] = self::query()
->insertGetId( ->insertGetId(
[ [
+1 -1
View File
@@ -119,7 +119,7 @@ class ReleaseComment extends Model
*/ */
public static function addComment($id, $gid, $text, $userid, $host): int public static function addComment($id, $gid, $text, $userid, $host): int
{ {
if ((int) Settings::settingValue('..storeuserips') !== 1) { if (config('nntmux:settings.store_user_ip') === false) {
$host = ''; $host = '';
} }
-1
View File
@@ -90,7 +90,6 @@ class UsenetGroup extends Model
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
$this->allasmgr = (int) Settings::settingValue('..allasmgr') === 1;
} }
public function release(): HasMany public function release(): HasMany
+1 -1
View File
@@ -595,7 +595,7 @@ class User extends Authenticatable
return false; return false;
} }
$storeips = (int) Settings::settingValue('..storeuserips') === 1 ? $host : ''; $storeips = config('nntmux:settings.store_user_ip') === true ? $host : '';
$user = self::create( $user = self::create(
[ [
+2
View File
@@ -15,4 +15,6 @@ return [
'alternate_server_socket_timeout' => env('NNTP_SOCKET_TIMEOUT_A', 120), 'alternate_server_socket_timeout' => env('NNTP_SOCKET_TIMEOUT_A', 120),
'main_nntp_connections' => env('NNTP_CONNECTIONS', 1), 'main_nntp_connections' => env('NNTP_CONNECTIONS', 1),
'alternate_nntp_connections' => env('NNTP_CONNECTIONS_A', 1), 'alternate_nntp_connections' => env('NNTP_CONNECTIONS_A', 1),
'compressed_headers' => env('NNTP_COMPRESSED_HEADERS', false),
'use_alternate_nntp_server' => env('USE_ALTERNATE_NNTP_SERVER', false),
]; ];
+20
View File
@@ -0,0 +1,20 @@
<?php
return [
'unrar_path' => env('UNRAR_PATH', '/usr/bin/unrar'),
'unzip_path' => env('UNZIP_PATH', '/usr/bin/7z'),
'check_passworded_rars' => env('CHECK_PASSWORDED_RARS', false),
'delete_passworded_releases' => env('DELETE_PASSWORDED_RELEASES', false),
'delete_possible_passworded_releases' => env('DELETE_POSSIBLE_PASSWORDED_RELEASES', false),
'extract_using_rarinfo' => env('EXTRACT_USING_RARINFO', false),
'path_to_nzbs' => env('PATH_TO_NZBS', '/var/www/NNTmux/storage/nzb'),
'private_profiles' => env('PRIVATE_PROFILES', true),
'store_user_ip' => env('STORE_USER_IP', false),
'ffmpeg_path' => env('FFMPEG_PATH', '/usr/bin/ffmpeg'),
'ffprobe_path' => env('FFPROBE_PATH', '/usr/bin/ffprobe'),
'mediainfo_path' => env('MEDIAINFO_PATH', '/usr/bin/mediainfo'),
'timeout_path' => env('TIMEOUT_PATH', '/usr/bin/timeout'),
'magic_file_path' => env('MAGIC_FILE_PATH', '/usr/share/misc/magic'),
'covers_path' => env('COVERS_PATH', '/var/www/NNTmux/storage/covers'),
'add_par2' => env('ADD_PAR2', false),
];
@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('settings', function (Blueprint $table) {
$table->dropColumn(['section', 'subsection', 'hint', 'setting']);
$table->dropIndex('ui_settings_settings');
$table->dropPrimary();
$table->primary(['name']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('settings', function (Blueprint $table) {
$table->string('section')->nullable();
$table->string('subsection')->nullable();
$table->string('hint')->nullable();
$table->string('setting')->nullable();
});
}
};
+1 -5
View File
@@ -1244,13 +1244,9 @@ DROP TABLE IF EXISTS `settings`;
/*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */; /*!40101 SET character_set_client = utf8 */;
CREATE TABLE `settings` ( CREATE TABLE `settings` (
`section` varchar(25) NOT NULL DEFAULT '',
`subsection` varchar(25) NOT NULL DEFAULT '',
`name` varchar(25) NOT NULL DEFAULT '', `name` varchar(25) NOT NULL DEFAULT '',
`value` varchar(1000) NOT NULL DEFAULT '', `value` varchar(1000) NOT NULL DEFAULT '',
`hint` text NOT NULL, PRIMARY KEY (`name`),
`setting` varchar(64) NOT NULL DEFAULT '',
PRIMARY KEY (`section`,`subsection`,`name`),
UNIQUE KEY `ui_settings_setting` (`setting`) UNIQUE KEY `ui_settings_setting` (`setting`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
+1 -1
View File
@@ -36,7 +36,7 @@ $couldbe = ($argv[1] === 'true') ? 'could be ' : '';
$colorCli->header('Getting List of nzbs to check against db.'); $colorCli->header('Getting List of nzbs to check against db.');
$colorCli->header("Checked / {$couldbe}moved\n"); $colorCli->header("Checked / {$couldbe}moved\n");
$dirItr = new RecursiveDirectoryIterator(Settings::settingValue('..nzbpath')); $dirItr = new RecursiveDirectoryIterator(config('nntux_settings.path_to_nzbs'));
$itr = new RecursiveIteratorIterator($dirItr, RecursiveIteratorIterator::LEAVES_ONLY); $itr = new RecursiveIteratorIterator($dirItr, RecursiveIteratorIterator::LEAVES_ONLY);
foreach ($itr as $filePath) { foreach ($itr as $filePath) {
+2 -1
View File
@@ -30,7 +30,8 @@ if (isset($argv[1], $argv[2], $argv[3], $argv[4])) {
$show = isset($argv[5]) && $argv[5] === 'show' ? 1 : 2; $show = isset($argv[5]) && $argv[5] === 'show' ? 1 : 2;
if ($argv[1] === 7 || $argv[1] === 8) { if ($argv[1] === 7 || $argv[1] === 8) {
if ((Settings::settingValue('..alternate_nntp') === 1 ? $nntp->doConnect(true, true) : $nntp->doConnect()) !== true) { $compressedHeaders = config('nntmux_nntp.compressed_headers');
if ((config('nntmux_nntp.use_alternate_nntp_server') === true ? $nntp->doConnect($compressedHeaders, true) : $nntp->doConnect()) !== true) {
$colorCli->error('Unable to connect to usenet.'); $colorCli->error('Unable to connect to usenet.');
return; return;
@@ -421,7 +421,7 @@ function charCheck(string $char): bool
function &nntp(): NNTP function &nntp(): NNTP
{ {
$nntp = new NNTP(); $nntp = new NNTP();
if (((int) Settings::settingValue('..alternate_nntp') === 1 ? $nntp->doConnect(false, true) : $nntp->doConnect()) !== true) { if ((config('nntmux_nntp.use_alternate_nntp_server') === true ? $nntp->doConnect(false, true) : $nntp->doConnect()) !== true) {
exit('ERROR: Unable to connect to usenet.'.PHP_EOL); exit('ERROR: Unable to connect to usenet.'.PHP_EOL);
} }
+2 -1
View File
@@ -61,7 +61,8 @@ if (! isset($argv[1], $argv[2]) || ! in_array($argv[1], $args, false) || ! in_ar
$nntp = null; $nntp = null;
if ($args[$argv[1]] === true) { if ($args[$argv[1]] === true) {
$nntp = new NNTP; $nntp = new NNTP;
if ((Settings::settingValue('..alternate_nntp') === 1 ? $nntp->doConnect(true, true) : $nntp->doConnect()) !== true) { $compressedHeaders = config('nntmux_nntp.compressed_headers');
if ((config('nntmux_nntp.use_alternate_nntp_server') === true ? $nntp->doConnect($compressedHeaders, true) : $nntp->doConnect()) !== true) {
echo 'Unable to connect to usenet.'.PHP_EOL; echo 'Unable to connect to usenet.'.PHP_EOL;
exit; exit;
} }
+2 -1
View File
@@ -192,7 +192,8 @@ switch (true) {
$colorCli->primaryOver('p'); $colorCli->primaryOver('p');
if (! isset($nzbcontents)) { if (! isset($nzbcontents)) {
$nntp = new NNTP; $nntp = new NNTP;
if (((int) Settings::settingValue('..alternate_nntp') === 1 ? $nntp->doConnect(true, true) : $nntp->doConnect()) !== true) { $compressedHeaders = config('nntmux_nntp.compressed_headers');
if ((config('nntmux_nntp.use_alternate_nntp_server') === true ? $nntp->doConnect($compressedHeaders, true) : $nntp->doConnect()) !== true) {
$colorCli->error('Unable to connect to usenet.'); $colorCli->error('Unable to connect to usenet.');
} }
$Nfo = new Nfo; $Nfo = new Nfo;
@@ -211,20 +211,6 @@
</tbody> </tbody>
</table> </table>
{if {{App\Models\Settings::settingValue('site.main.userselstyle')}} == 1}
<table class="data table table-striped">
<tbody>
<tr class="bg-aqua-active">
<td colspan="2" style="padding-left: 8px;"><strong>Site theme</strong></td>
</tr>
<tr>
<td>
{html_options id="style" name='style' values=$themelist output=$themelist selected=$user.style}
</td>
</tr>
</tbody>
</table>
{/if}
</div> </div>
</div> </div>
{{Form::submit('Save', ['class' => 'btn btn-success'])}} {{Form::submit('Save', ['class' => 'btn btn-success'])}}