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"".getConfigItem("DMR", "ColorCode", $mmdvmconfigs).""; if (getEnabled("DMR Network", $mmdvmconfigs) == 1) { - echo"".getConfigItem("DMR Network", "Address", $mmdvmconfigs).""; + echo""; + if (getDMRMasterState()) { + echo ""; + } else { + echo ""; + } + echo getConfigItem("DMR Network", "Address", $mmdvmconfigs).""; ?> + enabled'; diff --git a/version.php b/version.php index 9f2284a..21a8baf 100644 --- a/version.php +++ b/version.php @@ -1,3 +1,3 @@