diff --git a/include/functions.php b/include/functions.php index ec02cc7..5b81863 100644 --- a/include/functions.php +++ b/include/functions.php @@ -1,46 +1,60 @@ 0) { - $callsign = substr($callsign2, 0, strpos($callsign2,"/")); - } - $callsign = trim($callsign); - $id =""; - if ($mode == "D-Star") { - $id = substr($callsign2, strpos($callsign2,"/") + 1); - } - $target = substr($logLine, strpos($logLine, "to") + 3); - $source = "RF"; - if (strpos($logLine,"network") > 0 ) { - $source = "Network"; - } - - if ( strlen($callsign <7) ) { - array_push($heardList, array($timestamp, $mode, $callsign, $id, $target, $source)); - } + foreach ($logLines as $logLine) { + //removing invalid lines + if(strpos($logLine,"BS_Dwn_Act")) { + break; + } else if(strpos($logLine,"invalid access")) { + break; + } + + $timestamp = substr($logLine, 3, 19); + $mode = substr($logLine, 27, strpos($logLine,",") - 27); + $callsign2 = substr($logLine, strpos($logLine,"from") + 5, strpos($logLine,"to") - strpos($logLine,"from") - 6); + $callsign = $callsign2; + if (strpos($callsign2,"/") > 0) { + $callsign = substr($callsign2, 0, strpos($callsign2,"/")); + } + $callsign = trim($callsign); + $id =""; + if ($mode == "D-Star") { + $id = substr($callsign2, strpos($callsign2,"/") + 1); + } + $target = substr($logLine, strpos($logLine, "to") + 3); + $source = "RF"; + if (strpos($logLine,"network") > 0 ) { + $source = "Network"; + } + + if ( strlen($callsign <7) ) { + array_push($heardList, array($timestamp, $mode, $callsign, $id, $target, $source)); } - fclose($log); } return $heardList; } -function getLastHeard() { +function getLastHeard($logLines) { $lastHeard = array(); $heardCalls = array(); - $heardList = getHeardList(); + $heardList = getHeardList($logLines); array_multisort($heardList,SORT_DESC); foreach ($heardList as $listElem) { if ( ($listElem[1] == "D-Star") || (startsWith($listElem[1], "DMR")) ) { @@ -52,4 +66,7 @@ function getLastHeard() { } return $lastHeard; } + +//Some basic inits +$logLines = getLog(); ?> \ No newline at end of file diff --git a/include/lh.php b/include/lh.php index 286d0bc..8989f0a 100644 --- a/include/lh.php +++ b/include/lh.php @@ -1,5 +1,5 @@