<?php
session_start();

function checkLogin() {
    if (!isset($_SESSION['id_guru'])) {
        header("Location: login.php");
        exit();
    }
}

function getCurrentUser() {
    if (isset($_SESSION['id_guru'])) {
        return [
            'id_guru' => $_SESSION['id_guru'],
            'nama_guru' => $_SESSION['nama_guru'],
            'email' => $_SESSION['email'],
            'id_kelas' => $_SESSION['id_kelas'] ?? null,
            'nama_kelas' => $_SESSION['nama_kelas'] ?? null
        ];
    }
    return null;
}
?>
