some code cleanup

This commit is contained in:
dg9vh 2016-09-15 18:30:41 +00:00
parent d269ad0811
commit 9099b4d744
11 changed files with 54 additions and 161 deletions

View file

@ -4,10 +4,8 @@
<!-- Tabelle --> <!-- Tabelle -->
<div class="table-responsive"> <div class="table-responsive">
<table id="diskuse" class="table table-condensed table-striped table-hover"> <table id="diskuse" class="table table-condensed table-striped table-hover">
<thead> <thead>
<tr> <tr>
<th class="w10p filesystem">Filesystem</th> <th class="w10p filesystem">Filesystem</th>
<th class="w20p">Mount</th> <th class="w20p">Mount</th>
<th>Use</th> <th>Use</th>
@ -17,18 +15,12 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php <?php
error_reporting(E_ERROR | E_WARNING | E_PARSE); error_reporting(E_ERROR | E_WARNING | E_PARSE);
//include "./functions.php"; //include "./functions.php";
try{ try{
$datas = array(); $datas = array();
if (!(exec('/bin/df -T | awk -v c=`/bin/df -T | grep -bo "Type" | awk -F: \'{print $2}\'` \'{print substr($0,c);}\' | tail -n +2 | awk \'{print $1","$2","$3","$4","$5","$6","$7}\'', $df))) {
if (!(exec('/bin/df -T | awk -v c=`/bin/df -T | grep -bo "Type" | awk -F: \'{print $2}\'` \'{print substr($0,c);}\' | tail -n +2 | awk \'{print $1","$2","$3","$4","$5","$6","$7}\'', $df)))
{
$datas[] = array( $datas[] = array(
'total' => 'N.A', 'total' => 'N.A',
'used' => 'N.A', 'used' => 'N.A',
@ -37,22 +29,14 @@ if (!(exec('/bin/df -T | awk -v c=`/bin/df -T | grep -bo "Type" | awk -F: \'{pri
'mount' => 'N.A', 'mount' => 'N.A',
'filesystem' => 'N.A', 'filesystem' => 'N.A',
); );
} } else {
else
{
$mounted_points = array(); $mounted_points = array();
$key = 0; $key = 0;
foreach ($df as $mounted) {
foreach ($df as $mounted)
{
list($filesystem, $type, $total, $used, $free, $percent, $mount) = explode(',', $mounted); list($filesystem, $type, $total, $used, $free, $percent, $mount) = explode(',', $mounted);
if ((strpos($type, 'tmpfs') !== false) && (strpos($mount, '/mnt/ramdisk') === false)) if ((strpos($type, 'tmpfs') !== false) && (strpos($mount, '/mnt/ramdisk') === false))
continue; continue;
?>
?>
<tr> <tr>
<td><?php echo $filesystem ?></td> <td><?php echo $filesystem ?></td>
<td><?php echo $mount ?></td> <td><?php echo $mount ?></td>
@ -61,27 +45,16 @@ else
<td><?php echo getSize($used * 1024) ?></td> <td><?php echo getSize($used * 1024) ?></td>
<td><?php echo getSize($total * 1024) ?></td> <td><?php echo getSize($total * 1024) ?></td>
</tr> </tr>
<?php
<?php
$key++; $key++;
} }
}
}
} catch (Exception $e) { } catch (Exception $e) {
return false; return false;
} }
?> ?>
</tbody> </tbody>
</table> </table>
</div> </div>
</div> </div>

View file

@ -58,7 +58,6 @@ function getConfigItem($section, $key, $configs) {
} }
$sectionpos++; $sectionpos++;
} }
return substr($configs[$sectionpos], strlen($key) + 1); return substr($configs[$sectionpos], strlen($key) + 1);
} }
@ -109,26 +108,9 @@ function showMode($mode, $mmdvmconfigs) {
<?php <?php
} }
/*
function getMMDVMLog() {
// Open Logfile and copy loglines into LogLines-Array()
$logLines = array();
if ($log = fopen(MMDVMLOGPATH."/".MMDVMLOGPREFIX."-".date("Y-m-d").".log", 'r')) {
while ($logLine = fgets($log)) {
if (!strpos($logLine, "Debug") && !strpos($logLine,"Received a NAK") && !startsWith($logLine,"I:") && !startsWith($logLine,"E:")) {
array_push($logLines, $logLine);
}
}
fclose($log);
}
return $logLines;
}
*/
function getMMDVMLog() { function getMMDVMLog() {
// Open Logfile and copy loglines into LogLines-Array() // Open Logfile and copy loglines into LogLines-Array()
$logPath = MMDVMLOGPATH."/".MMDVMLOGPREFIX."-".date("Y-m-d").".log"; $logPath = MMDVMLOGPATH."/".MMDVMLOGPREFIX."-".date("Y-m-d").".log";
$logLines = explode("\n", `grep M: $logPath`); $logLines = explode("\n", `grep M: $logPath`);
return $logLines; return $logLines;
} }
@ -136,31 +118,13 @@ function getMMDVMLog() {
function getShortMMDVMLog() { function getShortMMDVMLog() {
// Open Logfile and copy loglines into LogLines-Array() // Open Logfile and copy loglines into LogLines-Array()
$logPath = MMDVMLOGPATH."/".MMDVMLOGPREFIX."-".date("Y-m-d").".log"; $logPath = MMDVMLOGPATH."/".MMDVMLOGPREFIX."-".date("Y-m-d").".log";
$logLines = explode("\n", `tail -n100 $logPath`); $logLines = explode("\n", `tail -n100 $logPath`);
return $logLines; return $logLines;
} }
/*
function getYSFGatewayLog() {
// Open Logfile and copy loglines into LogLines-Array()
$logLines = array();
if ($log = fopen(YSFGATEWAYLOGPATH."/".YSFGATEWAYLOGPREFIX."-".date("Y-m-d").".log", 'r')) {
while ($logLine = fgets($log)) {
if (startsWith($logLine,"D:")) {
array_push($logLines, $logLine);
}
}
fclose($log);
}
return $logLines;
}
*/
function getYSFGatewayLog() { function getYSFGatewayLog() {
// Open Logfile and copy loglines into LogLines-Array() // Open Logfile and copy loglines into LogLines-Array()
$logPath = YSFGATEWAYLOGPATH."/".YSFGATEWAYLOGPREFIX."-".date("Y-m-d").".log"; $logPath = YSFGATEWAYLOGPATH."/".YSFGATEWAYLOGPREFIX."-".date("Y-m-d").".log";
$logLines = explode("\n", `grep D: $logPath`); $logLines = explode("\n", `grep D: $logPath`);
return $logLines; return $logLines;
} }
@ -171,7 +135,6 @@ function getYSFGatewayLog() {
// M: 2016-04-29 19:43:21.839 DMR Slot 2, received network voice header from DL1ESZ to TG 9 // M: 2016-04-29 19:43:21.839 DMR Slot 2, received network voice header from DL1ESZ to TG 9
// M: 2016-04-30 14:57:43.072 DMR Slot 2, received RF voice header from DG9VH to 5000 // M: 2016-04-30 14:57:43.072 DMR Slot 2, received RF voice header from DG9VH to 5000
function getHeardList($logLines, $onlyLast) { function getHeardList($logLines, $onlyLast) {
//array_multisort($logLines,SORT_DESC);
$heardList = array(); $heardList = array();
$ts1duration = ""; $ts1duration = "";
$ts1loss = ""; $ts1loss = "";
@ -202,7 +165,6 @@ function getHeardList($logLines, $onlyLast) {
continue; continue;
} }
if(strpos($logLine,"end of") || strpos($logLine,"watchdog has expired") || strpos($logLine,"ended RF data") || strpos($logLine,"ended network")) { if(strpos($logLine,"end of") || strpos($logLine,"watchdog has expired") || strpos($logLine,"ended RF data") || strpos($logLine,"ended network")) {
$lineTokens = explode(", ",$logLine); $lineTokens = explode(", ",$logLine);
if (array_key_exists(2,$lineTokens)) { if (array_key_exists(2,$lineTokens)) {
@ -327,10 +289,7 @@ function getLastHeard($logLines, $onlyLast) {
array_push($heardCalls, $listElem[2]."#".$listElem[1].$listElem[3]); array_push($heardCalls, $listElem[2]."#".$listElem[1].$listElem[3]);
array_push($lastHeard, $listElem); array_push($lastHeard, $listElem);
$counter++; $counter++;
}/* }
if ($counter == LHLINES) {
return $lastHeard;
}*/
} }
} }
return $lastHeard; return $lastHeard;
@ -479,8 +438,6 @@ function getActualReflector($logLines, $mode) {
//M: 2016-05-02 07:04:10.504 D-Star link status set to "Verlinkt zu DCS002 S" //M: 2016-05-02 07:04:10.504 D-Star link status set to "Verlinkt zu DCS002 S"
//M: 2016-04-03 16:16:18.638 DMR Slot 2, received network voice header from 4000 to 2625094 //M: 2016-04-03 16:16:18.638 DMR Slot 2, received network voice header from 4000 to 2625094
//M: 2016-04-03 19:30:03.099 DMR Slot 2, received network voice header from 4020 to 2625094 //M: 2016-04-03 19:30:03.099 DMR Slot 2, received network voice header from 4020 to 2625094
//array_multisort($logLines,SORT_DESC);
foreach ($logLines as $logLine) { foreach ($logLines as $logLine) {
if(substr($logLine, 27, strpos($logLine,",") - 27) == "DMR Slot 2") { if(substr($logLine, 27, strpos($logLine,",") - 27) == "DMR Slot 2") {
$from = substr($logLine, strpos($logLine,"from") + 5, strpos($logLine,"to") - strpos($logLine,"from") - 6); $from = substr($logLine, strpos($logLine,"from") + 5, strpos($logLine,"to") - strpos($logLine,"from") - 6);
@ -556,5 +513,4 @@ function getName($callsign) {
$name = substr($name, strpos($name,$delimiter)+1); $name = substr($name, strpos($name,$delimiter)+1);
return $name; return $name;
} }
?> ?>

View file

@ -56,7 +56,6 @@ for ($i = 0; ($i < $totalLH); $i++) {
} }
echo"</tr>\n"; echo"</tr>\n";
} }
?> ?>
</tbody> </tbody>
</table> </table>

View file

@ -32,7 +32,6 @@ $localTXList = getHeardList($reverseLogLinesMMDVM);
</thead> </thead>
<tbody> <tbody>
<?php <?php
$counter = 0;
for ($i = 0; $i < count($localTXList); $i++) { for ($i = 0; $i < count($localTXList); $i++) {
$listElem = $localTXList[$i]; $listElem = $localTXList[$i];
if ($listElem[5] == "RF" && ($listElem[1]=="D-Star" || startsWith($listElem[1], "DMR") || $listElem[1]=="YSF")) { if ($listElem[5] == "RF" && ($listElem[1]=="D-Star" || startsWith($listElem[1], "DMR") || $listElem[1]=="YSF")) {
@ -56,12 +55,10 @@ for ($i = 0; $i < count($localTXList); $i++) {
echo"<td nowrap>$listElem[8]</td>"; echo"<td nowrap>$listElem[8]</td>";
} }
echo"</tr>\n"; echo"</tr>\n";
$counter++;
} }
} }
?> ?>
</tbody> </tbody>
</table> </table>
</div> </div>

View file

@ -1,8 +1,6 @@
<div class="panel panel-default"> <div class="panel panel-default">
<!-- Standard-Panel-Inhalt --> <!-- Standard-Panel-Inhalt -->
<div class="panel-heading">Enabled Modes</div> <div class="panel-heading">Enabled Modes</div>
<!-- Tabelle --> <!-- Tabelle -->
<table class="table"> <table class="table">
<tr> <tr>

View file

@ -1,7 +1,6 @@
<div class="panel panel-default"> <div class="panel panel-default">
<!-- Standard-Panel-Inhalt --> <!-- Standard-Panel-Inhalt -->
<div class="panel-heading">Repeater Info</div> <div class="panel-heading">Repeater Info</div>
<!-- Tabelle --> <!-- Tabelle -->
<div class="table-responsive"> <div class="table-responsive">
<table class="table"> <table class="table">

View file

@ -111,15 +111,11 @@
<th>Power</th> <th>Power</th>
<?php <?php
} }
?>
<?php
if ($cputemp !== NULL) { if ($cputemp !== NULL) {
?> ?>
<th>CPU-Temperature</th> <th>CPU-Temperature</th>
<?php <?php
} }
?>
<?php
if ($cpufreq !== NULL) { if ($cpufreq !== NULL) {
?> ?>
<th>CPU-Frequency</th> <th>CPU-Frequency</th>
@ -138,15 +134,11 @@
<td><?php if ($pinStatus == POWERONLINESTATE ) {echo "online";} else {echo "on battery";} ?></td> <td><?php if ($pinStatus == POWERONLINESTATE ) {echo "online";} else {echo "on battery";} ?></td>
<?php <?php
} }
?>
<?php
if ($cputemp !== NULL) { if ($cputemp !== NULL) {
?> ?>
<td><?php echo $cputemp; ?> &deg;C</td> <td><?php echo $cputemp; ?> &deg;C</td>
<?php <?php
} }
?>
<?php
if ($cpufreq !== NULL) { if ($cpufreq !== NULL) {
?> ?>
<td><?php echo $cpufreq; ?> MHz</td> <td><?php echo $cpufreq; ?> MHz</td>

View file

@ -22,21 +22,6 @@
</tr> </tr>
</thead> </thead>
<tbody id="txline"> <tbody id="txline">
<!--<tr >
<td></td>
<td></td>
<td></td>
<?php
if (defined("ENABLEXTDLOOKUP")) {
?>
<td></td>
<?php
}
?>
<td></td>
<td></td>
<td></td>
</tr>-->
</tbody> </tbody>
</table> </table>
</div> </div>

View file

@ -5,7 +5,6 @@ $time = $time[1] + $time[0];
$start = $time; $start = $time;
header("Cache-Control: no-cache, must-revalidate"); header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
// do not touch this includes!!! Never ever!!! // do not touch this includes!!! Never ever!!!
include "config/config.php"; include "config/config.php";
include "include/tools.php"; include "include/tools.php";
@ -18,7 +17,6 @@ include "version.php";
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=0.6,maximum-scale=1, user-scalable=yes"> <meta name="viewport" content="width=device-width, initial-scale=0.6,maximum-scale=1, user-scalable=yes">
<!--<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">-->
<?php <?php
if (!isset($_GET['stoprefresh'])) { if (!isset($_GET['stoprefresh'])) {
?> ?>
@ -28,11 +26,11 @@ include "version.php";
?> ?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.3/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.3/jquery.min.js"></script>
<!-- Das neueste kompilierte und minimierte CSS --> <!-- Das neueste kompilierte und minimierte CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap.min.css">
<!-- Optionales Theme --> <!-- Optionales Theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap-theme.min.css">
<!-- Das neueste kompilierte und minimierte JavaScript --> <!-- Das neueste kompilierte und minimierte JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/latest/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css"> <link rel="stylesheet" href="https://cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css">
<script type="text/javascript" src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script> <script type="text/javascript" src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>
<style> <style>
@ -40,8 +38,6 @@ include "version.php";
white-space:nowrap white-space:nowrap
} }
</style> </style>
<title><?php echo getCallsign($mmdvmconfigs) ?> - MMDVM-Dashboard by DG9VH</title> <title><?php echo getCallsign($mmdvmconfigs) ?> - MMDVM-Dashboard by DG9VH</title>
</head> </head>
<body> <body>
@ -90,13 +86,11 @@ $total_time = round(($finish - $start), 4);
echo '<!--Page generated in '.$total_time.' seconds.-->'; echo '<!--Page generated in '.$total_time.' seconds.-->';
?> | ?> |
<?php <?php
if (!isset($_GET['stoprefresh'])) { if (!isset($_GET['stoprefresh'])) {
echo '<a href="?stoprefresh">stop refreshing</a>'; echo '<a href="?stoprefresh">stop refreshing</a>';
} else { } else {
echo '<a href=".">start refreshing</a>'; echo '<a href=".">start refreshing</a>';
} }
?> ?>
| get your own at: <a href="https://github.com/dg9vh/MMDVMHost-Dashboard">https://github.com/dg9vh/MMDVMHost-Dashboard</a> | get your own at: <a href="https://github.com/dg9vh/MMDVMHost-Dashboard">https://github.com/dg9vh/MMDVMHost-Dashboard</a>
</div> </div>