From c91cf060b1e00b329012fcd6bfa184a246dc79fa Mon Sep 17 00:00:00 2001 From: xiaomlove <1939737565@qq.com> Date: Wed, 7 Jan 2026 16:00:14 +0700 Subject: [PATCH 1/5] delete torrent extra when delete torrent --- include/functions.php | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/include/functions.php b/include/functions.php index 948c2cb3..fa52b0cb 100644 --- a/include/functions.php +++ b/include/functions.php @@ -3138,6 +3138,7 @@ function deletetorrent($id, $notify = false) { $idStr = implode(', ', $idArr ?: [0]); $torrent_dir = get_setting('main.torrent_dir'); \Nexus\Database\NexusDB::statement("DELETE FROM torrents WHERE id in ($idStr)"); + \Nexus\Database\NexusDB::statement("DELETE FROM torrent_extras WHERE torrent_id in ($idStr)"); //delete by torrent, make sure user is deleted \Nexus\Database\NexusDB::statement("DELETE FROM snatched WHERE torrentid in ($idStr) and not exists (select 1 from users where id = snatched.userid)"); foreach(array("peers", "files", "comments") as $x) { @@ -3157,13 +3158,11 @@ function deletetorrent($id, $notify = false) { 'action_type' => \App\Models\TorrentOperationLog::ACTION_TYPE_DELETE, 'comment' => '', ], $notify); + do_action("torrent_delete", $_id); + fire_event("torrent_deleted", $torrentInfo->get($_id)); } $meiliSearchRep = new \App\Repositories\MeiliSearchRepository(); $meiliSearchRep->deleteDocuments($idArr); - if (is_int($id)) { - do_action("torrent_delete", $id); - fire_event("torrent_deleted", $torrentInfo->get($id)); - } } function pager($rpp, $count, $href, $opts = array(), $pagename = "page") { @@ -6550,4 +6549,18 @@ function hide_text($text) { return '' . $text . ''; } +function bbcode_attach_to_img(string $text) { + $pattern = "/\[attach\]([0-9a-zA-z][0-9a-zA-z]*)\[\/attach\]/is"; + preg_match_all($pattern, $text, $matches); + if (empty($matches)) { + return $text; + } + $attachments = \App\Models\Attachment::query()->whereIn("dlkey", $matches[1])->get(); + if ($attachments->isEmpty()) { + return $text; + } + $httpdirectory_attachment = get_setting('attachment.httpdirectory'); + +} + ?> From 74940410055f9f54a2310fc325b38a5e7440da0a Mon Sep 17 00:00:00 2001 From: xiaomlove <1939737565@qq.com> Date: Thu, 15 Jan 2026 23:24:28 +0700 Subject: [PATCH 2/5] fix get_ip_location_from_geoip() missing continent_en --- include/functions.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/functions.php b/include/functions.php index fa52b0cb..667c4ebf 100644 --- a/include/functions.php +++ b/include/functions.php @@ -5885,6 +5885,7 @@ function get_ip_location_from_geoip($ip): bool|array 'city' => '', 'country_en' => '', 'city_en' => '', + 'continent_en' => '', ]; try { $database = nexus_env('GEOIP2_DATABASE'); @@ -5913,7 +5914,7 @@ function get_ip_location_from_geoip($ip): bool|array $info['continent'] = $continentName; $info['continent_en'] = $record->continent->names['en'] ?? ''; } catch (\Exception $exception) { - do_log($exception->getMessage()); + do_log($exception->getMessage() . ", trace: " . $exception->getTraceAsString(), 'error'); } return $info; }); From 3ced82fc0a4adfa3d204efb80eae7ca960505a5b Mon Sep 17 00:00:00 2001 From: xiaomlove <1939737565@qq.com> Date: Fri, 23 Jan 2026 13:01:16 +0700 Subject: [PATCH 3/5] bbcode_attach_to_img --- app/Http/Resources/CommentResource.php | 2 +- config/sanctum.php | 2 +- include/functions.php | 36 +++++++++++++++++++------- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/app/Http/Resources/CommentResource.php b/app/Http/Resources/CommentResource.php index b29e5886..9d02e0b7 100644 --- a/app/Http/Resources/CommentResource.php +++ b/app/Http/Resources/CommentResource.php @@ -17,7 +17,7 @@ class CommentResource extends JsonResource { return [ 'id' => $this->id, - 'text' => $this->text, + 'text' => bbcode_attach_to_img($this->text), 'updated_at' => format_datetime($this->editdate), 'created_at' => format_datetime($this->added), 'create_user' => new UserResource($this->whenLoaded('create_user')), diff --git a/config/sanctum.php b/config/sanctum.php index 0fff0453..82eaa2b1 100644 --- a/config/sanctum.php +++ b/config/sanctum.php @@ -29,7 +29,7 @@ return [ | */ - 'expiration' => 129600, + 'expiration' => 5256000, /* |-------------------------------------------------------------------------- diff --git a/include/functions.php b/include/functions.php index 667c4ebf..6bc03326 100644 --- a/include/functions.php +++ b/include/functions.php @@ -6552,16 +6552,32 @@ function hide_text($text) { function bbcode_attach_to_img(string $text) { $pattern = "/\[attach\]([0-9a-zA-z][0-9a-zA-z]*)\[\/attach\]/is"; - preg_match_all($pattern, $text, $matches); - if (empty($matches)) { - return $text; - } - $attachments = \App\Models\Attachment::query()->whereIn("dlkey", $matches[1])->get(); - if ($attachments->isEmpty()) { - return $text; - } - $httpdirectory_attachment = get_setting('attachment.httpdirectory'); - + return preg_replace_callback($pattern, function ($matches) { + $dlkey = $matches[1]; + $httpdirectory_attachment = get_setting('attachment.httpdirectory'); + $row = \Nexus\Database\NexusDB::remember('attachment_'.$dlkey.'_content', 86400, function() use ($dlkey) { + $record = \App\Models\Attachment::query()->where("dlkey", $dlkey)->first(); + if ($record) { + return $record->toArray(); + } + return []; + }); + if (empty($row) || $row['isimage'] != 1) { + do_log(sprintf("dlkey: %s get attachment %s not exists or not image", $dlkey, json_encode($row))); + return $matches[0]; + } + $driver = $row['driver'] ?? 'local'; + if ($driver == "local") { + if ($row['thumb'] == 1){ + $url = $httpdirectory_attachment."/".$row['location'].".thumb.jpg"; + } else { + $url = $httpdirectory_attachment."/".$row['location']; + } + } else { + $url = \Nexus\Attachment\Storage::getDriver($driver)->getImageUrl($row['location']); + } + return "[img]" . $url . "[/img]"; + }, $text, 20); } ?> From 5e163da05e3655538816abbfc8f308189bf65e66 Mon Sep 17 00:00:00 2001 From: xiaomlove <1939737565@qq.com> Date: Fri, 23 Jan 2026 13:10:24 +0700 Subject: [PATCH 4/5] fix bbcode_attach_to_img driver local --- include/functions.php | 1 + 1 file changed, 1 insertion(+) diff --git a/include/functions.php b/include/functions.php index 6bc03326..976d8b84 100644 --- a/include/functions.php +++ b/include/functions.php @@ -6573,6 +6573,7 @@ function bbcode_attach_to_img(string $text) { } else { $url = $httpdirectory_attachment."/".$row['location']; } + $url = sprintf("%s/%s", getSchemeAndHttpHost(true), trim($url, "/")); } else { $url = \Nexus\Attachment\Storage::getDriver($driver)->getImageUrl($row['location']); } From dd8df70f7e70bb59a36062e3b4b14bb6f9eb4f19 Mon Sep 17 00:00:00 2001 From: xiaomlove <1939737565@qq.com> Date: Fri, 23 Jan 2026 15:38:56 +0700 Subject: [PATCH 5/5] update version to 1.9.14 --- app/Repositories/CommentRepository.php | 2 +- include/constants.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Repositories/CommentRepository.php b/app/Repositories/CommentRepository.php index b81195a1..d1fb81bb 100644 --- a/app/Repositories/CommentRepository.php +++ b/app/Repositories/CommentRepository.php @@ -28,7 +28,7 @@ class CommentRepository extends BaseRepository if (!empty($request->request_id)) { $query->where('request', $request->request_id); } - $query->orderBy('id', 'desc'); + $query->orderBy('id', 'asc'); return $query->paginate($this->getPerPageFromRequest($request)); } diff --git a/include/constants.php b/include/constants.php index 9649eb04..8c816dcd 100644 --- a/include/constants.php +++ b/include/constants.php @@ -1,6 +1,6 @@