2016-08-08 12:48:16 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function DisplayDashboard(){
|
|
|
|
|
2016-08-15 12:25:20 +00:00
|
|
|
$status = new StatusMessages();
|
|
|
|
|
2017-12-07 19:00:48 +00:00
|
|
|
exec( 'ip a s ' . RASPI_WIFI_CLIENT_INTERFACE , $return );
|
|
|
|
exec( 'iwconfig ' . RASPI_WIFI_CLIENT_INTERFACE, $return );
|
2016-08-08 12:48:16 +00:00
|
|
|
|
2016-08-08 20:37:44 +00:00
|
|
|
$strWlan0 = implode( " ", $return );
|
|
|
|
$strWlan0 = preg_replace( '/\s\s+/', ' ', $strWlan0 );
|
2016-08-08 12:48:16 +00:00
|
|
|
|
2016-08-08 20:37:44 +00:00
|
|
|
// Parse results from ifconfig/iwconfig
|
2017-10-03 16:09:50 +00:00
|
|
|
preg_match( '/link\/ether ([0-9a-f:]+)/i',$strWlan0,$result ) || $result[1] = 'No MAC Address Found';
|
2016-08-08 20:37:44 +00:00
|
|
|
$strHWAddress = $result[1];
|
2017-10-03 16:09:50 +00:00
|
|
|
preg_match_all( '/inet ([0-9.]+)/i',$strWlan0,$result ) || $result[1] = 'No IP Address Found';
|
|
|
|
$strIPAddress = '';
|
|
|
|
foreach($result[1] as $ip) {
|
|
|
|
$strIPAddress .= $ip." ";
|
|
|
|
}
|
|
|
|
preg_match_all( '/[0-9.]+\/([0-3][0-9])/i',$strWlan0,$result ) || $result[1] = 'No Subnet Mask Found';
|
|
|
|
$strNetMask = '';
|
|
|
|
foreach($result[1] as $netmask) {
|
|
|
|
$strNetMask .= long2ip(-1 << (32 -(int)$netmask))." ";
|
|
|
|
}
|
2017-10-01 12:54:16 +00:00
|
|
|
preg_match( '/RX packets:(\d+)/',$strWlan0,$result ) || $result[1] = 'No Data';
|
2016-08-08 20:37:44 +00:00
|
|
|
$strRxPackets = $result[1];
|
2017-10-01 12:54:16 +00:00
|
|
|
preg_match( '/TX packets:(\d+)/',$strWlan0,$result ) || $result[1] = 'No Data';
|
2016-08-08 20:37:44 +00:00
|
|
|
$strTxPackets = $result[1];
|
2017-10-01 12:54:16 +00:00
|
|
|
preg_match( '/RX bytes:(\d+ \(\d+.\d+ [K|M|G]iB\))/i',$strWlan0,$result ) || $result[1] = 'No Data';
|
2016-08-08 20:37:44 +00:00
|
|
|
$strRxBytes = $result[1];
|
2017-10-01 12:54:16 +00:00
|
|
|
preg_match( '/TX Bytes:(\d+ \(\d+.\d+ [K|M|G]iB\))/i',$strWlan0,$result ) || $result[1] = 'No Data';
|
2016-08-08 20:37:44 +00:00
|
|
|
$strTxBytes = $result[1];
|
2017-12-26 18:55:30 +00:00
|
|
|
preg_match( '/ESSID:\"([a-zA-Z0-9\s].+)\"/i',$strWlan0,$result ) || $result[1] = 'Not connected';
|
2016-08-08 20:37:44 +00:00
|
|
|
$strSSID = str_replace( '"','',$result[1] );
|
2017-10-01 19:10:04 +00:00
|
|
|
preg_match( '/Access Point: ([0-9a-f:]+)/i',$strWlan0,$result ) || $result[1] = '';
|
2016-08-08 20:37:44 +00:00
|
|
|
$strBSSID = $result[1];
|
2017-10-01 19:10:04 +00:00
|
|
|
preg_match( '/Bit Rate=([0-9\.]+ Mb\/s)/i',$strWlan0,$result ) || $result[1] = '';
|
2016-08-08 20:37:44 +00:00
|
|
|
$strBitrate = $result[1];
|
2017-10-01 19:10:04 +00:00
|
|
|
preg_match( '/Tx-Power=([0-9]+ dBm)/i',$strWlan0,$result ) || $result[1] = '';
|
2016-08-08 20:37:44 +00:00
|
|
|
$strTxPower = $result[1];
|
2017-10-01 19:10:04 +00:00
|
|
|
preg_match( '/Link Quality=([0-9]+)/i',$strWlan0,$result ) || $result[1] = '';
|
2016-08-08 20:37:44 +00:00
|
|
|
$strLinkQuality = $result[1];
|
2017-10-01 19:10:04 +00:00
|
|
|
preg_match( '/Signal level=(-?[0-9]+ dBm)/i',$strWlan0,$result ) || $result[1] = '';
|
2016-08-08 20:37:44 +00:00
|
|
|
$strSignalLevel = $result[1];
|
2017-10-01 19:10:04 +00:00
|
|
|
preg_match('/Frequency:(\d+.\d+ GHz)/i',$strWlan0,$result) || $result[1] = '';
|
2016-08-08 20:37:44 +00:00
|
|
|
$strFrequency = $result[1];
|
2016-08-08 12:48:16 +00:00
|
|
|
|
2017-10-03 16:09:50 +00:00
|
|
|
if(strpos( $strWlan0, "UP" ) !== false) {
|
2016-08-15 12:25:20 +00:00
|
|
|
$status->addMessage('Interface is up', 'success');
|
2016-08-08 20:37:44 +00:00
|
|
|
$wlan0up = true;
|
|
|
|
} else {
|
2016-08-15 12:25:20 +00:00
|
|
|
$status->addMessage('Interface is down', 'warning');
|
2016-08-08 20:37:44 +00:00
|
|
|
}
|
2016-08-08 12:48:16 +00:00
|
|
|
|
2016-08-08 20:37:44 +00:00
|
|
|
if( isset($_POST['ifdown_wlan0']) ) {
|
2017-12-07 19:00:48 +00:00
|
|
|
exec( 'ifconfig ' . RASPI_WIFI_CLIENT_INTERFACE . ' | grep -i running | wc -l',$test );
|
2016-08-08 20:37:44 +00:00
|
|
|
if($test[0] == 1) {
|
2017-12-07 19:00:48 +00:00
|
|
|
exec( 'sudo ip link set ' . RASPI_WIFI_CLIENT_INTERFACE . ' down',$return );
|
2016-08-08 20:37:44 +00:00
|
|
|
} else {
|
|
|
|
echo 'Interface already down';
|
|
|
|
}
|
|
|
|
} elseif( isset($_POST['ifup_wlan0']) ) {
|
2017-12-07 19:00:48 +00:00
|
|
|
exec( 'ifconfig ' . RASPI_WIFI_CLIENT_INTERFACE . ' | grep -i running | wc -l',$test );
|
2016-08-08 20:37:44 +00:00
|
|
|
if($test[0] == 0) {
|
2017-12-07 19:00:48 +00:00
|
|
|
exec( 'sudo ip link set ' . RASPI_WIFI_CLIENT_INTERFACE . ' up',$return );
|
|
|
|
exec( 'sudo ip -s a f label ' . RASPI_WIFI_CLIENT_INTERFACE,$return);
|
2016-08-08 20:37:44 +00:00
|
|
|
} else {
|
|
|
|
echo 'Interface already up';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-lg-12">
|
|
|
|
<div class="panel panel-primary">
|
2017-10-23 19:51:34 +00:00
|
|
|
<div class="panel-heading"><i class="fa fa-dashboard fa-fw"></i> <?php echo _("Dashboard"); ?></div>
|
2016-08-08 20:37:44 +00:00
|
|
|
<div class="panel-body">
|
2016-08-15 12:25:20 +00:00
|
|
|
<p><?php $status->showMessages(); ?></p>
|
2016-08-08 20:37:44 +00:00
|
|
|
<div class="row">
|
2018-05-27 08:42:54 +00:00
|
|
|
<div class="col-md-6">
|
2016-08-08 20:37:44 +00:00
|
|
|
<div class="panel panel-default">
|
2018-05-27 08:42:54 +00:00
|
|
|
<div class="panel-body">
|
|
|
|
<h4><?php echo _("Interface Information"); ?></h4>
|
2018-08-03 23:58:34 +00:00
|
|
|
<div class="info-item"><?php echo _("Interface Name"); ?></div> <?php echo RASPI_WIFI_CLIENT_INTERFACE; ?><br />
|
|
|
|
<div class="info-item"><?php echo _("IP Address"); ?></div> <?php echo htmlspecialchars($strIPAddress, ENT_QUOTES); ?><br />
|
|
|
|
<div class="info-item"><?php echo _("Subnet Mask"); ?></div> <?php echo htmlspecialchars($strNetMask, ENT_QUOTES); ?><br />
|
|
|
|
<div class="info-item"><?php echo _("Mac Address"); ?></div> <?php echo htmlspecialchars($strHWAddress, ENT_QUOTES); ?><br /><br />
|
2016-08-08 12:48:16 +00:00
|
|
|
|
2018-05-27 08:42:54 +00:00
|
|
|
<h4><?php echo _("Interface Statistics"); ?></h4>
|
2018-08-03 23:58:34 +00:00
|
|
|
<div class="info-item"><?php echo _("Received Packets"); ?></div> <?php echo htmlspecialchars($strRxPackets, ENT_QUOTES); ?><br />
|
|
|
|
<div class="info-item"><?php echo _("Received Bytes"); ?></div> <?php echo htmlspecialchars($strRxBytes, ENT_QUOTES); ?><br /><br />
|
|
|
|
<div class="info-item"><?php echo _("Transferred Packets"); ?></div> <?php echo htmlspecialchars($strTxPackets, ENT_QUOTES); ?><br />
|
|
|
|
<div class="info-item"><?php echo _("Transferred Bytes"); ?></div> <?php echo htmlspecialchars($strTxBytes, ENT_QUOTES); ?><br />
|
2018-05-27 08:42:54 +00:00
|
|
|
</div><!-- /.panel-body -->
|
|
|
|
</div><!-- /.panel-default -->
|
2016-08-08 20:37:44 +00:00
|
|
|
</div><!-- /.col-md-6 -->
|
2018-05-27 08:42:54 +00:00
|
|
|
<div class="col-md-6">
|
|
|
|
<div class="panel panel-default">
|
|
|
|
<div class="panel-body wireless">
|
2017-10-23 19:51:34 +00:00
|
|
|
<h4><?php echo _("Wireless Information"); ?></h4>
|
2018-08-03 23:58:34 +00:00
|
|
|
<div class="info-item"><?php echo _("Connected To"); ?></div> <?php echo htmlspecialchars($strSSID, ENT_QUOTES); ?><br />
|
|
|
|
<div class="info-item"><?php echo _("AP Mac Address"); ?></div> <?php echo htmlspecialchars($strBSSID, ENT_QUOTES); ?><br />
|
|
|
|
<div class="info-item"><?php echo _("Bitrate"); ?></div> <?php echo htmlspecialchars($strBitrate, ENT_QUOTES); ?><br />
|
|
|
|
<div class="info-item"><?php echo _("Signal Level"); ?></div> <?php echo htmlspecialchars($strSignalLevel, ENT_QUOTES); ?><br />
|
|
|
|
<div class="info-item"><?php echo _("Transmit Power"); ?></div> <?php echo htmlspecialchars($strTxPower, ENT_QUOTES); ?><br />
|
|
|
|
<div class="info-item"><?php echo _("Frequency"); ?></div> <?php echo htmlspecialchars($strFrequency, ENT_QUOTES); ?><br /><br />
|
2018-05-27 08:42:54 +00:00
|
|
|
<div class="info-item"><?php echo _("Link Quality"); ?></div>
|
|
|
|
<div class="progress">
|
|
|
|
<div class="progress-bar progress-bar-info progress-bar-striped active"
|
|
|
|
role="progressbar"
|
2018-08-03 23:58:34 +00:00
|
|
|
aria-valuenow="<?php echo htmlspecialchars($strLinkQuality, ENT_QUOTES); ?>" aria-valuemin="0" aria-valuemax="100"
|
|
|
|
style="width: <?php echo htmlspecialchars($strLinkQuality, ENT_QUOTES); ?>%;"><?php echo htmlspecialchars($strLinkQuality, ENT_QUOTES); ?>%
|
2018-05-27 08:42:54 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div><!-- /.panel-body -->
|
|
|
|
</div><!-- /.panel-default -->
|
|
|
|
</div><!-- /.col-md-6 -->
|
|
|
|
</div><!-- /.row -->
|
2016-08-08 12:48:16 +00:00
|
|
|
|
2018-05-27 08:42:54 +00:00
|
|
|
<div class="col-lg-12">
|
2016-08-08 20:37:44 +00:00
|
|
|
<div class="row">
|
|
|
|
<form action="?page=wlan0_info" method="POST">
|
|
|
|
<?php if ( !$wlan0up ) {
|
2018-05-27 08:42:54 +00:00
|
|
|
echo '<input type="submit" class="btn btn-success" value="' . _("Start ") . RASPI_WIFI_CLIENT_INTERFACE . '" name="ifup_wlan0" />';
|
2016-08-08 20:37:44 +00:00
|
|
|
} else {
|
2018-05-27 08:42:54 +00:00
|
|
|
echo '<input type="submit" class="btn btn-warning" value="' . _("Stop ") . RASPI_WIFI_CLIENT_INTERFACE . '" name="ifdown_wlan0" />';
|
|
|
|
}
|
2016-08-08 20:37:44 +00:00
|
|
|
?>
|
2017-10-23 19:51:34 +00:00
|
|
|
<input type="button" class="btn btn-outline btn-primary" value="<?php echo _("Refresh"); ?>" onclick="document.location.reload(true)" />
|
2016-08-08 20:37:44 +00:00
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
2016-08-08 12:48:16 +00:00
|
|
|
|
2016-08-08 20:37:44 +00:00
|
|
|
</div><!-- /.panel-body -->
|
2017-10-23 19:51:34 +00:00
|
|
|
<div class="panel-footer"><?php echo _("Information provided by ifconfig and iwconfig"); ?></div>
|
2016-08-08 20:37:44 +00:00
|
|
|
</div><!-- /.panel-default -->
|
|
|
|
</div><!-- /.col-lg-12 -->
|
|
|
|
</div><!-- /.row -->
|
2017-10-03 04:46:02 +00:00
|
|
|
<?php
|
2016-08-08 12:48:16 +00:00
|
|
|
}
|
|
|
|
|