mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-14 18:48:21 -07:00
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:
parent
3db9095b78
commit
437c2e5d8d
12 changed files with 2614 additions and 4 deletions
|
@ -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);
|
||||
|
|
54
library/includes/datastore/build_files_integrity.php
Normal file
54
library/includes/datastore/build_files_integrity.php
Normal 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);
|
Loading…
Add table
Add a link
Reference in a new issue