<?php
        require __DIR__ . '/core/config.php';

        // error_reporting(0); // Producción
        error_reporting(E_ALL);
        ini_set('display_errors', 1);
        ini_set('log_errors', 1);
        ini_set('error_log', '/var/log/php_errors.log'); // crea un log apartea

        // Establece la zona horaria para fechas
        date_default_timezone_set('America/Mexico_City');

        /*
                especifica si las cookies solo deben enviarse a través de conexiones seguras (HTTPS).
                Si está utilizando HTTP, no obtendrá ninguna cookie del servidor
        */
        // Iniciar la Sesion en Modo Seguro y HTTPS si esta habilitado
        $https = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443;

        $view = isset($_GET['view']) ? htmlentities($_GET['view']) : 'home';

        if ($view === 'index') {
                $view = 'home';
        }

        if (file_exists(VIEWS_PATH . '/' . $view . '.php')) {
        ?>
        <!DOCTYPE html>

        <html lang="es-MX" lang=en ontouchmove>

        <head>
                <?php include 'vistas/inc/head.php' ?>
        </head>
        <body class="over-hidden">
                <?php
                        include 'vistas/inc/header.php';
                        include VIEWS_PATH . '/' . $view . '.php';
                        include 'vistas/inc/footer.php';
                        include 'vistas/inc/scripts.php';
                ?>
        </body>
        </html>
        <?php
        } else {
                http_response_code(404);
                echo "Vista no encontrada";
        }
        ?>
