Numbering YSFReflectors, showing only active within last 2 hours

This commit is contained in:
dg9vh 2016-06-12 08:50:30 +00:00
parent f5db7ad19e
commit 305afe8f8c
2 changed files with 21 additions and 11 deletions

View file

@ -113,9 +113,9 @@ function getYSFGatewayLog() {
$logLines = array(); $logLines = array();
if ($log = fopen(YSFGATEWAYLOGPATH."/".YSFGATEWAYLOGPREFIX."-".date("Y-m-d").".log", 'r')) { if ($log = fopen(YSFGATEWAYLOGPATH."/".YSFGATEWAYLOGPREFIX."-".date("Y-m-d").".log", 'r')) {
while ($logLine = fgets($log)) { while ($logLine = fgets($log)) {
// if (!strpos($logLine, "Debug") && !strpos($logLine,"Received a NAK") && !startsWith($logLine,"I:")) { if (startsWith($logLine,"D:")) {
array_push($logLines, $logLine); array_push($logLines, $logLine);
// } }
} }
fclose($log); fclose($log);
} }
@ -438,14 +438,20 @@ function getActiveYSFReflectors($logLines) {
foreach ($logLines as $logLine) { foreach ($logLines as $logLine) {
if (strpos($logLine, "Have reflector status reply from")) { if (strpos($logLine, "Have reflector status reply from")) {
$timestamp = substr($logLine, 3, 19); $timestamp = substr($logLine, 3, 19);
$str = substr($logLine, 60); $timestamp2 = new DateTime($timestamp);
$id = strtok($str, "/"); $now = new DateTime();
$name = strtok("/"); $timestamp2->add(new DateInterval('PT2H'));
$description = strtok("/");
$concount = strtok("/"); if ($now->format('U') <= $timestamp2->format('U')) {
if(!(array_search($name, $reflectors) > -1)) { $str = substr($logLine, 60);
array_push($reflectors,$name); $id = strtok($str, "/");
array_push($reflectorlist, array($name, $description, $id, $concount, $timestamp)); $name = strtok("/");
$description = strtok("/");
$concount = strtok("/");
if(!(array_search($name, $reflectors) > -1)) {
array_push($reflectors,$name);
array_push($reflectorlist, array($name, $description, $id, $concount, $timestamp));
}
} }
} }
} }

View file

@ -20,7 +20,7 @@
</div> </div>
<div class="panel panel-default"> <div class="panel panel-default">
<!-- Standard-Panel-Inhalt --> <!-- Standard-Panel-Inhalt -->
<div class="panel-heading">Reflectors-Info</div> <div class="panel-heading">YSFReflectors reported active last 2 hours</div>
<!-- Tabelle --> <!-- Tabelle -->
<table class="table"> <table class="table">
@ -30,6 +30,7 @@
if (count($activeYSFReflectors) > 0) { if (count($activeYSFReflectors) > 0) {
?> ?>
<tr> <tr>
<th>No.</th>
<th>Name</th> <th>Name</th>
<th>Description</th> <th>Description</th>
<th>ID</th> <th>ID</th>
@ -37,12 +38,15 @@
<th>Last info of</th> <th>Last info of</th>
</tr> </tr>
<?php <?php
$counter = 1;
foreach ($activeYSFReflectors as $reflector) { foreach ($activeYSFReflectors as $reflector) {
echo "<tr>"; echo "<tr>";
echo "<td>$counter</td>";
for ($i = 0; $i < 5; $i++) { for ($i = 0; $i < 5; $i++) {
echo"<td>$reflector[$i]</td>"; echo"<td>$reflector[$i]</td>";
} }
echo "</tr>"; echo "</tr>";
$counter++;
} }
} }
?> ?>