mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 13:54:02 -07:00
removed: Integrity checker 🥺🪦 (#1827)
* removed: Integrity checker * Update schedule.yml
This commit is contained in:
parent
912b080b16
commit
ba3ce885c8
12 changed files with 1 additions and 2736 deletions
|
@ -75,6 +75,3 @@ if ($bb_cfg['indexnow_settings']['enabled'] && !is_file(BB_ROOT . $bb_cfg['index
|
|||
|
||||
// Check for updates
|
||||
$datastore->update('check_updates');
|
||||
|
||||
// Integrity check
|
||||
$datastore->update('files_integrity');
|
||||
|
|
|
@ -1,117 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* TorrentPier – Bull-powered BitTorrent tracker engine
|
||||
*
|
||||
* @copyright Copyright (c) 2005-2025 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;
|
||||
|
||||
if (!$bb_cfg['integrity_check'] || APP_ENV === 'local' || IN_DEMO_MODE) {
|
||||
return;
|
||||
}
|
||||
|
||||
$filesList = [];
|
||||
$wrongFilesList = [];
|
||||
|
||||
$checksumFile = new SplFileObject(CHECKSUMS_FILE, 'r+');
|
||||
$checksumFile->setFlags(SplFileObject::SKIP_EMPTY | SplFileObject::DROP_NEW_LINE);
|
||||
|
||||
$ignoreFiles = [
|
||||
'.git/*',
|
||||
'.github/*',
|
||||
'*.md',
|
||||
'*.yml',
|
||||
'*.toml',
|
||||
'*.json',
|
||||
'*.lock',
|
||||
'.env*',
|
||||
'vendor',
|
||||
'.gitignore',
|
||||
'.editorconfig',
|
||||
'.htaccess',
|
||||
'*/.htaccess',
|
||||
'robots.txt',
|
||||
// TorrentPier specific
|
||||
'*.md5',
|
||||
'install.php',
|
||||
'favicon.png',
|
||||
'internal_data/triggers/*',
|
||||
'library/config.php',
|
||||
'library/defines.php',
|
||||
'styles/images/logo/logo.png'
|
||||
];
|
||||
|
||||
foreach ($checksumFile as $line) {
|
||||
$parts = explode(' ', $line);
|
||||
if (!isset($parts[0]) || !isset($parts[1])) {
|
||||
// Skip end line
|
||||
break;
|
||||
}
|
||||
|
||||
// Skip files from "Ignoring list"
|
||||
if (!empty($ignoreFiles)) {
|
||||
$skip = false;
|
||||
foreach ($ignoreFiles as $pattern) {
|
||||
$pattern = trim($pattern);
|
||||
if (fnmatch($pattern, $parts[1])) {
|
||||
$skip = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($skip) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$filesList[] = [
|
||||
'path' => trim($parts[1]),
|
||||
'hash' => trim($parts[0])
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($filesList as $file) {
|
||||
if (!file_exists(BB_ROOT . $file['path']) || (strtolower(md5_file(BB_ROOT . $file['path'])) !== strtolower($file['hash']))) {
|
||||
$wrongFilesList[] = $file['path'];
|
||||
}
|
||||
}
|
||||
|
||||
// Restore corrupt files
|
||||
if (is_file(RESTORE_CORRUPT_CONFIRM_FILE)) {
|
||||
$buildDownloader = new \TorrentPier\Updater();
|
||||
if ($buildDownloader->download(INT_DATA_DIR . '/', $bb_cfg['tp_version'])) {
|
||||
// Unzip downloaded build file
|
||||
$zipArchive = new ZipArchive;
|
||||
$extractDownloadedFile = $zipArchive->open($buildDownloader->savePath);
|
||||
if ($extractDownloadedFile === true) {
|
||||
if ($zipArchive->extractTo(BB_ROOT, $wrongFilesList)) {
|
||||
$wrongFilesList = [];
|
||||
}
|
||||
$zipArchive->close();
|
||||
}
|
||||
}
|
||||
|
||||
// Delete restore confirm file & build file
|
||||
if (isset($buildDownloader->savePath)) {
|
||||
unlink($buildDownloader->savePath);
|
||||
}
|
||||
if (is_file(RESTORE_CORRUPT_CONFIRM_FILE)) {
|
||||
unlink(RESTORE_CORRUPT_CONFIRM_FILE);
|
||||
}
|
||||
}
|
||||
|
||||
$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