Automatic WordPress security: local firewall, malware and file-integrity scanning, vulnerability protection, quarantine, scheduled backups, an optional page cache, and automatic global threat intelligence. See README.md for installation, update, and uninstall instructions.
53 lines
1.5 KiB
PHP
53 lines
1.5 KiB
PHP
<?php
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit;
|
|
}
|
|
|
|
class Argus_Scan_History {
|
|
|
|
const TYPE_QUICK = 'quick';
|
|
const TYPE_FULL = 'full';
|
|
const TYPE_SCHEDULED_INCREMENTAL = 'scheduled_incremental';
|
|
const TYPE_SCHEDULED_FULL = 'scheduled_full';
|
|
|
|
const PER_PAGE = 5;
|
|
|
|
public static function record( $type, $started_at, $files_scanned = 0 ) {
|
|
global $wpdb;
|
|
|
|
$findings_count = Argus_Findings::count_open( 'malware' ) + Argus_Findings::count_open( 'integrity' );
|
|
|
|
$wpdb->insert(
|
|
Argus_DB::table( 'scan_history' ),
|
|
array(
|
|
'scan_type' => $type,
|
|
'started_at' => gmdate( 'Y-m-d H:i:s', $started_at ),
|
|
'finished_at' => current_time( 'mysql', true ),
|
|
'files_scanned' => (int) $files_scanned,
|
|
'findings_count' => $findings_count,
|
|
'result' => $findings_count > 0 ? 'issues' : 'clean',
|
|
)
|
|
);
|
|
}
|
|
|
|
public static function paginated( $page = 1, $per_page = self::PER_PAGE ) {
|
|
global $wpdb;
|
|
$table = Argus_DB::table( 'scan_history' );
|
|
$page = max( 1, (int) $page );
|
|
$offset = ( $page - 1 ) * $per_page;
|
|
|
|
$total = (int) $wpdb->get_var( "SELECT COUNT(*) FROM {$table}" ); // phpcs:ignore
|
|
$rows = $wpdb->get_results(
|
|
$wpdb->prepare( "SELECT * FROM {$table} ORDER BY started_at DESC LIMIT %d OFFSET %d", $per_page, $offset ) // phpcs:ignore
|
|
);
|
|
|
|
return array(
|
|
'rows' => $rows,
|
|
'total' => $total,
|
|
'total_pages' => max( 1, (int) ceil( $total / $per_page ) ),
|
|
'page' => $page,
|
|
);
|
|
}
|
|
}
|