<?php
/**
 * get-data.php — GET -> returns { promos: [...], testimonials: [...] }
 * Read-only, requires login.
 */
require_once __DIR__ . '/auth.php';
header('Content-Type: application/json');

function read_json($path, $fallback) {
    if (!file_exists($path)) return $fallback;
    $raw = file_get_contents($path);
    $data = json_decode($raw, true);
    return is_array($data) ? $data : $fallback;
}

echo json_encode([
    'promos' => read_json(DATA_DIR . 'promos.json', []),
    'testimonials' => read_json(DATA_DIR . 'testimonials.json', []),
]);
