<?php

declare(strict_types=1);



session_start();

require_once '../../../config.php';

require_once dirname(__DIR__) . '/helpers.php';



header('Content-Type: application/json');



if (!isset($_SESSION['user_id'])) {

    http_response_code(401);

    echo json_encode([]);

    exit;

}



$conn = getDBConnection();

if (!$conn) {

    echo json_encode([]);

    exit;

}



$class_name = trim((string)($_GET['class_name'] ?? $_POST['class_name'] ?? ''));

echo json_encode(timetableGetPeriods($conn, $class_name));



