<?php
// Set the content type to application/json to ensure the client receives a JSON response
header('Content-Type: application/json');

// Define the path to the configuration file
$configFilePath = '../../database/config.json';

// Check if the file exists and is readable
if (!file_exists($configFilePath) || !is_readable($configFilePath)) {
    // If the file is not found or not readable, return an error message as JSON
    echo json_encode(['status' => 'error', 'message' => 'Configuration file not found or is unreadable.']);
    exit;
}

// Read the content of the configuration file
$configContent = file_get_contents($configFilePath);

// Check if reading the file content was successful
if ($configContent === false) {
    // If reading failed, return an error message
    echo json_encode(['status' => 'error', 'message' => 'Failed to read configuration file content.']);
    exit;
}

// Return the content of the file.
// Since the file is already in JSON format, we can simply echo it.
echo $configContent;
?>
