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 -->
<div class="table-responsive">
<table id="diskuse" class="table table-condensed table-striped table-hover">
<thead>
<tr>
<th class="w10p filesystem">Filesystem</th>
<th class="w20p">Mount</th>
<th>Use</th>
@ -17,71 +15,46 @@
</tr>
</thead>
<tbody>
<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE);
//include "./functions.php";
try{
$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(
'total' => 'N.A',
'used' => 'N.A',
'free' => 'N.A',
'percent_used' => 0,
'mount' => 'N.A',
'filesystem' => 'N.A',
);
}
else
{
$mounted_points = array();
$key = 0;
foreach ($df as $mounted)
{
list($filesystem, $type, $total, $used, $free, $percent, $mount) = explode(',', $mounted);
if ((strpos($type, 'tmpfs') !== false) && (strpos($mount, '/mnt/ramdisk') === false))
continue;
?>
<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++;
}
}
try{
$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(
'total' => 'N.A',
'used' => 'N.A',
'free' => 'N.A',
'percent_used' => 0,
'mount' => 'N.A',
'filesystem' => 'N.A',
);
} else {
$mounted_points = array();
$key = 0;
foreach ($df as $mounted) {
list($filesystem, $type, $total, $used, $free, $percent, $mount) = explode(',', $mounted);
if ((strpos($type, 'tmpfs') !== false) && (strpos($mount, '/mnt/ramdisk') === false))
continue;
?>
<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) {
return false;
return false;
}
?>
</tbody>
</table>
</div>
</div>

View file

@ -58,7 +58,6 @@ function getConfigItem($section, $key, $configs) {
}
$sectionpos++;
}
return substr($configs[$sectionpos], strlen($key) + 1);
}
@ -109,26 +108,9 @@ function showMode($mode, $mmdvmconfigs) {
<?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() {
// Open Logfile and copy loglines into LogLines-Array()
$logPath = MMDVMLOGPATH."/".MMDVMLOGPREFIX."-".date("Y-m-d").".log";
$logLines = explode("\n", `grep M: $logPath`);
return $logLines;
}
@ -136,31 +118,13 @@ function getMMDVMLog() {
function getShortMMDVMLog() {
// Open Logfile and copy loglines into LogLines-Array()
$logPath = MMDVMLOGPATH."/".MMDVMLOGPREFIX."-".date("Y-m-d").".log";
$logLines = explode("\n", `tail -n100 $logPath`);
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() {
// Open Logfile and copy loglines into LogLines-Array()
$logPath = YSFGATEWAYLOGPATH."/".YSFGATEWAYLOGPREFIX."-".date("Y-m-d").".log";
$logLines = explode("\n", `grep D: $logPath`);
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-30 14:57:43.072 DMR Slot 2, received RF voice header from DG9VH to 5000
function getHeardList($logLines, $onlyLast) {
//array_multisort($logLines,SORT_DESC);
$heardList = array();
$ts1duration = "";
$ts1loss = "";
@ -202,7 +165,6 @@ function getHeardList($logLines, $onlyLast) {
continue;
}
if(strpos($logLine,"end of") || strpos($logLine,"watchdog has expired") || strpos($logLine,"ended RF data") || strpos($logLine,"ended network")) {
$lineTokens = explode(", ",$logLine);
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($lastHeard, $listElem);
$counter++;
}/*
if ($counter == LHLINES) {
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-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
//array_multisort($logLines,SORT_DESC);
foreach ($logLines as $logLine) {
if(substr($logLine, 27, strpos($logLine,",") - 27) == "DMR Slot 2") {
$from = substr($logLine, strpos($logLine,"from") + 5, strpos($logLine,"to") - strpos($logLine,"from") - 6);
@ -492,10 +449,10 @@ function getActualReflector($logLines, $mode) {
return "Reflector ".$from;
}
}
$source = "RF";
if (strpos($logLine,"network") > 0 ) {
$source = "Net";
}
$source = "RF";
if (strpos($logLine,"network") > 0 ) {
$source = "Net";
}
if ( $source == "RF") {
$to = substr($logLine, strpos($logLine, "to") + 3);
@ -556,5 +513,4 @@ function getName($callsign) {
$name = substr($name, strpos($name,$delimiter)+1);
return $name;
}
?>

View file

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

View file

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

View file

@ -32,7 +32,6 @@ $localTXList = getHeardList($reverseLogLinesMMDVM);
</thead>
<tbody>
<?php
$counter = 0;
for ($i = 0; $i < count($localTXList); $i++) {
$listElem = $localTXList[$i];
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"</tr>\n";
$counter++;
}
}
?>
</tbody>
</table>
</div>

View file

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

View file

@ -1,7 +1,6 @@
<div class="panel panel-default">
<!-- Standard-Panel-Inhalt -->
<div class="panel-heading">Repeater Info</div>
<!-- Tabelle -->
<div class="table-responsive">
<table class="table">
@ -61,16 +60,16 @@
?>
<td><span class="label <?php
if (getConfigItem("DMR Network", "Slot1", $mmdvmconfigs) == 1) {
echo 'label-success">enabled';
echo 'label-success">enabled';
} else {
echo 'label-default">disabled';
echo 'label-default">disabled';
}
?></span></td>
<td><span class="label <?php
if (getConfigItem("DMR Network", "Slot2", $mmdvmconfigs) == 1) {
echo 'label-success">enabled';
echo 'label-success">enabled';
} else {
echo 'label-default">disabled';
echo 'label-default">disabled';
}
?></span></td>
<?php

View file

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

View file

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

View file

@ -22,22 +22,7 @@
</tr>
</thead>
<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>
</div>
</div>

View file

@ -5,7 +5,6 @@ $time = $time[1] + $time[0];
$start = $time;
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
// do not touch this includes!!! Never ever!!!
include "config/config.php";
include "include/tools.php";
@ -18,7 +17,6 @@ include "version.php";
<head>
<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=1, maximum-scale=1, user-scalable=no">-->
<?php
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>
<!-- 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 -->
<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 -->
<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">
<script type="text/javascript" src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>
<style>
@ -40,8 +38,6 @@ include "version.php";
white-space:nowrap
}
</style>
<title><?php echo getCallsign($mmdvmconfigs) ?> - MMDVM-Dashboard by DG9VH</title>
</head>
<body>
@ -90,13 +86,11 @@ $total_time = round(($finish - $start), 4);
echo '<!--Page generated in '.$total_time.' seconds.-->';
?> |
<?php
if (!isset($_GET['stoprefresh'])) {
echo '<a href="?stoprefresh">stop refreshing</a>';
} else {
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>
</div>