<!DOCTYPE html>
<html>

<head>
    <title>Edit JSON File</title>
</head>

<body>

    <?php
    // Function to update JSON file
    function updateConfig($newValue)
    {
        // Read the JSON file
        $file = 'a.json';
        $data = file_get_contents($file);
        $json = json_decode($data, true);

        // Modify the JSON data
        $json['config'] = $newValue;

        // Write the modified data back to the file
        file_put_contents($file, json_encode($json, JSON_PRETTY_PRINT));

        echo "JSON file has been updated.";
    }

    // Read the JSON file to determine which radio button should be checked
    $file = 'a.json';
    $data = file_get_contents($file);
    $json = json_decode($data, true);
    $currentValue = $json['config'];
    ?>

    <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>">
        <label><input type="radio" name="config" value="true" <?php if ($currentValue == "true")
            echo "checked"; ?>>
            Erro 404</label>
        <label><input type="radio" name="config" value="false" <?php if ($currentValue == "false")
            echo "checked"; ?>>
            Error 404.</label><br>
        <input type="submit" name="submit" value="Error 404">
    </form>

    <?php
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        if (isset($_POST['config'])) {
            $newValue = $_POST['config'];
            updateConfig($newValue);
        } else {
            echo "No data received!";
        }
    }
    ?>

</body>

</html>