<?php
include("conn.php");

$query = "SELECT atadaaidi, UNIX_TIMESTAMP(dinankavannuracisi) AS timestamp FROM `gelluonduhogu` ORDER BY kramasankhye DESC LIMIT 1";
$result = $conn->query($query);

if ($result && $row = $result->fetch_assoc()) {
    echo json_encode([
        "success" => true,
        "period_id" => $row['atadaaidi'],
        "start_time" => (int)$row['timestamp'],
        "server_time" => time()
    ]);
} else {
    echo json_encode(["success" => false]);
}
?>

