From 05ebaf44428410c55294fb7d081324432c87ba27 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Mon, 28 Oct 2024 11:29:09 +0100 Subject: [PATCH] Use config where possible --- .env.example | 26 ++++++++++++-- Blacklight/Backfill.php | 2 +- Blacklight/Binaries.php | 2 +- Blacklight/Books.php | 4 +-- Blacklight/NNTP.php | 10 +++--- Blacklight/NZB.php | 2 +- Blacklight/NZBContents.php | 2 +- Blacklight/libraries/Forking.php | 25 -------------- Blacklight/processing/PostProcess.php | 4 +-- .../processing/post/ProcessAdditional.php | 22 ++++++------ Blacklight/utility/Utility.php | 2 +- app/Console/Commands/CleanNZB.php | 2 +- app/Console/Commands/InstallNntmux.php | 25 +++++++------- app/Console/Commands/NntmuxResetDb.php | 2 +- .../Auth/ForgotPasswordController.php | 2 +- app/Http/Controllers/Auth/LoginController.php | 4 +-- .../Controllers/Auth/RegisterController.php | 2 +- .../Auth/ResetPasswordController.php | 2 +- app/Http/Controllers/BasePageController.php | 24 ++----------- app/Http/Controllers/DetailsController.php | 2 +- app/Http/Controllers/ForumController.php | 4 +-- app/Http/Controllers/ProfileController.php | 8 ++--- app/Models/Release.php | 2 +- app/Models/ReleaseComment.php | 2 +- app/Models/UsenetGroup.php | 1 - app/Models/User.php | 2 +- config/nntmux_nntp.php | 2 ++ config/nntux_settings.php | 20 +++++++++++ ...92803_drop_columns_from_settings_table.php | 34 +++++++++++++++++++ database/schema/mariadb-schema.sql | 6 +--- misc/testing/Dev/clean_nzbs.php | 2 +- misc/testing/Releases/fixReleaseNames.php | 3 +- .../multiprocessing/.do_not_run/switch.php | 2 +- misc/update/postprocess.php | 3 +- misc/update/tmux/bin/groupfixrelnames.php | 3 +- .../views/themes/Gentele/profileedit.tpl | 14 -------- 36 files changed, 144 insertions(+), 130 deletions(-) create mode 100644 config/nntux_settings.php create mode 100644 database/migrations/2024_10_28_092803_drop_columns_from_settings_table.php diff --git a/.env.example b/.env.example index ec64fff47..7a955c311 100644 --- a/.env.example +++ b/.env.example @@ -20,6 +20,9 @@ ELASTICSEARCH_PASS= ELASTICSEARCH_LOGGING=false ELASTICSEARCH_ENABLED=false +NNTP_COMPRESSED_HEADERS=false +USE_ALTERNATE_NNTP_SERVER=false + NNTP_USERNAME= NNTP_PASSWORD= NNTP_SERVER= @@ -110,7 +113,8 @@ ITEMS_PER_PAGE=50 ITEMS_PER_COVER_PAGE=25 MAX_PAGER_RESULTS=125000 ECHOCLI=true -RENAME_PAR2 = false +RENAME_PAR2=false +ADD_PAR2=false RENAME_MUSIC_MEDIAINFO=true CACHE_EXPIRY_SHORT=5 CACHE_EXPIRY_MEDIUM=10 @@ -149,8 +153,8 @@ FANARTTV_APIKEY= OMDB_APIKEY= TRAKTTV_APIKEY= -TEMP_UNRAR_PATH= -TEMP_UNZIP_PATH= +TEMP_UNRAR_PATH='/var/www/nntmux/resources/tmp/unrar/' +TEMP_UNZIP_PATH='/var/www/nntmux/resources/tmp/unzip/' VIEW_COMPILED_PATH=/var/www/NNTmux/storage/framework/views ASSET_URL= @@ -184,3 +188,19 @@ PURGE_INACTIVE_USERS=false OTP_ENABLED=false 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/' diff --git a/Blacklight/Backfill.php b/Blacklight/Backfill.php index fcc103640..9723c98c2 100755 --- a/Blacklight/Backfill.php +++ b/Blacklight/Backfill.php @@ -54,7 +54,7 @@ class Backfill $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->_safePartRepair = (int) Settings::settingValue('..safepartrepair') === 1 ? 'update' : 'backfill'; $this->_disableBackfillGroup = (int) Settings::settingValue('..disablebackfillgroup') === 1; diff --git a/Blacklight/Binaries.php b/Blacklight/Binaries.php index 6b0bbef92..43263d569 100644 --- a/Blacklight/Binaries.php +++ b/Blacklight/Binaries.php @@ -182,7 +182,7 @@ class Binaries $this->messageBuffer = Settings::settingValue('..maxmssgs') !== '' ? (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->_newGroupScanByDays = (int) Settings::settingValue('..newgroupscanmethod') === 1; $this->_newGroupMessagesToScan = Settings::settingValue('..newgroupmsgstoscan') !== '' ? (int) Settings::settingValue('..newgroupmsgstoscan') : 50000; diff --git a/Blacklight/Books.php b/Blacklight/Books.php index 1341e0095..127968e11 100755 --- a/Blacklight/Books.php +++ b/Blacklight/Books.php @@ -69,8 +69,8 @@ class Books $this->bookqty = Settings::settingValue('..maxbooksprocessed') !== '' ? (int) Settings::settingValue('..maxbooksprocessed') : 300; $this->sleeptime = Settings::settingValue('..amazonsleep') !== '' ? (int) Settings::settingValue('..amazonsleep') : 1000; $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->failCache = []; diff --git a/Blacklight/NNTP.php b/Blacklight/NNTP.php index 2821a50d9..21bedbd74 100755 --- a/Blacklight/NNTP.php +++ b/Blacklight/NNTP.php @@ -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 ($connected && $authenticated) { // 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; } @@ -325,7 +325,7 @@ class NNTP extends \Net_NNTP_Client */ public function enableCompression(): void { - if ((int) Settings::settingValue('..compressedheaders') !== 1) { + if (config('nntmux_nntp.compressed_headers') === false) { return; } $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. } elseif ($alternate) { if (! $aConnected) { + $compressedHeaders = config('nntmux_nntp.compressed_headers'); // 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 ($aConnected === true) { @@ -590,7 +591,8 @@ class NNTP extends \Net_NNTP_Client } elseif (\is_string($identifiers) || is_numeric($identifiers)) { $body = $this->_getMessage($groupName, $identifiers); if ($alternate && self::isError($body)) { - $nntp->doConnect(true, true); + $compressedHeaders = config('nntmux_nntp.compressed_headers'); + $nntp->doConnect($compressedHeaders, true); $body = $nntp->_getMessage($groupName, $identifiers); $aConnected = true; } diff --git a/Blacklight/NZB.php b/Blacklight/NZB.php index 997a3ed75..4eb98dc83 100755 --- a/Blacklight/NZB.php +++ b/Blacklight/NZB.php @@ -65,7 +65,7 @@ class NZB { $nzbSplitLevel = (int) Settings::settingValue('..nzbsplitlevel'); $this->nzbSplitLevel = $nzbSplitLevel ?? 1; - $this->siteNzbPath = (string) Settings::settingValue('..nzbpath'); + $this->siteNzbPath = config('nntmux_settings.path_to_nzbs'); if (! Str::endsWith($this->siteNzbPath, '/')) { $this->siteNzbPath .= '/'; } diff --git a/Blacklight/NZBContents.php b/Blacklight/NZBContents.php index 89c771869..c07f12582 100755 --- a/Blacklight/NZBContents.php +++ b/Blacklight/NZBContents.php @@ -41,7 +41,7 @@ class NZBContents $this->pp = new PostProcess; $this->nzb = new NZB; $this->lookuppar2 = (int) Settings::settingValue('..lookuppar2') === 1; - $this->alternateNNTP = (int) Settings::settingValue('..alternate_nntp') === 1; + $this->alternateNNTP = config('nntmux_nntp.use_alternate_nntp_server'); } /** diff --git a/Blacklight/libraries/Forking.php b/Blacklight/libraries/Forking.php index d58e8aaf8..f9fc9fa92 100755 --- a/Blacklight/libraries/Forking.php +++ b/Blacklight/libraries/Forking.php @@ -187,10 +187,6 @@ class Forking $this->postProcessNfo(); break; - case 'postProcess_sha': - $this->processSharing(); - break; - case 'postProcess_tv': $this->ppRenamedOnly = (isset($this->workTypeOptions[0]) && $this->workTypeOptions[0] === true); $this->postProcessTv(); @@ -841,27 +837,6 @@ class Forking $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. * diff --git a/Blacklight/processing/PostProcess.php b/Blacklight/processing/PostProcess.php index c3c1c18c3..d70ba4235 100755 --- a/Blacklight/processing/PostProcess.php +++ b/Blacklight/processing/PostProcess.php @@ -59,8 +59,8 @@ class PostProcess $this->Nfo = new Nfo; // Site settings. - $this->addpar2 = (int) Settings::settingValue('..addpar2') !== 0; - $this->alternateNNTP = (int) Settings::settingValue('..alternate_nntp') === 1; + $this->addpar2 = config('nntmux:settings.add_par2'); + $this->alternateNNTP = config('nntmux_nntp.use_alternate_nntp_server'); } /** diff --git a/Blacklight/processing/post/ProcessAdditional.php b/Blacklight/processing/post/ProcessAdditional.php index d3d2cdf6f..53fb74b65 100755 --- a/Blacklight/processing/post/ProcessAdditional.php +++ b/Blacklight/processing/post/ProcessAdditional.php @@ -285,17 +285,15 @@ class ProcessAdditional // Pass the binary extractors to ArchiveInfo. $clients = []; - if (! empty(Settings::settingValue('apps..unrarpath'))) { - $this->_unrarPath = Settings::settingValue('apps..unrarpath'); - $clients += [ArchiveInfo::TYPE_RAR => $this->_unrarPath]; - } + $this->_unrarPath = config('nntmux_settings.unrar_path'); + $clients += [ArchiveInfo::TYPE_RAR => $this->_unrarPath]; $this->_archiveInfo->setExternalClients($clients); $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 = ( - '"'.Settings::settingValue('apps..timeoutpath'). + '"'.config('nntmux_settings.timeout_path'). '" --foreground --signal=KILL '. Settings::settingValue('..timeoutseconds').' "' ); @@ -327,13 +325,13 @@ class ProcessAdditional $this->_minSize = (Settings::settingValue('..minsizetopostprocess') !== '') ? (int) Settings::settingValue('..minsizetopostprocess') : 100; // 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->_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; } else { $this->_processAudioSample = (int) Settings::settingValue('..saveaudiopreview') !== 0; @@ -342,11 +340,11 @@ class ProcessAdditional } $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->_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->_ignoreBookRegex = '/\b(epub|lit|mobi|pdf|sipdf|html)\b.*\.rar(?!.{20,})/i'; diff --git a/Blacklight/utility/Utility.php b/Blacklight/utility/Utility.php index 6e0dfc2c1..8e8f11dcd 100755 --- a/Blacklight/utility/Utility.php +++ b/Blacklight/utility/Utility.php @@ -127,7 +127,7 @@ class Utility */ 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()) { $magicSwitch = " -m $magicPath"; $output = runCmd('file'.$magicSwitch.' -b "'.$path.'"'); diff --git a/app/Console/Commands/CleanNZB.php b/app/Console/Commands/CleanNZB.php index 0a690c618..577b9975b 100644 --- a/app/Console/Commands/CleanNZB.php +++ b/app/Console/Commands/CleanNZB.php @@ -55,7 +55,7 @@ class CleanNZB extends Command $releases = new Release; $checked = $deleted = 0; // 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); // Checking filename GUIDs against the releases table diff --git a/app/Console/Commands/InstallNntmux.php b/app/Console/Commands/InstallNntmux.php index cdc12dc30..685d81c0a 100644 --- a/app/Console/Commands/InstallNntmux.php +++ b/app/Console/Commands/InstallNntmux.php @@ -60,14 +60,7 @@ class InstallNntmux extends Command $paths = $this->updatePaths(); if ($paths !== false) { - $sql1 = Settings::query()->where('setting', '=', 'nzbpath')->update(['value' => $paths['nzb_path']]); - $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'); - } + $this->info('Paths checked successfully'); } if (! $error && $this->addAdminUser()) { @@ -93,10 +86,10 @@ class InstallNntmux extends Command */ private function updatePaths() { - $covers_path = storage_path('covers'); - $nzb_path = storage_path('nzb'); - $tmp_path = resource_path('tmp'); - $unrar_path = $tmp_path.'unrar/'; + $covers_path = config('nntmux_settings.covers_path'); + $nzb_path = config('nntmux_settings.path_to_nzbs'); + $tmp_path = config('nntmux.tmp_path'); + $unrar_path = config('nntmux_settings.unrar_path'); $nzbPathCheck = File::isWritable($nzb_path); if (! $nzbPathCheck) { @@ -126,10 +119,18 @@ class InstallNntmux extends Command return false; } + $tmpPathCheck = File::isWritable($tmp_path); + if (! $tmpPathCheck) { + $this->warn($tmp_path.' is not writable. Please fix folder permissions'); + + return false; + } + return [ 'nzb_path' => Str::finish($nzb_path, '/'), 'covers_path' => Str::finish($covers_path, '/'), 'unrar_path' => Str::finish($unrar_path, '/'), + 'tmp_path' => Str::finish($tmp_path, '/'), ]; } diff --git a/app/Console/Commands/NntmuxResetDb.php b/app/Console/Commands/NntmuxResetDb.php index 877c2030a..ec6111314 100644 --- a/app/Console/Commands/NntmuxResetDb.php +++ b/app/Console/Commands/NntmuxResetDb.php @@ -176,7 +176,7 @@ class NntmuxResetDb extends Command } $this->info('Deleting nzbfiles subfolders.'); - $files = File::allFiles(Settings::settingValue('..nzbpath')); + $files = File::allFiles(config('nntmux_settings.path_to_nzbs')); File::delete($files); $this->info('Deleting all images, previews and samples that still remain.'); diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php index 183c6d2c5..85000f1c3 100644 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -73,7 +73,7 @@ class ForgotPasswordController extends Controller } } - $theme = Settings::settingValue('site.main.style'); + $theme = 'Gentele'; $title = 'Forgotten Password'; $meta_title = 'Forgotten Password'; diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index da426d89a..682ddafc3 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -81,7 +81,7 @@ class LoginController extends Controller } 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)); Auth::logoutOtherDevices($request->input('password')); @@ -108,7 +108,7 @@ class LoginController extends Controller public function showLoginForm() { - $theme = Settings::settingValue('site.main.style'); + $theme = 'Gentele'; $meta_title = 'Login'; $meta_keywords = 'Login'; diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 03d64a292..cdcc96462 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -227,7 +227,7 @@ class RegisterController extends Controller app('smarty.view')->assign('showregister', $showRegister); app('smarty.view')->assign('error', $error); app('smarty.view')->assign('invite_code_query', $this->inviteCodeQuery); - $theme = Settings::settingValue('site.main.style'); + $theme = 'Gentele'; $nocaptcha = config('settings.nocaptcha_enabled'); diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php index 5ed4d84dd..0bd974d50 100644 --- a/app/Http/Controllers/Auth/ResetPasswordController.php +++ b/app/Http/Controllers/Auth/ResetPasswordController.php @@ -69,7 +69,7 @@ class ResetPasswordController extends Controller } } - $theme = Settings::settingValue('site.main.style'); + $theme = 'Gentele'; $title = 'Forgotten Password'; $meta_title = 'Forgotten Password'; diff --git a/app/Http/Controllers/BasePageController.php b/app/Http/Controllers/BasePageController.php index 94f65cd94..173dadcdb 100644 --- a/app/Http/Controllers/BasePageController.php +++ b/app/Http/Controllers/BasePageController.php @@ -79,14 +79,10 @@ class BasePageController extends Controller if (Auth::check()) { $this->userdata = User::find(Auth::id()); $this->setUserPreferences(); - if ($this->theme === 'None') { - $this->theme = Settings::settingValue('site.main.style'); - } } else { - $this->theme = Settings::settingValue('site.main.style'); // Tell Smarty which directories to use for templates $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', 'default' => config('ytake-laravel-smarty.template_path').'/Gentele', ]); @@ -102,7 +98,7 @@ class BasePageController extends Controller $this->smarty->assign( [ - 'theme' => $this->theme, + 'theme' => 'Gentele', 'site' => $this->settings, ] ); @@ -139,16 +135,6 @@ class BasePageController extends Controller { $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. if (now()->subHours(3) > $this->userdata->lastlogin) { event(new UserLoggedIn($this->userdata)); @@ -167,7 +153,7 @@ class BasePageController extends Controller // Tell Smarty which directories to use for templates $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', 'default' => config('ytake-laravel-smarty.template_path').'/Gentele', ]); @@ -178,10 +164,6 @@ class BasePageController extends Controller } $content = new Contents; - if ($this->userdata !== null) { - $this->smarty->assign('recentforumpostslist', Forumpost::getPosts(Settings::settingValue('..showrecentforumposts'))); - } - $parentcatlist = Category::getForMenu($this->userdata->categoryexclusions); $this->smarty->assign('parentcatlist', $parentcatlist); diff --git a/app/Http/Controllers/DetailsController.php b/app/Http/Controllers/DetailsController.php index 750a3f8f8..52cd67d25 100644 --- a/app/Http/Controllers/DetailsController.php +++ b/app/Http/Controllers/DetailsController.php @@ -151,7 +151,7 @@ class DetailsController extends BasePageController $this->smarty->assign('comments', $comments); $this->smarty->assign('searchname', getSimilarName($data['searchname'])); $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('cpapi', $cpapi); $this->smarty->assign('cpurl', $cpurl); diff --git a/app/Http/Controllers/ForumController.php b/app/Http/Controllers/ForumController.php index 90991833f..a2f4754e9 100644 --- a/app/Http/Controllers/ForumController.php +++ b/app/Http/Controllers/ForumController.php @@ -48,7 +48,7 @@ class ForumController extends BasePageController $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); @@ -89,7 +89,7 @@ class ForumController extends BasePageController $meta_description = 'View forum post'; $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'); diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index 3d5a5fba9..69626d011 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -30,7 +30,7 @@ class ProfileController extends BasePageController $userID = $this->userdata->id; $privileged = $this->userdata->hasRole('Admin') || $this->userdata->hasRole('Moderator'); - $privateProfiles = (int) Settings::settingValue('..privateprofiles') === 1; + $privateProfiles = config('nntmux_settings.private_profiles'); $publicView = false; if ($privileged || ! $privateProfiles) { @@ -150,7 +150,7 @@ class ProfileController extends BasePageController $request->has('xxxview') ? 1 : 0, $request->has('consoleview') ? 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')) { @@ -245,10 +245,6 @@ class ProfileController extends BasePageController default: 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('user', $this->userdata); diff --git a/app/Models/Release.php b/app/Models/Release.php index 4e224f221..8774580de 100644 --- a/app/Models/Release.php +++ b/app/Models/Release.php @@ -235,7 +235,7 @@ class Release extends Model */ 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() ->insertGetId( [ diff --git a/app/Models/ReleaseComment.php b/app/Models/ReleaseComment.php index 5a0d76c9f..e9ed228af 100644 --- a/app/Models/ReleaseComment.php +++ b/app/Models/ReleaseComment.php @@ -119,7 +119,7 @@ class ReleaseComment extends Model */ 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 = ''; } diff --git a/app/Models/UsenetGroup.php b/app/Models/UsenetGroup.php index 2ce6bd091..ce2f7fbcf 100644 --- a/app/Models/UsenetGroup.php +++ b/app/Models/UsenetGroup.php @@ -90,7 +90,6 @@ class UsenetGroup extends Model public function __construct() { parent::__construct(); - $this->allasmgr = (int) Settings::settingValue('..allasmgr') === 1; } public function release(): HasMany diff --git a/app/Models/User.php b/app/Models/User.php index 61d9db5a7..03b94f1bc 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -595,7 +595,7 @@ class User extends Authenticatable return false; } - $storeips = (int) Settings::settingValue('..storeuserips') === 1 ? $host : ''; + $storeips = config('nntmux:settings.store_user_ip') === true ? $host : ''; $user = self::create( [ diff --git a/config/nntmux_nntp.php b/config/nntmux_nntp.php index 5bc58c675..c0afc0e56 100644 --- a/config/nntmux_nntp.php +++ b/config/nntmux_nntp.php @@ -15,4 +15,6 @@ return [ 'alternate_server_socket_timeout' => env('NNTP_SOCKET_TIMEOUT_A', 120), 'main_nntp_connections' => env('NNTP_CONNECTIONS', 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), ]; diff --git a/config/nntux_settings.php b/config/nntux_settings.php new file mode 100644 index 000000000..d87b3466d --- /dev/null +++ b/config/nntux_settings.php @@ -0,0 +1,20 @@ + 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), +]; diff --git a/database/migrations/2024_10_28_092803_drop_columns_from_settings_table.php b/database/migrations/2024_10_28_092803_drop_columns_from_settings_table.php new file mode 100644 index 000000000..3826db44d --- /dev/null +++ b/database/migrations/2024_10_28_092803_drop_columns_from_settings_table.php @@ -0,0 +1,34 @@ +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(); + }); + } +}; diff --git a/database/schema/mariadb-schema.sql b/database/schema/mariadb-schema.sql index 9fad88599..d176d7176 100644 --- a/database/schema/mariadb-schema.sql +++ b/database/schema/mariadb-schema.sql @@ -1244,13 +1244,9 @@ DROP TABLE IF EXISTS `settings`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `settings` ( - `section` varchar(25) NOT NULL DEFAULT '', - `subsection` varchar(25) NOT NULL DEFAULT '', `name` varchar(25) NOT NULL DEFAULT '', `value` varchar(1000) NOT NULL DEFAULT '', - `hint` text NOT NULL, - `setting` varchar(64) NOT NULL DEFAULT '', - PRIMARY KEY (`section`,`subsection`,`name`), + PRIMARY KEY (`name`), UNIQUE KEY `ui_settings_setting` (`setting`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; diff --git a/misc/testing/Dev/clean_nzbs.php b/misc/testing/Dev/clean_nzbs.php index 1099a31f4..5f0d10be3 100644 --- a/misc/testing/Dev/clean_nzbs.php +++ b/misc/testing/Dev/clean_nzbs.php @@ -36,7 +36,7 @@ $couldbe = ($argv[1] === 'true') ? 'could be ' : ''; $colorCli->header('Getting List of nzbs to check against db.'); $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); foreach ($itr as $filePath) { diff --git a/misc/testing/Releases/fixReleaseNames.php b/misc/testing/Releases/fixReleaseNames.php index f9737b7c2..6e572246d 100755 --- a/misc/testing/Releases/fixReleaseNames.php +++ b/misc/testing/Releases/fixReleaseNames.php @@ -30,7 +30,8 @@ if (isset($argv[1], $argv[2], $argv[3], $argv[4])) { $show = isset($argv[5]) && $argv[5] === 'show' ? 1 : 2; 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.'); return; diff --git a/misc/update/multiprocessing/.do_not_run/switch.php b/misc/update/multiprocessing/.do_not_run/switch.php index d4466a8f0..7555ee8b5 100644 --- a/misc/update/multiprocessing/.do_not_run/switch.php +++ b/misc/update/multiprocessing/.do_not_run/switch.php @@ -421,7 +421,7 @@ function charCheck(string $char): bool function &nntp(): 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); } diff --git a/misc/update/postprocess.php b/misc/update/postprocess.php index 2aae707e2..00374ab96 100644 --- a/misc/update/postprocess.php +++ b/misc/update/postprocess.php @@ -61,7 +61,8 @@ if (! isset($argv[1], $argv[2]) || ! in_array($argv[1], $args, false) || ! in_ar $nntp = null; if ($args[$argv[1]] === true) { $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; exit; } diff --git a/misc/update/tmux/bin/groupfixrelnames.php b/misc/update/tmux/bin/groupfixrelnames.php index b5c5056ce..b7d08046f 100644 --- a/misc/update/tmux/bin/groupfixrelnames.php +++ b/misc/update/tmux/bin/groupfixrelnames.php @@ -192,7 +192,8 @@ switch (true) { $colorCli->primaryOver('p'); if (! isset($nzbcontents)) { $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.'); } $Nfo = new Nfo; diff --git a/resources/views/themes/Gentele/profileedit.tpl b/resources/views/themes/Gentele/profileedit.tpl index e86f9fc0e..c3c2615d2 100755 --- a/resources/views/themes/Gentele/profileedit.tpl +++ b/resources/views/themes/Gentele/profileedit.tpl @@ -211,20 +211,6 @@ - {if {{App\Models\Settings::settingValue('site.main.userselstyle')}} == 1} - - - - - - - - - -
Site theme
- {html_options id="style" name='style' values=$themelist output=$themelist selected=$user.style} -
- {/if} {{Form::submit('Save', ['class' => 'btn btn-success'])}}