Add connected device for bridged, edit regex

This commit is contained in:
Taikuh 2020-03-24 20:40:18 +08:00
parent 80b0634d2d
commit c2cff9d947
1 changed files with 11 additions and 4 deletions

View File

@ -1,11 +1,18 @@
<?php
$arrHostapdConf = parse_ini_file('/etc/raspap/hostapd.ini');
if ($arrHostapdConf['WifiAPEnable'] == 1) {
$client_iface = 'uap0';
$client_iface = 'uap0';
} else {
$client_iface = RASPI_WIFI_CLIENT_INTERFACE;
$client_iface = RASPI_WIFI_CLIENT_INTERFACE;
}
$MACPattern = '([[:xdigit:]]{2}:){5}[[:xdigit:]]{2}';
if ($arrHostapdConf['BridgedEnable'] == 1) {
$moreLink = "index.php?page=hostapd_conf";
exec('arp -i '.$client_iface.' -a | grep -E $(iw dev '.$client_iface.' station dump | grep -oE '.$MACPattern.' | paste -sd "|") | tr -d "()" | awk -F" " \'{print $7 " " $4 " " $2 " " $1}\'', $clients);
} else {
$moreLink = "index.php?page=dhcpd_conf";
exec('cat '.RASPI_DNSMASQ_LEASES.'| grep -E $(arp -i '.$client_iface.' -n | grep -oE '.$MACPattern.' | paste -sd "|")', $clients);
}
exec('cat '.RASPI_DNSMASQ_LEASES.'| grep -E $(arp -i '.$client_iface.' -n | grep -oE "(([0-9]|[a-f]|[A-F]){2}:){5}([0-9]|[a-f]|[A-F]){2}" | tr "\n" "\|" | sed "s/.$//")', $clients);
$ifaceStatus = $wlan0up ? "up" : "down";
?>
<div class="row">
@ -89,7 +96,7 @@ $ifaceStatus = $wlan0up ? "up" : "down";
</table>
<?php if (sizeof($clients) >2) : ?>
<div class="col-lg-12 float-right">
<a class="btn btn-outline-info" role="button" href="index.php?page=dhcpd_conf"><?php echo _("More");?> <i class="fas fa-chevron-right"></i></a>
<a class="btn btn-outline-info" role="button" href="<?php echo $moreLink ?>"><?php echo _("More");?> <i class="fas fa-chevron-right"></i></a>
</div>
<?php elseif (sizeof($clients) ==0) : ?>
<div class="col-lg-12 mt-3"><?php echo _("No connected devices");?></div>