Added TorrentPier files integrity check 📦 (#1491)

* Added file integrity check 📦

* Update CHANGELOG.md

* Update CHANGELOG.md

* Updated

* Update Common.php

* Updated

* Update board_maintenance.php

* Update index.tpl

* Updated

* Updated

* Update build_check_updates.php

* Update build_check_updates.php

* Update build_check_updates.php

* Update build_check_updates.php

* Update build_check_updates.php

* Update index.php

* Updated

* Update build_check_updates.php

* Update build_files_integrity.php

* Update build_files_integrity.php

* Update build_files_integrity.php

* Create checksums.md5

* Update build_files_integrity.php

* Update build_files_integrity.php

* Updated

* Update checksums.md5

* Update defines.php

* Update build_files_integrity.php

* Updated

* Update main.php

* Update main.php

* Update main.php

* Update index.tpl

* Update index.tpl

* Update index.php

* Update build_check_updates.php

* Update build_check_updates.php

* Update checksums.md5

* Update build_files_integrity.php

* Update checksums.md5
This commit is contained in:
Roman Kelesidis 2024-06-08 00:32:10 +07:00 committed by GitHub
commit 437c2e5d8d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 2614 additions and 4 deletions

View file

@ -15,7 +15,7 @@ global $bb_cfg;
$data = [];
$context = stream_context_create(['http' => ['header' => 'User-Agent: ' . APP_NAME]]);
$context = stream_context_create(['http' => ['header' => 'User-Agent: ' . APP_NAME, 'timeout' => 10, 'ignore_errors' => true]]);
$updater_content = file_get_contents(UPDATER_URL, context: $context);
$json_response = false;
@ -23,7 +23,7 @@ if ($updater_content !== false) {
$json_response = json_decode(utf8_encode($updater_content), true);
}
if (is_array($json_response) && !empty($json_response)) {
if ((is_array($json_response) && !empty($json_response)) && !isset($json_response['message'])) {
$get_version = $json_response['tag_name'];
$version_code_actual = (int)trim(str_replace(['.', 'v'], '', $get_version));
@ -52,4 +52,5 @@ if (is_array($json_response) && !empty($json_response)) {
}
}
$data[] = ['latest_check_timestamp' => TIMENOW];
$this->store('check_updates', $data);

View file

@ -0,0 +1,54 @@
<?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 = [];
$filesList = [];
$checksumFile = new SplFileObject(CHECKSUMS_FILE, 'r');
$checksumFile->setFlags(SplFileObject::SKIP_EMPTY | SplFileObject::DROP_NEW_LINE);
$lines = [];
foreach ($checksumFile as $line) {
$parts = explode(' ', $line);
if (!isset($parts[1])) {
// Skip end line
break;
}
if (basename($parts[1]) === basename(CHECKSUMS_FILE)) {
// Skip checksums.md5
continue;
}
$filesList[] = [
'path' => trim($parts[1]),
'hash' => trim($parts[0])
];
}
$wrongFilesList = [];
foreach ($filesList as $file) {
if (strtolower(md5_file(BB_ROOT . '/' . $file['path'])) !== strtolower($file['hash'])) {
$wrongFilesList[] = $file['path'];
}
}
$data = [
'success' => empty($wrongFilesList),
'wrong_files' => $wrongFilesList,
'wrong_files_num' => count($wrongFilesList),
'total_num' => count($filesList),
'timestamp' => TIMENOW,
];
$this->store('files_integrity', $data);