diff --git a/CHANGELOG.md b/CHANGELOG.md index 8018180a8..5dc1d3c7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - Fixed issues with searching by username [\#1722](https://github.com/torrentpier/torrentpier/pull/1722) ([belomaxorka](https://github.com/belomaxorka)) - Fixed searching by username in `memberlist.php` [\#1721](https://github.com/torrentpier/torrentpier/pull/1721) ([belomaxorka](https://github.com/belomaxorka)) - Set `cursor: pointer;` for buttons, inputs (buttons) [\#1710](https://github.com/torrentpier/torrentpier/pull/1710), [\#1711](https://github.com/torrentpier/torrentpier/pull/1711) ([belomaxorka](https://github.com/belomaxorka)) +- Some updater improvements [\#1725](https://github.com/torrentpier/torrentpier/pull/1725) ([belomaxorka](https://github.com/belomaxorka)) - Minor improvements [\#1705](https://github.com/torrentpier/torrentpier/pull/1705), [\#1713](https://github.com/torrentpier/torrentpier/pull/1713), [\#1715](https://github.com/torrentpier/torrentpier/pull/1715), [\#1717](https://github.com/torrentpier/torrentpier/pull/1717), [\#1719](https://github.com/torrentpier/torrentpier/pull/1719), [\#1720](https://github.com/torrentpier/torrentpier/pull/1720) ([belomaxorka](https://github.com/belomaxorka)) - Updated deps [\#1723](https://github.com/torrentpier/torrentpier/pull/1723) ([belomaxorka](https://github.com/belomaxorka)) - New Crowdin updates [\#1704](https://github.com/torrentpier/torrentpier/pull/1704), [\#1706](https://github.com/torrentpier/torrentpier/pull/1706), [\#1714](https://github.com/torrentpier/torrentpier/pull/1714), [\#1716](https://github.com/torrentpier/torrentpier/pull/1716) ([Exileum](https://github.com/Exileum)) diff --git a/library/config.php b/library/config.php index 319586bc8..6ba66bd5c 100644 --- a/library/config.php +++ b/library/config.php @@ -112,6 +112,12 @@ $bb_cfg['client_ban'] = [ ] ]; +// TorrentPier updater settings +$bb_cfg['tp_updater_settings'] = [ + 'enabled' => true, + 'allow_pre_releases' => false +]; + // TorrServer integration $bb_cfg['torr_server'] = [ // Read more: https://github.com/YouROK/TorrServer @@ -584,7 +590,7 @@ $bb_cfg['flist_max_files'] = 0; // Max allowed number of files to process for gi $bb_cfg['last_visit_date_format'] = 'd-M H:i'; $bb_cfg['last_post_date_format'] = 'd-M-y H:i'; $bb_cfg['poll_max_days'] = 180; // How many days will the poll be active -$bb_cfg['integrity_check'] = true; // TorrentPier files integrity check (Not recommended to disable!) +$bb_cfg['integrity_check'] = true; // TorrentPier files integrity check $bb_cfg['allow_change'] = [ 'language' => true, // Allow user to change language @@ -604,7 +610,7 @@ $bb_cfg['advert_url'] = 'info.php?show=advert'; $bb_cfg['sitemap_sending'] = [ // A list of URLs to which to send a sitemap for indexing by a search robot. // Syntax: 'Resource name' => 'link to endpoint' - 'Google' => 'https://google.com/webmasters/sitemaps/ping?sitemap=', + // Sitemap sending is deprecated. See: https://developers.google.com/search/blog/2023/06/sitemaps-lastmod-ping ]; // Extensions diff --git a/library/includes/datastore/build_check_updates.php b/library/includes/datastore/build_check_updates.php index 1f7b11e00..070ef3466 100644 --- a/library/includes/datastore/build_check_updates.php +++ b/library/includes/datastore/build_check_updates.php @@ -13,10 +13,14 @@ if (!defined('BB_ROOT')) { global $bb_cfg; +if (!$bb_cfg['tp_updater_settings']['enabled']) { + return; +} + $data = []; $updaterDownloader = new \TorrentPier\Updater(); -$updaterDownloader = $updaterDownloader->getLastVersion(); +$updaterDownloader = $updaterDownloader->getLastVersion($bb_cfg['tp_updater_settings']['allow_pre_releases']); $getVersion = $updaterDownloader['tag_name']; $versionCodeActual = version_code($getVersion); diff --git a/library/includes/init_bb.php b/library/includes/init_bb.php index 5472c388d..6714e2892 100644 --- a/library/includes/init_bb.php +++ b/library/includes/init_bb.php @@ -394,6 +394,11 @@ $user = new TorrentPier\Legacy\Common\User(); $userdata =& $user->data; +/** + * Some shared defines + */ +define('TP_INSTANCE_HASH', $bb_cfg['tp_instance_hash']); + /** * Cron */ diff --git a/src/Updater.php b/src/Updater.php index c31623113..6eb4ab722 100644 --- a/src/Updater.php +++ b/src/Updater.php @@ -45,7 +45,7 @@ class Updater */ private const STREAM_CONTEXT = [ 'http' => [ - 'header' => 'User-Agent: ' . APP_NAME, + 'header' => 'User-Agent: ' . APP_NAME . '-' . TP_INSTANCE_HASH, 'timeout' => 10, 'ignore_errors' => true ] @@ -132,10 +132,21 @@ class Updater /** * Returns information of latest TorrentPier version * + * @param bool $allowRC * @return array */ - public function getLastVersion(): array + public function getLastVersion(bool $allowRC = true): array { + if (!$allowRC) { + foreach ($this->jsonResponse as $index) { + if (isset($index['prerelease']) && $index['prerelease']) { + continue; + } + + return $index; + } + } + return $this->jsonResponse[0]; } } diff --git a/styles/templates/admin/index.tpl b/styles/templates/admin/index.tpl index e3ae677be..0b6155561 100644 --- a/styles/templates/admin/index.tpl +++ b/styles/templates/admin/index.tpl @@ -183,7 +183,7 @@