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.
214 lines
10 KiB
PHP
214 lines
10 KiB
PHP
<?php
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit;
|
|
}
|
|
|
|
$argus_active_page = 'firewall';
|
|
include ARGUS_WPD_DIR . 'admin/views/partials/header.php';
|
|
|
|
$action_labels = array(
|
|
'block' => __( 'Block', 'argus-wordpress-defence' ),
|
|
'challenge' => __( 'Challenge', 'argus-wordpress-defence' ),
|
|
'rate_limit' => __( 'Rate Limit', 'argus-wordpress-defence' ),
|
|
'allow' => __( 'Allow', 'argus-wordpress-defence' ),
|
|
);
|
|
|
|
$tabs = array(
|
|
'overview' => __( 'Overview', 'argus-wordpress-defence' ),
|
|
'rule-activity' => __( 'Rule Activity', 'argus-wordpress-defence' ),
|
|
'manual-block' => __( 'Manual IP Block', 'argus-wordpress-defence' ),
|
|
'blocked-ips' => __( 'Blocked IPs', 'argus-wordpress-defence' ),
|
|
);
|
|
|
|
$blocked_24h = $security_actions[ __( 'Blocked', 'argus-wordpress-defence' ) ] ?? 0;
|
|
$challenged_24h = $security_actions[ __( 'Challenged', 'argus-wordpress-defence' ) ] ?? 0;
|
|
$top_categories = array_slice( $attack_categories, 0, 3, true );
|
|
?>
|
|
|
|
<h1 class="argus-wpd-page-title"><?php esc_html_e( 'Firewall', 'argus-wordpress-defence' ); ?></h1>
|
|
<p style="color:var(--muted);font-size:13px;margin:0 0 20px;"><?php esc_html_e( 'ARGUS actively monitors and blocks malicious requests before they can reach sensitive areas of your website.', 'argus-wordpress-defence' ); ?></p>
|
|
|
|
<?php if ( ! empty( $notice ) ) : ?>
|
|
<div class="notice notice-success" style="padding:14px 18px;margin:0 0 20px;"><p style="margin:0"><?php echo esc_html( $notice ); ?></p></div>
|
|
<?php endif; ?>
|
|
|
|
<div class="argus-wpd-range-tabs" style="margin-bottom:20px;flex-wrap:wrap;">
|
|
<?php foreach ( $tabs as $key => $label ) : ?>
|
|
<a href="<?php echo esc_url( admin_url( 'admin.php?page=argus-wpd-firewall&tab=' . $key ) ); ?>" class="<?php echo $key === $tab ? 'active' : ''; ?>"><?php echo esc_html( $label ); ?></a>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
|
|
<?php if ( 'overview' === $tab ) : ?>
|
|
|
|
<div class="argus-wpd-tile-row">
|
|
<div class="argus-wpd-tile">
|
|
<div class="argus-wpd-tile-label"><?php esc_html_e( 'Requests Blocked Today', 'argus-wordpress-defence' ); ?></div>
|
|
<div class="argus-wpd-tile-value"><?php echo esc_html( number_format_i18n( $requests_blocked_24h ) ); ?></div>
|
|
</div>
|
|
<div class="argus-wpd-tile">
|
|
<div class="argus-wpd-tile-label"><?php esc_html_e( 'Rules Active', 'argus-wordpress-defence' ); ?></div>
|
|
<div class="argus-wpd-tile-value"><?php echo esc_html( number_format_i18n( $rules_active ) ); ?></div>
|
|
</div>
|
|
<div class="argus-wpd-tile">
|
|
<div class="argus-wpd-tile-label"><?php esc_html_e( 'Malicious IPs', 'argus-wordpress-defence' ); ?></div>
|
|
<div class="argus-wpd-tile-value"><?php echo esc_html( number_format_i18n( $malicious_ips ) ); ?></div>
|
|
</div>
|
|
<div class="argus-wpd-tile">
|
|
<div class="argus-wpd-tile-label"><?php esc_html_e( 'Mode', 'argus-wordpress-defence' ); ?></div>
|
|
<div class="argus-wpd-tile-value" style="font-size:16px;text-transform:capitalize;"><?php echo esc_html( Argus_Settings::mode() ); ?></div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="argus-wpd-columns-equal">
|
|
<div class="argus-wpd-panel">
|
|
<h2><?php esc_html_e( 'Attack Categories', 'argus-wordpress-defence' ); ?> <span class="argus-wpd-subtle-label"><?php esc_html_e( 'Last 24h', 'argus-wordpress-defence' ); ?></span></h2>
|
|
<?php if ( empty( $attack_categories ) ) : ?>
|
|
<p class="argus-wpd-empty"><?php esc_html_e( 'No attack activity in the last 24 hours.', 'argus-wordpress-defence' ); ?></p>
|
|
<?php else : ?>
|
|
<div class="argus-wpd-donut-row">
|
|
<?php echo Argus_Charts::donut( $attack_categories ); // phpcs:ignore WordPress.Security.EscapeOutput ?>
|
|
<?php echo Argus_Charts::legend( $attack_categories ); // phpcs:ignore WordPress.Security.EscapeOutput ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
<div class="argus-wpd-panel">
|
|
<h2><?php esc_html_e( 'Security Actions', 'argus-wordpress-defence' ); ?> <span class="argus-wpd-subtle-label"><?php esc_html_e( 'Last 24h', 'argus-wordpress-defence' ); ?></span></h2>
|
|
<?php if ( empty( $security_actions ) ) : ?>
|
|
<p class="argus-wpd-empty"><?php esc_html_e( 'No enforcement activity in the last 24 hours.', 'argus-wordpress-defence' ); ?></p>
|
|
<?php else : ?>
|
|
<div class="argus-wpd-donut-row">
|
|
<?php echo Argus_Charts::donut( $security_actions ); // phpcs:ignore WordPress.Security.EscapeOutput ?>
|
|
<?php echo Argus_Charts::legend( $security_actions ); // phpcs:ignore WordPress.Security.EscapeOutput ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="argus-wpd-panel">
|
|
<?php if ( $blocked_24h > 0 || $challenged_24h > 0 ) : ?>
|
|
<p style="font-size:14px;color:var(--text);margin:0 0 14px;">
|
|
<?php
|
|
echo esc_html(
|
|
$challenged_24h > 0
|
|
? sprintf(
|
|
|
|
__( 'ARGUS blocked %1$s malicious requests and challenged %2$s suspicious requests during the last 24 hours.', 'argus-wordpress-defence' ),
|
|
number_format_i18n( $blocked_24h ),
|
|
number_format_i18n( $challenged_24h )
|
|
)
|
|
: sprintf(
|
|
|
|
__( 'ARGUS blocked %s malicious requests during the last 24 hours.', 'argus-wordpress-defence' ),
|
|
number_format_i18n( $blocked_24h )
|
|
)
|
|
);
|
|
?>
|
|
</p>
|
|
<?php if ( ! empty( $top_categories ) ) : ?>
|
|
<p style="font-size:12.5px;color:var(--muted);margin:0 0 6px;font-weight:700;text-transform:uppercase;letter-spacing:.04em;"><?php esc_html_e( 'Top activity', 'argus-wordpress-defence' ); ?></p>
|
|
<ul style="margin:0;padding:0;list-style:none;">
|
|
<?php foreach ( $top_categories as $label => $count ) : ?>
|
|
<li style="font-size:13px;color:var(--text);padding:4px 0;">— <?php echo esc_html( $label ); ?>: <strong><?php echo esc_html( number_format_i18n( $count ) ); ?> <?php esc_html_e( 'blocked', 'argus-wordpress-defence' ); ?></strong></li>
|
|
<?php endforeach; ?>
|
|
</ul>
|
|
<?php endif; ?>
|
|
<?php else : ?>
|
|
<p class="argus-wpd-empty"><?php esc_html_e( 'No malicious activity detected in the last 24 hours.', 'argus-wordpress-defence' ); ?></p>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<?php elseif ( 'rule-activity' === $tab ) : ?>
|
|
|
|
<div class="argus-wpd-panel">
|
|
<h2><?php esc_html_e( 'Rule Activity', 'argus-wordpress-defence' ); ?> · <?php esc_html_e( 'Last 24h', 'argus-wordpress-defence' ); ?></h2>
|
|
<?php if ( empty( $rule_hits ) ) : ?>
|
|
<p class="argus-wpd-empty"><?php esc_html_e( 'No rule hits in the last 24 hours.', 'argus-wordpress-defence' ); ?></p>
|
|
<?php else : ?>
|
|
<table class="widefat striped">
|
|
<thead>
|
|
<tr>
|
|
<th><?php esc_html_e( 'Rule', 'argus-wordpress-defence' ); ?></th>
|
|
<th><?php esc_html_e( 'Category', 'argus-wordpress-defence' ); ?></th>
|
|
<th><?php esc_html_e( 'Action', 'argus-wordpress-defence' ); ?></th>
|
|
<th><?php esc_html_e( 'Hits (24h)', 'argus-wordpress-defence' ); ?></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ( $rule_hits as $hit ) : ?>
|
|
<tr>
|
|
<td><code><?php echo esc_html( $hit['label'] ); ?></code></td>
|
|
<td><?php echo esc_html( $hit['category'] ); ?></td>
|
|
<td><?php echo esc_html( $action_labels[ $hit['action'] ] ?? ucfirst( $hit['action'] ) ); ?></td>
|
|
<td><?php echo esc_html( number_format_i18n( $hit['hits'] ) ); ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<?php elseif ( 'manual-block' === $tab ) : ?>
|
|
|
|
<div class="argus-wpd-panel">
|
|
<h2><?php esc_html_e( 'Block an IP manually', 'argus-wordpress-defence' ); ?></h2>
|
|
<p style="color:var(--muted);font-size:12.5px;margin:0 0 16px;"><?php esc_html_e( 'The address is blocked immediately and appears in Blocked IPs.', 'argus-wordpress-defence' ); ?></p>
|
|
<form method="post" class="argus-wpd-inline-form">
|
|
<?php wp_nonce_field( 'argus_wpd_block_ip', 'argus_wpd_block_nonce' ); ?>
|
|
<input type="text" name="block_ip" placeholder="203.0.113.10" required pattern="^[0-9a-fA-F:.]+$" />
|
|
<input type="text" name="block_reason" placeholder="<?php esc_attr_e( 'Reason (optional)', 'argus-wordpress-defence' ); ?>" />
|
|
<button type="submit" class="button button-primary"><?php esc_html_e( 'Block', 'argus-wordpress-defence' ); ?></button>
|
|
</form>
|
|
</div>
|
|
|
|
<?php elseif ( 'blocked-ips' === $tab ) : ?>
|
|
|
|
<div class="argus-wpd-panel">
|
|
<h2><?php esc_html_e( 'Blocked IPs', 'argus-wordpress-defence' ); ?></h2>
|
|
<p style="color:var(--muted);font-size:12.5px;margin:0 0 16px;"><?php esc_html_e( 'Currently active blocks only. Lifted or expired blocks no longer appear here -- the full history is in the Audit Log.', 'argus-wordpress-defence' ); ?></p>
|
|
<?php if ( empty( $bans ) ) : ?>
|
|
<p class="argus-wpd-empty"><?php esc_html_e( 'No IPs are currently blocked.', 'argus-wordpress-defence' ); ?></p>
|
|
<?php else : ?>
|
|
<table class="widefat striped">
|
|
<thead>
|
|
<tr>
|
|
<th><?php esc_html_e( 'IP', 'argus-wordpress-defence' ); ?></th>
|
|
<th><?php esc_html_e( 'Source', 'argus-wordpress-defence' ); ?></th>
|
|
<th><?php esc_html_e( 'Reason', 'argus-wordpress-defence' ); ?></th>
|
|
<th><?php esc_html_e( 'Level', 'argus-wordpress-defence' ); ?></th>
|
|
<th><?php esc_html_e( 'Blocked', 'argus-wordpress-defence' ); ?></th>
|
|
<th><?php esc_html_e( 'Expires', 'argus-wordpress-defence' ); ?></th>
|
|
<th></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ( $bans as $ban ) : ?>
|
|
<tr>
|
|
<td><span class="argus-wpd-flag" title="<?php echo esc_attr( Argus_GeoIP::label( $ban->ip ) ); ?>"><?php echo esc_html( Argus_GeoIP::icon( $ban->ip ) ); ?></span> <code><?php echo esc_html( $ban->ip ); ?></code></td>
|
|
<td><?php echo esc_html( $ban->source ); ?></td>
|
|
<td><?php echo esc_html( $ban->reason ); ?></td>
|
|
<td><?php echo esc_html( $ban->ban_level ); ?></td>
|
|
<td><?php echo esc_html( human_time_diff( strtotime( $ban->created_at . ' UTC' ) ) ); ?> <?php esc_html_e( 'ago', 'argus-wordpress-defence' ); ?></td>
|
|
<td><?php echo esc_html( $ban->expires_at ?: __( 'Permanent', 'argus-wordpress-defence' ) ); ?></td>
|
|
<td>
|
|
<form method="post">
|
|
<?php wp_nonce_field( 'argus_wpd_unban_' . $ban->id, 'argus_wpd_unban_nonce' ); ?>
|
|
<input type="hidden" name="ban_id" value="<?php echo esc_attr( $ban->id ); ?>" />
|
|
<button type="submit" class="button"><?php esc_html_e( 'Unban', 'argus-wordpress-defence' ); ?></button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
<?php
|
|
$base_url = remove_query_arg( 'paged' );
|
|
include ARGUS_WPD_DIR . 'admin/views/partials/pagination.php';
|
|
?>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<?php endif; ?>
|
|
|
|
<?php include ARGUS_WPD_DIR . 'admin/views/partials/footer.php'; ?>
|