Commit dd47b891 authored by Ad Schellevis's avatar Ad Schellevis

(legacy) refactor status_wireless.php

parent 1571fa31
...@@ -30,16 +30,29 @@ ...@@ -30,16 +30,29 @@
require_once("guiconfig.inc"); require_once("guiconfig.inc");
require_once("interfaces.inc"); require_once("interfaces.inc");
include("head.inc");
$if = $_POST['if']; if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if($_GET['if'] <> "") if(!empty($_GET['if'])) {
$if = $_GET['if']; $if = htmlspecialchars($_GET['if']);
}
if (!empty($_GET['savemsg']) && $_GET['savemsg'] == 'rescan') {
$savemsg = gettext("Rescan has been initiated in the background. Refresh this page in 10 seconds to see the results.");
}
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (!empty($_POST['if'])) {
$if = htmlspecialchars($_POST['if']);
}
$rwlif = escapeshellarg(get_real_interface($if));
if(!empty($_POST['rescanwifi'])) {
mwexec_bg("/sbin/ifconfig {$rwlif} scan 2>&1");
header("Location: status_wireless.php?if=" . $if. "&savemsg=rescan");
exit;
}
}
$ciflist = get_configured_interface_with_descr(); $ciflist = get_configured_interface_with_descr();
if(empty($if)) { if(empty($if)) {
/* Find the first interface /* Find the first wireless interface */
that is wireless */
foreach($ciflist as $interface => $ifdescr) { foreach($ciflist as $interface => $ifdescr) {
if(is_interface_wireless(get_real_interface($interface))) { if(is_interface_wireless(get_real_interface($interface))) {
$if = $interface; $if = $interface;
...@@ -47,69 +60,57 @@ if(empty($if)) { ...@@ -47,69 +60,57 @@ if(empty($if)) {
} }
} }
} }
$rwlif = escapeshellarg(get_real_interface($if));
include("head.inc");
?> ?>
<body> <body>
<?php include("fbegin.inc"); ?> <?php include("fbegin.inc"); ?>
<section class="page-content-main"> <section class="page-content-main">
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<section class="col-xs-12">
<?php if (isset($savemsg)) print_info_box($savemsg); ?> <?php if (isset($savemsg)) print_info_box($savemsg); ?>
<?php <?php
$tab_array = array(); $tab_array = array();
foreach($ciflist as $interface => $ifdescr) { foreach($ciflist as $interface => $ifdescr) {
if (is_interface_wireless(get_real_interface($interface))) { if (is_interface_wireless(get_real_interface($interface))) {
$enabled = false; $enabled = false;
if($if == $interface) if($if == $interface) {
$enabled = true; $enabled = true;
$tab_array[] = array(gettext("Status") . " ({$ifdescr})", $enabled, "status_wireless.php?if={$interface}");
} }
$tab_array[] = array(gettext("Status") . " ({$ifdescr})", $enabled, "status_wireless.php?if={$interface}");
} }
$rwlif = get_real_interface($if);
if($_POST['rescanwifi'] <> "") {
mwexec_bg("/sbin/ifconfig {$rwlif} scan 2>&1");
$savemsg = gettext("Rescan has been initiated in the background. Refresh this page in 10 seconds to see the results.");
} }
if (isset($savemsg)) print_info_box($savemsg);
display_top_tabs($tab_array); display_top_tabs($tab_array);
?> ?>
<section class="col-xs-12">
<div class="content-box"> <div class="content-box">
<form method="post" name="iform" id="iform">
<form action="status_wireless.php" method="post" name="iform" id="iform"> <input type="hidden" name="if" id="if" value="<?=$if;?>">
<input type="hidden" name="if" id="if" value="<?php echo htmlspecialchars($if); ?>"> <header class="content-box-head container-fluid">
<h3><?=gettext("Nearby access points or ad-hoc peers"); ?></h3>
<div class="col-xs-12"> </header>
<input type="submit" name="rescanwifi" id="rescanwifi" value="Rescan" class="btn btn-primary"/>
<p><?php echo gettext("Nearby access points or ad-hoc peers"); ?></p>
</div>
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-striped table-sort"> <table class="table table-striped">
<thead> <thead>
<tr> <tr>
<td>SSID</td> <th><?=gettext("SSID");?></th>
<td>BSSID</td> <th><?=gettext("BSSID");?></th>
<td>CHAN</td> <th><?=gettext("CHAN");?></th>
<td>RATE</td> <th><?=gettext("RATE");?></th>
<td>RSSI</td> <th><?=gettext("RSSI");?></th>
<td>INT</td> <th><?=gettext("INT");?></th>
<td>CAPS</td> <th><?=gettext("CAPS");?></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php <?php
exec("/sbin/ifconfig {$rwlif} list scan 2>&1", $states, $ret); exec("/sbin/ifconfig {$rwlif} list scan 2>&1", $states, $ret);
/* Skip Header */ /* Skip Header */
array_shift($states); array_shift($states);
$counter=0; $counter=0;
foreach($states as $state) { foreach($states as $state):
/* Split by Mac address for the SSID Field */ /* Split by Mac address for the SSID Field */
$split = preg_split("/([0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f])/i", $state); $split = preg_split("/([0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f])/i", $state);
preg_match("/([0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f])/i", $state, $bssid); preg_match("/([0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f])/i", $state, $bssid);
...@@ -122,78 +123,87 @@ if(empty($if)) { ...@@ -122,78 +123,87 @@ if(empty($if)) {
$rssi = $split[3]; $rssi = $split[3];
$int = $split[4]; $int = $split[4];
$caps = "$split[5] $split[6] $split[7] $split[8] $split[9] $split[10] $split[11] "; $caps = "$split[5] $split[6] $split[7] $split[8] $split[9] $split[10] $split[11] ";
?>
print "<tr>"; <tr>
print "<td>{$ssid}</td>"; <td><?=$ssid;?></td>
print "<td>{$bssid}</td>"; <td><?=$bssid;?></td>
print "<td>{$channel}</td>"; <td><?=$channel;?></td>
print "<td>{$rate}</td>"; <td><?=$rate;?></td>
print "<td>{$rssi}</td>"; <td><?=$rssi;?></td>
print "<td>{$int}</td>"; <td><?=$int;?></td>
print "<td>{$caps}</td>"; <td><?=$caps;?></td>
print "</tr>\n"; </tr>
} <?php
?> endforeach;?>
</tbody> </tbody>
</table> </table>
</div> </div>
<br/>
<div class="table-responsive"> <div class="table-responsive">
<p><?php echo gettext("Associated or ad-hoc peers"); ?></p> <header class="content-box-head container-fluid">
<table class="table table-striped sortable" colspan="3" cellpadding="3" width="100%"> <h3><?=gettext("Associated or ad-hoc peers"); ?></h3>
</header>
<table class="table table-striped">
<thead> <thead>
<tr> <tr>
<td>ADDR</td> <th><?=gettext("ADDR");?></th>
<td>AID</td> <th><?=gettext("AID");?></th>
<td>CHAN</td> <th><?=gettext("CHAN");?></th>
<td>RATE</td> <th><?=gettext("RATE");?></th>
<td>RSSI</td> <th><?=gettext("RSSI");?></th>
<td>IDLE</td> <th><?=gettext("IDLE");?></th>
<td>TXSEQ</td> <th><?=gettext("TXSEQ");?></th>
<td>RXSEQ</td> <th><?=gettext("RXSEQ");?></th>
<td>CAPS</td> <th><?=gettext("CAPS");?></th>
<td>ERP</td> <th><?=gettext("ERP");?></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php
<?php
$states = array(); $states = array();
exec("/sbin/ifconfig {$rwlif} list sta 2>&1", $states, $ret); exec("/sbin/ifconfig {$rwlif} list sta 2>&1", $states, $ret);
array_shift($states); array_shift($states);
$counter=0; $counter=0;
foreach($states as $state) { foreach($states as $state):
$split = preg_split("/[ ]+/i", $state); $split = preg_split("/[ ]+/i", $state);?>
/* Split the rest by using spaces for this line using the 2nd part */ <tr>
print "<tr>"; <td><?=$split[0];?></td>
print "<td>{$split[0]}</td>"; <td><?=$split[1];?></td>
print "<td>{$split[1]}</td>"; <td><?=$split[2];?></td>
print "<td>{$split[2]}</td>"; <td><?=$split[3];?></td>
print "<td>{$split[3]}</td>"; <td><?=$split[4];?></td>
print "<td>{$split[4]}</td>"; <td><?=$split[5];?></td>
print "<td>{$split[5]}</td>"; <td><?=$split[6];?></td>
print "<td>{$split[6]}</td>"; <td><?=$split[7];?></td>
print "<td>{$split[7]}</td>"; <td><?=$split[8];?></td>
print "<td>{$split[8]}</td>"; <td><?=$split[9];?></td>
print "<td>{$split[9]}</td>"; </tr>
print "</tr>\n"; <?php
} endforeach;?>
/* XXX: what stats to we get for adhoc mode? */
?>
</tbody> </tbody>
</table> </table>
</div> </div>
<div class="table-responsive">
<table class="table table-striped">
<tr>
<td>
<input type="submit" name="rescanwifi" value="<?=gettext("Rescan");?>" class="btn btn-primary"/>
</td>
</tr>
<tfoot>
<tr>
<td>
<b><?=gettext('Flags:') ?></b> <?=gettext('A = authorized, E = Extended Rate (802.11g), P = Power save mode') ?><br /> <b><?=gettext('Flags:') ?></b> <?=gettext('A = authorized, E = Extended Rate (802.11g), P = Power save mode') ?><br />
<b><?=gettext('Capabilities:') ?></b> <?=gettext('E = ESS (infrastructure mode), I = IBSS (ad-hoc mode), P = privacy (WEP/TKIP/AES), S = Short preamble, s = Short slot time') ?> <b><?=gettext('Capabilities:') ?></b> <?=gettext('E = ESS (infrastructure mode), I = IBSS (ad-hoc mode), P = privacy (WEP/TKIP/AES), S = Short preamble, s = Short slot time') ?>
</td>
</tr>
</tfoot>
</table>
</div>
</form> </form>
</div> </div>
</section> </section>
</div> </div>
</div> </div>
</section> </section>
<?php include("foot.inc"); ?> <?php include("foot.inc"); ?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment