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();
if ($log = fopen(YSFGATEWAYLOGPATH."/".YSFGATEWAYLOGPREFIX."-".date("Y-m-d").".log", 'r')) {
while ($logLine = fgets($log)) {
// if (!strpos($logLine, "Debug") && !strpos($logLine,"Received a NAK") && !startsWith($logLine,"I:")) {
if (startsWith($logLine,"D:")) {
array_push($logLines, $logLine);
// }
}
}
fclose($log);
}
@ -438,6 +438,11 @@ function getActiveYSFReflectors($logLines) {
foreach ($logLines as $logLine) {
if (strpos($logLine, "Have reflector status reply from")) {
$timestamp = substr($logLine, 3, 19);
$timestamp2 = new DateTime($timestamp);
$now = new DateTime();
$timestamp2->add(new DateInterval('PT2H'));
if ($now->format('U') <= $timestamp2->format('U')) {
$str = substr($logLine, 60);
$id = strtok($str, "/");
$name = strtok("/");
@ -449,6 +454,7 @@ function getActiveYSFReflectors($logLines) {
}
}
}
}
array_multisort($reflectorlist);
return $reflectorlist;
}

View file

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