diff --git a/include/functions.php b/include/functions.php index 12ce25d..87a4d53 100644 --- a/include/functions.php +++ b/include/functions.php @@ -38,6 +38,31 @@ function getFirmwareVersion() { echo $firmware; } +function getDMRMasterState() { + $logPath = MMDVMLOGPATH."/".MMDVMLOGPREFIX."-".date("Y-m-d").".log"; + $logLines = explode("\n", `egrep -h "(DMR, Logged into the master successfully)|(DMR, Closing DMR Network)" $logPath`); + $state = -1; + foreach($logLines as $logLine) { + if (strpos($logLine, "successfully") > 0) { + $state = 1; + } + if (strpos($logLine, "Closing") > 0) { + $state = 0; + } + } + if ($state >= 0) { + $fp = fopen('/tmp/DMRMasterState.txt', 'w'); + fwrite($fp, $state); + fclose($fp); + } else { + $fp = fopen('/tmp/DMRMasterState.txt', 'r'); + $contents = fread($fp, filesize("/tmp/DMRMasterState.txt")); + $state = $contents; + } + return $state; + +} + function getMMDVMConfig() { // loads MMDVM.ini into array for further use $conf = array(); diff --git a/include/repeaterinfo.php b/include/repeaterinfo.php index e3fc998..19a7417 100644 --- a/include/repeaterinfo.php +++ b/include/repeaterinfo.php @@ -58,8 +58,15 @@ if (getEnabled("DMR", $mmdvmconfigs) == 1) { echo"