From 11f5b50760e4de8e43f9a6600dac65c90699dc34 Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Tue, 31 Dec 2024 12:16:59 +0700 Subject: [PATCH] Added `TorrentPier instance hash` generation (#1726) * Added `TorrentPier instance hash` generation * Update CHANGELOG.md --- CHANGELOG.md | 1 + install.php | 2 +- install/sql/mysql.sql | 3 ++- install/upgrade/legacy-changes.txt | 3 ++- library/includes/cron/jobs/board_maintenance.php | 5 +++++ 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27794a530..8018180a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ **Merged pull requests:** - Release 2.4.5 🍧️ ([belomaxorka](https://github.com/belomaxorka)) +- Added `TorrentPier instance hash` generation [\#1726](https://github.com/torrentpier/torrentpier/pull/1726) ([belomaxorka](https://github.com/belomaxorka)) - Added `m4a` extension support in M3U playback [\#1724](https://github.com/torrentpier/torrentpier/pull/1724) ([belomaxorka](https://github.com/belomaxorka)) - Show torrent's announcers list in `filelist.php` page [\#1708](https://github.com/torrentpier/torrentpier/pull/1708) ([belomaxorka](https://github.com/belomaxorka)) - [PHP 8.4] Fixed some deprecations [\#1718](https://github.com/torrentpier/torrentpier/pull/1718) ([belomaxorka](https://github.com/belomaxorka)) diff --git a/install.php b/install.php index 60160c8ac..9676d7688 100644 --- a/install.php +++ b/install.php @@ -388,5 +388,5 @@ if (!empty($DB_HOST) && !empty($DB_DATABASE) && !empty($DB_USERNAME)) { $conn->close(); out("- Importing SQL dump completed!\n", 'success'); out("- Voila! Good luck & have fun!", 'success'); - rename(__FILE__, __FILE__ . '_' . hash('md5', time())); + rename(__FILE__, __FILE__ . '_' . hash('xxh128', time())); } diff --git a/install/sql/mysql.sql b/install/sql/mysql.sql index 5231b54d1..71d05fb14 100644 --- a/install/sql/mysql.sql +++ b/install/sql/mysql.sql @@ -600,7 +600,8 @@ VALUES ('allow_autologin', '1'), ('premod', '0'), ('tor_comment', '1'), ('terms', ''), - ('show_board_start_index', '1'); + ('show_board_start_index', '1'), + ('tp_instance_hash', ''); -- ---------------------------- -- Table structure for `bb_cron` diff --git a/install/upgrade/legacy-changes.txt b/install/upgrade/legacy-changes.txt index 05cdb974b..8f3b17d22 100644 --- a/install/upgrade/legacy-changes.txt +++ b/install/upgrade/legacy-changes.txt @@ -150,4 +150,5 @@ INSERT INTO `bb_extensions` (`group_id`, `extension`, `comment`) VALUES ('1', 'a ALTER TABLE `bb_topics` ADD COLUMN `topic_allow_robots` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0'; // 2.4.5 -INSERT INTO bb_config VALUES ('magnet_links_for_guests', '0'); +INSERT INTO `bb_config` VALUES ('magnet_links_for_guests', '0'); +INSERT INTO `bb_config` VALUES ('tp_instance_hash', ''); diff --git a/library/includes/cron/jobs/board_maintenance.php b/library/includes/cron/jobs/board_maintenance.php index e83ceac3d..8e898cf33 100644 --- a/library/includes/cron/jobs/board_maintenance.php +++ b/library/includes/cron/jobs/board_maintenance.php @@ -59,6 +59,11 @@ if (IN_DEMO_MODE) { DB()->query("UPDATE " . BB_FORUMS . " SET allow_reg_tracker = 1 WHERE allow_reg_tracker = 0"); } +// Create unique TorrentPier instance hash +if (empty($bb_cfg['tp_instance_hash']) || ($bb_cfg['tp_instance_hash'] !== hash('xxh128', FULL_URL))) { + bb_update_config(['tp_instance_hash' => hash('xxh128', FULL_URL)]); +} + // Check for updates $datastore->update('check_updates');