<?php
// Set the header to tell the browser we are returning JSON
header('Content-Type: application/json');

// Path to the settings JSON file
$settingsFilePath = '../../database/settings/settings.json';

// Check if the settings file exists
if (file_exists($settingsFilePath)) {
    // Read the contents of the file
    $settingsContent = file_get_contents($settingsFilePath);

    // Decode the JSON data into a PHP associative array
    $settingsData = json_decode($settingsContent, true);

    // Check if JSON decoding was successful
    if ($settingsData !== null) {
        // Return the settings data as a JSON response
        echo json_encode($settingsData);
    } else {
        // If JSON decoding failed, send an error response
        echo json_encode(['status' => 'error', 'message' => 'Error decoding JSON data.']);
    }
} else {
    // If the settings file doesn't exist, send an error response
    echo json_encode(['status' => 'error', 'message' => 'Settings file not found.']);
}
?>
