$defaultQdir,'restore_dir'=>'/tmp/bastionguard-restore']); // The privileged helper uses the shared quarantine directory. Keeping it fixed avoids // PHP permission problems and makes restore/delete work even when files are owned by root. $qdir = $defaultQdir; $restoreDir = trim((string)($cfg['restore_dir'] ?? '/tmp/bastionguard-restore')) ?: '/tmp/bastionguard-restore'; if ($_SERVER['REQUEST_METHOD'] === 'POST') { csrf_validate(); $action = $_POST['action'] ?? ''; if ($action === 'save-dir') { $cfg['dir'] = $defaultQdir; $cfg['restore_dir'] = trim($_POST['restore_dir'] ?? $restoreDir) ?: $restoreDir; bg_write_json('quarantine.json', $cfg); bg_flash('success', bg_language()==='en' ? 'Quarantine options saved.' : 'Opzioni quarantena salvate.'); bg_redirect('quarantine.php'); } $file = basename((string)($_POST['file'] ?? '')); if ($file === '' || $file === '.' || $file === '..') { bg_flash('danger', bg_language()==='en' ? 'Invalid quarantine item.' : 'Elemento quarantena non valido.'); bg_redirect('quarantine.php'); } if ($action === 'delete') { $res = bg_quarantine_delete_item($file); bg_flash(($res['code'] ?? 1) === 0 ? 'success' : 'danger', trim((string)($res['output'] ?? '')) ?: (($res['code'] ?? 1) === 0 ? 'Deleted.' : 'Deletion failed.')); bg_redirect('quarantine.php'); } if ($action === 'restore') { $res = bg_quarantine_restore_item($file, $restoreDir); bg_flash(($res['code'] ?? 1) === 0 ? 'success' : 'danger', trim((string)($res['output'] ?? '')) ?: (($res['code'] ?? 1) === 0 ? 'Restored.' : 'Restore failed.')); bg_redirect('quarantine.php'); } bg_redirect('quarantine.php'); } $files = []; if (is_dir($qdir)) { foreach (scandir($qdir) ?: [] as $f) { if ($f === '.' || $f === '..' || $f === '.metadata') continue; $p = $qdir . '/' . $f; if (!is_file($p)) continue; $meta = bg_quarantine_metadata($qdir, $f); $files[] = [ 'name'=>$f, 'size'=>@filesize($p) ?: 0, 'mtime'=>@filemtime($p) ?: 0, 'original_path'=>(string)($meta['original_path'] ?? ''), 'quarantined_at'=>(string)($meta['quarantined_at'] ?? ''), ]; } usort($files, function($a,$b){ return ($b['mtime'] <=> $a['mtime']); }); } include 'includes/header.php'; include 'includes/sidebar.php'; $lang = bg_language(); ?>

'.bg_e($f['original_path']).'' : ''.($lang==='en'?'unknown':'sconosciuto').'' ?>