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,71 +15,46 @@
</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))) {
$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))) 'total' => 'N.A',
{ 'used' => 'N.A',
$datas[] = array( 'free' => 'N.A',
'total' => 'N.A', 'percent_used' => 0,
'used' => 'N.A', 'mount' => 'N.A',
'free' => 'N.A', 'filesystem' => 'N.A',
'percent_used' => 0, );
'mount' => 'N.A', } else {
'filesystem' => 'N.A', $mounted_points = array();
); $key = 0;
} foreach ($df as $mounted) {
else list($filesystem, $type, $total, $used, $free, $percent, $mount) = explode(',', $mounted);
{ if ((strpos($type, 'tmpfs') !== false) && (strpos($mount, '/mnt/ramdisk') === false))
$mounted_points = array(); continue;
$key = 0; ?>
<tr>
foreach ($df as $mounted) <td><?php echo $filesystem ?></td>
{ <td><?php echo $mount ?></td>
list($filesystem, $type, $total, $used, $free, $percent, $mount) = explode(',', $mounted); <td><div class="progress"><div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="<?php echo trim($percent, '%') ?>" aria-valuemin="0" aria-valuemax="100" style="width: <?php echo trim($percent, '%') ?>%;"><?php echo trim($percent, '%') ?>%</div></div></td>
<td><?php echo getSize($free * 1024) ?></td>
if ((strpos($type, 'tmpfs') !== false) && (strpos($mount, '/mnt/ramdisk') === false)) <td><?php echo getSize($used * 1024) ?></td>
continue; <td><?php echo getSize($total * 1024) ?></td>
</tr>
<?php
?> $key++;
}
<tr> }
<td><?php echo $filesystem ?></td>
<td><?php echo $mount ?></td>
<td><div class="progress"><div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="<?php echo trim($percent, '%') ?>" aria-valuemin="0" aria-valuemax="100" style="width: <?php echo trim($percent, '%') ?>%;"><?php echo trim($percent, '%') ?>%</div></div></td>
<td><?php echo getSize($free * 1024) ?></td>
<td><?php echo getSize($used * 1024) ?></td>
<td><?php echo getSize($total * 1024) ?></td>
</tr>
<?php
$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 = "";
@ -201,7 +164,6 @@ function getHeardList($logLines, $onlyLast) {
} else if(strpos($logLine,"overflow in the DMR slot RF queue")) { } else if(strpos($logLine,"overflow in the DMR slot RF queue")) {
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);
@ -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);
@ -492,11 +449,11 @@ function getActualReflector($logLines, $mode) {
return "Reflector ".$from; return "Reflector ".$from;
} }
} }
$source = "RF"; $source = "RF";
if (strpos($logLine,"network") > 0 ) { if (strpos($logLine,"network") > 0 ) {
$source = "Net"; $source = "Net";
} }
if ( $source == "RF") { if ( $source == "RF") {
$to = substr($logLine, strpos($logLine, "to") + 3); $to = substr($logLine, strpos($logLine, "to") + 3);
if (strlen($to) == 5 && startsWith($to, "4")) { if (strlen($to) == 5 && startsWith($to, "4")) {
@ -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

@ -6,9 +6,9 @@ $reverseLogLinesMMDVM = $logLinesMMDVM;
array_multisort($reverseLogLinesMMDVM,SORT_DESC); array_multisort($reverseLogLinesMMDVM,SORT_DESC);
$lastHeard = getLastHeard($reverseLogLinesMMDVM); $lastHeard = getLastHeard($reverseLogLinesMMDVM);
if (defined("ENABLEYSFGATEWAY")) { if (defined("ENABLEYSFGATEWAY")) {
$YSFGatewayconfigs = getYSFGatewayConfig(); $YSFGatewayconfigs = getYSFGatewayConfig();
$logLinesYSFGateway = getYSFGatewayLog(); $logLinesYSFGateway = getYSFGatewayLog();
$reverseLogLinesYSFGateway = $logLinesYSFGateway; $reverseLogLinesYSFGateway = $logLinesYSFGateway;
array_multisort($reverseLogLinesYSFGateway,SORT_DESC); array_multisort($reverseLogLinesYSFGateway,SORT_DESC);
} }
?> ?>

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">
@ -61,16 +60,16 @@
?> ?>
<td><span class="label <?php <td><span class="label <?php
if (getConfigItem("DMR Network", "Slot1", $mmdvmconfigs) == 1) { if (getConfigItem("DMR Network", "Slot1", $mmdvmconfigs) == 1) {
echo 'label-success">enabled'; echo 'label-success">enabled';
} else { } else {
echo 'label-default">disabled'; echo 'label-default">disabled';
} }
?></span></td> ?></span></td>
<td><span class="label <?php <td><span class="label <?php
if (getConfigItem("DMR Network", "Slot2", $mmdvmconfigs) == 1) { if (getConfigItem("DMR Network", "Slot2", $mmdvmconfigs) == 1) {
echo 'label-success">enabled'; echo 'label-success">enabled';
} else { } else {
echo 'label-default">disabled'; echo 'label-default">disabled';
} }
?></span></td> ?></span></td>
<?php <?php

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

@ -26,7 +26,7 @@ function format_time($seconds) {
} }
function startsWith($haystack, $needle) { function startsWith($haystack, $needle) {
return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== false; return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== false;
} }
function getMHZ($freq) { function getMHZ($freq) {
@ -36,8 +36,8 @@ function getMHZ($freq) {
function isProcessRunning($processname) { function isProcessRunning($processname) {
exec("pgrep " . $processname, $pids); exec("pgrep " . $processname, $pids);
if(empty($pids)) { if(empty($pids)) {
// process not running! // process not running!
return false; return false;
} else { } else {
// process running! // process running!
return true; return true;

View file

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