Transfer template logic to includes, see #749 thx @mp035

This commit is contained in:
billz
2021-02-02 12:26:14 +00:00
parent 3d2d608477
commit b21ea0d28d
19 changed files with 216 additions and 193 deletions

View File

@@ -2,6 +2,7 @@
require_once 'includes/config.php';
require_once 'includes/wifi_functions.php';
require_once 'includes/functions.php';
/**
* Show dashboard page.
@@ -136,7 +137,7 @@ function DisplayDashboard(&$extraFooterScripts)
if ($signalLevel >= 0) {
$strLinkQuality = 100;
} else {
$strLinkQuality = 100 + $signalLevel;
$strLinkQuality = 100 + intval($signalLevel);
}
}
@@ -177,9 +178,30 @@ function DisplayDashboard(&$extraFooterScripts)
$status->addMessage(sprintf(_('Interface is %s.'), strtolower($interfaceState)), $classMsgDevicestatus);
}
}
// brought in from template
$arrHostapdConf = parse_ini_file(RASPI_CONFIG.'/hostapd.ini');
$bridgedEnable = $arrHostapdConf['BridgedEnable'];
$clientInterface = $_SESSION['wifi_client_interface'];
$apInterface = $_SESSION['ap_interface'];
$MACPattern = '"([[:xdigit:]]{2}:){5}[[:xdigit:]]{2}"';
if (getBridgedState()) {
$moreLink = "hostapd_conf";
exec('iw dev ' . $apInterface . ' station dump | grep -oE ' . $MACPattern, $clients);
} else {
$moreLink = "dhcpd_conf";
exec('cat ' . RASPI_DNSMASQ_LEASES . '| grep -E $(iw dev ' . $apInterface . ' station dump | grep -oE ' . $MACPattern . ' | paste -sd "|")', $clients);
}
$ifaceStatus = $wlan0up ? "up" : "down";
echo renderTemplate(
"dashboard", compact(
"clients",
"moreLink",
"apInterface",
"clientInterface",
"ifaceStatus",
"bridgedEnable",
"status",
"ipv4Addrs",
"ipv4Netmasks",