true, 'count' => count($rows), 'domains' => $rows], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); exit; } if ($action === 'csv') { $rows = ds_normalize_domains(ds_fetch_domains()); ds_save_exports($rows); header('Content-Type: text/csv; charset=utf-8'); header('Content-Disposition: attachment; filename="godaddy-domain-inventory-' . date('Y-m-d-His') . '.csv"'); echo ds_csv($rows); exit; } if ($action === 'save') { $rows = ds_normalize_domains(ds_fetch_domains()); $files = ds_save_exports($rows); header('Content-Type: application/json; charset=utf-8'); echo json_encode(['ok' => true, 'count' => count($rows), 'files' => $files], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); exit; } if ($action === 'config-check') { $creds = ds_credentials(); $settings = ds_settings(); header('Content-Type: application/json; charset=utf-8'); echo json_encode([ 'ok' => true, 'credentials_present' => ($creds['key'] !== '' && $creds['secret'] !== ''), 'api_base_url' => $settings['api_base_url'], 'shopper_id_present' => !empty($settings['shopper_id']), 'destructive_actions_implemented' => false ], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); exit; } http_response_code(400); header('Content-Type: application/json; charset=utf-8'); echo json_encode(['ok' => false, 'error' => 'Unknown action'], JSON_PRETTY_PRINT); } catch (Throwable $e) { http_response_code(500); header('Content-Type: application/json; charset=utf-8'); echo json_encode(['ok' => false, 'error' => $e->getMessage()], JSON_PRETTY_PRINT); }