$values) {
// UnBreak special cases
$section = str_replace("_", " ", $section);
$content .= "[".$section."]\n";
//append the values
foreach($values as $key=>$value) {
// Strip CR/LF from values before they land in the INI
// file. The save handler writes `$key=$value\n` and a
// newline inside $value would split the value into a
// new INI line, allowing injection of arbitrary
// additional keys (e.g. `value=foo\nDEBUG=1`). On a
// single-operator device the practical risk is low
// but the sanitiser is one line.
$value = str_replace(array("\r", "\n"), "", (string)$value);
$content .= $key."=".$value."\n";
}
$content .= "\n";
}
//write it into file
if (!$handle = fopen($filepath, 'w')) {
return false;
}
$success = fwrite($handle, $content);
fclose($handle);
// Atomic install: mode + owner set in one syscall sequence.
// /etc/dapnetapi.key holds DAPNET credentials — mode 600 keeps
// them readable only by www-data. Owner left as www-data
// because the dapnetgateway daemon reads via the dashboard
// (and dashboard reads it directly without sudo elsewhere);
// see fulledit_bmapikey.php for the same rationale.
exec('sudo mount -o remount,rw /');
exec('sudo install -m 600 -o www-data -g www-data '
. escapeshellarg($filepath) . ' /etc/dapnetapi.key');
exec('sudo mount -o remount,ro /');
return $success;
}
//parse the ini file using default parse_ini_file() PHP function
$parsed_ini = parse_ini_file($filepath, true);
echo '
";
?>