mirror of
https://github.com/billz/raspap-webgui.git
synced 2025-03-01 10:31:47 +00:00
Replaced tabs w/ spaces, applied PSR-2 code standard
This commit is contained in:
parent
b128c4106c
commit
1a8ffd94fc
@ -52,7 +52,8 @@ function nearbyWifiStations(&$networks, $cached = true)
|
|||||||
}
|
}
|
||||||
|
|
||||||
$scan_results = cache(
|
$scan_results = cache(
|
||||||
$cacheKey, function () {
|
$cacheKey,
|
||||||
|
function () {
|
||||||
exec('sudo wpa_cli -i ' . RASPI_WIFI_CLIENT_INTERFACE . ' scan');
|
exec('sudo wpa_cli -i ' . RASPI_WIFI_CLIENT_INTERFACE . ' scan');
|
||||||
sleep(3);
|
sleep(3);
|
||||||
|
|
||||||
@ -63,18 +64,22 @@ function nearbyWifiStations(&$networks, $cached = true)
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// get the name of the AP - should be excluded von the nearby networks
|
// get the name of the AP. Should be excluded from nearby networks
|
||||||
exec('cat '.RASPI_HOSTAPD_CONFIG.' | sed -rn "s/ssid=(.*)\s*$/\1/p" ',$ap_ssid);
|
exec('cat '.RASPI_HOSTAPD_CONFIG.' | sed -rn "s/ssid=(.*)\s*$/\1/p" ', $ap_ssid);
|
||||||
$ap_ssid = $ap_ssid[0];
|
$ap_ssid = $ap_ssid[0];
|
||||||
|
|
||||||
foreach (explode("\n", $scan_results) as $network) {
|
foreach (explode("\n", $scan_results) as $network) {
|
||||||
$arrNetwork = preg_split("/[\t]+/", $network); // split result into array
|
$arrNetwork = preg_split("/[\t]+/", $network); // split result into array
|
||||||
if (!array_key_exists(4, $arrNetwork) ||
|
if (!array_key_exists(4, $arrNetwork) ||
|
||||||
trim($arrNetwork[4]) == $ap_ssid) continue;
|
trim($arrNetwork[4]) == $ap_ssid) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$ssid = trim($arrNetwork[4]);
|
$ssid = trim($arrNetwork[4]);
|
||||||
// filter SSID string - anything invisable in 7bit ASCII or quotes -> ignore network
|
// filter SSID string: anything invisible in 7bit ASCII or quotes -> ignore network
|
||||||
if( preg_match('[\x00-\x1f\x7f-\xff\'\`\´\"]',$ssid)) continue;
|
if (preg_match('[\x00-\x1f\x7f-\xff\'\`\´\"]', $ssid)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// If network is saved
|
// If network is saved
|
||||||
if (array_key_exists($ssid, $networks)) {
|
if (array_key_exists($ssid, $networks)) {
|
||||||
@ -93,11 +98,11 @@ function nearbyWifiStations(&$networks, $cached = true)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,17 +116,20 @@ function connectedWifiStations(&$networks)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function sortNetworksByRSSI(&$networks) {
|
function sortNetworksByRSSI(&$networks)
|
||||||
$valRSSI = array();
|
{
|
||||||
foreach ($networks as $SSID => $net) {
|
$valRSSI = array();
|
||||||
if (!array_key_exists('RSSI',$net)) $net['RSSI'] = -1000;
|
foreach ($networks as $SSID => $net) {
|
||||||
$valRSSI[$SSID] = $net['RSSI'];
|
if (!array_key_exists('RSSI', $net)) {
|
||||||
}
|
$net['RSSI'] = -1000;
|
||||||
$nets = $networks;
|
|
||||||
arsort($valRSSI);
|
|
||||||
$networks = array();
|
|
||||||
foreach ($valRSSI as $SSID => $RSSI) {
|
|
||||||
$networks[$SSID] = $nets[$SSID];
|
|
||||||
$networks[$SSID]['RSSI'] = $RSSI;
|
|
||||||
}
|
}
|
||||||
|
$valRSSI[$SSID] = $net['RSSI'];
|
||||||
|
}
|
||||||
|
$nets = $networks;
|
||||||
|
arsort($valRSSI);
|
||||||
|
$networks = array();
|
||||||
|
foreach ($valRSSI as $SSID => $RSSI) {
|
||||||
|
networks[$SSID] = $nets[$SSID];
|
||||||
|
$networks[$SSID]['RSSI'] = $RSSI;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,40 +16,46 @@
|
|||||||
} ?>
|
} ?>
|
||||||
<h5 class="card-title"><?php echo htmlspecialchars($ssid, ENT_QUOTES); ?></h5>
|
<h5 class="card-title"><?php echo htmlspecialchars($ssid, ENT_QUOTES); ?></h5>
|
||||||
|
|
||||||
<div class="info-item-wifi"><?php echo _("Status"); ?></div>
|
<div class="info-item-wifi"><?php echo _("Status"); ?></div>
|
||||||
<div>
|
<div>
|
||||||
<?php if ($network['configured']) { ?>
|
<?php if ($network['configured']) { ?>
|
||||||
<i class="fas fa-check-circle"></i>
|
<i class="fas fa-check-circle"></i>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php if ($network['connected']) { ?>
|
<?php if ($network['connected']) { ?>
|
||||||
<i class="fas fa-exchange-alt"></i>
|
<i class="fas fa-exchange-alt"></i>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php if (!$network['configured'] && !$network['connected']) {
|
<?php if (!$network['configured'] && !$network['connected']) {
|
||||||
echo _("Not configured");
|
echo _("Not configured");
|
||||||
} ?>
|
} ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="info-item-wifi"><?php echo _("Channel"); ?></div>
|
<div class="info-item-wifi"><?php echo _("Channel"); ?></div>
|
||||||
<div>
|
<div>
|
||||||
<?php if ($network['visible']) { ?>
|
<?php if ($network['visible']) { ?>
|
||||||
<?php echo htmlspecialchars($network['channel'], ENT_QUOTES) ?>
|
<?php echo htmlspecialchars($network['channel'], ENT_QUOTES) ?>
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
<span class="label label-warning"> X </span>
|
<span class="label label-warning"> X </span>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="info-item-wifi"><?php echo _("RSSI"); ?></div>
|
<div class="info-item-wifi"><?php echo _("RSSI"); ?></div>
|
||||||
<div>
|
<div>
|
||||||
<?php
|
<?php
|
||||||
if (isset($network['RSSI']) && $network['RSSI'] >= -200 ) {
|
if (isset($network['RSSI']) && $network['RSSI'] >= -200) {
|
||||||
echo htmlspecialchars($network['RSSI'], ENT_QUOTES);
|
echo htmlspecialchars($network['RSSI'], ENT_QUOTES);
|
||||||
echo "dB (";
|
echo "dB (";
|
||||||
if ($network['RSSI'] >= -50) echo 100;
|
if ($network['RSSI'] >= -50) {
|
||||||
elseif ($network['RSSI'] <= -100) echo 0;
|
echo 100;
|
||||||
else echo 2*($network['RSSI'] + 100);
|
} elseif ($network['RSSI'] <= -100) {
|
||||||
|
echo 0;
|
||||||
|
} else {
|
||||||
|
echo 2*($network['RSSI'] + 100);
|
||||||
|
}
|
||||||
echo "%)";
|
echo "%)";
|
||||||
} else echo " not found ";
|
} else {
|
||||||
?>
|
echo " not found ";
|
||||||
|
}
|
||||||
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php if (array_key_exists('priority', $network)) { ?>
|
<?php if (array_key_exists('priority', $network)) { ?>
|
||||||
@ -57,35 +63,35 @@
|
|||||||
<?php } ?>
|
<?php } ?>
|
||||||
<input type="hidden" name="protocol<?php echo $index ?>" value="<?php echo htmlspecialchars($network['protocol'], ENT_QUOTES); ?>" />
|
<input type="hidden" name="protocol<?php echo $index ?>" value="<?php echo htmlspecialchars($network['protocol'], ENT_QUOTES); ?>" />
|
||||||
|
|
||||||
<div class="info-item-wifi"><?php echo _("Security"); ?></div>
|
<div class="info-item-wifi"><?php echo _("Security"); ?></div>
|
||||||
<div><?php echo $network['protocol'] ?></div>
|
<div><?php echo $network['protocol'] ?></div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="info-item-wifi"><?php echo _("Passphrase"); ?></div>
|
<div class="info-item-wifi"><?php echo _("Passphrase"); ?></div>
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<?php if ($network['protocol'] === 'Open') { ?>
|
<?php if ($network['protocol'] === 'Open') { ?>
|
||||||
<input type="password" disabled class="form-control" aria-describedby="passphrase" name="passphrase<?php echo $index ?>" value="" />
|
<input type="password" disabled class="form-control" aria-describedby="passphrase" name="passphrase<?php echo $index ?>" value="" />
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
<input type="password" class="form-control js-validate-psk" aria-describedby="passphrase" name="passphrase<?php echo $index ?>" value="<?php echo $network['passphrase'] ?>" data-target="#update<?php echo $index ?>" data-colors="#ffd0d0,#d0ffd0">
|
<input type="password" class="form-control js-validate-psk" aria-describedby="passphrase" name="passphrase<?php echo $index ?>" value="<?php echo $network['passphrase'] ?>" data-target="#update<?php echo $index ?>" data-colors="#ffd0d0,#d0ffd0">
|
||||||
<div class="input-group-append">
|
<div class="input-group-append">
|
||||||
<button class="btn btn-outline-secondary js-toggle-password" type="button" data-target="[name=passphrase<?php echo $index ?>]" data-toggle-with="<?php echo _("Hide") ?>">Show</button>
|
<button class="btn btn-outline-secondary js-toggle-password" type="button" data-target="[name=passphrase<?php echo $index ?>]" data-toggle-with="<?php echo _("Hide") ?>">Show</button>
|
||||||
</div>
|
</div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="btn-group btn-block ">
|
<div class="btn-group btn-block ">
|
||||||
<?php if ($network['configured']) { ?>
|
<?php if ($network['configured']) { ?>
|
||||||
<input type="submit" class="col-xs-4 col-md-4 btn btn-warning" value="<?php echo _("Update"); ?>" id="update<?php echo $index ?>" name="update<?php echo $index ?>"<?php echo ($network['protocol'] === 'Open' ? ' disabled' : '')?> />
|
<input type="submit" class="col-xs-4 col-md-4 btn btn-warning" value="<?php echo _("Update"); ?>" id="update<?php echo $index ?>" name="update<?php echo $index ?>"<?php echo ($network['protocol'] === 'Open' ? ' disabled' : '')?> />
|
||||||
<button type="submit" class="col-xs-4 col-md-4 btn btn-info" value="<?php echo $index?>" name="connect"><?php echo _("Connect"); ?></button>
|
<button type="submit" class="col-xs-4 col-md-4 btn btn-info" value="<?php echo $index?>" name="connect"><?php echo _("Connect"); ?></button>
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
<input type="submit" class="col-xs-4 col-md-4 btn btn-info" value="<?php echo _("Add"); ?>" id="update<?php echo $index ?>" name="update<?php echo $index ?>" <?php echo ($network['protocol'] === 'Open' ? '' : ' disabled')?> />
|
<input type="submit" class="col-xs-4 col-md-4 btn btn-info" value="<?php echo _("Add"); ?>" id="update<?php echo $index ?>" name="update<?php echo $index ?>" <?php echo ($network['protocol'] === 'Open' ? '' : ' disabled')?> />
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<input type="submit" class="col-xs-4 col-md-4 btn btn-danger" value="<?php echo _("Delete"); ?>" name="delete<?php echo $index ?>"<?php echo ($network['configured'] ? '' : ' disabled')?> />
|
<input type="submit" class="col-xs-4 col-md-4 btn btn-danger" value="<?php echo _("Delete"); ?>" name="delete<?php echo $index ?>"<?php echo ($network['configured'] ? '' : ' disabled')?> />
|
||||||
</div><!-- /.btn-group -->
|
</div><!-- /.btn-group -->
|
||||||
</div><!-- /.card-body -->
|
</div><!-- /.card-body -->
|
||||||
</div><!-- /.card -->
|
</div><!-- /.card -->
|
||||||
</div><!-- /.col-sm -->
|
</div><!-- /.col-sm -->
|
||||||
<?php $index += 1; ?>
|
<?php $index += 1; ?>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
</div><!-- /.row -->
|
</div><!-- /.row -->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user