Files
AvianVisitors/avian/api/menu.php
T
Twarner491 0105fb54f0 Menu: rename 'avianvisitors' link to 'github' + add built-by attribution
avian/api/menu.php: 4th drawer link label is now 'github' (shorter,
matches what the link actually points to).

avian/frontend/index.html: 'built by teddy' attribution sits below
the menu items (sibling of #dd-items inside #menu-dd) so it shows in
both local and forwarded modes. Drops the redundant 'built with
AvianVisitors' line that lived inside the lock screen - the github
menu item covers source-of-truth attribution.
2026-05-28 12:10:09 -07:00

38 lines
1.6 KiB
PHP

<?php
// AvianVisitors - drawer menu items.
//
// Returns the list of links shown in the side drawer when a user clicks
// the menu button. The live JS expects {items: [{label, href, native}]}.
//
// Default LAN deploy: returns items immediately, no auth.
// Forwarded deploy: set AV_REQUIRE_AUTH=1 in /etc/avian/env (or in your
// php-fpm pool's env block) AND configure Caddy basic_auth on /avian/api/
// to force the lock screen.
declare(strict_types=1);
header('Content-Type: application/json; charset=utf-8');
header('Cache-Control: no-store');
// If forwarded mode is on AND no Basic-auth header arrived, 401 so the
// frontend shows the lock screen. The actual credential check is done
// by Caddy (basic_auth directive in forwarding/caddy-auth.caddy); this
// PHP only checks that *some* Authorization header reached us.
if (getenv('AV_REQUIRE_AUTH') === '1' && empty($_SERVER['HTTP_AUTHORIZATION'])) {
http_response_code(401);
echo json_encode(['error' => 'unauthorized']);
exit;
}
echo json_encode([
'items' => [
// Stock BirdNET-Pi UI (AvianVisitors took over `/`, so the stock
// UI is reachable at /index.php directly)
['label' => 'birdnet-pi', 'href' => '/index.php', 'native' => false],
// BirdNET-Pi log view (php served at /views.php)
['label' => 'logs', 'href' => '/views.php?view=Log+Out', 'native' => false],
['label' => 'system', 'href' => '/views.php?view=Services', 'native' => false],
// AvianVisitors source
['label' => 'github', 'href' => 'https://github.com/Twarner491/AvianVisitors', 'native' => false],
],
]);