Minor improvements (#1452)

* Minor improvements

* Updated

* Create updater.php

* Revert "Create updater.php"

This reverts commit be2f3d5006.

* Revert "Updated"

This reverts commit 6aae9339cd.

* Updated

* Update board_maintenance.php

* Updated

* Updated

* Update build_check_updates.php

* Updated

* Update board_maintenance.php

* Update functions.php

* Updated

* Update defines.php

* Updated

* Updated

* Updater

* Updated

* Update .gitignore

* Update

* Update updater.php

* Updated

* Update tracker.php

* Update .htaccess

* Update tracker.php

* Update tracker.tpl

* Update CHANGELOG.md
This commit is contained in:
Roman Kelesidis 2024-04-24 15:01:37 +07:00 committed by GitHub
commit 24dbd25d9b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 110 additions and 39 deletions

View file

@ -0,0 +1,45 @@
<?php
/**
* TorrentPier Bull-powered BitTorrent tracker engine
*
* @copyright Copyright (c) 2005-2024 TorrentPier (https://torrentpier.com)
* @link https://github.com/torrentpier/torrentpier for the canonical source repository
* @license https://github.com/torrentpier/torrentpier/blob/master/LICENSE MIT License
*/
if (!defined('BB_ROOT')) {
die(basename(__FILE__));
}
global $bb_cfg;
$data = [];
$context = stream_context_create(['http' => ['header' => 'User-Agent: TorrentPier Updater. With love!']]);
$updater_content = file_get_contents(UPDATER_URL, context: $context);
$json_response = false;
if ($updater_content !== false) {
$json_response = json_decode(utf8_encode($updater_content), true);
}
if (is_array($json_response) && !empty($json_response)) {
$get_version = $json_response['tag_name'];
$version_code_actual = (int)trim(str_replace(['.', 'v', ','], '', $get_version));
$has_update = VERSION_CODE < $version_code_actual;
// Save current version & latest available
if ($has_update) {
file_write(VERSION_CODE . "\n" . $version_code_actual, UPDATER_FILE, replace_content: true);
}
// Build data array
$data = [
'available_update' => $has_update,
'latest_version' => $get_version,
'latest_version_size' => isset($json_response['assets'][0]['size']) ? humn_size($json_response['assets'][0]['size']) : false,
'latest_version_link' => $json_response['assets'][0]['browser_download_url'] ?? $json_response['html_url']
];
}
$this->store('check_updates', $data);