From d0aa6f23ab4ceb255532ded18bdf151aa3b15b7d Mon Sep 17 00:00:00 2001 From: DariusIII Date: Thu, 22 Jan 2026 12:44:59 +0100 Subject: [PATCH] Update code for php 8.5 compatibility --- app/Console/Commands/FetchMovieByImdb.php | 9 ++++--- app/Console/Commands/NntmuxCheckIndex.php | 7 +++--- .../Commands/NntmuxCreateESIndexes.php | 2 +- app/Console/Commands/NntmuxESReindex.php | 6 ++--- app/Console/Commands/NntmuxOffsetPopulate.php | 14 +++++------ app/Console/Commands/NntmuxOffsetWorker.php | 2 +- app/Console/Commands/NntmuxOptimizeTables.php | 7 +++--- .../Commands/NntmuxPopulateSearchIndexes.php | 3 ++- app/Console/Commands/NntmuxResetDb.php | 25 ++++++++++--------- .../Commands/UpdateReleasesIndexSchemaES.php | 2 +- app/Exceptions/Handler.php | 1 + .../helper/age_verification_helpers.php | 5 ++-- app/Extensions/helper/helpers.php | 2 +- .../Controllers/Admin/AdminPageController.php | 9 ++++--- .../Controllers/Admin/AdminUserController.php | 7 +++--- app/Http/Controllers/Auth/LoginController.php | 10 ++++---- .../PasswordSecurityController.php | 13 +++++----- app/Http/Controllers/ProfileController.php | 3 ++- app/Listeners/UpdateUserLoggedIn.php | 3 ++- app/Models/UserActivityStat.php | 11 ++++---- app/Services/NameFixing/NameFixingService.php | 2 +- app/Services/Runners/BaseRunner.php | 7 +++--- app/Services/TurnstileService.php | 3 ++- app/Support/CaptchaHelper.php | 3 ++- app/Support/UpdatePerformanceHelper.php | 9 ++++--- config/app.php | 4 ++- 26 files changed, 94 insertions(+), 75 deletions(-) diff --git a/app/Console/Commands/FetchMovieByImdb.php b/app/Console/Commands/FetchMovieByImdb.php index 7f7bcd088..acba6041c 100644 --- a/app/Console/Commands/FetchMovieByImdb.php +++ b/app/Console/Commands/FetchMovieByImdb.php @@ -4,6 +4,7 @@ namespace App\Console\Commands; use App\Services\MovieService; use Illuminate\Console\Command; +use Illuminate\Support\Facades\Cache; class FetchMovieByImdb extends Command { @@ -39,10 +40,10 @@ class FetchMovieByImdb extends Command $this->info('Force fetching movie data for IMDb id: tt'.$imdbId.' ...'); // Clear all caches for this movie to force fresh data retrieval - \Cache::forget('tmdb_movie_'.md5('tt'.$imdbId)); - \Cache::forget('trakt_movie_'.md5($imdbId)); - \Cache::forget('imdb_movie_'.md5($imdbId)); - \Cache::forget('omdb_movie_'.md5($imdbId)); + Cache::forget('tmdb_movie_'.md5('tt'.$imdbId)); + Cache::forget('trakt_movie_'.md5($imdbId)); + Cache::forget('imdb_movie_'.md5($imdbId)); + Cache::forget('omdb_movie_'.md5($imdbId)); $ok = $movie->updateMovieInfo($imdbId); diff --git a/app/Console/Commands/NntmuxCheckIndex.php b/app/Console/Commands/NntmuxCheckIndex.php index 7e58e574d..853e7db1b 100644 --- a/app/Console/Commands/NntmuxCheckIndex.php +++ b/app/Console/Commands/NntmuxCheckIndex.php @@ -2,6 +2,7 @@ namespace App\Console\Commands; +use App\Facades\Elasticsearch; use Exception; use Illuminate\Console\Command; @@ -63,7 +64,7 @@ class NntmuxCheckIndex extends Command { try { // Check if index exists - $exists = \Elasticsearch::indices()->exists(['index' => $index]); + $exists = Elasticsearch::indices()->exists(['index' => $index]); if (! $exists) { $this->error("ElasticSearch index '{$index}' does not exist."); @@ -74,7 +75,7 @@ class NntmuxCheckIndex extends Command $this->info("ElasticSearch index '{$index}' exists."); // Get index stats - $stats = \Elasticsearch::indices()->stats(['index' => $index]); + $stats = Elasticsearch::indices()->stats(['index' => $index]); $docCount = $stats['indices'][$index]['total']['docs']['count'] ?? 0; $storeSize = $stats['indices'][$index]['total']['store']['size_in_bytes'] ?? 0; @@ -83,7 +84,7 @@ class NntmuxCheckIndex extends Command // Get a sample document if ($docCount > 0) { - $sample = \Elasticsearch::search([ + $sample = Elasticsearch::search([ 'index' => $index, 'size' => 1, 'body' => [ diff --git a/app/Console/Commands/NntmuxCreateESIndexes.php b/app/Console/Commands/NntmuxCreateESIndexes.php index f20c3293d..98b9e5f3e 100644 --- a/app/Console/Commands/NntmuxCreateESIndexes.php +++ b/app/Console/Commands/NntmuxCreateESIndexes.php @@ -2,7 +2,7 @@ namespace App\Console\Commands; -use Elasticsearch; +use App\Facades\Elasticsearch; use Illuminate\Console\Command; class NntmuxCreateESIndexes extends Command diff --git a/app/Console/Commands/NntmuxESReindex.php b/app/Console/Commands/NntmuxESReindex.php index 1f6864d13..06cfbbbd2 100644 --- a/app/Console/Commands/NntmuxESReindex.php +++ b/app/Console/Commands/NntmuxESReindex.php @@ -32,13 +32,13 @@ class NntmuxESReindex extends Command /** * Execute the console command. - * - * @return int */ - public function handle() + public function handle(): int { passthru('php '.app()->/* @scrutinizer ignore-call */ path().'/../misc/elasticsearch/create_es_indexes.php'); passthru('php '.app()->/* @scrutinizer ignore-call */ path().'/../misc/elasticsearch/populate_es_indexes.php releases'); passthru('php '.app()->/* @scrutinizer ignore-call */ path().'/../misc/elasticsearch/populate_es_indexes.php predb'); + + return self::SUCCESS; } } diff --git a/app/Console/Commands/NntmuxOffsetPopulate.php b/app/Console/Commands/NntmuxOffsetPopulate.php index d9a1252ed..70e063900 100644 --- a/app/Console/Commands/NntmuxOffsetPopulate.php +++ b/app/Console/Commands/NntmuxOffsetPopulate.php @@ -250,7 +250,7 @@ class NntmuxOffsetPopulate extends Command // Wait a moment for ElasticSearch to refresh sleep(2); - $stats = \Elasticsearch::indices()->stats(['index' => $index]); + $stats = Elasticsearch::indices()->stats(['index' => $index]); $actualCount = $stats['indices'][$index]['total']['docs']['count'] ?? 0; $this->info('Expected: '.number_format($expectedTotal).' records'); @@ -281,18 +281,18 @@ class NntmuxOffsetPopulate extends Command } else { // For ElasticSearch, just clear the data instead of recreating the index try { - $exists = \Elasticsearch::indices()->exists(['index' => $index]); + $exists = Elasticsearch::indices()->exists(['index' => $index]); if ($exists) { // Get current document count - $stats = \Elasticsearch::indices()->stats(['index' => $index]); + $stats = Elasticsearch::indices()->stats(['index' => $index]); $currentCount = $stats['indices'][$index]['total']['docs']['count'] ?? 0; if ($currentCount > 0) { $this->info("ElasticSearch index '{$index}' exists with {$currentCount} documents. Clearing data..."); // Delete all documents but keep the index structure - \Elasticsearch::deleteByQuery([ + Elasticsearch::deleteByQuery([ 'index' => $index, 'body' => [ 'query' => ['match_all' => (object) []], @@ -300,7 +300,7 @@ class NntmuxOffsetPopulate extends Command ]); // Force refresh to ensure deletions are visible - \Elasticsearch::indices()->refresh(['index' => $index]); + Elasticsearch::indices()->refresh(['index' => $index]); $this->info("Cleared all documents from ElasticSearch index: {$index}"); } else { $this->info("ElasticSearch index '{$index}' exists but is already empty"); @@ -315,7 +315,7 @@ class NntmuxOffsetPopulate extends Command // Fallback: delete and recreate try { - \Elasticsearch::indices()->delete(['index' => $index]); + Elasticsearch::indices()->delete(['index' => $index]); } catch (Exception $e) { // Index might not exist, that's okay } @@ -346,7 +346,7 @@ class NntmuxOffsetPopulate extends Command ], ]; - \Elasticsearch::indices()->create($settings); + Elasticsearch::indices()->create($settings); $this->info("Created optimized ElasticSearch index: {$indexName}"); } diff --git a/app/Console/Commands/NntmuxOffsetWorker.php b/app/Console/Commands/NntmuxOffsetWorker.php index ed5494778..cc27241ea 100644 --- a/app/Console/Commands/NntmuxOffsetWorker.php +++ b/app/Console/Commands/NntmuxOffsetWorker.php @@ -276,7 +276,7 @@ class NntmuxOffsetWorker extends Command while ($attempt < $retries) { try { - $response = \Elasticsearch::bulk($data); + $response = Elasticsearch::bulk($data); if (isset($response['errors']) && $response['errors']) { $errorCount = 0; diff --git a/app/Console/Commands/NntmuxOptimizeTables.php b/app/Console/Commands/NntmuxOptimizeTables.php index b29b4ffdb..304e52e27 100644 --- a/app/Console/Commands/NntmuxOptimizeTables.php +++ b/app/Console/Commands/NntmuxOptimizeTables.php @@ -3,6 +3,7 @@ namespace App\Console\Commands; use Illuminate\Console\Command; +use Illuminate\Support\Facades\DB; class NntmuxOptimizeTables extends Command { @@ -40,7 +41,7 @@ class NntmuxOptimizeTables extends Command */ private function optimizeAllTables(): void { - $tables = \DB::select('SHOW TABLES'); + $tables = DB::select('SHOW TABLES'); foreach ($tables as $table) { $this->optimizeTable($table->Tables_in_nntmux); } @@ -63,11 +64,11 @@ class NntmuxOptimizeTables extends Command private function tableCheck($table): void { $this->info('Checking table: '.$table); - $tableCheck = \DB::select('CHECK TABLE '.$table); + $tableCheck = DB::select('CHECK TABLE '.$table); if ($tableCheck[0]->Msg_text !== 'OK') { $this->error('Table '.$table.' is corrupted. Please repair it.'); $this->info('Optimizing table: '.$table); - \DB::select('OPTIMIZE TABLE '.$table); + DB::select('OPTIMIZE TABLE '.$table); } else { $this->info('Table '.$table.' is ok. Optimization is not needed.'); } diff --git a/app/Console/Commands/NntmuxPopulateSearchIndexes.php b/app/Console/Commands/NntmuxPopulateSearchIndexes.php index 90773d77c..ba70ae53b 100644 --- a/app/Console/Commands/NntmuxPopulateSearchIndexes.php +++ b/app/Console/Commands/NntmuxPopulateSearchIndexes.php @@ -2,6 +2,7 @@ namespace App\Console\Commands; +use App\Facades\Elasticsearch; use App\Facades\Search; use App\Models\MovieInfo; use App\Models\Predb; @@ -827,7 +828,7 @@ class NntmuxPopulateSearchIndexes extends Command while ($attempt < $retries) { try { - $response = \Elasticsearch::bulk($data); + $response = Elasticsearch::bulk($data); // Check for errors in bulk response if (isset($response['errors']) && $response['errors']) { diff --git a/app/Console/Commands/NntmuxResetDb.php b/app/Console/Commands/NntmuxResetDb.php index ccaf718d6..0c774a805 100644 --- a/app/Console/Commands/NntmuxResetDb.php +++ b/app/Console/Commands/NntmuxResetDb.php @@ -2,6 +2,7 @@ namespace App\Console\Commands; +use App\Facades\Elasticsearch; use App\Facades\Search; use App\Models\UsenetGroup; use Illuminate\Console\Command; @@ -91,8 +92,8 @@ class NntmuxResetDb extends Command unset($value); if (config('search.default') === 'elasticsearch') { - if (\Elasticsearch::indices()->exists(['index' => 'releases'])) { - \Elasticsearch::indices()->delete(['index' => 'releases']); + if (Elasticsearch::indices()->exists(['index' => 'releases'])) { + Elasticsearch::indices()->delete(['index' => 'releases']); } $releases_index = [ 'index' => 'releases', @@ -133,10 +134,10 @@ class NntmuxResetDb extends Command ], ]; - \Elasticsearch::indices()->create($releases_index); + Elasticsearch::indices()->create($releases_index); - if (\Elasticsearch::indices()->exists(['index' => 'predb'])) { - \Elasticsearch::indices()->delete(['index' => 'predb']); + if (Elasticsearch::indices()->exists(['index' => 'predb'])) { + Elasticsearch::indices()->delete(['index' => 'predb']); } $predb_index = [ 'index' => 'predb', @@ -167,11 +168,11 @@ class NntmuxResetDb extends Command ]; - \Elasticsearch::indices()->create($predb_index); + Elasticsearch::indices()->create($predb_index); // Delete and recreate movies index - if (\Elasticsearch::indices()->exists(['index' => 'movies'])) { - \Elasticsearch::indices()->delete(['index' => 'movies']); + if (Elasticsearch::indices()->exists(['index' => 'movies'])) { + Elasticsearch::indices()->delete(['index' => 'movies']); } $movies_index = [ 'index' => 'movies', @@ -208,11 +209,11 @@ class NntmuxResetDb extends Command ], ]; - \Elasticsearch::indices()->create($movies_index); + Elasticsearch::indices()->create($movies_index); // Delete and recreate tvshows index - if (\Elasticsearch::indices()->exists(['index' => 'tvshows'])) { - \Elasticsearch::indices()->delete(['index' => 'tvshows']); + if (Elasticsearch::indices()->exists(['index' => 'tvshows'])) { + Elasticsearch::indices()->delete(['index' => 'tvshows']); } $tvshows_index = [ 'index' => 'tvshows', @@ -248,7 +249,7 @@ class NntmuxResetDb extends Command ], ]; - \Elasticsearch::indices()->create($tvshows_index); + Elasticsearch::indices()->create($tvshows_index); $this->info('All done! ElasticSearch indexes are deleted and recreated.'); } else { diff --git a/app/Console/Commands/UpdateReleasesIndexSchemaES.php b/app/Console/Commands/UpdateReleasesIndexSchemaES.php index 72744de82..d56653157 100644 --- a/app/Console/Commands/UpdateReleasesIndexSchemaES.php +++ b/app/Console/Commands/UpdateReleasesIndexSchemaES.php @@ -2,8 +2,8 @@ namespace App\Console\Commands; +use App\Facades\Elasticsearch; use App\Models\Release; -use Elasticsearch; use Elasticsearch\Common\Exceptions\Missing404Exception; use Illuminate\Console\Command; use Illuminate\Support\Facades\DB; diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index ff18b45fa..13f48c331 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -3,6 +3,7 @@ namespace App\Exceptions; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; +use Throwable; class Handler extends ExceptionHandler { diff --git a/app/Extensions/helper/age_verification_helpers.php b/app/Extensions/helper/age_verification_helpers.php index b2414f047..cce1329bc 100644 --- a/app/Extensions/helper/age_verification_helpers.php +++ b/app/Extensions/helper/age_verification_helpers.php @@ -10,6 +10,7 @@ use App\Services\AdultProcessing\AgeVerificationManager; use GuzzleHttp\Client; use GuzzleHttp\Exception\RequestException; +use Illuminate\Support\Facades\Log; if (! function_exists('getRawHtmlWithAgeVerification')) { /** @@ -82,13 +83,13 @@ if (! function_exists('getRawHtmlWithAgeVerification')) { } catch (RequestException $e) { if (config('app.debug') === true) { - \Log::error('getRawHtmlWithAgeVerification: '.$e->getMessage()); + Log::error('getRawHtmlWithAgeVerification: '.$e->getMessage()); } return false; } catch (\Exception $e) { if (config('app.debug') === true) { - \Log::error('getRawHtmlWithAgeVerification: '.$e->getMessage()); + Log::error('getRawHtmlWithAgeVerification: '.$e->getMessage()); } return false; diff --git a/app/Extensions/helper/helpers.php b/app/Extensions/helper/helpers.php index 2c399ac0a..ce8f818bd 100644 --- a/app/Extensions/helper/helpers.php +++ b/app/Extensions/helper/helpers.php @@ -12,8 +12,8 @@ use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Log; use Illuminate\Support\Str; use sspat\ESQuerySanitizer\Sanitizer; +use STS\ZipStream\Facades\Zip as ZipStream; use Symfony\Component\Process\Process; -use Zip as ZipStream; if (! function_exists('getRawHtml')) { /** diff --git a/app/Http/Controllers/Admin/AdminPageController.php b/app/Http/Controllers/Admin/AdminPageController.php index 349465201..fc8e018b9 100644 --- a/app/Http/Controllers/Admin/AdminPageController.php +++ b/app/Http/Controllers/Admin/AdminPageController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Admin; use App\Http\Controllers\BasePageController; use App\Services\SystemMetricsService; use App\Services\UserStatsService; +use Illuminate\Support\Facades\Log; class AdminPageController extends BasePageController { @@ -254,7 +255,7 @@ class AdminPageController extends BasePageController } } } catch (\Exception $e) { - \Log::warning('Could not get CPU usage: '.$e->getMessage()); + Log::warning('Could not get CPU usage: '.$e->getMessage()); } return 0; @@ -349,7 +350,7 @@ class AdminPageController extends BasePageController } } } catch (\Exception $e) { - \Log::warning('Could not get CPU info: '.$e->getMessage()); + Log::warning('Could not get CPU info: '.$e->getMessage()); } return $info; @@ -388,7 +389,7 @@ class AdminPageController extends BasePageController } } } catch (\Exception $e) { - \Log::warning('Could not get load average: '.$e->getMessage()); + Log::warning('Could not get load average: '.$e->getMessage()); } return $loadAvg; @@ -438,7 +439,7 @@ class AdminPageController extends BasePageController } } } catch (\Exception $e) { - \Log::warning('Could not get RAM usage: '.$e->getMessage()); + Log::warning('Could not get RAM usage: '.$e->getMessage()); } return [ diff --git a/app/Http/Controllers/Admin/AdminUserController.php b/app/Http/Controllers/Admin/AdminUserController.php index 0f5799ace..4b1a115ab 100644 --- a/app/Http/Controllers/Admin/AdminUserController.php +++ b/app/Http/Controllers/Admin/AdminUserController.php @@ -9,6 +9,7 @@ use App\Models\UserDownload; use App\Models\UserRequest; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Log; use Jrean\UserVerification\Facades\UserVerification; use Spatie\Permission\Models\Role; @@ -162,7 +163,7 @@ class AdminUserController extends BasePageController ? $editedUser->rolechangedate->toDateTimeString() : null; - \Log::info('AdminUserController - Before updates', [ + Log::info('AdminUserController - Before updates', [ 'user_id' => $editedUser->id, 'originalRoleChangeDate' => $originalRoleChangeDate, 'current_roles_id' => $editedUser->roles_id, @@ -191,7 +192,7 @@ class AdminUserController extends BasePageController } $editedUser->refresh(); - \Log::info('AdminUserController - After expiry update', [ + Log::info('AdminUserController - After expiry update', [ 'user_id' => $editedUser->id, 'new_rolechangedate' => $editedUser->rolechangedate, 'adminManuallySetExpiry' => $adminManuallySetExpiry, @@ -201,7 +202,7 @@ class AdminUserController extends BasePageController // If role is changing, handle it with stacking logic // Pass the original expiry so history records the correct old_expiry_date if ($roleChanged && $request->input('role') !== null) { - \Log::info('AdminUserController - About to call updateUserRole', [ + Log::info('AdminUserController - About to call updateUserRole', [ 'user_id' => $editedUser->id, 'new_role' => (int) $request->input('role'), 'originalRoleChangeDate_passed' => $originalRoleChangeDate, diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index e96e6efb8..ffb04b81e 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -134,7 +134,7 @@ class LoginController extends Controller return $this->checkPasswordBreachAndRedirect($request->input('password'), $redirect); } } catch (\Exception $e) { - \Log::error('Login - Error processing trusted device cookie', [ + Log::error('Login - Error processing trusted device cookie', [ 'error' => $e->getMessage(), ]); } @@ -213,7 +213,7 @@ class LoginController extends Controller $remainingSeconds = max(0, $cookieData['expires_at'] - time()); $remainingMinutes = (int) ceil($remainingSeconds / 60); - \Log::info('Logout - Cookie Expiration', [ + Log::info('Logout - Cookie Expiration', [ 'expires_at' => $cookieData['expires_at'], 'current_time' => time(), 'remaining_seconds' => $remainingSeconds, @@ -238,13 +238,13 @@ class LoginController extends Controller // Queue the cookie to be sent with the response cookie()->queue($cookie); } else { - \Log::warning('Logout - Cookie Already Expired'); + Log::warning('Logout - Cookie Already Expired'); } } else { - \Log::warning('Logout - Cookie Missing Expiration Data'); + Log::warning('Logout - Cookie Missing Expiration Data'); } } catch (\Exception $e) { - \Log::error('Logout - Error Processing Cookie', [ + Log::error('Logout - Error Processing Cookie', [ 'error' => $e->getMessage(), ]); } diff --git a/app/Http/Controllers/PasswordSecurityController.php b/app/Http/Controllers/PasswordSecurityController.php index 9875e7372..ab58c4ce8 100644 --- a/app/Http/Controllers/PasswordSecurityController.php +++ b/app/Http/Controllers/PasswordSecurityController.php @@ -13,6 +13,7 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Log; +use PragmaRX\Google2FALaravel\Facade as Google2FA; class PasswordSecurityController extends Controller { @@ -28,7 +29,7 @@ class PasswordSecurityController extends Controller $google2fa_url = ''; if ($user->passwordSecurity()->exists()) { - $google2fa_url = \Google2FA::getQRCodeInline( + $google2fa_url = Google2FA::getQRCodeInline( config('app.name'), $user->email, $user->passwordSecurity->google2fa_secret @@ -62,7 +63,7 @@ class PasswordSecurityController extends Controller [ 'user_id' => $user->id, 'google2fa_enable' => 0, - 'google2fa_secret' => \Google2FA::generateSecretKey(), + 'google2fa_secret' => Google2FA::generateSecretKey(), ] ); @@ -90,7 +91,7 @@ class PasswordSecurityController extends Controller } $secret = $request->input('verify-code'); - $valid = \Google2FA::verifyKey($user->passwordSecurity->google2fa_secret, $secret); + $valid = Google2FA::verifyKey($user->passwordSecurity->google2fa_secret, $secret); if ($valid) { $user->passwordSecurity->google2fa_enable = 1; $user->passwordSecurity->save(); @@ -178,7 +179,7 @@ class PasswordSecurityController extends Controller } // Verify the OTP code - $valid = \Google2FA::verifyKey( + $valid = Google2FA::verifyKey( $user->passwordSecurity->google2fa_secret, $request->input('one_time_password') ); @@ -340,7 +341,7 @@ class PasswordSecurityController extends Controller $google2fa_url = ''; if ($user->passwordSecurity()->exists()) { - $google2fa_url = \Google2FA::getQRCodeInline( + $google2fa_url = Google2FA::getQRCodeInline( config('app.name'), $user->email, $user->passwordSecurity->google2fa_secret @@ -370,7 +371,7 @@ class PasswordSecurityController extends Controller $google2fa_url = ''; if ($user->passwordSecurity()->exists()) { - $google2fa_url = \Google2FA::getQRCodeInline( + $google2fa_url = Google2FA::getQRCodeInline( config('app.name'), $user->email, $user->passwordSecurity->google2fa_secret diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index 9917a3b66..52a6a4829 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -17,6 +17,7 @@ use Illuminate\Support\Arr; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Validator; use Jrean\UserVerification\Facades\UserVerification; +use PragmaRX\Google2FALaravel\Facade as Google2FA; class ProfileController extends BasePageController { @@ -116,7 +117,7 @@ class ProfileController extends BasePageController // Generate 2FA QR code URL if 2FA is set up but not enabled $google2fa_url = ''; if ($this->userdata->passwordSecurity()->exists() && ! $this->userdata->passwordSecurity->google2fa_enable) { - $google2fa_url = \Google2FA::getQRCodeInline( + $google2fa_url = Google2FA::getQRCodeInline( config('app.name'), $this->userdata->email, $this->userdata->passwordSecurity->google2fa_secret diff --git a/app/Listeners/UpdateUserLoggedIn.php b/app/Listeners/UpdateUserLoggedIn.php index b6d03a307..20c185c47 100644 --- a/app/Listeners/UpdateUserLoggedIn.php +++ b/app/Listeners/UpdateUserLoggedIn.php @@ -4,6 +4,7 @@ namespace App\Listeners; use App\Events\UserLoggedIn; use App\Models\User; +use Illuminate\Support\Facades\Log; class UpdateUserLoggedIn { @@ -30,7 +31,7 @@ class UpdateUserLoggedIn ); // Log the user login event - \Log::channel('user_login')->info('User logged in', [ + Log::channel('user_login')->info('User logged in', [ 'user_id' => $event->user->id, 'username' => $event->user->username, 'ip' => $event->ip, diff --git a/app/Models/UserActivityStat.php b/app/Models/UserActivityStat.php index f80d5524b..639afb86c 100644 --- a/app/Models/UserActivityStat.php +++ b/app/Models/UserActivityStat.php @@ -5,6 +5,7 @@ namespace App\Models; use Carbon\Carbon; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Facades\DB; class UserActivityStat extends Model { @@ -153,13 +154,13 @@ class UserActivityStat extends Model ->count(); // Store in hourly stats table - \DB::table('user_activity_stats_hourly')->updateOrInsert( + DB::table('user_activity_stats_hourly')->updateOrInsert( ['stat_hour' => $statHour], [ 'downloads_count' => $downloadsCount, 'api_hits_count' => $apiHitsCount, 'updated_at' => now(), - 'created_at' => \DB::raw('COALESCE(created_at, NOW())'), + 'created_at' => DB::raw('COALESCE(created_at, NOW())'), ] ); } @@ -171,7 +172,7 @@ class UserActivityStat extends Model { $startHour = Carbon::now()->subHours($hours - 1)->startOfHour()->format('Y-m-d H:00:00'); - $stats = \DB::table('user_activity_stats_hourly') + $stats = DB::table('user_activity_stats_hourly') ->select('stat_hour', 'downloads_count') ->where('stat_hour', '>=', $startHour) ->orderBy('stat_hour', 'asc') @@ -213,7 +214,7 @@ class UserActivityStat extends Model { $startHour = Carbon::now()->subHours($hours - 1)->startOfHour()->format('Y-m-d H:00:00'); - $stats = \DB::table('user_activity_stats_hourly') + $stats = DB::table('user_activity_stats_hourly') ->select('stat_hour', 'api_hits_count') ->where('stat_hour', '>=', $startHour) ->orderBy('stat_hour', 'asc') @@ -255,7 +256,7 @@ class UserActivityStat extends Model { $cutoffHour = Carbon::now()->subDays($keepDays)->startOfHour()->format('Y-m-d H:00:00'); - return \DB::table('user_activity_stats_hourly') + return DB::table('user_activity_stats_hourly') ->where('stat_hour', '<', $cutoffHour) ->delete(); } diff --git a/app/Services/NameFixing/NameFixingService.php b/app/Services/NameFixing/NameFixingService.php index b7b1b0248..2fd3582a7 100644 --- a/app/Services/NameFixing/NameFixingService.php +++ b/app/Services/NameFixing/NameFixingService.php @@ -1363,7 +1363,7 @@ class NameFixingService $counted++; } if ($show === false) { - cli()->info('Renamed Releases: ['.number_format($counted).'] '.(new ColorCLI)->percentString(++$counter, $total)); + cli()->info('Renamed Releases: ['.number_format($counted).'] '.cli()->percentString(++$counter, $total)); } } cli()->info(PHP_EOL.'Renamed '.number_format($counted).' releases in '.now()->diffInSeconds($timeStart, true).' seconds.'); diff --git a/app/Services/Runners/BaseRunner.php b/app/Services/Runners/BaseRunner.php index 76eca7140..8ccbff473 100644 --- a/app/Services/Runners/BaseRunner.php +++ b/app/Services/Runners/BaseRunner.php @@ -2,6 +2,7 @@ namespace App\Services\Runners; +use Illuminate\Support\Facades\Log; use Symfony\Component\Process\Process; abstract class BaseRunner @@ -110,7 +111,7 @@ abstract class BaseRunner default: // Log unrecognized command and return empty string if (config('app.debug')) { - \Log::warning('Unrecognized multiprocessing command: '.$args); + Log::warning('Unrecognized multiprocessing command: '.$args); } return ''; @@ -196,7 +197,7 @@ abstract class BaseRunner try { $results[$key] = $callable(); } catch (\Throwable $e) { - \Log::error("Task {$key} failed: ".$e->getMessage()); + Log::error("Task {$key} failed: ".$e->getMessage()); $results[$key] = ''; } } @@ -226,7 +227,7 @@ abstract class BaseRunner try { $results[$key] = $callable(); } catch (\Throwable $e) { - \Log::error("Task {$key} failed: ".$e->getMessage()); + Log::error("Task {$key} failed: ".$e->getMessage()); $results[$key] = ''; } } diff --git a/app/Services/TurnstileService.php b/app/Services/TurnstileService.php index 0d28c8db9..2edc7cd94 100644 --- a/app/Services/TurnstileService.php +++ b/app/Services/TurnstileService.php @@ -3,6 +3,7 @@ namespace App\Services; use Illuminate\Support\Facades\Http; +use Illuminate\Support\Facades\Log; class TurnstileService { @@ -28,7 +29,7 @@ class TurnstileService return isset($result['success']) && $result['success'] === true; } catch (\Exception $e) { - \Log::error('Turnstile verification failed: '.$e->getMessage()); + Log::error('Turnstile verification failed: '.$e->getMessage()); return false; } diff --git a/app/Support/CaptchaHelper.php b/app/Support/CaptchaHelper.php index 97779d4c8..39bc1fb30 100644 --- a/app/Support/CaptchaHelper.php +++ b/app/Support/CaptchaHelper.php @@ -3,6 +3,7 @@ namespace App\Support; use App\Services\TurnstileService; +use Illuminate\Support\Facades\Log; class CaptchaHelper { @@ -24,7 +25,7 @@ class CaptchaHelper // If both are configured as enabled, log a warning and use the configured provider if ($recaptchaEnabled && $turnstileEnabled) { - \Log::warning('Both reCAPTCHA and Turnstile are enabled. Only one can be active at a time. Using provider: '.$provider); + Log::warning('Both reCAPTCHA and Turnstile are enabled. Only one can be active at a time. Using provider: '.$provider); } if ($provider === 'turnstile') { diff --git a/app/Support/UpdatePerformanceHelper.php b/app/Support/UpdatePerformanceHelper.php index 6b5bd3337..76e71b31f 100644 --- a/app/Support/UpdatePerformanceHelper.php +++ b/app/Support/UpdatePerformanceHelper.php @@ -2,6 +2,7 @@ namespace App\Support; +use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\Process; @@ -63,10 +64,10 @@ class UpdatePerformanceHelper public static function clearAllCaches(): array { $cacheOperations = [ - 'config' => fn () => \Artisan::call('config:clear'), - 'route' => fn () => \Artisan::call('route:clear'), - 'view' => fn () => \Artisan::call('view:clear'), - 'cache' => fn () => \Artisan::call('cache:clear'), + 'config' => fn () => Artisan::call('config:clear'), + 'route' => fn () => Artisan::call('route:clear'), + 'view' => fn () => Artisan::call('view:clear'), + 'cache' => fn () => Artisan::call('cache:clear'), 'opcache' => fn () => function_exists('opcache_reset') ? opcache_reset() : true, ]; diff --git a/config/app.php b/config/app.php index b56ff81cf..d243364fe 100644 --- a/config/app.php +++ b/config/app.php @@ -21,9 +21,11 @@ return [ 'timezone' => env('APP_TIMEZONE', 'UTC'), 'aliases' => Facade::defaultAliases()->merge([ + 'Elasticsearch' => App\Facades\Elasticsearch::class, + 'Google2FA' => PragmaRX\Google2FALaravel\Facade::class, + 'Gravatar' => Creativeorange\Gravatar\Facades\Gravatar::class, 'RedisManager' => Illuminate\Support\Facades\Redis::class, 'UserVerification' => Jrean\UserVerification\Facades\UserVerification::class, - 'Gravatar' => Creativeorange\Gravatar\Facades\Gravatar::class, 'Yenc' => App\Facades\Yenc::class, ])->toArray(),