Skip to content

Instantly share code, notes, and snippets.

@brettbeeson
Created June 1, 2020 10:25
Show Gist options
  • Save brettbeeson/ea50473f9d609258021265ca9a86373b to your computer and use it in GitHub Desktop.
Save brettbeeson/ea50473f9d609258021265ca9a86373b to your computer and use it in GitHub Desktop.
Hacky patches for RaspAP
--- /tmp/wifi_functions.php 2020-06-01 20:04:41.178166241 +1000
+++ includes/wifi_functions.php 2020-06-01 19:12:34.424035192 +1000
@@ -5,10 +5,12 @@
function knownWifiStations(&$networks)
{
// Find currently configured networks
+ $index = 0;
exec(' sudo cat ' . RASPI_WPA_SUPPLICANT_CONFIG, $known_return);
foreach ($known_return as $line) {
if (preg_match('/network\s*=/', $line)) {
- $network = array('visible' => false, 'configured' => true, 'connected' => false);
+ $network = array('visible' => false, 'configured' => true, 'connected' => false,'wpa_index' => $index);
+ $index += 1;
} elseif ($network !== null) {
if (preg_match('/^\s*}\s*$/', $line)) {
$networks[$ssid] = $network;
--- /tmp/x 2020-06-01 20:15:26.491897490 +1000
+++ templates/wifi_stations.php 2020-06-01 20:14:57.032173214 +1000
@@ -6,6 +6,14 @@
<div class="row ml-1 mr-1">
<?php foreach ($networks as $ssid => $network) : ?>
+<?php
+if (array_key_exists('wpa_index',$network)) {
+ $wpa_index = $network['wpa_index'];
+} else {
+ $wpa_index = -1;
+}
+?>
+
<div class="col-sm-6 align-items-stretch mb-3">
<div class="card h-100">
<div class="card-body">
@@ -83,7 +91,7 @@
<div class="btn-group btn-block ">
<?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' : '')?> />
- <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 $wpa_index?>" name="connect"><?php echo _("Connect"); ?></button>
<?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')?> />
<?php } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment