BastionGuard/webui/notification_action.php
specialworld83 f0f913a209 Release 2.0
2026-07-15 10:52:22 +02:00

25 lines
924 B
PHP

<?php
include 'auth.php';
header('Content-Type: application/json; charset=utf-8');
csrf_validate();
$id = trim((string)($_POST['id'] ?? ''));
$action = trim((string)($_POST['action'] ?? ''));
$path = trim((string)($_POST['path'] ?? ''));
if ($id === '' || !in_array($action, ['ignore','quarantine'], true)) {
http_response_code(400);
echo json_encode(['ok'=>false, 'error'=>'Invalid request.']);
exit;
}
$out = '';
$code = 0;
if ($action === 'quarantine') {
$res = bg_quarantine_alert_path($path);
$code = (int)($res['code'] ?? 1);
$out = trim((string)($res['output'] ?? ''));
if ($code !== 0) {
echo json_encode(['ok'=>false, 'error'=>$out ?: 'Quarantine failed.', 'code'=>$code], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
exit;
}
}
bg_alert_mark_handled($id, $action);
echo json_encode(['ok'=>true, 'output'=>$out], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);