Files
netconfig/ajax/export.php
T

29 lines
770 B
PHP
Raw Normal View History

2026-05-22 13:37:55 +02:00
<?php
declare(strict_types=1);
include('../../../inc/includes.php');
header("Content-Type: application/octet-stream");
header("Pragma: no-cache");
Html::header_nocache();
$id = (int)($_GET['id'] ?? 0);
if (!$id || !\PluginNetconfig\Config::canView()) {
http_response_code(403);
exit('Access denied');
}
$config = new \PluginNetconfig\Config();
if (!$config->getFromDB($id)) {
http_response_code(404);
exit('Configuration not found');
}
$content = $config->getDecryptedContent();
// Opzionale: mascheramento credenziali
$content = preg_replace('/(?<=password\s|secret\s|enable\s)[^\s\r\n]+/i', '***REDACTED***', $content);
header('Content-Disposition: attachment; filename="netconfig_' . $id . '_' . date('Ymd_His') . '.txt"');
echo $content;
exit;