improved configuration-readout

This commit is contained in:
dg9vh 2016-05-10 09:17:50 +02:00
parent 84e4e56188
commit d981c6c9c6

View file

@ -19,27 +19,33 @@ function getMMDVMConfig() {
} }
function getCallsign($mmdvmconfigs) { function getCallsign($mmdvmconfigs) {
foreach ($mmdvmconfigs as $config) { return getConfigItem("general", "Callsign", $mmdvmconfigs);
$pos = strpos($config, "Callsign"); }
if ($pos !== false) {
return substr($config, 9); function getConfigItem($section, $key, $configs) {
} $sectionpos = array_search("[" . $section . "]", $configs) + 1;
$len = count($configs);
while(startsWith($configs[$sectionpos],$key."=") === false && $sectionpos <= ($len) ) {
if (startsWith($configs[$sectionpos],"[")) {
return null;
}
$sectionpos++;
} }
return substr($configs[$sectionpos], strlen($key) + 1);
} }
function getEnabled ($mode, $mmdvmconfigs) { function getEnabled ($mode, $mmdvmconfigs) {
$modepos = array_search($mode,$mmdvmconfigs); return getConfigItem($mode, "Enable", $mmdvmconfigs);
while(strpos($mmdvmconfigs[$modepos],"Enable") === false ) {
$modepos++;
}
return substr($mmdvmconfigs[$modepos], 7);
} }
function showMode($mode, $mmdvmconfigs) { function showMode($mode, $mmdvmconfigs) {
?> ?>
<td><span class="label <?php <td><span class="label <?php
if (getEnabled("[" . $mode . "]", $mmdvmconfigs) == 1) { if (getEnabled($mode, $mmdvmconfigs) == 1) {
echo "label-success"; } else { echo "label-success";
} else {
echo "label-danger"; echo "label-danger";
} }
?>"><?php echo $mode ?></span></td> ?>"><?php echo $mode ?></span></td>