From 305afe8f8c18e1f4693153ba6808415fa7889e54 Mon Sep 17 00:00:00 2001 From: dg9vh Date: Sun, 12 Jun 2016 08:50:30 +0000 Subject: [PATCH] Numbering YSFReflectors, showing only active within last 2 hours --- include/functions.php | 26 ++++++++++++++++---------- include/ysfgatewayinfo.php | 6 +++++- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/include/functions.php b/include/functions.php index bacfb98..a9f126b 100644 --- a/include/functions.php +++ b/include/functions.php @@ -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,14 +438,20 @@ function getActiveYSFReflectors($logLines) { foreach ($logLines as $logLine) { if (strpos($logLine, "Have reflector status reply from")) { $timestamp = substr($logLine, 3, 19); - $str = substr($logLine, 60); - $id = strtok($str, "/"); - $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)); + $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("/"); + $description = strtok("/"); + $concount = strtok("/"); + if(!(array_search($name, $reflectors) > -1)) { + array_push($reflectors,$name); + array_push($reflectorlist, array($name, $description, $id, $concount, $timestamp)); + } } } } diff --git a/include/ysfgatewayinfo.php b/include/ysfgatewayinfo.php index 5853f3c..b2066c5 100644 --- a/include/ysfgatewayinfo.php +++ b/include/ysfgatewayinfo.php @@ -20,7 +20,7 @@
-
Reflectors-Info
+
YSFReflectors reported active last 2 hours
@@ -30,6 +30,7 @@ if (count($activeYSFReflectors) > 0) { ?> + @@ -37,12 +38,15 @@ "; + echo ""; for ($i = 0; $i < 5; $i++) { echo""; } echo ""; + $counter++; } } ?>
No. Name Description IDLast info of
$counter$reflector[$i]