Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8ea7e72
Fix. Code. Comments and method place fixed.
Glomberg Jul 21, 2026
0072ead
Fix. Scanner. Remove the front scanner - work started.
Glomberg Jul 23, 2026
98f2652
Merge remote-tracking branch 'origin/dev' into Upd-Scanner-Frontend-c…
Glomberg Aug 17, 2026
2527201
Fix. React. Select tab endpoint fixed.
Glomberg Aug 19, 2026
c709857
Fix. React. `Security Log` tab moved to the legacy endpoint.
Glomberg Aug 19, 2026
7078e1e
Fix. React. `Settings General` tab fixed.
Glomberg Aug 19, 2026
9875665
Fix. React. A lot of unused code removed.
Glomberg Aug 19, 2026
11689ae
Fix. Code. ESLint notice fixed.
Glomberg Aug 19, 2026
49c243e
Fix. Code. Psalm notice fixed.
Glomberg Aug 19, 2026
49db567
Fix. React. Select tab endpoint fixed.
Glomberg Aug 19, 2026
c10cd4e
Fix. React. `Security Log` tab moved to the legacy endpoint.
Glomberg Aug 19, 2026
2396560
Fix. React. `Settings General` tab fixed.
Glomberg Aug 19, 2026
ee7892d
Fix. React. A lot of unused code removed.
Glomberg Aug 19, 2026
222f988
Fix. Code. ESLint notice fixed.
Glomberg Aug 19, 2026
208145e
Fix. Code. Psalm notice fixed.
Glomberg Aug 19, 2026
eded902
Fix. Code. Debug removed.
Glomberg Aug 20, 2026
b43315f
Fix. Code. JS bundle rebuilt.
Glomberg Aug 20, 2026
ff6b333
Merge remote-tracking branch 'origin/Fix-Code-Remove-unused-code-afte…
Glomberg Aug 20, 2026
19193b5
Fix. React. `FSWatcher` unused code removed.
Glomberg Aug 24, 2026
268b00a
Merge remote-tracking branch 'origin/Fix-Code-Remove-unused-code-afte…
Glomberg Aug 24, 2026
fec7f67
Merge remote-tracking branch 'origin/dev' into Fix-Code-Remove-unused…
Glomberg Aug 24, 2026
35c8828
Merge remote-tracking branch 'origin/Fix-Code-Remove-unused-code-afte…
Glomberg Aug 24, 2026
b1b5db4
Merge remote-tracking branch 'origin/dev' into Fix-Code-Remove-unused…
Glomberg Aug 24, 2026
ce91ab5
Merge remote-tracking branch 'origin/Fix-Code-Remove-unused-code-afte…
Glomberg Aug 24, 2026
5fff981
Merge remote-tracking branch 'origin/dev' into Upd-Scanner-Frontend-c…
Glomberg Sep 2, 2026
4a4e1e1
Fix. Code. ES-Lint notice fixed.
Glomberg Sep 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion inc/spbc-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,13 @@ function spbc_admin_init()
add_action('wp_ajax_spbc_tc__filter_ip', 'spbc_tc__filter_ip');

// Scanner
add_action('wp_ajax_spbc_scanner_controller_front', array(ScannerQueue::class, 'controllerFront'));
//add_action('wp_ajax_spbc_scanner_controller_front', array(ScannerQueue::class, 'controllerFront'));
add_action('wp_ajax_spbc_scanner_load_more_scan_logs', array(ScannerAjaxEndpoints::class, 'loadMoreScanLogs'));
add_action('wp_ajax_spbc_scanner_save_to_pdf', array(ScannerAjaxEndpoints::class, 'downloadPDFReport'));
add_action('wp_ajax_spbc_scanner_get_pdf_file_name', array(ScannerAjaxEndpoints::class, 'getPDFReportFileName'));
add_action('wp_ajax_spbc_scanner_clear', array(ScannerAjaxEndpoints::class, 'clearScannerResults')); // Debug. Clear the table
add_action('wp_ajax_spbc_scanner__start', 'spbc_scanner__launch');
add_action('wp_ajax_spbc_scanner__getScannerStatus', 'spbc_scanner__getScannerStatus');
add_action('wp_ajax_spbc_scanner__last_scan_info', 'spbc_scanner__last_scan_info');

// Scanner buttons
Expand Down
68 changes: 66 additions & 2 deletions inc/spbc-scanner.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<?php

// Prevent direct call
use CleantalkSP\SpbctWP\Cron;
use CleantalkSP\SpbctWP\Transaction;

if ( ! defined('ABSPATH') ) {
die('Not allowed!');
}

/**
* Cron wrapper function for launchBackground
* Cron|RemoteCall wrapper function for launchBackground
*
* @return bool|string|string[]|void
*/
Expand All @@ -24,7 +27,7 @@ function spbc_scanner__launch()
}

