Files

42 lines
1.6 KiB
PHP

<?php
/*
* Reflector Dashboard — web front-end for SvxReflector
* Copyright (C) 2026 SA7AUX (Björn)
* SPDX-License-Identifier: AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version. See the LICENSE file for details.
*/
declare(strict_types=1);
require __DIR__ . '/auth/lib.php';
// Public canonical TG list. Reads the SVX JSON file (source of truth; DMR is
// Redis, not this). No auth — the URL every box/program fetches. The internal
// 'owner'/'admins' fields are NOT exposed here (edit-authority, not display).
$p = cfg()['tglist_file'] ?? '/etc/svxlink/tglist.json';
$tgs = [];
if (is_string($p) && is_file($p)) {
$raw = @file_get_contents($p);
$j = json_decode((string)$raw, true);
if (is_array($j) && isset($j['tgs']) && is_array($j['tgs'])) {
foreach ($j['tgs'] as $o) {
if (!is_array($o)) continue;
$tgs[] = [
'tg' => (int)($o['tg'] ?? 0),
'name' => (string)($o['name'] ?? ''),
'system' => (string)($o['system'] ?? ''),
'allstar' => (string)($o['allstar'] ?? ''),
'mode' => (string)($o['mode'] ?? ''),
];
}
}
}
usort($tgs, fn($a, $b) => $a['tg'] <=> $b['tg']);
header('Content-Type: application/json; charset=utf-8');
header('Cache-Control: public, max-age=60');
echo json_encode(['ok' => true, 'count' => count($tgs), 'tgs' => $tgs], JSON_UNESCAPED_SLASHES);