Some improvements for integrity checker (#1501)

* Some improvements for integrity checker

* Update build_files_integrity.php

* Updated
This commit is contained in:
Roman Kelesidis 2024-06-09 17:09:21 +07:00 committed by GitHub
commit 6a10adabf5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 33 additions and 26 deletions

View file

@ -1,5 +1,13 @@
# 📖 Change Log # 📖 Change Log
## [v2.4.4](https://github.com/torrentpier/torrentpier/tree/v2.4.4) (2024-XX-XX)
[Full Changelog](https://github.com/torrentpier/torrentpier/compare/v2.4.3...v2.4.4)
**Merged pull requests:**
- Release 2.4.4 🦩 ([belomaxorka](https://github.com/belomaxorka))
- Some improvements for integrity checker [\#1501](https://github.com/torrentpier/torrentpier/pull/1501) ([belomaxorka](https://github.com/belomaxorka))
## [v2.4.3](https://github.com/torrentpier/torrentpier/tree/v2.4.3) (2024-06-09) ## [v2.4.3](https://github.com/torrentpier/torrentpier/tree/v2.4.3) (2024-06-09)
[Full Changelog](https://github.com/torrentpier/torrentpier/compare/v2.4.2...v2.4.3) [Full Changelog](https://github.com/torrentpier/torrentpier/compare/v2.4.2...v2.4.3)

View file

@ -22,7 +22,7 @@ $bb_cfg['js_ver'] = $bb_cfg['css_ver'] = 1;
// Version info // Version info
$bb_cfg['tp_version'] = 'v2.4.3'; $bb_cfg['tp_version'] = 'v2.4.3';
$bb_cfg['tp_release_date'] = '09-06-2024'; $bb_cfg['tp_release_date'] = 'XX-XX-2024';
$bb_cfg['tp_release_codename'] = 'Cattle'; $bb_cfg['tp_release_codename'] = 'Cattle';
// Database // Database

View file

@ -20,25 +20,7 @@ if (!$bb_cfg['integrity_check']) {
$checksumFile = new SplFileObject(CHECKSUMS_FILE, 'r'); $checksumFile = new SplFileObject(CHECKSUMS_FILE, 'r');
$checksumFile->setFlags(SplFileObject::SKIP_EMPTY | SplFileObject::DROP_NEW_LINE); $checksumFile->setFlags(SplFileObject::SKIP_EMPTY | SplFileObject::DROP_NEW_LINE);
$filesList = []; $ignoreFiles = [
$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])
];
}
$dynamicFiles = [
'.env.example', '.env.example',
'.htaccess', '.htaccess',
'robots.txt', 'robots.txt',
@ -47,19 +29,34 @@ $dynamicFiles = [
'favicon.png', 'favicon.png',
'composer.json', 'composer.json',
'composer.lock', 'composer.lock',
hide_bb_path(CHECKSUMS_FILE),
hide_bb_path(BB_ENABLED), hide_bb_path(BB_ENABLED),
'library/config.php', 'library/config.php',
'library/defines.php', 'library/defines.php',
'styles/images/logo/logo.png' 'styles/images/logo/logo.png'
]; ];
$wrongFilesList = []; $filesList = [];
foreach ($filesList as $file) { $lines = [];
if (!empty($dynamicFiles) && in_array($file['path'], $dynamicFiles)) { foreach ($checksumFile as $line) {
// Exclude dynamic files $parts = explode(' ', $line);
if (!isset($parts[0]) || !isset($parts[1])) {
// Skip end line
break;
}
if (!empty($ignoreFiles) && in_array($parts[1], $ignoreFiles)) {
// Skip files from "Ignoring list"
continue; continue;
} }
if (!file_exists(BB_ROOT . '/' . $file['path']) || strtolower(md5_file(BB_ROOT . '/' . $file['path'])) !== strtolower($file['hash'])) { $filesList[] = [
'path' => trim($parts[1]),
'hash' => trim($parts[0])
];
}
$wrongFilesList = [];
foreach ($filesList as $file) {
if (!file_exists(BB_ROOT . '/' . $file['path']) || (strtolower(md5_file(BB_ROOT . '/' . $file['path'])) !== strtolower($file['hash']))) {
$wrongFilesList[] = $file['path']; $wrongFilesList[] = $file['path'];
} }
} }
@ -83,8 +80,10 @@ if (is_file(RESTORE_CORRUPT_CONFIRM_FILE)) {
if (isset($buildDownloader->savePath)) { if (isset($buildDownloader->savePath)) {
unlink($buildDownloader->savePath); unlink($buildDownloader->savePath);
} }
if (is_file(RESTORE_CORRUPT_CONFIRM_FILE)) {
unlink(RESTORE_CORRUPT_CONFIRM_FILE); unlink(RESTORE_CORRUPT_CONFIRM_FILE);
} }
}
$data = [ $data = [
'success' => empty($wrongFilesList), 'success' => empty($wrongFilesList),