0) { ob_end_clean(); } header('Content-Type: application/gzip'); header('Content-Disposition: attachment; filename="' . basename($path) . '"'); header('Content-Length: ' . filesize($path)); readfile($path); exit; } if ($_SERVER['REQUEST_METHOD'] === 'POST') { $do = (string)($_POST['do'] ?? ''); if ($do === 'create') { list($ok, $result) = znote_backups_create(); if ($ok) { $removed = znote_backups_prune($retention); acp_log('backups.create', $result, ['pruned' => $removed]); acp_flash_success(t_default('acp.bkp.created', 'Backup created: {name}.', ['name' => h($result)])); } else { acp_flash_error(t_default('acp.bkp.create_failed', 'Backup failed: {error}', ['error' => h($result)])); } acp_redirect('backups'); } if ($do === 'delete') { $name = (string)($_POST['name'] ?? ''); if (znote_backups_delete($name)) { acp_log('backups.delete', $name); acp_flash_success(t_default('acp.bkp.deleted', 'Backup deleted.')); } else { acp_flash_error(t_default('acp.bkp.delete_failed', 'Could not delete that backup.')); } acp_redirect('backups'); } if ($do === 'retention') { $value = max(1, min(100, intv($_POST['retention'] ?? 10))); setting_set($retentionKey, (string)$value); acp_log('backups.retention', (string)$value); acp_flash_success(t_default('acp.bkp.retention_saved', 'Kept backups set to {n}.', ['n' => $value])); acp_redirect('backups'); } } $backups = znote_backups_list(); $totalSize = array_sum(array_column($backups, 'size')); ?>
= t_default('acp.bkp.create_sub', 'A full SQL dump of the database, compressed. Restorable with any MySQL client - nothing ZnoteX-specific about the file.') ?>