![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/soundstudiopro.com/public_html/radio/api/v1/endpoints/ |
<?php
/**
* Get stream status
*/
// Get stream for this station
$stmt = $pdo->prepare("
SELECT rs.*,
(SELECT COUNT(*) FROM radio_listeners WHERE stream_id = rs.id AND disconnected_at IS NULL) as current_listeners
FROM radio_streams rs
WHERE rs.station_id = ?
ORDER BY rs.started_at DESC
LIMIT 1
");
$stmt->execute([$station['id']]);
$stream = $stmt->fetch();
if (!$stream) {
echo json_encode([
'is_live' => false,
'stream' => null
]);
exit;
}
// Get current track
$stmt = $pdo->prepare("
SELECT np.*, mt.title, mt.audio_url, mt.image_url,
u.name as artist_name
FROM radio_now_playing np
JOIN music_tracks mt ON np.track_id = mt.id
LEFT JOIN users u ON mt.user_id = u.id
WHERE np.stream_id = ? AND np.ended_at IS NULL
ORDER BY np.started_at DESC
LIMIT 1
");
$stmt->execute([$stream['id']]);
$now_playing = $stmt->fetch();
// Get queue count
$stmt = $pdo->prepare("
SELECT COUNT(*) as queue_count
FROM radio_stream_queue
WHERE stream_id = ? AND played_at IS NULL
");
$stmt->execute([$stream['id']]);
$queue = $stmt->fetch();
$stream['current_listeners'] = (int)$stream['current_listeners'];
$stream['now_playing'] = $now_playing;
$stream['queue_count'] = (int)$queue['queue_count'];
echo json_encode([
'is_live' => (bool)$stream['is_live'],
'stream' => $stream
]);