<?php
/**
 * Admin Panel Index
 * Redirects to login if not authenticated, otherwise to dashboard
 */

session_start();

if (isset($_SESSION['admin_user_id'])) {
    // Use relative path to work with both /admin/ and /backend/admin/
    $basePath = strpos($_SERVER['REQUEST_URI'], '/backend/admin') === 0 ? '/backend/admin' : '/admin';
    header('Location: ' . $basePath . '/dashboard.php');
    exit;
} else {
    // Use relative path to work with both /admin/ and /backend/admin/
    $basePath = strpos($_SERVER['REQUEST_URI'], '/backend/admin') === 0 ? '/backend/admin' : '/admin';
    header('Location: ' . $basePath . '/login.php');
    exit;
}

