'', '443' => '', '1935' => '', '1937' => '', '8080' => '', ]; $data = $defaults; if (is_file($jsonFile)) { $stored = json_decode(file_get_contents($jsonFile), true); if (is_array($stored)) { $data = array_merge($data, $stored); } } if ($_SERVER['REQUEST_METHOD'] === 'POST') { foreach ($defaults as $port => $_) { $data[$port] = trim($_POST["port_$port"] ?? ''); } $tmp = $jsonFile . '.tmp'; file_put_contents( $tmp, json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) ); rename($tmp, $jsonFile); } ?> ?>