<?php
// index.php – route to wizard on first run, otherwise to login/dashboard.
require_once __DIR__ . '/env_loader.php';
osce_load_env();

if (!osce_env_present() || osce_env('DB_NAME', '') === '') {
    header('Location: setup.php');
    exit;
}

if (session_status() === PHP_SESSION_NONE) {
    session_name('OSCESESSID');
    session_start();
}

if (!empty($_SESSION['user_id'])) {
    header('Location: dashboard.php');
} else {
    header('Location: login.php');
}
exit;
