$values) {
// UnBreak special cases
$section = str_replace("_", " ", $section);
$content .= "[".$section."]\n";
//append the values
foreach($values as $key=>$value) {
if ($section == "DMR Network" && $key == "Password" && $value) {
$value = str_replace('"', "", $value);
$content .= $key."=\"".$value."\"\n";
}
elseif ($section == "DMR Network" && $key == "Options" && $value) {
$value = str_replace('"', "", $value);
$content .= $key."=\"".$value."\"\n";
}
elseif ($section == "DMR Network" && $key == "Options" && !$value) {
$content .= $key."= \n";
}
elseif ($value == '') {
$content .= $key."=none\n";
}
else {
$content .= $key."=".$value."\n";
}
}
$content .= "\n";
}
//write it into file
if (!$handle = fopen($filepath, 'w')) {
return false;
}
$success = fwrite($handle, $content);
fclose($handle);
// Updates complete - copy the working file back to the proper location
exec('sudo mount -o remount,rw /'); // Make rootfs writable
exec('sudo cp /tmp/bW1kdm1ob3N0DQo.tmp /etc/mmdvmhost'); // Move the file back
exec('sudo chmod 644 /etc/mmdvmhost'); // Set the correct runtime permissions
exec('sudo chown root:root /etc/mmdvmhost'); // Set the owner
exec('sudo mount -o remount,ro /'); // Make rootfs read-only
// Reload the affected daemon
exec('sudo systemctl restart mmdvmhost.service'); // Reload the daemon
return $success;
}
//parse the ini file using default parse_ini_file() PHP function
$parsed_ini = parse_ini_file($filepath, true);
echo '
";
?>