From 59b7a2916ea7ff6f450be2db2e736d7c0d4f4096 Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Mon, 6 Feb 2023 14:25:05 +0800 Subject: [PATCH] clear icon cache after modify --- .../Resources/Section/IconResource/Pages/CreateIcon.php | 5 +++++ .../Resources/Section/IconResource/Pages/EditIcon.php | 5 +++++ app/Http/Kernel.php | 2 +- app/Models/SecondIcon.php | 2 +- app/Repositories/AuthenticateRepository.php | 6 +++--- include/constants.php | 2 +- include/functions_announce.php | 2 +- include/globalfunctions.php | 9 +++++++++ nexus/Torrent/Torrent.php | 2 +- public/announce.php | 4 ++-- public/download.php | 5 ++++- public/takelogin.php | 4 ++-- 12 files changed, 35 insertions(+), 13 deletions(-) diff --git a/app/Filament/Resources/Section/IconResource/Pages/CreateIcon.php b/app/Filament/Resources/Section/IconResource/Pages/CreateIcon.php index 7c1b840c..e06407c5 100644 --- a/app/Filament/Resources/Section/IconResource/Pages/CreateIcon.php +++ b/app/Filament/Resources/Section/IconResource/Pages/CreateIcon.php @@ -18,4 +18,9 @@ class CreateIcon extends CreateRecord 'desc' => nexus_trans('label.icon.desc') ]; } + + public function afterCreate() + { + clear_icon_cache(); + } } diff --git a/app/Filament/Resources/Section/IconResource/Pages/EditIcon.php b/app/Filament/Resources/Section/IconResource/Pages/EditIcon.php index 236381cc..84998c4e 100644 --- a/app/Filament/Resources/Section/IconResource/Pages/EditIcon.php +++ b/app/Filament/Resources/Section/IconResource/Pages/EditIcon.php @@ -28,4 +28,9 @@ class EditIcon extends EditRecord 'desc' => nexus_trans('label.icon.desc') ]; } + + public function afterSave() + { + clear_icon_cache(); + } } diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 13fbdfa6..a76bfca9 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -43,7 +43,7 @@ class Kernel extends HttpKernel 'api' => [ 'throttle:api', \Illuminate\Routing\Middleware\SubstituteBindings::class, - \App\Http\Middleware\Platform::class, +// \App\Http\Middleware\Platform::class, ], 'filament' => [ \Illuminate\Session\Middleware\StartSession::class, diff --git a/app/Models/SecondIcon.php b/app/Models/SecondIcon.php index 2e3e0140..f437eef4 100644 --- a/app/Models/SecondIcon.php +++ b/app/Models/SecondIcon.php @@ -17,7 +17,7 @@ class SecondIcon extends NexusModel foreach (SearchBox::$taxonomies as $torrentField => $taxonomyTableModel) { $mode = $data['mode']; if ($mode === null || empty($data[$torrentField][$mode])) { - unset($data[$torrentField]); + $data[$torrentField] = 0; } else { $data[$torrentField] = $data[$torrentField][$mode]; } diff --git a/app/Repositories/AuthenticateRepository.php b/app/Repositories/AuthenticateRepository.php index 7669fb9a..ca1ff01c 100644 --- a/app/Repositories/AuthenticateRepository.php +++ b/app/Repositories/AuthenticateRepository.php @@ -17,9 +17,9 @@ class AuthenticateRepository extends BaseRepository if (!$user || md5($user->secret . $password . $user->secret) != $user->passhash) { throw new \InvalidArgumentException('Username or password invalid.'); } - if (nexus()->isPlatformAdmin() && !$user->canAccessAdmin()) { - throw new UnauthorizedException('Unauthorized!'); - } +// if (nexus()->isPlatformAdmin() && !$user->canAccessAdmin()) { +// throw new UnauthorizedException('Unauthorized!'); +// } $user->checkIsNormal(); $tokenName = __METHOD__ . __LINE__; $token = DB::transaction(function () use ($user, $tokenName) { diff --git a/include/constants.php b/include/constants.php index 553ba266..4206d85d 100644 --- a/include/constants.php +++ b/include/constants.php @@ -1,6 +1,6 @@ where('torrentid', $id)->count() == 0; -if ((($row['banned'] == 'yes' || ($approvalNotAllowed && !$allowOwnerDownload)) && !user_can('seebanned')) || !can_access_torrent($row)) { +$canSeedBanned = user_can('seebanned'); +$canAccessTorrent = can_access_torrent($row); +if ((($row['banned'] == 'yes' || ($approvalNotAllowed && !$allowOwnerDownload)) && !$canSeedBanned) || !$canAccessTorrent) { + do_log("[DENY_DOWNLOAD], user: {$CURUSER['id']}, approvalNotAllowed: $approvalNotAllowed, allowOwnerDownload: $allowOwnerDownload, canSeedBanned: $canSeedBanned, canAccessTorrent: $canAccessTorrent", 'error'); denyDownload(); } diff --git a/public/takelogin.php b/public/takelogin.php index ec7d1fde..a22beb47 100644 --- a/public/takelogin.php +++ b/public/takelogin.php @@ -41,8 +41,8 @@ $locationInfo = get_ip_location_from_geoip($ip); $thisLoginLog = \App\Models\LoginLog::query()->create([ 'ip' => $ip, 'uid' => $row['id'], - 'country' => $locationInfo['country_en'], - 'city' => $locationInfo['city_en'], + 'country' => $locationInfo['country_en'] ?? '', + 'city' => $locationInfo['city_en'] ?? '', 'client' => 'Web', ]); $lastLoginLog = \App\Models\LoginLog::query()->where('uid', $row['id'])->orderBy('id', 'desc')->first();