<?php
// api/export_config.php — Export konfigurasi (tanpa credential sensitif)
session_start();
require_once '../includes/config.php';
require_once '../includes/auth.php';
requireAdmin();

$cfg = loadConfig();

// Hapus semua credential sebelum export
$sensitiveKeys = ['ft_pass','ft_api_key','ar_client_secret','sl_token','anthropic_key','admin_pass'];
foreach ($sensitiveKeys as $k) {
    if (isset($cfg[$k])) $cfg[$k] = '*** REDACTED ***';
}

$cfg['exported_at'] = date('Y-m-d H:i:s');
$cfg['app_version'] = APP_VERSION;

header('Content-Type: application/json');
header('Content-Disposition: attachment; filename="ship-network-config-' . date('Ymd') . '.json"');
echo json_encode($cfg, JSON_PRETTY_PRINT);
