Files
2026-06-17 15:46:26 +02:00

53 lines
1.0 KiB
PHP

<?php
header('Content-Type: application/json');
require('../inc/connect.php');
$device_id = $_GET["id"];
if($device_id == "")
{
echo '{"error":"device-id not set"}';
exit;
}
// Get all the details for the ID
$sql = "SELECT stream.id, stream.name, stream.ip, stream.port, stream.path FROM stream, device WHERE stream.dev_id=device.id AND device.dev_id='" . $device_id . "'";
$query = ExecQuery($mysqli, $sql);
if ($query->num_rows === 0) {
echo '{"error":"device-id not found", "device-id":"' . $device_id . '"}';
exit;
}
$size = $query->num_rows;
$str = '{"streams": [';
$count = 1;
while ($row = $query->fetch_assoc()) {
$str .= '{"id":"' . $row["id"] . '", ';
$str .= '"name":"' . $row["name"] . '", ';
$str .= '"ip":"' . $row["ip"] . '", ';
$str .= '"port":"' . $row["port"] . '", ';
$str .= '"path":"/' . $row["path"] . '"';
if($count == $query->num_rows)
{
$str .= '}';
}
else
{
$str .= '}, ';
}
$count++;
}
$str .= ']}';
echo $str;
?>