Fixes bug in config editing

main
Yasen Pramatarov 2024-09-06 19:03:08 +03:00
parent de7133be3d
commit 2d4205916b
1 changed files with 17 additions and 17 deletions

View File

@ -39,23 +39,23 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
}
// check if file is writable
if (!is_writable($config_file)) {
$_SESSION['error'] = getError('Configuration file is not writable.');
header("Location: $app_root?platform=$platform_id&page=config");
exit();
}
// try to update the config file
if (file_put_contents($config_file, $updatedContent) !== false) {
// update successful
$_SESSION['notice'] = "Configuration for {$_POST['name']} is updated.";
} else {
// unsuccessful
$error = error_get_last();
$_SESSION['error'] = getError('Error updating the config: ' . ($error['message'] ?? 'unknown error'));
}
// FIXME - if this is not needed for editing the flat file, remove it
// // check if file is writable
// if (!is_writable($config_file)) {
// $_SESSION['error'] = getError('Configuration file is not writable.');
// header("Location: $app_root?platform=$platform_id&page=config");
// exit();
// }
//
// // try to update the config file
// if (file_put_contents($config_file, $updatedContent) !== false) {
// // update successful
// $_SESSION['notice'] = "Configuration for {$_POST['name']} is updated.";
// } else {
// // unsuccessful
// $error = error_get_last();
// $_SESSION['error'] = getError('Error updating the config: ' . ($error['message'] ?? 'unknown error'));
// }
// FIXME the new file is not loaded on first page load
unset($config);