27 lines
662 B
PHP
27 lines
662 B
PHP
<?php
|
|
session_start();
|
|
|
|
if (!isset($_SESSION['user_id'])) {
|
|
header("HTTP/1.1 401 Unauthorized");
|
|
exit();
|
|
}
|
|
|
|
require_once 'db/config.php';
|
|
|
|
if (isset($_GET['id'])) {
|
|
$event_id = $_GET['id'];
|
|
$pdo = db();
|
|
$stmt = $pdo->prepare("SELECT c.*, t.name as type_name FROM calendar_events c LEFT JOIN event_types t ON c.event_type_id = t.id WHERE c.id = ?");
|
|
$stmt->execute([$event_id]);
|
|
$event = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
|
if ($event) {
|
|
header('Content-Type: application/json');
|
|
echo json_encode($event);
|
|
} else {
|
|
header("HTTP/1.1 404 Not Found");
|
|
}
|
|
} else {
|
|
header("HTTP/1.1 400 Bad Request");
|
|
}
|