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