Merge pull request #212 from f1rmb/fix_array_offset_checking
Fix getConfigItem() function
This commit is contained in:
commit
157274df45
1 changed files with 13 additions and 7 deletions
|
@ -168,15 +168,21 @@ function getDMRId ($mmdvmconfigs) {
|
||||||
|
|
||||||
function getConfigItem($section, $key, $configs) {
|
function getConfigItem($section, $key, $configs) {
|
||||||
// retrieves the corresponding config-entry within a [section]
|
// retrieves the corresponding config-entry within a [section]
|
||||||
$sectionpos = array_search("[" . $section . "]", $configs) + 1;
|
$sectionpos = arraye_search("[" . $section . "]", $configs);
|
||||||
|
if ($sectionpos !== FALSE) {
|
||||||
|
$sectionpos++;
|
||||||
$len = count($configs);
|
$len = count($configs);
|
||||||
while(startsWith($configs[$sectionpos],$key."=") === false && $sectionpos <= ($len) ) {
|
while(($sectionpos < $len) && (startsWith($configs[$sectionpos],$key."=") === false) ) {
|
||||||
if (startsWith($configs[$sectionpos],"[")) {
|
if (startsWith($configs[$sectionpos],"[")) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$sectionpos++;
|
$sectionpos++;
|
||||||
}
|
}
|
||||||
|
if ($sectionpos < $len) {
|
||||||
return substr($configs[$sectionpos], strlen($key) + 1);
|
return substr($configs[$sectionpos], strlen($key) + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getEnabled ($mode, $mmdvmconfigs) {
|
function getEnabled ($mode, $mmdvmconfigs) {
|
||||||
|
|
Loading…
Reference in a new issue