hostname(); $revision = $system->rpiRevision(); $hostapd = $system->hostapdStatus(); $adblock = $system->adBlockStatus(); $vpn = $system->getActiveVpnInterface(); $frequency = $dashboard->getFrequencyBand($interface); $details = $dashboard->getInterfaceDetails($interface); $wireless = $dashboard->getWirelessDetails($interface); $connectionType = $dashboard->getConnectionType(); $connectionIcon = $dashboard->getConnectionIcon($connectionType); $state = strtolower($details['state']); $wirelessClients = $dashboard->getWirelessClients(); $ethernetClients = $dashboard->getEthernetClients(); $totalClients = $wirelessClients + $ethernetClients; $plugins = $pluginManager->getInstalledPlugins(); $arrHostapdConf = parse_ini_file(RASPI_CONFIG.'/hostapd.ini'); $bridgedEnable = $arrHostapdConf['BridgedEnable']; // handle page actions if (!empty($_POST)) { $status = $dashboard->handlePageAction($state, $_POST, $status, $interface); // refresh interface details + state $details = $dashboard->getInterfaceDetails($interface); $state = strtolower($details['state']); } $ipv4Address = $details['ipv4']; $ipv4Netmask = $details['ipv4_netmask']; $macAddress = $details['mac']; $ssid = $wireless['ssid']; $ethernetActive = ($connectionType === 'ethernet') ? "active" : ""; $wirelessActive = ($connectionType === 'wireless') ? "active" : ""; $tetheringActive = ($connectionType === 'tethering') ? "active" : ""; $cellularActive = ($connectionType === 'cellular') ? "active" : ""; $bridgedStatus = ($bridgedEnable == 1) ? "active" : ""; $hostapdStatus = ($hostapd[0] == 1) ? "active" : ""; $adblockStatus = ($adblock == true) ? "active" : ""; $wirelessClientLabel = $wirelessClients. ' WLAN '.$dashboard->formatClientLabel($wirelessClients); $ethernetClientLabel = $ethernetClients. ' LAN '.$dashboard->formatClientLabel($ethernetClients); $freq5active = $freq24active = ""; $varName = "freq" . str_replace('.', '', $frequency) . "active"; $$varName = "active"; $vpnStatus = $vpn ? "active" : "inactive"; if ($vpn) { $vpnManaged = $dashboard->getVpnManged($vpn); } $firewallStatus = ""; $firewallInstalled = array_filter($plugins, fn($p) => str_ends_with($p, 'Firewall')) ? true : false; if (!$firewallInstalled) { $firewallUnavailable = ''; } else { $firewallStatus = ($dashboard->firewallEnabled() == true) ? "active" : ""; } echo renderTemplate( "dashboard", compact( "revision", "interface", "clientInterface", "state", "bridgedStatus", "hostapdStatus", "adblockStatus", "vpnStatus", "vpnManaged", "firewallUnavailable", "firewallStatus", "ipv4Address", "ipv4Netmask", "macAddress", "ssid", "frequency", "freq5active", "freq24active", "wirelessClients", "ethernetClients", "wirelessClientLabel", "ethernetClientLabel", "totalClients", "connectionType", "connectionIcon", "ethernetActive", "wirelessActive", "tetheringActive", "cellularActive", "status" ) ); } /** * Renders a URL for an svg solid line representing the associated * connection type * * @param string $connectionType * @return string */ function renderConnection(string $connectionType): string { $deviceMap = [ 'ethernet' => 'device-1', 'wireless' => 'device-2', 'tethering' => 'device-3', 'cellular' => 'device-4' ]; $device = $deviceMap[$connectionType] ?? 'device-unknown'; // return generated URL for solid.php return sprintf('app/img/solid.php?joint&%s&out', $device); } /** * Renders a URL for an svg solid line representing associated * client connection(s) * * @param int $wirelessClients * @param int $ethernetClients * @return string */ function renderClientConnections(int $wirelessClients, int $ethernetClients): string { $devices = []; if ($wirelessClients > 0) { $devices[] = 'device-1&out'; } if ($ethernetClients > 0) { $devices[] = 'device-2&out'; } return empty($devices) ? '' : sprintf( 'Client connections', implode('&', $devices) ); }