torrentpier/library/includes/datastore/build_check_updates.php
Roman Kelesidis 126c75cd57
Minor improvements (#1536)
* Minor improvements

* Update viewtopic_attach.tpl

* Update viewtopic_attach.tpl

* Update viewforum.tpl

* Update viewforum.tpl

* Update viewtopic.tpl

* Update viewtopic.tpl

* Update CHANGELOG.md

* Updated

* Update defines.php
2024-07-12 23:05:14 +07:00

53 lines
1.7 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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 = [];
$updaterDownloader = new \TorrentPier\Updater();
$updaterDownloader = $updaterDownloader->getLastVersion();
$getVersion = $updaterDownloader['tag_name'];
$versionCodeActual = (int)trim(str_replace(['.', 'v'], '', $getVersion));
// Has update!
if (VERSION_CODE < $versionCodeActual) {
$latestBuildFileLink = $updaterDownloader['assets'][0]['browser_download_url'];
// Save current version & latest available
file_write(json_encode([
'previous_version' => VERSION_CODE,
'latest_version' => $versionCodeActual
]), UPDATER_FILE, replace_content: true);
// Get MD5 checksum
$buildFileChecksum = '';
if (isset($latestBuildFileLink)) {
$buildFileChecksum = strtoupper(md5_file($latestBuildFileLink));
}
// Build data array
$data = [
'available_update' => true,
'latest_version' => $getVersion,
'latest_version_size' => isset($updaterDownloader['assets'][0]['size']) ? humn_size($updaterDownloader['assets'][0]['size']) : false,
'latest_version_dl_link' => $latestBuildFileLink ?? $updaterDownloader['html_url'],
'latest_version_checksum' => $buildFileChecksum,
'latest_version_link' => $updaterDownloader['html_url']
];
}
$data[] = ['latest_check_timestamp' => TIMENOW];
$this->store('check_updates', $data);