mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-14 18:48:21 -07:00
Some improvements for integrity checker (#1501)
* Some improvements for integrity checker * Update build_files_integrity.php * Updated
This commit is contained in:
parent
784e3aef1c
commit
6a10adabf5
3 changed files with 33 additions and 26 deletions
|
@ -20,25 +20,7 @@ if (!$bb_cfg['integrity_check']) {
|
|||
$checksumFile = new SplFileObject(CHECKSUMS_FILE, 'r');
|
||||
$checksumFile->setFlags(SplFileObject::SKIP_EMPTY | SplFileObject::DROP_NEW_LINE);
|
||||
|
||||
$filesList = [];
|
||||
$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 = [
|
||||
$ignoreFiles = [
|
||||
'.env.example',
|
||||
'.htaccess',
|
||||
'robots.txt',
|
||||
|
@ -47,19 +29,34 @@ $dynamicFiles = [
|
|||
'favicon.png',
|
||||
'composer.json',
|
||||
'composer.lock',
|
||||
hide_bb_path(CHECKSUMS_FILE),
|
||||
hide_bb_path(BB_ENABLED),
|
||||
'library/config.php',
|
||||
'library/defines.php',
|
||||
'styles/images/logo/logo.png'
|
||||
];
|
||||
|
||||
$wrongFilesList = [];
|
||||
foreach ($filesList as $file) {
|
||||
if (!empty($dynamicFiles) && in_array($file['path'], $dynamicFiles)) {
|
||||
// Exclude dynamic files
|
||||
$filesList = [];
|
||||
$lines = [];
|
||||
foreach ($checksumFile as $line) {
|
||||
$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;
|
||||
}
|
||||
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'];
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +80,9 @@ if (is_file(RESTORE_CORRUPT_CONFIRM_FILE)) {
|
|||
if (isset($buildDownloader->savePath)) {
|
||||
unlink($buildDownloader->savePath);
|
||||
}
|
||||
unlink(RESTORE_CORRUPT_CONFIRM_FILE);
|
||||
if (is_file(RESTORE_CORRUPT_CONFIRM_FILE)) {
|
||||
unlink(RESTORE_CORRUPT_CONFIRM_FILE);
|
||||
}
|
||||
}
|
||||
|
||||
$data = [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue