diff --git a/ajax/networking/wifi_stations.php b/ajax/networking/wifi_stations.php index 7d9bb82ef..10f2bd8d0 100644 --- a/ajax/networking/wifi_stations.php +++ b/ajax/networking/wifi_stations.php @@ -1,18 +1,7 @@ addMessage('Adblock configuration updated successfully', 'success'); - } else { - $status->addMessage('Adblock configuration failed to be updated.', 'danger'); - } - } elseif (isset($_POST['restartadblock']) || isset($_POST['startadblock'])) { - exec('sudo /bin/systemctl restart dnsmasq.service', $dnsmasq, $return); - if ($return == 0) { - $status->addMessage('Adblock restart successful', 'success'); - } else { - $status->addMessage('Adblock failed to restart.', 'danger'); - } - } - } - - exec('cat '. RASPI_ADBLOCK_CONFIG, $return); - $arrConf = ParseConfig($return); - if (sizeof($arrConf) > 0) { - $enabled = true; - } - - exec('pidof dnsmasq | wc -l', $dnsmasq); - $dnsmasq_state = ($dnsmasq[0] > 0); - $serviceStatus = $dnsmasq_state && $enabled ? "up" : "down"; - - echo renderTemplate( - "adblock", compact( - "status", - "serviceStatus", - "dnsmasq_state", - "enabled" - ) - ); +{ $config = getAdBlockConfig(); + echo renderTemplate("adblock", $config); } - diff --git a/includes/functions.php b/includes/functions.php index 55d1d1f7e..372672094 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -1,5 +1,6 @@ addMessage('Adblock configuration updated successfully', 'success'); + } else { + $status->addMessage('Adblock configuration failed to be updated.', 'danger'); + } + } elseif (isset($_POST['restartadblock']) || isset($_POST['startadblock'])) { + exec('sudo /bin/systemctl restart dnsmasq.service', $dnsmasq, $return); + if ($return == 0) { + $status->addMessage('Adblock restart successful', 'success'); + } else { + $status->addMessage('Adblock failed to restart.', 'danger'); + } + } + } + + exec('cat '. RASPI_ADBLOCK_CONFIG, $return); + $arrConf = ParseConfig($return); + if (sizeof($arrConf) > 0) { + $enabled = true; + } + + exec('pidof dnsmasq | wc -l', $dnsmasq); + $dnsmasq_state = ($dnsmasq[0] > 0); + $serviceStatus = $dnsmasq_state && $enabled ? "up" : "down"; + + return compact( + "status", + "serviceStatus", + "dnsmasq_state", + "enabled" + ); +} + diff --git a/includes/wifi_functions.php b/includes/wifi_functions.php index 248cbda0f..4fa500842 100755 --- a/includes/wifi_functions.php +++ b/includes/wifi_functions.php @@ -1,6 +1,7 @@ ignore network - if (preg_match('[\x00-\x1f\x7f-\xff\'\`\´\"]', $ssid)) { + if (preg_match('[\x00-\x1f\x7f-\xff\'\`\�\"]', $ssid)) { continue; } @@ -133,3 +134,16 @@ function sortNetworksByRSSI(&$networks) $networks[$SSID]['RSSI'] = $RSSI; } } + +function getWifiStations() { + $networks = []; + $network = null; + $ssid = null; + + knownWifiStations($networks); + nearbyWifiStations($networks, !isset($_REQUEST["refresh"])); + connectedWifiStations($networks); + sortNetworksByRSSI($networks); + + return $networks; +} \ No newline at end of file diff --git a/rest/get_adblock_config.php b/rest/get_adblock_config.php new file mode 100755 index 000000000..1f3289149 --- /dev/null +++ b/rest/get_adblock_config.php @@ -0,0 +1,4 @@ +