From 60f7a81ef562509aeb446a283a65fe814442823d Mon Sep 17 00:00:00 2001 From: xiaomlove <1939737565@qq.com> Date: Fri, 31 Oct 2025 19:51:08 +0700 Subject: [PATCH 1/5] initTrackerUrl when fresh install --- nexus/Install/Install.php | 19 +++++++++++++++++++ nexus/Install/Update.php | 14 +------------- nexus/Install/install/install.php | 1 + 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/nexus/Install/Install.php b/nexus/Install/Install.php index 61836f40..b9fd5cbd 100644 --- a/nexus/Install/Install.php +++ b/nexus/Install/Install.php @@ -3,6 +3,7 @@ namespace Nexus\Install; use App\Models\Setting; +use App\Models\TrackerUrl; use App\Models\User; use App\Repositories\SearchBoxRepository; use App\Repositories\UserRepository; @@ -763,4 +764,22 @@ class Install $searchBoxRep->migrateToModeRelated(); } + public function initTrackerUrl(): void + { + $announceUrl = get_setting("security.https_announce_url"); + if (empty($announceUrl)) { + $announceUrl = get_setting("basic.announce_url"); + } + if (!str_starts_with($announceUrl, "http")) { + $announceUrl = (isHttps() ? "https://" : "http://"). $announceUrl; + } + TrackerUrl::query()->create([ + "url" => $announceUrl, + "enabled" => 1, + "is_default" => 1, + ]); + TrackerUrl::saveUrlCache(); + $this->doLog("[initTrackerUrl] $announceUrl success."); + } + } diff --git a/nexus/Install/Update.php b/nexus/Install/Update.php index d832a82d..bf833727 100644 --- a/nexus/Install/Update.php +++ b/nexus/Install/Update.php @@ -364,19 +364,7 @@ class Update extends Install } if (!Schema::hasTable("tracker_urls")) { $this->runMigrate("database/migrations/2025_06_19_194137_create_tracker_urls_table.php"); - $announceUrl = get_setting("security.https_announce_url"); - if (empty($announceUrl)) { - $announceUrl = get_setting("basic.announce_url"); - } - if (!str_starts_with($announceUrl, "http")) { - $announceUrl = (isHttps() ? "https://" : "http://"). $announceUrl; - } - TrackerUrl::query()->create([ - "url" => $announceUrl, - "enabled" => 1, - "is_default" => 1, - ]); - TrackerUrl::saveUrlCache(); + $this->initTrackerUrl(); NexusDB::cache_del("nexus_plugin_store_all"); } } diff --git a/nexus/Install/install/install.php b/nexus/Install/install/install.php index cfbd053d..e6771f91 100644 --- a/nexus/Install/install/install.php +++ b/nexus/Install/install/install.php @@ -112,6 +112,7 @@ if ($currentStep == 4) { $install->runDatabaseSeeder(); $install->saveSettings($settings); $install->migrateSearchBoxModeRelated(); + $install->initTrackerUrl(); $install->nextStep(); } catch (\Exception $e) { $error = $e->getMessage(); From 46845ce6d719e0479ff947a98b845e74bb2357ed Mon Sep 17 00:00:00 2001 From: xiaomlove <1939737565@qq.com> Date: Fri, 31 Oct 2025 20:07:07 +0700 Subject: [PATCH 2/5] improve initTrackerUrl() --- nexus/Install/Install.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/nexus/Install/Install.php b/nexus/Install/Install.php index b9fd5cbd..5a7a89d2 100644 --- a/nexus/Install/Install.php +++ b/nexus/Install/Install.php @@ -764,11 +764,25 @@ class Install $searchBoxRep->migrateToModeRelated(); } - public function initTrackerUrl(): void + /** + * 初始化,注意这里不能使用 get_tracker_schema_and_host()。里面会调用 TrackerUrl, 这本来就是要往里面插入数据 + * + * @param string $scene install or update + * @return void + */ + public function initTrackerUrl(string $scene): void { - $announceUrl = get_setting("security.https_announce_url"); + if ($scene == "update") { + $announceUrl = get_setting("security.https_announce_url"); + if (empty($announceUrl)) { + $announceUrl = get_setting("basic.announce_url"); + } + } if (empty($announceUrl)) { - $announceUrl = get_setting("basic.announce_url"); + $announceUrl = sprintf( + "%s/%s", + trim($_SERVER['HTTP_HOST'], '/'), trim(DEFAULT_TRACKER_URI, '/') + ); } if (!str_starts_with($announceUrl, "http")) { $announceUrl = (isHttps() ? "https://" : "http://"). $announceUrl; From 3924a542fbaaec83b9365aa4e4f169690a10a657 Mon Sep 17 00:00:00 2001 From: xiaomlove <1939737565@qq.com> Date: Fri, 31 Oct 2025 20:07:58 +0700 Subject: [PATCH 3/5] improve initTrackerUrl() 2 --- nexus/Install/Update.php | 2 +- nexus/Install/install/install.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nexus/Install/Update.php b/nexus/Install/Update.php index bf833727..f171e75c 100644 --- a/nexus/Install/Update.php +++ b/nexus/Install/Update.php @@ -364,7 +364,7 @@ class Update extends Install } if (!Schema::hasTable("tracker_urls")) { $this->runMigrate("database/migrations/2025_06_19_194137_create_tracker_urls_table.php"); - $this->initTrackerUrl(); + $this->initTrackerUrl('update'); NexusDB::cache_del("nexus_plugin_store_all"); } } diff --git a/nexus/Install/install/install.php b/nexus/Install/install/install.php index e6771f91..d311059e 100644 --- a/nexus/Install/install/install.php +++ b/nexus/Install/install/install.php @@ -112,7 +112,7 @@ if ($currentStep == 4) { $install->runDatabaseSeeder(); $install->saveSettings($settings); $install->migrateSearchBoxModeRelated(); - $install->initTrackerUrl(); + $install->initTrackerUrl('install'); $install->nextStep(); } catch (\Exception $e) { $error = $e->getMessage(); From ea644fa484192197ba89eda5f62d2602c57b9c38 Mon Sep 17 00:00:00 2001 From: xiaomlove <1939737565@qq.com> Date: Sun, 2 Nov 2025 19:48:50 +0700 Subject: [PATCH 4/5] formatUrl dont use filter_src --- include/functions.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/include/functions.php b/include/functions.php index 520f924a..b6330460 100644 --- a/include/functions.php +++ b/include/functions.php @@ -223,10 +223,6 @@ function formatAdUrl($adid, $url, $content, $newWindow=true) return formatUrl("adredir.php?id=".$adid."&url=".rawurlencode($url), $newWindow, $content); } function formatUrl($url, $newWindow = false, $text = '', $linkClass = '') { - $src = filter_src($url); - if (empty($src)) { - return ""; - } if (!$text) { $text = $url; } From bb50137e9aeac54a438c706abbad7ac59c92c819 Mon Sep 17 00:00:00 2001 From: xiaomlove <1939737565@qq.com> Date: Sun, 2 Nov 2025 21:59:16 +0700 Subject: [PATCH 5/5] version 1.9.11 --- include/constants.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/constants.php b/include/constants.php index 7216ad48..b8122a79 100644 --- a/include/constants.php +++ b/include/constants.php @@ -1,6 +1,6 @@