25 lines
924 B
PHP
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);
|