mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-14 18:48:21 -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
33
.github/workflows/schedule.yml
vendored
33
.github/workflows/schedule.yml
vendored
|
@ -1,4 +1,4 @@
|
|||
name: Changelog & checksums generation
|
||||
name: Changelog generation
|
||||
|
||||
on:
|
||||
schedule:
|
||||
|
@ -39,34 +39,3 @@ jobs:
|
|||
git add CHANGELOG.md
|
||||
git commit -m "Update CHANGELOG.md 📖"
|
||||
git push https://${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git master
|
||||
|
||||
checksums:
|
||||
name: Generate checksums.md5 file
|
||||
runs-on: ubuntu-22.04
|
||||
needs: [ changelog ]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
ref: master
|
||||
token: ${{ secrets.REPO_TOKEN }}
|
||||
|
||||
- name: Generate checksums.md5 file
|
||||
run: |
|
||||
find . -type f -not -path "./.git/*" -exec md5sum {} \; > internal_data/checksums.md5
|
||||
|
||||
- name: Commit and push checksums.md5 if changed
|
||||
run: |
|
||||
git checkout master
|
||||
git config --local user.name 'belomaxorka'
|
||||
git config --local user.email 'roman25052006.kelesh@gmail.com'
|
||||
|
||||
if git diff --quiet internal_data/checksums.md5; then
|
||||
echo "No changes... "
|
||||
else
|
||||
set +e
|
||||
git add internal_data/checksums.md5
|
||||
git commit -m "Update checksums.md5 📄"
|
||||
git push https://${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git master
|
||||
fi
|
||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -5,7 +5,6 @@
|
|||
### TorrentPier ###
|
||||
*.log
|
||||
/*.txt
|
||||
*.integrity
|
||||
install.php_*
|
||||
composer-setup.php
|
||||
.env
|
||||
|
|
|
@ -15,12 +15,6 @@ if (!$stats = $datastore->get('stats')) {
|
|||
$stats = $datastore->get('stats');
|
||||
}
|
||||
|
||||
// Files integrity check
|
||||
if (!$files_integrity_data = $datastore->get('files_integrity')) {
|
||||
$datastore->update('files_integrity');
|
||||
$files_integrity_data = $datastore->get('files_integrity');
|
||||
}
|
||||
|
||||
// Check for updates
|
||||
if (!$update_data = $datastore->get('check_updates')) {
|
||||
$datastore->update('check_updates');
|
||||
|
@ -88,16 +82,6 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
|
|||
'ADMIN_LOCK_CRON' => is_file(BB_DISABLED),
|
||||
]);
|
||||
|
||||
// Files integrity check results
|
||||
if (!empty($files_integrity_data)) {
|
||||
$template->assign_block_vars('integrity_check', [
|
||||
'INTEGRITY_SUCCESS' => (bool)$files_integrity_data['success'],
|
||||
'INTEGRITY_WRONG_FILES_LIST' => implode("\n</li>\n<li>\n", $files_integrity_data['wrong_files']),
|
||||
'INTEGRITY_LAST_CHECK_TIME' => sprintf($lang['INTEGRITY_LAST_CHECK'], bb_date($files_integrity_data['timestamp'])),
|
||||
'INTEGRITY_CHECKED_FILES' => sprintf($lang['INTEGRITY_CHECKED'], $files_integrity_data['total_num'], ($files_integrity_data['total_num'] - $files_integrity_data['wrong_files_num'])),
|
||||
]);
|
||||
}
|
||||
|
||||
// Check for updates
|
||||
if (isset($update_data['available_update'])) {
|
||||
$template->assign_block_vars('updater', [
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -82,10 +82,6 @@ switch ($mode) {
|
|||
\TorrentPier\Helpers\CronHelper::enableBoard();
|
||||
$this->response['unlock_cron_html'] = '<span class="seed bold">' . $lang['ADMIN_UNLOCKED'] . '</span>';
|
||||
break;
|
||||
case 'restore_corrupt_files':
|
||||
file_write('', RESTORE_CORRUPT_CONFIRM_FILE, replace_content: true);
|
||||
$this->response['restore_corrupt_files_html'] = '<span class="seed bold">' . $lang['INTEGRITY_RESTORE_CONFIRM_OK'] . '</span>';
|
||||
break;
|
||||
default:
|
||||
$this->ajax_die('Invalid mode: ' . $mode);
|
||||
}
|
||||
|
|
|
@ -602,7 +602,6 @@ $bb_cfg['flist_max_files'] = 0; // Max allowed number of files to process for gi
|
|||
$bb_cfg['last_visit_date_format'] = 'd-M H:i';
|
||||
$bb_cfg['last_post_date_format'] = 'd-M-y H:i';
|
||||
$bb_cfg['poll_max_days'] = 180; // How many days will the poll be active
|
||||
$bb_cfg['integrity_check'] = true; // TorrentPier files integrity check
|
||||
|
||||
$bb_cfg['allow_change'] = [
|
||||
'language' => true, // Allow user to change language
|
||||
|
|
|
@ -33,8 +33,6 @@ define('APP_NAME', 'TorrentPier');
|
|||
define('DEFAULT_CHARSET', 'UTF-8');
|
||||
define('UPDATER_URL', 'https://api.github.com/repos/torrentpier/torrentpier/releases');
|
||||
define('UPDATER_FILE', INT_DATA_DIR . '/updater.json');
|
||||
define('CHECKSUMS_FILE', INT_DATA_DIR . '/checksums.md5');
|
||||
define('RESTORE_CORRUPT_CONFIRM_FILE', INT_DATA_DIR . '/rescorrupt.integrity');
|
||||
define('COOKIE_DBG', 'bb_dbg');
|
||||
|
||||
// TODO: Move in another section
|
||||
|
|
|
@ -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);
|
|
@ -2322,14 +2322,6 @@ $lang['DISALLOWED_ALREADY'] = 'The name you entered could not be disallowed. It
|
|||
|
||||
$lang['CLICK_RETURN_DISALLOWADMIN'] = 'Click %sHere%s to return to Disallow Username Administration';
|
||||
|
||||
// Integrity check
|
||||
$lang['INTEGRITY_CHECK_SUCCESS'] = 'TorrentPier files integrity check was successful!';
|
||||
$lang['INTEGRITY_CHECK_FAIL'] = 'Some TorrentPier files not pass integrity check!';
|
||||
$lang['INTEGRITY_CHECKED'] = 'Total checked: %s file(s), of which pass integrity check: %s file(s).';
|
||||
$lang['INTEGRITY_LAST_CHECK'] = 'Last check: %s.';
|
||||
$lang['INTEGRITY_RESTORE_ON_NEXT_RUN'] = 'Restore corrupt files on next integrity check?';
|
||||
$lang['INTEGRITY_RESTORE_CONFIRM_OK'] = 'Corrupt files will be restored on next integrity check!';
|
||||
|
||||
// Version Check
|
||||
$lang['VERSION_INFORMATION'] = 'Version Information';
|
||||
$lang['UPDATE_AVAILABLE'] = 'Update available';
|
||||
|
|
|
@ -43,7 +43,6 @@ class Common
|
|||
'cat_forums' => 'build_cat_forums.php',
|
||||
'censor' => 'build_censor.php',
|
||||
'check_updates' => 'build_check_updates.php',
|
||||
'files_integrity' => 'build_files_integrity.php',
|
||||
'jumpbox' => 'build_cat_forums.php',
|
||||
'viewtopic_forum_select' => 'build_cat_forums.php',
|
||||
'latest_news' => 'build_cat_forums.php',
|
||||
|
|
|
@ -80,32 +80,10 @@
|
|||
$('#sync_topics').html(data.sync_topics_html);
|
||||
$('#sync_user_posts').html(data.sync_user_posts_html);
|
||||
$('#unlock_cron').html(data.unlock_cron_html);
|
||||
$('#restore_corrupt_files').html(data.restore_corrupt_files_html);
|
||||
}
|
||||
</script>
|
||||
|
||||
<br/>
|
||||
<!-- BEGIN integrity_check -->
|
||||
<!-- IF integrity_check.INTEGRITY_SUCCESS -->
|
||||
<div class="alert alert-success" style="width: 95%;">
|
||||
<h4 class="alert-heading">{L_INTEGRITY_CHECK_SUCCESS}</h4>
|
||||
<h6>{integrity_check.INTEGRITY_CHECKED_FILES} {integrity_check.INTEGRITY_LAST_CHECK_TIME}</h6>
|
||||
</div>
|
||||
<!-- ELSE -->
|
||||
<div class="alert alert-danger" style="width: 95%;">
|
||||
<h4 class="alert-heading">{L_INTEGRITY_CHECK_FAIL}</h4>
|
||||
<h6>{integrity_check.INTEGRITY_CHECKED_FILES} {integrity_check.INTEGRITY_LAST_CHECK_TIME}</h6>
|
||||
<hr/>
|
||||
<!-- IF integrity_check.INTEGRITY_WRONG_FILES_LIST -->
|
||||
<ul style="max-height: 120px; overflow-x: auto;">
|
||||
<li>{integrity_check.INTEGRITY_WRONG_FILES_LIST}</li>
|
||||
</ul>
|
||||
<hr/>
|
||||
<a href="#" id="restore_corrupt_files" onclick="ajax.manage_admin('restore_corrupt_files'); return false;">{L_INTEGRITY_RESTORE_ON_NEXT_RUN}</a>
|
||||
<!-- ENDIF -->
|
||||
</div>
|
||||
<!-- ENDIF -->
|
||||
<!-- END integrity_check -->
|
||||
|
||||
<!-- IF ADMIN_LOCK_CRON -->
|
||||
<div class="alert alert-danger" style="width: 95%;">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue