38428-vm/api/get_latest_tips.php
2026-02-17 19:34:31 +00:00

24 lines
747 B
PHP

<?php
require_once __DIR__ . "/../db/config.php";
header("Content-Type: application/json");
try {
$pdo = db();
// Fetch tips from the last 15 seconds to trigger celebrations
$stmt = $pdo->prepare("SELECT * FROM dj_tips WHERE created_at > (NOW() - INTERVAL 15 SECOND) ORDER BY created_at DESC LIMIT 5");
$stmt->execute();
$tips = $stmt->fetchAll();
// Also get current DJ
$stmt = $pdo->query("SELECT setting_value FROM settings WHERE setting_key = 'current_dj'");
$dj = $stmt->fetchColumn() ?: "Lili";
echo json_encode([
"success" => true,
"tips" => $tips,
"current_dj" => $dj
]);
} catch (Exception $e) {
echo json_encode(["success" => false, "error" => $e->getMessage()]);
}