<?php
require_once __DIR__ . '/../../config/config.php';
requireLogin();

$db = getDB();
$tipo = $_GET['tipo'] ?? '';

$stmt = $db->query("SELECT * FROM configuracion LIMIT 1");
$config = $stmt->fetch();

if ($tipo == 'logo' && !empty($config['logo'])) {
    header('Content-Type: image/' . $config['logo_extension']);
    echo $config['logo'];
} elseif ($tipo == 'sello' && !empty($config['sello_jvc'])) {
    header('Content-Type: image/' . $config['sello_extension']);
    echo $config['sello_jvc'];
} else {
    // Imagen por defecto
    header('Content-Type: image/png');
    readfile(__DIR__ . '/../../assets/default-logo.png');
}
