Fix php warning + undefined var notice

This commit is contained in:
billz 2023-09-06 12:25:39 +02:00
parent c64bdb42c8
commit ceea867c69
2 changed files with 41 additions and 35 deletions

View File

@ -125,7 +125,11 @@ function DisplaySystem(&$extraFooterScripts)
exec('cat '. RASPI_LIGHTTPD_CONFIG, $return); exec('cat '. RASPI_LIGHTTPD_CONFIG, $return);
$conf = ParseConfig($return); $conf = ParseConfig($return);
$serverPort = $conf['server.port']; $serverPort = $conf['server.port'];
$serverBind = str_replace('"', '',$conf['server.bind']); if (isset($conf['server.bind'])) {
$serverBind = str_replace('"', '',$conf['server.bind']);
} else {
$serverBind = '';
}
// define locales // define locales
$arrLocales = getLocales(); $arrLocales = getLocales();

View File

@ -77,44 +77,46 @@ function nearbyWifiStations(&$networks, $cached = true)
if ( isset($lastnet['index']) ) $index = $lastnet['index'] + 1; if ( isset($lastnet['index']) ) $index = $lastnet['index'] + 1;
} }
array_shift($scan_results); if (is_array($scan_results)) {
foreach ($scan_results as $network) { array_shift($scan_results);
$arrNetwork = preg_split("/[\t]+/", $network); // split result into array foreach ($scan_results as $network) {
$ssid = $arrNetwork[4]; $arrNetwork = preg_split("/[\t]+/", $network); // split result into array
$ssid = $arrNetwork[4];
// exclude raspap ssid // exclude raspap ssid
if (empty($ssid) || $ssid == $ap_ssid) { if (empty($ssid) || $ssid == $ap_ssid) {
continue; continue;
} }
// filter SSID string: unprintable 7bit ASCII control codes, delete or quotes -> ignore network // filter SSID string: unprintable 7bit ASCII control codes, delete or quotes -> ignore network
if (preg_match('[\x00-\x1f\x7f\'\`\´\"]', $ssid)) { if (preg_match('[\x00-\x1f\x7f\'\`\´\"]', $ssid)) {
continue; continue;
} }
// If network is saved // If network is saved
if (array_key_exists($ssid, $networks)) { if (array_key_exists($ssid, $networks)) {
$networks[$ssid]['visible'] = true; $networks[$ssid]['visible'] = true;
$networks[$ssid]['channel'] = ConvertToChannel($arrNetwork[1]); $networks[$ssid]['channel'] = ConvertToChannel($arrNetwork[1]);
// TODO What if the security has changed? // TODO What if the security has changed?
} else { } else {
$networks[$ssid] = array( $networks[$ssid] = array(
'ssid' => $ssid, 'ssid' => $ssid,
'configured' => false, 'configured' => false,
'protocol' => ConvertToSecurity($arrNetwork[3]), 'protocol' => ConvertToSecurity($arrNetwork[3]),
'channel' => ConvertToChannel($arrNetwork[1]), 'channel' => ConvertToChannel($arrNetwork[1]),
'passphrase' => '', 'passphrase' => '',
'visible' => true, 'visible' => true,
'connected' => false, 'connected' => false,
'index' => $index 'index' => $index
); );
++$index; ++$index;
} }
// Save RSSI, if the current value is larger than the already stored // Save RSSI, if the current value is larger than the already stored
if (array_key_exists(4, $arrNetwork) && array_key_exists($arrNetwork[4], $networks)) { if (array_key_exists(4, $arrNetwork) && array_key_exists($arrNetwork[4], $networks)) {
if (! array_key_exists('RSSI', $networks[$arrNetwork[4]]) || $networks[$ssid]['RSSI'] < $arrNetwork[2]) { if (! array_key_exists('RSSI', $networks[$arrNetwork[4]]) || $networks[$ssid]['RSSI'] < $arrNetwork[2]) {
$networks[$ssid]['RSSI'] = $arrNetwork[2]; $networks[$ssid]['RSSI'] = $arrNetwork[2];
}
} }
} }
} }