From 7592fa9beb144adccb11199c3bb45d4f06ca6f41 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Thu, 26 Mar 2020 17:44:45 +0100 Subject: [PATCH] Revert constants removal changes --- Blacklight/Books.php | 2 +- Blacklight/Console.php | 2 +- Blacklight/Games.php | 2 +- Blacklight/Movie.php | 2 +- Blacklight/Music.php | 2 +- Blacklight/NZB.php | 2 +- Blacklight/NZBExport.php | 6 +-- Blacklight/Nfo.php | 2 +- Blacklight/ReleaseImage.php | 10 ++--- Blacklight/Tmux.php | 2 +- Blacklight/XXX.php | 4 +- Blacklight/db/PreDb.php | 5 +-- Blacklight/db/populate/AniDB.php | 2 +- .../processing/post/ProcessAdditional.php | 8 ++-- Blacklight/processing/tv/TV.php | 2 +- Blacklight/utility/Git.php | 2 +- Blacklight/utility/Utility.php | 26 +++++++++-- Changelog | 2 - app/Console/Commands/InstallNntmux.php | 2 +- app/Console/Commands/NntmuxResetDb.php | 2 +- app/Extensions/util/Git.php | 2 +- app/Http/Controllers/Admin/GameController.php | 2 +- app/Http/Controllers/Admin/NzbController.php | 4 +- app/Http/Controllers/Admin/SiteController.php | 2 +- bootstrap/autoload.php | 1 + bootstrap/constants.php | 44 +++++++++++++++++++ cli/data/predb_import_daily_batch.php | 12 ++--- .../2020_03_07_213224_remove_text_hash.php | 10 ++++- misc/testing/Dev/clean_nzbs.php | 2 +- misc/testing/PostProc/check_covers.php | 11 ++++- misc/testing/PostProc/check_previews.php | 11 ++++- misc/testing/PostProc/getGameCovers.php | 2 +- misc/testing/PostProc/getXXXSamples.php | 2 +- misc/testing/PostProc/updateBookImages.php | 2 +- misc/testing/PostProc/updateConsoleImages.php | 2 +- misc/testing/PostProc/updateGamesImages.php | 10 ++++- misc/testing/PostProc/updateMovieImages.php | 10 ++++- misc/testing/PostProc/updateMusicImages.php | 2 +- misc/testing/PostProc/updateXXXImages.php | 2 +- misc/testing/nzb-export.php | 4 +- misc/testing/nzb-import.php | 6 +-- misc/update/tmux/monitor.php | 6 +-- misc/update/tmux/run.php | 4 +- resources/views/themes/admin/site-edit.tpl | 8 ++++ tests/Install/InstallTest.php | 2 +- 45 files changed, 180 insertions(+), 70 deletions(-) create mode 100644 bootstrap/constants.php diff --git a/Blacklight/Books.php b/Blacklight/Books.php index 9b99acc0c..bebd48fe4 100755 --- a/Blacklight/Books.php +++ b/Blacklight/Books.php @@ -94,7 +94,7 @@ class Books $this->asstag = Settings::settingValue('APIs..amazonassociatetag'); $this->bookqty = Settings::settingValue('..maxbooksprocessed') !== '' ? (int) Settings::settingValue('..maxbooksprocessed') : 300; $this->sleeptime = Settings::settingValue('..amazonsleep') !== '' ? (int) Settings::settingValue('..amazonsleep') : 1000; - $this->imgSavePath = resource_path().'/covers/'.'book/'; + $this->imgSavePath = NN_COVERS.'book'.DS; $result = Settings::settingValue('..book_reqids'); $this->bookreqids = $result ?? Category::BOOKS_EBOOK; $this->renamed = (int) Settings::settingValue('..lookupbooks') === 2 ? 'AND isrenamed = 1' : ''; diff --git a/Blacklight/Console.php b/Blacklight/Console.php index 5d90dcb2f..07a619e7e 100755 --- a/Blacklight/Console.php +++ b/Blacklight/Console.php @@ -106,7 +106,7 @@ class Console $this->asstag = Settings::settingValue('APIs..amazonassociatetag'); $this->gameqty = (Settings::settingValue('..maxgamesprocessed') !== '') ? (int) Settings::settingValue('..maxgamesprocessed') : 150; $this->sleeptime = (Settings::settingValue('..amazonsleep') !== '') ? (int) Settings::settingValue('..amazonsleep') : 1000; - $this->imgSavePath = resource_path().'/covers/'.'console/'; + $this->imgSavePath = NN_COVERS.'console'.DS; $this->renamed = (int) Settings::settingValue('..lookupgames') === 2; $this->failCache = []; diff --git a/Blacklight/Games.php b/Blacklight/Games.php index e8a88ad61..3deb064f6 100755 --- a/Blacklight/Games.php +++ b/Blacklight/Games.php @@ -128,7 +128,7 @@ class Games $this->publicKey = config('nntmux_api.giantbomb_api_key'); $this->gameQty = Settings::settingValue('..maxgamesprocessed') !== '' ? (int) Settings::settingValue('..maxgamesprocessed') : 150; - $this->imgSavePath = resource_path().'/covers/'.'games/'; + $this->imgSavePath = NN_COVERS.'games'.DS; $this->renamed = (int) Settings::settingValue('..lookupgames') === 2 ? 'AND isrenamed = 1' : ''; $this->matchPercentage = 60; $this->maxHitRequest = false; diff --git a/Blacklight/Movie.php b/Blacklight/Movie.php index 172c2d40a..937293eb6 100755 --- a/Blacklight/Movie.php +++ b/Blacklight/Movie.php @@ -196,7 +196,7 @@ class Movie $this->showPasswords = (new Releases())->showPasswords(); $this->echooutput = ($options['Echo'] && config('nntmux.echocli')); - $this->imgSavePath = resource_path().'/covers/'.'movies/'; + $this->imgSavePath = NN_COVERS.'movies/'; $this->service = ''; } diff --git a/Blacklight/Music.php b/Blacklight/Music.php index 1069ff062..795ad5e4c 100755 --- a/Blacklight/Music.php +++ b/Blacklight/Music.php @@ -94,7 +94,7 @@ class Music $this->asstag = Settings::settingValue('APIs..amazonassociatetag'); $this->musicqty = Settings::settingValue('..maxmusicprocessed') !== '' ? (int) Settings::settingValue('..maxmusicprocessed') : 150; $this->sleeptime = Settings::settingValue('..amazonsleep') !== '' ? (int) Settings::settingValue('..amazonsleep') : 1000; - $this->imgSavePath = resource_path().'/covers/'.'music/'; + $this->imgSavePath = NN_COVERS.'music'.DS; $this->renamed = (int) Settings::settingValue('..lookupmusic') === 2 ? 'AND isrenamed = 1' : ''; $this->failCache = []; diff --git a/Blacklight/NZB.php b/Blacklight/NZB.php index 10a542687..bd0adb4d1 100755 --- a/Blacklight/NZB.php +++ b/Blacklight/NZB.php @@ -263,7 +263,7 @@ class NZB $nzbPath = ''; for ($i = 0; $i < $levelsToSplit && $i < 32; $i++) { - $nzbPath .= $releaseGuid[$i].'/'; + $nzbPath .= $releaseGuid[$i].DS; } $nzbPath = $this->siteNzbPath.$nzbPath; diff --git a/Blacklight/NZBExport.php b/Blacklight/NZBExport.php index 58a487f15..d9e3db895 100755 --- a/Blacklight/NZBExport.php +++ b/Blacklight/NZBExport.php @@ -76,8 +76,8 @@ class NZBExport $path = $params[0]; // Check if the path ends with dir separator. - if (substr($path, -1) !== '/') { - $path .= '/'; + if (substr($path, -1) !== DS) { + $path .= DS; } // Check if it's a directory. @@ -145,7 +145,7 @@ class NZBExport } // Create a path to store the new NZB files. - $currentPath = $path.$this->safeFilename($group['name']).'/'; + $currentPath = $path.$this->safeFilename($group['name']).DS; if (! File::isDirectory($currentPath) && ! File::makeDirectory($currentPath) && ! File::isDirectory($currentPath)) { throw new \RuntimeException(sprintf('Directory "%s" was not created', $currentPath)); } diff --git a/Blacklight/Nfo.php b/Blacklight/Nfo.php index 5ac734a1d..1fb58cffa 100755 --- a/Blacklight/Nfo.php +++ b/Blacklight/Nfo.php @@ -75,7 +75,7 @@ class Nfo $this->tmpPath = (string) Settings::settingValue('..tmpunrarpath'); if (! preg_match('/[\/\\\\]$/', $this->tmpPath)) { - $this->tmpPath .= '/'; + $this->tmpPath .= DS; } } diff --git a/Blacklight/ReleaseImage.php b/Blacklight/ReleaseImage.php index 2c6ea64f7..7be1f565a 100755 --- a/Blacklight/ReleaseImage.php +++ b/Blacklight/ReleaseImage.php @@ -63,11 +63,11 @@ class ReleaseImage public function __construct() { $this->colorCli = new ColorCLI(); - $this->audSavePath = resource_path().'/covers/'.'audiosample/'; - $this->imgSavePath = resource_path().'/covers/'.'preview/'; - $this->jpgSavePath = resource_path().'/covers/'.'sample/'; - $this->movieImgSavePath = resource_path().'/covers/'.'movies/'; - $this->vidSavePath = resource_path().'/covers/'.'video/'; + $this->audSavePath = NN_COVERS.'audiosample'.DS; + $this->imgSavePath = NN_COVERS.'preview'.DS; + $this->jpgSavePath = NN_COVERS.'sample'.DS; + $this->movieImgSavePath = NN_COVERS.'movies'.DS; + $this->vidSavePath = NN_COVERS.'video'.DS; } /** diff --git a/Blacklight/Tmux.php b/Blacklight/Tmux.php index 595993797..d96c59cb0 100755 --- a/Blacklight/Tmux.php +++ b/Blacklight/Tmux.php @@ -264,7 +264,7 @@ class Tmux */ public function writelog($pane): ?string { - $path = storage_path().'/logs/'; + $path = NN_LOGS; $getdate = gmdate('Ymd'); $logs = Settings::settingValue('site.tmux.write_logs') ?? 0; if ($logs === 1) { diff --git a/Blacklight/XXX.php b/Blacklight/XXX.php index 9a9453b65..19e854f26 100755 --- a/Blacklight/XXX.php +++ b/Blacklight/XXX.php @@ -88,8 +88,8 @@ class XXX $this->movieQty = Settings::settingValue('..maxxxxprocessed') !== '' ? (int) Settings::settingValue('..maxxxxprocessed') : 100; $this->showPasswords = (new Releases())->showPasswords(); $this->echoOutput = ($options['Echo'] && config('nntmux.echocli')); - $this->imgSavePath = resource_path().'/covers/'.'xxx/'; - $this->cookie = resource_path().'/tmp/xxx.cookie'; + $this->imgSavePath = NN_COVERS.'xxx'.DS; + $this->cookie = NN_TMP.'xxx.cookie'; } /** diff --git a/Blacklight/db/PreDb.php b/Blacklight/db/PreDb.php index 33096b371..7698fa843 100755 --- a/Blacklight/db/PreDb.php +++ b/Blacklight/db/PreDb.php @@ -212,16 +212,15 @@ SQL_EXPORT; } /** - * @param null $settings + * @param null $settings * @param array $options * * @return mixed|null - * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException */ public function progress($settings = null, array $options = []) { $defaults = [ - 'path' => base_path().'/'.'cli/data/predb_progress.txt', + 'path' => NN_ROOT.'cli'.DS.'data'.DS.'predb_progress.txt', 'read' => true, ]; $options += $defaults; diff --git a/Blacklight/db/populate/AniDB.php b/Blacklight/db/populate/AniDB.php index 8496c4b5c..8e32b662f 100755 --- a/Blacklight/db/populate/AniDB.php +++ b/Blacklight/db/populate/AniDB.php @@ -74,7 +74,7 @@ class AniDB $anidbupdint = Settings::settingValue('APIs.AniDB.max_update_frequency'); $lastupdated = Settings::settingValue('APIs.AniDB.last_full_update'); - $this->imgSavePath = resource_path().'/covers/'.'anime/'; + $this->imgSavePath = NN_COVERS.'anime'.DS; $this->apiKey = config('nntmux_api.anidb_api_key'); $this->updateInterval = $anidbupdint ?? '7'; diff --git a/Blacklight/processing/post/ProcessAdditional.php b/Blacklight/processing/post/ProcessAdditional.php index 257dd71b4..6318a771b 100755 --- a/Blacklight/processing/post/ProcessAdditional.php +++ b/Blacklight/processing/post/ProcessAdditional.php @@ -463,7 +463,7 @@ class ProcessAdditional ); } - $this->_showCLIReleaseID = (PHP_BINARY.' '.__DIR__.'/ProcessAdditional.php ReleaseID: '); + $this->_showCLIReleaseID = (PHP_BINARY.' '.__DIR__.DS.'ProcessAdditional.php ReleaseID: '); // Maximum amount of releases to fetch per run. $this->_queryLimit = @@ -512,7 +512,7 @@ class ProcessAdditional $this->_processAudioInfo = $this->_processMediaInfo; $this->_processPasswords = ! empty(Settings::settingValue('..checkpasswordedrar')) && ! empty(Settings::settingValue('apps..unrarpath')); - $this->_audioSavePath = resource_path().'/covers/'.'audiosample/'; + $this->_audioSavePath = NN_COVERS.'audiosample'.DS; $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'; @@ -573,7 +573,7 @@ class ProcessAdditional // Check if it ends with a dir separator. if (! preg_match('/[\/\\\\]$/', $this->_mainTmpPath)) { - $this->_mainTmpPath .= '/'; + $this->_mainTmpPath .= DS; } // If we are doing per group, use the groupID has a inner path, so other scripts don't delete the files we are working on. @@ -782,7 +782,7 @@ class ProcessAdditional protected function _createTempFolder(): bool { // Per release defaults. - $this->tmpPath = $this->_mainTmpPath.$this->_release->guid.'/'; + $this->tmpPath = $this->_mainTmpPath.$this->_release->guid.DS; if (! File::isDirectory($this->tmpPath)) { if (! File::makeDirectory($this->tmpPath, 0777, true, false) && ! File::isDirectory($this->tmpPath)) { $this->_echo('Unable to create directory: '.$this->tmpPath, 'warning'); diff --git a/Blacklight/processing/tv/TV.php b/Blacklight/processing/tv/TV.php index 3ecb5ef88..0a1d72c8e 100755 --- a/Blacklight/processing/tv/TV.php +++ b/Blacklight/processing/tv/TV.php @@ -76,7 +76,7 @@ abstract class TV extends Videos $this->colorCli = new ColorCLI(); $this->catWhere = 'categories_id BETWEEN '.Category::TV_ROOT.' AND '.Category::TV_OTHER.' AND categories_id != '.Category::TV_ANIME; $this->tvqty = Settings::settingValue('..maxrageprocessed') !== '' ? (int) Settings::settingValue('..maxrageprocessed') : 75; - $this->imgSavePath = resource_path().'/covers/'.'tvshows/'; + $this->imgSavePath = NN_COVERS.'tvshows'.DS; $this->siteColumns = ['tvdb', 'trakt', 'tvrage', 'tvmaze', 'imdb', 'tmdb']; } diff --git a/Blacklight/utility/Git.php b/Blacklight/utility/Git.php index 4910a25a9..855269cf2 100755 --- a/Blacklight/utility/Git.php +++ b/Blacklight/utility/Git.php @@ -49,7 +49,7 @@ class Git extends GitRepository $defaults = [ 'create' => false, 'initialise' => false, - 'filepath' => base_path().'/', + 'filepath' => NN_ROOT, ]; $options += $defaults; diff --git a/Blacklight/utility/Utility.php b/Blacklight/utility/Utility.php index bde03b4ef..0ed7016f9 100755 --- a/Blacklight/utility/Utility.php +++ b/Blacklight/utility/Utility.php @@ -31,10 +31,10 @@ class Utility public static function canExecuteRead($path) { $paths = explode('#/#', $path); - $fullPath = '/'; + $fullPath = DS; foreach ($paths as $singlePath) { if ($singlePath !== '') { - $fullPath .= $singlePath.'/'; + $fullPath .= $singlePath.DS; if (! is_readable($fullPath) || ! is_executable($fullPath)) { return "The '$fullPath' directory must be readable and executable by all .".PHP_EOL; } @@ -244,6 +244,26 @@ class Utility return $string === '' ? false : $string; } + /** + * @param $path + */ + public static function setCoversConstant($path): void + { + if (! \defined('NN_COVERS')) { + switch (true) { + case $path[0] === '/' || $path[1] === ':' || $path[0] === '\\': + \define('NN_COVERS', Str::finish($path, '/')); + break; + case $path !== '' && $path[0] !== '/' && $path[1] !== ':' && $path[0] !== '\\': + \define('NN_COVERS', realpath(NN_ROOT.Str::finish($path, '/'))); + break; + case empty($path): // Default to resources location. + default: + \define('NN_COVERS', NN_RES.'covers/'); + } + } + } + /** * Creates an array to be used with stream_context_create() to verify openssl certificates * when connecting to a tls or ssl connection when using stream functions (fopen/file_get_contents/etc). @@ -337,7 +357,7 @@ class Utility ) ) { $fileSpec = sprintf($fileSpecTemplate, $options['type'], $options['id'], $options['suffix']); - $fileSpec = file_exists(resource_path().'/covers/'.$fileSpec) ? $fileSpec : + $fileSpec = file_exists(NN_COVERS.$fileSpec) ? $fileSpec : sprintf($fileSpecTemplate, $options['type'], 'no', $options['suffix']); } diff --git a/Changelog b/Changelog index 1a5dcaa19..aaad89130 100755 --- a/Changelog +++ b/Changelog @@ -1,5 +1,3 @@ -2020-03-22 DariusIII - * Chg: Remove option to set covers path in database, it is hardcoded now to resources/covers/ 2020-03-01 DariusIII * Chg: Move all third party api keys from database to .env file 2020-02-27 DariusIII diff --git a/app/Console/Commands/InstallNntmux.php b/app/Console/Commands/InstallNntmux.php index 1e1200184..e1edf711c 100644 --- a/app/Console/Commands/InstallNntmux.php +++ b/app/Console/Commands/InstallNntmux.php @@ -48,7 +48,7 @@ class InstallNntmux extends Command $error = false; if ($this->confirm('Are you sure you want to install NNTmux? This will wipe your database!!')) { - if (file_exists(base_path().'/'.'_install/install.lock')) { + if (file_exists(NN_ROOT.'_install/install.lock')) { if ($this->confirm('Do you want to remove install.lock file so you can continue with install?')) { $this->info('Removing install.lock file so we can continue with install process'); $remove = new Process('rm _install/install.lock'); diff --git a/app/Console/Commands/NntmuxResetDb.php b/app/Console/Commands/NntmuxResetDb.php index c12b2c485..90b9e21f4 100644 --- a/app/Console/Commands/NntmuxResetDb.php +++ b/app/Console/Commands/NntmuxResetDb.php @@ -177,7 +177,7 @@ class NntmuxResetDb extends Command $this->info('Deleting all images, previews and samples that still remain.'); - $files = File::allFiles(resource_path().'/covers/'); + $files = File::allFiles(NN_COVERS); foreach ($files as $file) { if (basename($file) !== '.gitignore' && basename($file) !== 'no-cover.jpg' && basename($file) !== 'no-backdrop.jpg') { File::delete($file); diff --git a/app/Extensions/util/Git.php b/app/Extensions/util/Git.php index b8459416a..7aed8e05e 100644 --- a/app/Extensions/util/Git.php +++ b/app/Extensions/util/Git.php @@ -62,7 +62,7 @@ class Git 'dev', ], ], - 'filepath' => base_path().'/', + 'filepath' => NN_ROOT, ]; $config += $defaults; diff --git a/app/Http/Controllers/Admin/GameController.php b/app/Http/Controllers/Admin/GameController.php index e27765f26..ebb34a067 100644 --- a/app/Http/Controllers/Admin/GameController.php +++ b/app/Http/Controllers/Admin/GameController.php @@ -57,7 +57,7 @@ class GameController extends BasePageController switch ($action) { case 'submit': - $coverLoc = resource_path().'/covers/'.'games/'.$id.'.jpg'; + $coverLoc = NN_COVERS.'games/'.$id.'.jpg'; if ($_FILES['cover']['size'] > 0) { $tmpName = $_FILES['cover']['tmp_name']; diff --git a/app/Http/Controllers/Admin/NzbController.php b/app/Http/Controllers/Admin/NzbController.php index 7474fc32d..499b95976 100644 --- a/app/Http/Controllers/Admin/NzbController.php +++ b/app/Http/Controllers/Admin/NzbController.php @@ -43,8 +43,8 @@ class NzbController extends BasePageController // Get the path the user set in the browser if he put one. $path = ($request->has('folder') ? $request->input('folder') : ''); - if (substr($path, \strlen($path) - 1) !== '/') { - $path .= '/'; + if (substr($path, \strlen($path) - 1) !== DS) { + $path .= DS; } // Get the files from the user specified path. diff --git a/app/Http/Controllers/Admin/SiteController.php b/app/Http/Controllers/Admin/SiteController.php index 078e0b263..c34f3850d 100644 --- a/app/Http/Controllers/Admin/SiteController.php +++ b/app/Http/Controllers/Admin/SiteController.php @@ -137,7 +137,7 @@ class SiteController extends BasePageController $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', resource_path().'/covers/'); + $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']); diff --git a/bootstrap/autoload.php b/bootstrap/autoload.php index 2a7e8d299..aaf841295 100644 --- a/bootstrap/autoload.php +++ b/bootstrap/autoload.php @@ -2,6 +2,7 @@ require_once dirname(__DIR__).DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'autoload.php'; require __DIR__.DIRECTORY_SEPARATOR.'app.php'; +require_once 'constants.php'; require_once dirname(__DIR__).DIRECTORY_SEPARATOR.'app/Extensions/util/PhpYenc.php'; use Dotenv\Dotenv; diff --git a/bootstrap/constants.php b/bootstrap/constants.php new file mode 100644 index 000000000..d7e30b2b9 --- /dev/null +++ b/bootstrap/constants.php @@ -0,0 +1,44 @@ + $files) { } // Store the dump. - $dumpFile = resource_path().'/'.$match[2].'_predb_dump.csv'; + $dumpFile = NN_RES.$match[2].'_predb_dump.csv'; $fetched = File::put($dumpFile, $dump); if (! $fetched) { - echo "Error storing dump file {$match[2]} in (".resource_path().'/'.').'. + echo "Error storing dump file {$match[2]} in (".NN_RES.').'. PHP_EOL; continue; } diff --git a/database/migrations/2020_03_07_213224_remove_text_hash.php b/database/migrations/2020_03_07_213224_remove_text_hash.php index 02ba87a2e..f022c4d3f 100644 --- a/database/migrations/2020_03_07_213224_remove_text_hash.php +++ b/database/migrations/2020_03_07_213224_remove_text_hash.php @@ -14,8 +14,14 @@ class RemoveTextHash extends Migration public function up() { Schema::table('release_comments', function (Blueprint $table) { - $table->dropUnique('ix_release_comments_hash_releases_id'); - $table->dropColumn('text_hash'); + $sm = Schema::getConnection()->getDoctrineSchemaManager(); + $indexesFound = $sm->listTableIndexes('release_comments'); + + if (array_key_exists('ix_release_comments_hash_releases_id', $indexesFound)) { + $table->dropUnique("ix_release_comments_hash_releases_id"); + } + + $table->dropIfExists('text_hash'); }); } diff --git a/misc/testing/Dev/clean_nzbs.php b/misc/testing/Dev/clean_nzbs.php index 89ef45c86..913591f1e 100644 --- a/misc/testing/Dev/clean_nzbs.php +++ b/misc/testing/Dev/clean_nzbs.php @@ -9,7 +9,7 @@ use Blacklight\ReleaseImage; use Blacklight\Releases; use Blacklight\utility\Utility; -$dir = resource_path().'/'.'movednzbs/'; +$dir = NN_RES.'movednzbs/'; $colorCli = new ColorCLI(); if (! isset($argv[1]) || ! in_array($argv[1], ['true', 'move'])) { diff --git a/misc/testing/PostProc/check_covers.php b/misc/testing/PostProc/check_covers.php index e2f27948c..ad3831dac 100644 --- a/misc/testing/PostProc/check_covers.php +++ b/misc/testing/PostProc/check_covers.php @@ -5,14 +5,23 @@ // -------------------------------------------------------------- require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; +use App\Models\Settings; use Blacklight\ColorCLI; use Blacklight\Movie; +use Blacklight\utility\Utility; use Illuminate\Support\Facades\DB; $movie = new Movie(['Echo' => true]); $colorCli = new ColorCLI(); -$path2cover = resource_path().'/covers/movies/'; +$row = Settings::settingValue('site.main.coverspath'); +if ($row !== null) { + Utility::setCoversConstant($row); +} else { + die('Unable to determine covers path!'.PHP_EOL); +} + +$path2cover = NN_COVERS.'movies'.DS; if (isset($argv[1]) && ($argv[1] === 'true' || $argv[1] === 'check')) { $couldbe = $argv[1] === 'true' ? $couldbe = 'had ' : 'could have '; diff --git a/misc/testing/PostProc/check_previews.php b/misc/testing/PostProc/check_previews.php index f1a1160e9..a3533d47e 100644 --- a/misc/testing/PostProc/check_previews.php +++ b/misc/testing/PostProc/check_previews.php @@ -5,17 +5,26 @@ // -------------------------------------------------------------- require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; +use App\Models\Settings; use Blacklight\ColorCLI; use Blacklight\ConsoleTools; use Blacklight\NZB; use Blacklight\ReleaseImage; use Blacklight\Releases; +use Blacklight\utility\Utility; use Illuminate\Support\Facades\DB; $pdo = DB::connection()->getPdo(); $colorCli = new ColorCLI(); -$path2preview = resource_path().'/covers/preview/'; +$row = Settings::settingValue('site.main.coverspath'); +if ($row !== null) { + Utility::setCoversConstant($row); +} else { + die("Unable to determine covers path!\n"); +} + +$path2preview = NN_COVERS.'preview'.DS; if (isset($argv[1]) && ($argv[1] === 'true' || $argv[1] === 'check')) { $releases = new Releases(); diff --git a/misc/testing/PostProc/getGameCovers.php b/misc/testing/PostProc/getGameCovers.php index a78f2b51d..27d2b37ef 100644 --- a/misc/testing/PostProc/getGameCovers.php +++ b/misc/testing/PostProc/getGameCovers.php @@ -27,7 +27,7 @@ if ($total > 0) { if ($gameData === false) { $colorCli->primary($gameInfo['release'].' not found'); } else { - if (file_exists(resource_path().'/covers/'.'games/'.$gameData.'.jpg')) { + if (file_exists(NN_COVERS.'games'.DS.$gameData.'.jpg')) { $pdo->exec(sprintf('UPDATE gamesinfo SET cover = 1 WHERE id = %d', $arr['id'])); } } diff --git a/misc/testing/PostProc/getXXXSamples.php b/misc/testing/PostProc/getXXXSamples.php index 5036d2040..2abd5b3a9 100644 --- a/misc/testing/PostProc/getXXXSamples.php +++ b/misc/testing/PostProc/getXXXSamples.php @@ -9,7 +9,7 @@ use Blacklight\ReleaseImage; $pdo = DB::connection()->getPdo(); $colorCli = new ColorCLI(); -$path2cover = resource_path().'/covers/'.'samples/'; +$path2cover = NN_COVERS.'samples'.DS; if (isset($argv[1]) && ($argv[1] === 'true' || $argv[1] === 'check')) { $releaseImage = new ReleaseImage(); diff --git a/misc/testing/PostProc/updateBookImages.php b/misc/testing/PostProc/updateBookImages.php index 64715d06f..5672fb874 100644 --- a/misc/testing/PostProc/updateBookImages.php +++ b/misc/testing/PostProc/updateBookImages.php @@ -14,7 +14,7 @@ if ($argc === 1 || $argv[1] !== 'true') { exit(); } -$path2covers = resource_path().'/covers/'.'book/'; +$path2covers = NN_COVERS.'book'.DS; $itr = File::allFiles($path2covers); foreach ($itr as $filePath) { diff --git a/misc/testing/PostProc/updateConsoleImages.php b/misc/testing/PostProc/updateConsoleImages.php index 70b63e489..e48d602e5 100644 --- a/misc/testing/PostProc/updateConsoleImages.php +++ b/misc/testing/PostProc/updateConsoleImages.php @@ -14,7 +14,7 @@ if ($argc === 1 || $argv[1] !== 'true') { exit(); } -$path2covers = resource_path().'/covers/'.'console/'; +$path2covers = NN_COVERS.'console'.DS; $itr = File::allFiles($path2covers); foreach ($itr as $filePath) { diff --git a/misc/testing/PostProc/updateGamesImages.php b/misc/testing/PostProc/updateGamesImages.php index 25539da9b..17d6d278b 100644 --- a/misc/testing/PostProc/updateGamesImages.php +++ b/misc/testing/PostProc/updateGamesImages.php @@ -3,7 +3,9 @@ require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use App\Models\GamesInfo; +use App\Models\Settings; use Blacklight\ColorCLI; +use Blacklight\utility\Utility; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\File; @@ -17,7 +19,13 @@ if ($argc === 1 || $argv[1] !== 'true') { $pdo = DB::connection()->getPdo(); -$path2covers = resource_path().'/covers/games/'; +$row = Settings::settingValue('site.main.coverspath'); +if ($row !== null) { + Utility::setCoversConstant($row); +} else { + die("Unable to set Covers' constant!\n"); +} +$path2covers = NN_COVERS.'games'.DS; $itr = File::allFiles($path2covers); foreach ($itr as $filePath) { diff --git a/misc/testing/PostProc/updateMovieImages.php b/misc/testing/PostProc/updateMovieImages.php index cfd4bd23d..94b6fea0f 100644 --- a/misc/testing/PostProc/updateMovieImages.php +++ b/misc/testing/PostProc/updateMovieImages.php @@ -3,7 +3,9 @@ require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use App\Models\MovieInfo; +use App\Models\Settings; use Blacklight\ColorCLI; +use Blacklight\utility\Utility; use Illuminate\Support\Facades\File; $covers = $updated = $deleted = 0; @@ -14,7 +16,13 @@ if ($argc === 1 || $argv[1] !== 'true') { exit(); } -$path2covers = resource_path().'/covers/movies/'; +$row = Settings::settingValue('site.main.coverspath'); +if ($row !== null) { + Utility::setCoversConstant($row); +} else { + die("Unable to set Covers' constant!\n"); +} +$path2covers = NN_COVERS.'movies'.DS; $itr = File::allFiles($path2covers); foreach ($itr as $filePath) { diff --git a/misc/testing/PostProc/updateMusicImages.php b/misc/testing/PostProc/updateMusicImages.php index 260c9cc80..15dafd306 100644 --- a/misc/testing/PostProc/updateMusicImages.php +++ b/misc/testing/PostProc/updateMusicImages.php @@ -14,7 +14,7 @@ if ($argc === 1 || $argv[1] !== 'true') { exit(); } -$path2covers = resource_path().'/covers/'.'music/'; +$path2covers = NN_COVERS.'music'.DS; $itr = File::allFiles($path2covers); foreach ($itr as $filePath) { diff --git a/misc/testing/PostProc/updateXXXImages.php b/misc/testing/PostProc/updateXXXImages.php index 2522d8bbb..da7e883d8 100644 --- a/misc/testing/PostProc/updateXXXImages.php +++ b/misc/testing/PostProc/updateXXXImages.php @@ -14,7 +14,7 @@ if ($argc === 1 || $argv[1] !== 'true') { exit(); } -$path2covers = resource_path().'/covers/'.'xxx/'; +$path2covers = NN_COVERS.'xxx'.DS; $itr = File::allFiles($path2covers); foreach ($itr as $filePath) { diff --git a/misc/testing/nzb-export.php b/misc/testing/nzb-export.php index cc35d518a..d4bdcb01c 100644 --- a/misc/testing/nzb-export.php +++ b/misc/testing/nzb-export.php @@ -18,8 +18,8 @@ if (count($argv) !== 6) { 'arg4 : Group ID for the group or false | number/false'.$n. 'arg5 : Gzip the NZB files (recommended, faster/takes less space) | true/false'.$n.$n. 'Examples: '.$n. - $_SERVER['_'].' '.$argv[0].' '.base_path().'/exportFolder/ 01/01/2012 01/01/2014 false true'.$n. - $_SERVER['_'].' '.$argv[0].' '.base_path().'/'.'exportFolder/ false 01/01/2014 12 false'.$n + $_SERVER['_'].' '.$argv[0].' '.NN_ROOT.'exportFolder'.DS.' 01/01/2012 01/01/2014 false true'.$n. + $_SERVER['_'].' '.$argv[0].' '.NN_ROOT.'exportFolder'.DS.' false 01/01/2014 12 false'.$n ); } diff --git a/misc/testing/nzb-import.php b/misc/testing/nzb-import.php index 3fd6c7cc0..b15f7cdef 100644 --- a/misc/testing/nzb-import.php +++ b/misc/testing/nzb-import.php @@ -18,7 +18,7 @@ if (count($argv) !== 6) { 'arg3 : Delete NZB when unsuccessfully imported.(not recommended) | true/false'.$n. 'arg4 : Use NZB file name as release name.(not recommended) | true/false'.$n. 'arg5 : Import this many NZB files. (RECOMMENDED 100,000) | a number'.$n.$n. - 'ie: '.$_SERVER['_'].' '.__FILE__.' '.base_path().'/nzbToImport/ true false false 1000'.$n + 'ie: '.$_SERVER['_'].' '.__FILE__.' '.NN_ROOT.'nzbToImport'.DS.' true false false 1000'.$n ); } @@ -44,8 +44,8 @@ if ($argv[5] < 0) { $path = $argv[1]; // Check if path ends with dir separator. -if (substr($path, -1) !== '/') { - $path .= '/'; +if (substr($path, -1) !== DS) { + $path .= DS; } $files = new \RegexIterator( diff --git a/misc/update/tmux/monitor.php b/misc/update/tmux/monitor.php index 96cd54445..9dded8ab7 100644 --- a/misc/update/tmux/monitor.php +++ b/misc/update/tmux/monitor.php @@ -26,9 +26,9 @@ try { echo $e; } -$runVar['paths']['misc'] = base_path().'/misc/'; -$runVar['paths']['cli'] = base_path().'/cli/'; -$runVar['paths']['scraper'] = base_path().'/misc/IRCScraper/scrape.php'; +$runVar['paths']['misc'] = NN_MISC; +$runVar['paths']['cli'] = NN_ROOT.'cli/'; +$runVar['paths']['scraper'] = NN_MISC.'IRCScraper'.DS.'scrape.php'; $db_name = config('nntmux.db_name'); diff --git a/misc/update/tmux/run.php b/misc/update/tmux/run.php index 1410ec907..759371f27 100644 --- a/misc/update/tmux/run.php +++ b/misc/update/tmux/run.php @@ -7,7 +7,7 @@ use App\Models\Settings; use Blacklight\ColorCLI; use Blacklight\utility\Utility; -$DIR = base_path().'/misc/update/tmux/'; +$DIR = NN_TMUX; $import = Settings::settingValue('site.tmux.import') ?? 0; $tmux_session = Settings::settingValue('site.tmux.tmux_session') ?? 0; $seq = Settings::settingValue('site.tmux.sequential') ?? 0; @@ -33,7 +33,7 @@ Collection::query()->where('dateadded', '<', now()->subHours($delaytimet))->upda function writelog($pane) { - $path = resource_path().'/'.'logs'; + $path = NN_RES.'logs'; $getdate = gmdate('Ymd'); $logs = Settings::settingValue('site.tmux.write_logs'); if ((int) $logs === 1) { diff --git a/resources/views/themes/admin/site-edit.tpl b/resources/views/themes/admin/site-edit.tpl index 3081608b5..c743001f6 100644 --- a/resources/views/themes/admin/site-edit.tpl +++ b/resources/views/themes/admin/site-edit.tpl @@ -61,6 +61,14 @@ + + + + +
The absolute path to the place covers will be stored.
+ + + : diff --git a/tests/Install/InstallTest.php b/tests/Install/InstallTest.php index b26a81cbc..a16a666b1 100644 --- a/tests/Install/InstallTest.php +++ b/tests/Install/InstallTest.php @@ -21,7 +21,7 @@ class InstallTest extends \PHPUnit\Framework\TestCase { public function testFullInstall() { - passthru('php '.base_path().'/'.'artisan migrate:fresh --seed'); + passthru('php '.NN_ROOT.'artisan migrate:fresh --seed'); $message = 'NNTmux installation completed successfully';