diff --git a/app/Filament/Resources/Section/IconResource.php b/app/Filament/Resources/Section/IconResource.php index 3caa067d..a904274c 100644 --- a/app/Filament/Resources/Section/IconResource.php +++ b/app/Filament/Resources/Section/IconResource.php @@ -72,12 +72,12 @@ class IconResource extends Resource return $table ->columns([ Tables\Columns\TextColumn::make('id'), - Tables\Columns\TextColumn::make('name'), - Tables\Columns\TextColumn::make('folder'), - Tables\Columns\TextColumn::make('cssfile'), - Tables\Columns\TextColumn::make('multilang'), - Tables\Columns\TextColumn::make('secondicon'), - Tables\Columns\TextColumn::make('designer'), + Tables\Columns\TextColumn::make('name')->label(__('label.name')), + Tables\Columns\TextColumn::make('folder')->label(__('label.icon.folder')), + Tables\Columns\TextColumn::make('multilang')->label(__('label.icon.multilang')), + Tables\Columns\TextColumn::make('secondicon')->label(__('label.icon.secondicon')), + Tables\Columns\TextColumn::make('cssfile')->label(__('label.icon.cssfile')), + Tables\Columns\TextColumn::make('designer')->label(__('label.icon.designer')), ]) ->filters([ // diff --git a/app/Filament/Resources/System/CategoryIconResource.php b/app/Filament/Resources/System/CategoryIconResource.php deleted file mode 100644 index e1ac46df..00000000 --- a/app/Filament/Resources/System/CategoryIconResource.php +++ /dev/null @@ -1,115 +0,0 @@ -schema([ - Forms\Components\TextInput::make('name')->label(__('label.name'))->required(), - Forms\Components\TextInput::make('folder') - ->label(__('label.icon.folder')) - ->helperText(__('label.icon.folder_help')) - ->required() - , - Forms\Components\Radio::make('multilang') - ->options(self::$yesOrNo) - ->default('no') - ->label(__('label.icon.multilang')) - ->helperText(__('label.icon.multilang_help')) - , - Forms\Components\Radio::make('secondicon') - ->options(self::$yesOrNo) - ->default('no') - ->label(__('label.icon.secondicon')) - ->helperText(__('label.icon.secondicon_help')) - , - Forms\Components\TextInput::make('cssfile') - ->label(__('label.icon.cssfile')) - ->helperText(__('label.icon.cssfile_help')) - , - Forms\Components\TextInput::make('designer') - ->label(__('label.icon.designer')) - ->helperText(__('label.icon.designer_help')) - , - Forms\Components\TextInput::make('comment') - ->label(__('label.icon.comment')) - ->helperText(__('label.icon.comment_help')) - , - ]); - } - - public static function table(Table $table): Table - { - return $table - ->columns([ - Tables\Columns\TextColumn::make('id'), - Tables\Columns\TextColumn::make('name')->label(__('label.name')), - Tables\Columns\TextColumn::make('folder')->label(__('label.icon.folder')), - Tables\Columns\TextColumn::make('multilang')->label(__('label.icon.multilang')), - Tables\Columns\TextColumn::make('secondicon')->label(__('label.icon.secondicon')), - Tables\Columns\TextColumn::make('cssfile')->label(__('label.icon.cssfile')), - Tables\Columns\TextColumn::make('designer')->label(__('label.icon.designer')), - Tables\Columns\TextColumn::make('comment')->label(__('label.icon.comment')), - ]) - ->filters([ - // - ]) - ->actions([ - Tables\Actions\EditAction::make(), - ]) - ->bulkActions([ - - ]); - } - - public static function getRelations(): array - { - return [ - // - ]; - } - - public static function getPages(): array - { - return [ - 'index' => Pages\ListCategoryIcons::route('/'), - 'create' => Pages\CreateCategoryIcon::route('/create'), - 'edit' => Pages\EditCategoryIcon::route('/{record}/edit'), - ]; - } -} diff --git a/app/Filament/Resources/System/CategoryIconResource/Pages/CreateCategoryIcon.php b/app/Filament/Resources/System/CategoryIconResource/Pages/CreateCategoryIcon.php deleted file mode 100644 index bc5e5098..00000000 --- a/app/Filament/Resources/System/CategoryIconResource/Pages/CreateCategoryIcon.php +++ /dev/null @@ -1,31 +0,0 @@ - nexus_trans('label.icon.desc') - ]; - } -} diff --git a/app/Filament/Resources/System/CategoryIconResource/Pages/EditCategoryIcon.php b/app/Filament/Resources/System/CategoryIconResource/Pages/EditCategoryIcon.php deleted file mode 100644 index bcace12a..00000000 --- a/app/Filament/Resources/System/CategoryIconResource/Pages/EditCategoryIcon.php +++ /dev/null @@ -1,38 +0,0 @@ - nexus_trans('label.icon.desc') - ]; - } -} diff --git a/app/Filament/Resources/System/CategoryIconResource/Pages/ListCategoryIcons.php b/app/Filament/Resources/System/CategoryIconResource/Pages/ListCategoryIcons.php deleted file mode 100644 index c834ef39..00000000 --- a/app/Filament/Resources/System/CategoryIconResource/Pages/ListCategoryIcons.php +++ /dev/null @@ -1,27 +0,0 @@ - nexus_trans('label.icon.desc') - ]; - } -} diff --git a/include/functions.php b/include/functions.php index 1608badd..0564e81e 100644 --- a/include/functions.php +++ b/include/functions.php @@ -4844,7 +4844,7 @@ function get_plain_username($id){ function get_searchbox_value($mode = 1, $item = 'showsubcat'){ global $Cache; static $rows; - $cacheKey = "search_box_content_{$mode}"; + $cacheKey = "search_box_content"; if (!$rows && !$rows = $Cache->get_value($cacheKey)){ $rows = array(); $res = sql_query("SELECT * FROM searchbox ORDER BY id ASC"); diff --git a/include/globalfunctions.php b/include/globalfunctions.php index 8ad83c8d..dd612a99 100644 --- a/include/globalfunctions.php +++ b/include/globalfunctions.php @@ -1002,10 +1002,10 @@ function clear_staff_message_cache() \App\Repositories\MessageRepository::updateStaffMessageCountCache(false); } -function clear_search_box_cache($id) +function clear_search_box_cache() { - do_log("clear_search_box_cache: $id"); - \Nexus\Database\NexusDB::cache_del("search_box_content_{$id}"); + do_log("clear_search_box_cache"); + \Nexus\Database\NexusDB::cache_del("search_box_content"); } function user_can($permission, $fail = false, $uid = 0): bool @@ -1061,3 +1061,29 @@ function is_donor(array $userInfo): bool { return $userInfo['donor'] == 'yes' && ($userInfo['donoruntil'] === null || $userInfo['donoruntil'] == '0000-00-00 00:00:00' || $userInfo['donoruntil'] >= date('Y-m-d H:i:s')); } + +/** + * @param $authkey + * @return false|int|mixed|string|null + * @throws \App\Exceptions\NexusException + * @see download.php + */ +function get_passkey_by_authkey($authkey) +{ + return \Nexus\Database\NexusDB::remember("authkey2passkey:$authkey", 3600*24, function () use ($authkey) { + $arr = explode('|', $authkey); + if (count($arr) != 3) { + throw new \InvalidArgumentException("Invalid authkey: $authkey, format error"); + } + $uid = $arr[1]; + $torrentRep = new \App\Repositories\TorrentRepository(); + $decrypted = $torrentRep->checkTrackerReportAuthKey($_REQUEST['authkey']); + if (empty($decrypted)) { + throw new \InvalidArgumentException("Invalid authkey: $authkey"); + } + $userInfo = \Nexus\Database\NexusDB::remember("announce_user_passkey_$uid", 3600, function () use ($uid) { + return \App\Models\User::query()->where('id', $uid)->first(['id', 'passkey']); + }); + return $userInfo->passkey; + }); +} diff --git a/public/announce.php b/public/announce.php index 19cee081..f21e88c9 100644 --- a/public/announce.php +++ b/public/announce.php @@ -1,50 +1,20 @@ checkTrackerReportAuthKey($_REQUEST['authkey']); + $_GET['passkey'] = get_passkey_by_authkey($_REQUEST['authkey']); } catch (\Exception $exception) { err($exception->getMessage()); } - if (empty($decrypted)) { - err('Invalid authkey'); - } - $userInfo = \Nexus\Database\NexusDB::remember("announce_user_passkey_$uid", 3600, function () use ($uid) { - return \App\Models\User::query()->where('id', $uid)->first(['id', 'passkey']); - }); - if (!$userInfo) { - err('Invalid authkey'); - } - $_GET['passkey'] = $userInfo->passkey; } - //2. GET ANNOUNCE VARIABLES // get string type passkey, info_hash, peer_id, event, ip from client foreach (array("passkey","info_hash","peer_id","event") as $x) @@ -168,8 +138,7 @@ if (!$torrent) { $start = strpos($queryString, $firstNeedle) + strlen($firstNeedle); $end = strpos($queryString, "&", $start); $infoHashUrlEncode = substr($queryString, $start, $end - $start); - do_log("[TORRENT NOT EXISTS] $checkTorrentSql, params: $queryString", 'error'); - do_log("[TORRENT NOT EXISTS] infoHashUrlEncode: $infoHashUrlEncode", 'error'); + do_log("[TORRENT NOT EXISTS] $checkTorrentSql, params: $queryString, infoHashUrlEncode: $infoHashUrlEncode"); err("torrent not registered with this tracker"); } diff --git a/public/download.php b/public/download.php index 79c68699..7aefe345 100644 --- a/public/download.php +++ b/public/download.php @@ -202,5 +202,6 @@ else //header ("Content-Disposition: attachment; filename=".$row["filename"].""); //ob_implicit_flush(true); //print(benc($dict)); +\Nexus\Database\NexusDB::cache_put("authkey2passkey:$trackerReportAuthKey", $CURUSER['passkey'], 3600*24); echo \Rhilip\Bencode\Bencode::encode($dict); ?>