/**
* Cron wrapper function for controllerBackground
* Cron|RemoteCall wrapper function for controllerBackground
*
* @param null $transaction_id
* @param null $stage
Expand Down Expand Up @@ -53,3 +56,64 @@ function spbc_scanner__controller($transaction_id = null, $stage = null, $offset

return $result;
}

function spbc_scanner__isScannerIsInProgress()
{
global $spbc;

// First sign - the transaction is in active state
$scanner_transaction_start = (int) get_option('spbc_transaction__background_scanner_start_time', 0);

// Second sign - scanner data scan_start_timestamp more than scan_finish_timestamp
$scanner_started_at = isset($spbc->data['scanner']['scan_start_timestamp'])
? (int) $spbc->data['scanner']['scan_start_timestamp']
: 0;
$scanner_finished_at = isset($spbc->data['scanner']['scan_finished_at'])
? (int) $spbc->data['scanner']['scan_finished_at']
: 0;

return $scanner_transaction_start !== 0 && ( $scanner_started_at > $scanner_finished_at );
}

function spbc_scanner__getScannerStatus()
{
if ( ! spbc_check_ajax_referer('spbc_secret_nonce', 'security', false) ) {
wp_send_json(array('error' => 'Nonce had been changed. Please, restart the scan.'));
}

if ( spbc_scanner__isScannerIsInProgress() ) {
$stages = get_option('spbc_scanning_stages');
$current_cron_task = Cron::getTask('background_scan');
if ( $current_cron_task && isset($current_cron_task['params']['stage'], $current_cron_task['params']['offset']) ) {
$current_stage = $current_cron_task['params']['stage'];
$current_offset = $current_cron_task['params']['offset'];
$completed_stages = [];
foreach ($stages as $stage_key => $stage) {
// Convert $stageKey like CleantalkSP\SpbctWP\Scanner\ScanningStagesModule\Stages\GetCmsHashes into get_cms_hashes
$stage_class_name = explode('\\', $stage_key);
$stage_class_name = end($stage_class_name);
$stage_name = strtolower(preg_replace('/(?<!^)[A-Z]/', '_$0', $stage_class_name));
if ($stage_name === $current_stage) {
break;
}
$completed_stages[] = [
'stage' => $stage_name,
'status' => 'completed',
];
}
wp_send_json_success(array(
'status' => 'in_progress',
'current_stage' => [
'stage' => $current_stage,
'offset' => $current_offset,
'status' => 'in_progress',
],
'completed_stages' => $completed_stages,
));
}
// What to do here?
}
wp_send_json_success(array(
'status' => 'end',
));
}
24 changes: 16 additions & 8 deletions inc/spbc-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -1676,15 +1676,25 @@ function spbc_field_scanner()
'</a>'
);
echo '</p>';
$scanner_disabled = isset($spbc->errors['configuration']) ? 'disabled="disabled"' : '';
$scanner_disabled = isset($spbc->errors['configuration']) || spbc_scanner__isScannerIsInProgress() ? 'disabled="disabled"' : '';
$disabled_reason = isset($spbc->errors['configuration'])
? __('Scanner is disabled. Please, check errors on the top of the settings.', 'security-malware-firewall')
: '';
$disabled_reason = ! $disabled_reason && spbc_scanner__isScannerIsInProgress()
? __('Scanner is in progress. Please, wait until the current scan is finished.', 'security-malware-firewall')
: '';
$scanner_disabled_reason = $scanner_disabled
? 'title="' . __('Scanner is disabled. Please, check errors on the top of the settings.', 'security-malware-firewall') . '"'
? 'title="' . $disabled_reason . '"'
: '';
$scan_button_text = spbc_scanner__isScannerIsInProgress()
? __('Scan in progress', 'security-malware-firewall')
: __('Perform Scan', 'security-malware-firewall');
$display = spbc_scanner__isScannerIsInProgress() ? 'display:inline-block;' : '';
echo '<div style="text-align: center; margin-top: 1em;">'
. '<button id="spbc_perform_scan" class="spbc_manual_link_scan" type="button" ' . $scanner_disabled . $scanner_disabled_reason . '>'
. __('Perform Scan', 'security-malware-firewall')
. $scan_button_text
. '</button>'
. '<img class="spbc_preloader" src="' . SPBC_PATH . '/images/preloader.gif" />'
. '<img class="spbc_preloader" src="' . SPBC_PATH . '/images/preloader.gif" style="' . $display . '" />'
. '</div>';

echo '<p id="spbc_scanner__last_scan_info" class="spbc_hint" style="text-align: center; margin-top: 5px;">';
Expand All @@ -1705,7 +1715,7 @@ function spbc_field_scanner()
echo '</p>';

echo
'<div id="spbc_scaner_progress_overall" class="spbc_hide" style="padding-bottom: 10px; text-align: center;">'
'<div id="spbc_scaner_progress_overall" class="spbc_hide" style="padding-bottom: 10px; text-align: center;' . $display . '">'
. '<span class="spbc_overall_scan_status_get_cms_hashes">' . __('Receiving core hashes', 'security-malware-firewall') . '</span> -> '
. '<span class="spbc_overall_scan_status_get_modules_hashes">' . __('Receiving plugin and theme hashes', 'security-malware-firewall') . '</span> -> '
. '<span class="spbc_overall_scan_status_clean_results">' . __('Preparing', 'security-malware-firewall') . '</span> -> '
Expand Down Expand Up @@ -1752,8 +1762,6 @@ function spbc_field_scanner()
echo '<span class="spbc_overall_scan_status_auto_cure">' . __('Curing', 'security-malware-firewall') . '</span> -> ';
}



if ($spbc->settings['scanner__outbound_links']) {
echo '<span class="spbc_overall_scan_status_outbound_links">' . __('Scanning links', 'security-malware-firewall') . '</span> -> ';
}
Expand All @@ -1769,7 +1777,7 @@ function spbc_field_scanner()
echo '<span class="spbc_overall_scan_status_send_results">' . __('Sending results', 'security-malware-firewall') . '</span>'

. '</div>';
echo '<div id="spbc_scaner_progress_bar" class="spbc_hide" style="height: 22px;"><div class="spbc_progressbar_counter"><span></span></div></div>';
echo '<div id="spbc_scaner_progress_bar" class="spbc_hide" style="height: 22px;' . $display . '"><div class="spbc_progressbar_counter"><span></span></div></div>';

// Log style output for scanned files

Expand Down
Loading
Loading