This commit is contained in:
Yuri Karamian
2026-02-04 20:30:32 +01:00
parent 291fd61b67
commit 6b719f4fac
44 changed files with 4974 additions and 4948 deletions
+575
View File
@@ -0,0 +1,575 @@
/**
* ArkHost Security Pack Admin Styles
*
* Clean, modern design - no scary dashboards or fake threat counters.
*/
/* CSS Custom Properties */
:root {
--arksp-primary: #2271b1;
--arksp-primary-hover: #135e96;
--arksp-success: #00a32a;
--arksp-success-bg: #edfaef;
--arksp-warning: #dba617;
--arksp-warning-bg: #fcf9e8;
--arksp-danger: #d63638;
--arksp-danger-bg: #fcf0f1;
--arksp-info: #72aee6;
--arksp-info-bg: #f0f6fc;
--arksp-border: #e0e0e0;
--arksp-border-light: #f0f0f1;
--arksp-text: #1d2327;
--arksp-text-light: #646970;
--arksp-bg: #fff;
--arksp-bg-alt: #f6f7f7;
--arksp-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
--arksp-shadow-hover: 0 2px 8px rgba(0, 0, 0, 0.08);
--arksp-radius: 8px;
--arksp-radius-sm: 4px;
--arksp-transition: 0.15s ease;
}
/* Main wrapper */
.arksp-wrap {
max-width: 1200px;
}
.arksp-wrap h1 {
font-size: 24px;
font-weight: 600;
margin-bottom: 1.5em;
padding: 0;
color: var(--arksp-text);
}
/* Tabs */
.arksp-tabs {
margin-bottom: 24px;
border-bottom: 1px solid var(--arksp-border);
display: flex;
flex-wrap: wrap;
gap: 2px;
}
.arksp-tabs .nav-tab {
margin-left: 0;
margin-right: 0;
border-radius: var(--arksp-radius-sm) var(--arksp-radius-sm) 0 0;
transition: background var(--arksp-transition), color var(--arksp-transition);
padding: 8px 16px;
font-weight: 500;
}
.arksp-tabs .nav-tab:hover {
background: var(--arksp-bg-alt);
}
.arksp-tabs .nav-tab-active {
background: var(--arksp-bg);
border-bottom-color: var(--arksp-bg);
}
/* Sections */
.arksp-section {
background: var(--arksp-bg);
border: 1px solid var(--arksp-border);
border-radius: var(--arksp-radius);
padding: 24px;
margin-bottom: 20px;
box-shadow: var(--arksp-shadow);
transition: box-shadow var(--arksp-transition);
}
.arksp-section:hover {
box-shadow: var(--arksp-shadow-hover);
}
.arksp-section h2 {
margin: 0 0 16px 0;
padding: 0 0 12px 0;
font-size: 1.2em;
font-weight: 600;
border-bottom: 1px solid var(--arksp-border-light);
color: var(--arksp-text);
}
.arksp-section h3 {
margin-top: 1.5em;
font-size: 1em;
font-weight: 600;
color: var(--arksp-text);
}
/* Form tables */
.arksp-section .form-table {
margin-top: 0;
}
.arksp-section .form-table th {
width: 220px;
padding-left: 0;
font-weight: 500;
color: var(--arksp-text);
}
.arksp-section .form-table td {
padding-top: 12px;
padding-bottom: 12px;
}
/* Status indicators */
.arksp-status {
display: inline-flex;
align-items: center;
padding: 4px 10px;
border-radius: 50px;
font-size: 12px;
font-weight: 600;
letter-spacing: 0.02em;
text-transform: uppercase;
}
.arksp-status-ok {
background: var(--arksp-success-bg);
color: var(--arksp-success);
}
.arksp-status-warning {
background: var(--arksp-warning-bg);
color: #8a6d00;
}
.arksp-status-error {
background: var(--arksp-danger-bg);
color: var(--arksp-danger);
}
/* Stats */
.arksp-stats {
display: flex;
gap: 16px;
margin-bottom: 24px;
flex-wrap: wrap;
}
.arksp-stat {
background: var(--arksp-bg);
border: 1px solid var(--arksp-border);
padding: 20px 28px;
border-radius: var(--arksp-radius);
text-align: center;
min-width: 130px;
transition: transform var(--arksp-transition), box-shadow var(--arksp-transition);
}
.arksp-stat:hover {
transform: translateY(-2px);
box-shadow: var(--arksp-shadow-hover);
}
.arksp-stat-value {
display: block;
font-size: 32px;
font-weight: 700;
color: var(--arksp-text);
line-height: 1.2;
}
.arksp-stat-label {
display: block;
font-size: 11px;
font-weight: 500;
color: var(--arksp-text-light);
margin-top: 6px;
text-transform: uppercase;
letter-spacing: 0.05em;
}
/* Stat color variations */
.arksp-stat-success {
border-left: 4px solid var(--arksp-success);
}
.arksp-stat-success .arksp-stat-value {
color: var(--arksp-success);
}
.arksp-stat-warning {
border-left: 4px solid var(--arksp-warning);
}
.arksp-stat-warning .arksp-stat-value {
color: #8a6d00;
}
.arksp-stat-danger {
border-left: 4px solid var(--arksp-danger);
}
.arksp-stat-danger .arksp-stat-value {
color: var(--arksp-danger);
}
.arksp-stat-info {
border-left: 4px solid var(--arksp-primary);
}
.arksp-stat-info .arksp-stat-value {
color: var(--arksp-primary);
}
/* Tables */
.arksp-section .widefat {
margin-top: 16px;
border-radius: var(--arksp-radius-sm);
overflow: hidden;
}
.arksp-section .widefat td,
.arksp-section .widefat th {
padding: 12px 14px;
}
.arksp-section .widefat thead th {
font-weight: 600;
background: var(--arksp-bg-alt);
}
.arksp-section .widefat tbody tr {
transition: background var(--arksp-transition);
}
.arksp-section .widefat tbody tr:hover {
background: var(--arksp-bg-alt);
}
/* Country select */
.arksp-country-select {
min-width: 300px;
height: 200px !important;
border-radius: var(--arksp-radius-sm);
}
/* Event type colors */
.arksp-event-login_success {
color: var(--arksp-success);
}
.arksp-event-login_failed {
color: #8a6d00;
}
.arksp-event-lockout,
.arksp-event-ip_blocked,
.arksp-event-geo_blocked {
color: var(--arksp-danger);
}
/* Country badge */
.arksp-country {
display: inline-block;
background: var(--arksp-bg-alt);
padding: 2px 8px;
border-radius: 50px;
font-size: 11px;
font-weight: 500;
margin-left: 6px;
}
/* Severity badges */
.arksp-badge {
display: inline-block;
padding: 3px 10px;
border-radius: 50px;
font-size: 10px;
font-weight: 700;
color: #fff;
margin-right: 6px;
text-transform: uppercase;
letter-spacing: 0.03em;
}
/* Footer */
.arksp-footer {
margin-top: 32px;
padding-top: 20px;
border-top: 1px solid var(--arksp-border);
color: var(--arksp-text-light);
font-size: 13px;
}
.arksp-footer a {
color: var(--arksp-primary);
text-decoration: none;
transition: color var(--arksp-transition);
}
.arksp-footer a:hover {
color: var(--arksp-primary-hover);
text-decoration: underline;
}
/* 2FA status */
.arksp-2fa-status {
display: inline-flex;
align-items: center;
padding: 6px 14px;
border-radius: 50px;
font-weight: 600;
font-size: 13px;
}
.arksp-2fa-enabled {
background: var(--arksp-success-bg);
color: var(--arksp-success);
}
.arksp-2fa-disabled {
background: var(--arksp-danger-bg);
color: var(--arksp-danger);
}
/* Responsive */
@media screen and (max-width: 782px) {
.arksp-stats {
flex-direction: column;
}
.arksp-stat {
min-width: auto;
}
.arksp-section .form-table th {
width: auto;
}
.arksp-country-select {
min-width: 100%;
}
.arksp-tabs {
gap: 4px;
}
.arksp-tabs .nav-tab {
padding: 6px 12px;
font-size: 13px;
}
}
/* Code blocks */
.arksp-section code {
background: var(--arksp-bg-alt);
padding: 3px 8px;
border-radius: var(--arksp-radius-sm);
font-size: 13px;
}
/* Button spacing & styling */
.arksp-section .button {
transition: all var(--arksp-transition);
}
.arksp-section .button:hover {
transform: translateY(-1px);
}
.arksp-section .button + .button {
margin-left: 8px;
}
/* Tablenav */
.arksp-section .tablenav {
margin: 16px 0;
}
.arksp-section .tablenav .actions {
padding: 0;
}
/* Alert boxes */
.arksp-alert {
padding: 14px 18px;
border-radius: var(--arksp-radius);
margin-bottom: 16px;
border-left: 4px solid;
}
.arksp-alert-info {
background: var(--arksp-info-bg);
border-left-color: var(--arksp-info);
color: #0a4b78;
}
.arksp-alert-warning {
background: var(--arksp-warning-bg);
border-left-color: var(--arksp-warning);
color: #6e5600;
}
.arksp-alert-error {
background: var(--arksp-danger-bg);
border-left-color: var(--arksp-danger);
color: #8a1f1f;
}
/* Loading states */
.arksp-loading {
opacity: 0.5;
pointer-events: none;
}
/* QR code container */
#arksp-2fa-qr img,
#arksp-2fa-qr svg {
border: 1px solid var(--arksp-border);
padding: 12px;
background: var(--arksp-bg);
border-radius: var(--arksp-radius);
margin: 12px 0;
}
/* Backup codes display */
#arksp-backup-codes-display pre,
#arksp-new-backup-codes {
background: var(--arksp-bg-alt);
padding: 16px;
border-radius: var(--arksp-radius-sm);
font-family: 'SF Mono', Monaco, Consolas, monospace;
font-size: 14px;
line-height: 2;
border: 1px solid var(--arksp-border);
}
/* Scan results */
.arksp-scan-results {
max-height: 400px;
overflow-y: auto;
}
/* Checkbox styling */
.arksp-section input[type="checkbox"] {
margin-right: 10px;
width: 18px;
height: 18px;
}
/* Description text */
.arksp-section .description {
color: var(--arksp-text-light);
font-style: normal;
margin-top: 6px;
font-size: 13px;
line-height: 1.5;
}
/* Tab intro descriptions */
.arksp-section p.arksp-description {
color: var(--arksp-text-light);
font-style: normal;
font-size: 14px;
margin: -8px 0 20px 0;
line-height: 1.6;
}
/* Import/export section */
#arksp-import-file {
margin-right: 12px;
}
#arksp-import-status {
margin-left: 12px;
color: var(--arksp-success);
font-weight: 500;
}
/* System info table */
.arksp-section .widefat td:first-child {
font-weight: 600;
width: 200px;
color: var(--arksp-text);
}
/* Status checklist icons */
.arksp-section .widefat td span[style*="color: #46b450"],
.arksp-section .widefat td span[style*="color: #dc3232"] {
font-size: 20px;
line-height: 1;
}
/* Notice improvements within sections */
.arksp-section .notice {
border-radius: var(--arksp-radius-sm);
margin: 12px 0;
}
/* Input focus states */
.arksp-section input[type="text"]:focus,
.arksp-section input[type="number"]:focus,
.arksp-section textarea:focus,
.arksp-section select:focus {
border-color: var(--arksp-primary);
box-shadow: 0 0 0 1px var(--arksp-primary);
outline: none;
}
/* Textarea styling */
.arksp-section textarea {
border-radius: var(--arksp-radius-sm);
}
/* Select styling */
.arksp-section select {
border-radius: var(--arksp-radius-sm);
}
/* Dashboard widget */
.arksp-widget-score {
text-align: center;
padding: 15px 0;
border-bottom: 1px solid #eee;
margin-bottom: 15px;
}
.arksp-widget-score-value {
font-size: 42px;
font-weight: 700;
line-height: 1;
}
.arksp-widget-score-label {
color: #666;
font-size: 12px;
margin-top: 5px;
}
.arksp-widget-score.good .arksp-widget-score-value { color: #00a32a; }
.arksp-widget-score.warning .arksp-widget-score-value { color: #dba617; }
.arksp-widget-score.bad .arksp-widget-score-value { color: #d63638; }
.arksp-widget-stats {
display: flex;
justify-content: space-around;
text-align: center;
margin-bottom: 15px;
}
.arksp-widget-stat-value {
font-size: 24px;
font-weight: 600;
}
.arksp-widget-stat-label {
font-size: 11px;
color: #666;
}
.arksp-widget-links {
border-top: 1px solid #eee;
padding-top: 12px;
text-align: center;
}
.arksp-widget-links a {
margin: 0 8px;
}
@@ -0,0 +1,6 @@
<?php
/**
* Silence is golden.
*
* @package ArkHost_Security_Pack
*/
+6
View File
@@ -0,0 +1,6 @@
<?php
/**
* Silence is golden.
*
* @package ArkHost_Security_Pack
*/
@@ -0,0 +1,89 @@
/**
* ArkHost Security Pack - 2FA Profile Scripts
*
* Handles 2FA setup, verification, disable, and backup code regeneration
* on the user profile page. Dynamic values are passed via arksp2fa object
* (wp_localize_script).
*/
/* global jQuery, ajaxurl, arksp2fa, qrcode */
jQuery(document).ready(function($) {
$('#arksp-setup-2fa').on('click', function() {
$('#arksp-2fa-setup').show();
$(this).hide();
// Generate new secret.
$.post(ajaxurl, {
action: 'arksp_generate_2fa_secret',
user_id: arksp2fa.userId,
_ajax_nonce: arksp2fa.nonce
}, function(response) {
if (response.success) {
$('#arksp-2fa-secret').text(response.data.secret);
// Generate QR code client-side.
var qr = qrcode(0, 'M');
qr.addData(response.data.otpauth);
qr.make();
$('#arksp-2fa-qr').html(qr.createSvgTag(5, 0));
}
});
});
$('#arksp-verify-2fa-setup').on('click', function() {
var code = $('#arksp-2fa-verify-code').val();
$.post(ajaxurl, {
action: 'arksp_verify_2fa_setup',
user_id: arksp2fa.userId,
code: code,
_ajax_nonce: arksp2fa.nonce
}, function(response) {
if (response.success && response.data.backup_codes) {
// Show backup codes - user MUST save these.
var codesHtml = '<div style="background:#d4edda;border:1px solid #c3e6cb;padding:20px;margin:10px 0;border-radius:4px;">';
codesHtml += '<h3 style="margin-top:0;color:#155724;">' + arksp2fa.strings.twoFaEnabledTitle + '</h3>';
codesHtml += '<p style="color:#dc3232;font-weight:bold;">' + arksp2fa.strings.codesNotShownAgain + '</p>';
codesHtml += '<pre style="background:#fff;padding:15px;font-size:14px;line-height:1.8;">' + response.data.backup_codes.join('\n') + '</pre>';
codesHtml += '<p>' + arksp2fa.strings.storeCodesInfo + '</p>';
codesHtml += '<button type="button" class="button button-primary" onclick="location.reload();">' + arksp2fa.strings.savedCodes + '</button>';
codesHtml += '</div>';
$('#arksp-2fa-setup').html(codesHtml);
} else if (response.success) {
location.reload();
} else {
$('#arksp-2fa-setup-result').html('<p style="color:red;">' + response.data.message + '</p>');
}
});
});
$('#arksp-disable-2fa').on('click', function() {
if (confirm(arksp2fa.strings.confirmDisable)) {
$.post(ajaxurl, {
action: 'arksp_disable_2fa',
user_id: arksp2fa.userId,
_ajax_nonce: arksp2fa.nonce
}, function(response) {
if (response.success) {
location.reload();
}
});
}
});
$('#arksp-regenerate-backup-codes').on('click', function() {
if (confirm(arksp2fa.strings.confirmRegenerate)) {
$.post(ajaxurl, {
action: 'arksp_regenerate_backup_codes',
user_id: arksp2fa.userId,
_ajax_nonce: arksp2fa.nonce
}, function(response) {
if (response.success) {
$('#arksp-new-backup-codes').text(response.data.codes.join('\n'));
$('#arksp-backup-codes-display').show();
}
});
}
});
});
+400
View File
@@ -0,0 +1,400 @@
/**
* ArkHost Security Pack - Admin Scripts
*
* All admin page AJAX handlers. Dynamic values are passed via arkspAdmin object
* (wp_localize_script).
*/
/* global jQuery, ajaxurl, arkspAdmin */
jQuery(document).ready(function($) {
// -------------------------------------------------------------------------
// Status tab: Delete WP info files (readme.html, license.txt).
// -------------------------------------------------------------------------
$('.arksp-delete-file').on('click', function() {
var $btn = $(this);
var file = $btn.data('file');
if (!confirm(arkspAdmin.strings.confirmDeleteFile)) {
return;
}
$btn.prop('disabled', true).text(arkspAdmin.strings.deleting);
$.post(ajaxurl, {
action: 'arksp_delete_wp_file',
file: file,
_ajax_nonce: arkspAdmin.nonce
}, function(response) {
if (response.success) {
$btn.closest('tr').fadeOut();
} else {
alert(response.data.message || arkspAdmin.strings.failedDeleteFile);
$btn.prop('disabled', false).text(arkspAdmin.strings.deleteBtn);
}
});
});
// -------------------------------------------------------------------------
// Login tab: Test email.
// -------------------------------------------------------------------------
$('#arksp-test-email').on('click', function() {
var $btn = $(this);
var $result = $('#arksp-test-email-result');
var email = $('#arksp-alert-email').val() || arkspAdmin.adminEmail;
$btn.prop('disabled', true);
$result.html('<span style="color: #666;">' + arkspAdmin.strings.sending + '</span>');
$.post(ajaxurl, {
action: 'arksp_test_email',
email: email,
_ajax_nonce: arkspAdmin.nonce
}, function(response) {
$btn.prop('disabled', false);
if (response.success) {
$result.html('<span style="color: #46b450;">' + arkspAdmin.strings.testEmailSent + '</span>');
} else {
$result.html('<span style="color: #dc3232;">' + response.data.message + '</span>');
}
}).fail(function() {
$btn.prop('disabled', false);
$result.html('<span style="color: #dc3232;">' + arkspAdmin.strings.requestFailed + '</span>');
});
});
// -------------------------------------------------------------------------
// IP Control tab: Unblock IP and download geo DB.
// -------------------------------------------------------------------------
$('.arksp-unblock-ip').on('click', function() {
var ip = $(this).data('ip');
var $row = $(this).closest('tr');
$.post(ajaxurl, {
action: 'arksp_unblock_ip',
ip: ip,
_ajax_nonce: arkspAdmin.nonce
}, function(response) {
if (response.success) {
$row.fadeOut();
}
});
});
$('#arksp-download-geo-db').on('click', function() {
var $btn = $(this);
$btn.prop('disabled', true).text(arkspAdmin.strings.downloading);
$.post(ajaxurl, {
action: 'arksp_download_geo_db',
_ajax_nonce: arkspAdmin.nonce
}, function(response) {
if (response.success) {
location.reload();
} else {
alert(response.data.message);
$btn.prop('disabled', false).text(arkspAdmin.strings.downloadGeoDb);
}
});
});
// -------------------------------------------------------------------------
// Headers tab: Reset headers and load example CSP.
// -------------------------------------------------------------------------
$('#arksp-reset-headers').on('click', function() {
if (confirm(arkspAdmin.strings.confirmResetHeaders)) {
$('[id^="header-"]').each(function() {
var defaultVal = $(this).data('default');
$(this).val(defaultVal);
});
}
});
$('#arksp-load-example-csp').on('click', function() {
var exampleCSP = "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self'; frame-ancestors 'self'; base-uri 'self'; form-action 'self';";
$('#header-content_security_policy').val(exampleCSP);
});
// -------------------------------------------------------------------------
// Scanner tab: File integrity scan, malware scan, quarantine.
// -------------------------------------------------------------------------
$('#arksp-run-file-scan').on('click', function() {
var $btn = $(this);
$btn.prop('disabled', true).text(arkspAdmin.strings.scanning);
$.post(ajaxurl, {
action: 'arksp_run_file_scan',
_ajax_nonce: arkspAdmin.nonce
}, function() {
location.reload();
});
});
$('#arksp-reset-baseline, #arksp-dismiss-file-changes').on('click', function() {
var $btn = $(this);
$btn.prop('disabled', true);
$.post(ajaxurl, {
action: 'arksp_reset_file_baseline',
_ajax_nonce: arkspAdmin.nonce
}, function() {
location.reload();
});
});
$('#arksp-run-malware-scan').on('click', function() {
var $btn = $(this);
$btn.prop('disabled', true);
$('#arksp-scan-status').text(arkspAdmin.strings.scanningMalware);
$.post(ajaxurl, {
action: 'arksp_run_malware_scan',
_ajax_nonce: arkspAdmin.nonce
}, function() {
location.reload();
});
});
$('#arksp-clear-malware-results').on('click', function() {
var $btn = $(this);
$btn.prop('disabled', true);
$.post(ajaxurl, {
action: 'arksp_clear_malware_results',
_ajax_nonce: arkspAdmin.nonce
}, function() {
location.reload();
});
});
// Quarantine file.
$('.arksp-quarantine-file').on('click', function() {
var $btn = $(this);
var filePath = $btn.data('file');
if (!confirm(arkspAdmin.strings.confirmQuarantine)) {
return;
}
$btn.prop('disabled', true).text(arkspAdmin.strings.moving);
$.post(ajaxurl, {
action: 'arksp_quarantine_file',
file_path: filePath,
_ajax_nonce: arkspAdmin.nonce
}, function(response) {
if (response.success) {
$btn.closest('tr').fadeOut(function() {
$(this).remove();
location.reload();
});
} else {
alert(response.data.message || arkspAdmin.strings.failedQuarantine);
$btn.prop('disabled', false).text(arkspAdmin.strings.quarantineBtn);
}
});
});
// Restore file from quarantine.
$('.arksp-restore-file').on('click', function() {
var $btn = $(this);
var name = $btn.data('name');
if (!confirm(arkspAdmin.strings.confirmRestore)) {
return;
}
$btn.prop('disabled', true).text(arkspAdmin.strings.restoring);
$.post(ajaxurl, {
action: 'arksp_restore_file',
quarantine_name: name,
_ajax_nonce: arkspAdmin.nonce
}, function(response) {
if (response.success) {
location.reload();
} else {
alert(response.data.message || arkspAdmin.strings.failedRestore);
$btn.prop('disabled', false).text(arkspAdmin.strings.restoreBtn);
}
});
});
// Delete quarantined file permanently.
$('.arksp-delete-quarantined').on('click', function() {
var $btn = $(this);
var name = $btn.data('name');
if (!confirm(arkspAdmin.strings.confirmDeletePermanent)) {
return;
}
$btn.prop('disabled', true).text(arkspAdmin.strings.deleting);
$.post(ajaxurl, {
action: 'arksp_delete_quarantined',
quarantine_name: name,
_ajax_nonce: arkspAdmin.nonce
}, function(response) {
if (response.success) {
$btn.closest('tr').fadeOut(function() {
$(this).remove();
});
} else {
alert(response.data.message || arkspAdmin.strings.failedDeleteFile);
$btn.prop('disabled', false).text(arkspAdmin.strings.deleteBtn);
}
});
});
// -------------------------------------------------------------------------
// Logs tab: Filter, export, clear.
// -------------------------------------------------------------------------
$('#arksp-filter-logs').on('click', function() {
var type = $('#arksp-filter-type').val();
var url = new URL(window.location.href);
if (type) {
url.searchParams.set('event_type', type);
} else {
url.searchParams.delete('event_type');
}
url.searchParams.delete('paged');
window.location.href = url.toString();
});
$('#arksp-export-logs').on('click', function() {
$.post(ajaxurl, {
action: 'arksp_export_logs',
_ajax_nonce: arkspAdmin.nonce
}, function(response) {
if (response.success) {
var blob = new Blob([response.data.csv], {type: 'text/csv'});
var url = URL.createObjectURL(blob);
var a = document.createElement('a');
a.href = url;
a.download = 'arkhost-security-pack-logs-' + new Date().toISOString().split('T')[0] + '.csv';
a.click();
URL.revokeObjectURL(url);
}
});
});
$('#arksp-clear-logs').on('click', function() {
if (confirm(arkspAdmin.strings.confirmClearLogs)) {
$.post(ajaxurl, {
action: 'arksp_clear_logs',
_ajax_nonce: arkspAdmin.nonce
}, function(response) {
if (response.success) {
location.reload();
}
});
}
});
// -------------------------------------------------------------------------
// Tools tab: Whitelist IP, clear lockouts, force logout, export/import/reset.
// -------------------------------------------------------------------------
$('#arksp-whitelist-my-ip').on('click', function() {
var $btn = $(this);
$btn.prop('disabled', true);
$.post(ajaxurl, {
action: 'arksp_whitelist_ip',
ip: arkspAdmin.currentIp,
_ajax_nonce: arkspAdmin.nonce
}, function(response) {
if (response.success) {
$('#arksp-whitelist-status').text(arkspAdmin.strings.ipWhitelisted).css('color', 'green');
setTimeout(function() { location.reload(); }, 1000);
} else {
$('#arksp-whitelist-status').text(response.data.message || arkspAdmin.strings.error).css('color', 'red');
$btn.prop('disabled', false);
}
});
});
$('#arksp-clear-lockouts').on('click', function() {
if (confirm(arkspAdmin.strings.confirmClearLockouts)) {
$.post(ajaxurl, {
action: 'arksp_clear_lockouts',
_ajax_nonce: arkspAdmin.nonce
}, function(response) {
if (response.success) {
$('#arksp-lockout-status').text(arkspAdmin.strings.lockoutsCleared).css('color', 'green');
}
});
}
});
$('#arksp-force-logout-all').on('click', function() {
if (confirm(arkspAdmin.strings.confirmForceLogout)) {
$.post(ajaxurl, {
action: 'arksp_force_logout_all',
_ajax_nonce: arkspAdmin.nonce
}, function(response) {
if (response.success) {
$('#arksp-logout-status').text(arkspAdmin.strings.sessionsTerminated).css('color', 'green');
setTimeout(function() {
window.location.href = arkspAdmin.loginUrl;
}, 1500);
}
});
}
});
$('#arksp-export-settings').on('click', function() {
$.post(ajaxurl, {
action: 'arksp_export_settings',
_ajax_nonce: arkspAdmin.nonce
}, function(response) {
if (response.success) {
var blob = new Blob([JSON.stringify(response.data, null, 2)], {type: 'application/json'});
var url = URL.createObjectURL(blob);
var a = document.createElement('a');
a.href = url;
a.download = 'arkhost-security-pack-settings.json';
a.click();
URL.revokeObjectURL(url);
}
});
});
$('#arksp-import-settings').on('click', function() {
var file = $('#arksp-import-file')[0].files[0];
if (!file) {
alert(arkspAdmin.strings.selectFileToImport);
return;
}
var reader = new FileReader();
reader.onload = function(e) {
$.post(ajaxurl, {
action: 'arksp_import_settings',
settings: e.target.result,
_ajax_nonce: arkspAdmin.nonce
}, function(response) {
if (response.success) {
$('#arksp-import-status').text(arkspAdmin.strings.settingsImported).css('color', 'green');
setTimeout(function() { location.reload(); }, 1000);
} else {
$('#arksp-import-status').text(response.data.message).css('color', 'red');
}
});
};
reader.readAsText(file);
});
$('#arksp-reset-settings').on('click', function() {
if (confirm(arkspAdmin.strings.confirmResetSettings)) {
$.post(ajaxurl, {
action: 'arksp_reset_settings',
_ajax_nonce: arkspAdmin.nonce
}, function(response) {
if (response.success) {
location.reload();
}
});
}
});
});
@@ -0,0 +1,2 @@
<?php
// Silence is golden.
File diff suppressed because one or more lines are too long