From a65ead94ade31bec994b8171719acc493cb3a6d7 Mon Sep 17 00:00:00 2001 From: Yasen Pramatarov Date: Fri, 1 Nov 2024 18:27:57 +0200 Subject: [PATCH] Fixes config editing --- app/classes/config.php | 4 ++-- app/pages/config.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/classes/config.php b/app/classes/config.php index 5db59fd..2c810b1 100644 --- a/app/classes/config.php +++ b/app/classes/config.php @@ -3,7 +3,7 @@ class Config { // edit the config file - public function editConfigFile($updatedConfig) { + public function editConfigFile($updatedConfig, $config_file) { // first we get a fresh config file contents as text $config_contents = file_get_contents($config_file); if (!$config_contents) { @@ -15,7 +15,7 @@ class Config { // we look for 'option' => value // option is always in single quotes // value is without quotes, because it could be true/false - $patterm = "/(['\"]{$key}['\"]\s*=>\s*)([^,]+),/" + $patterm = "/(['\"]{$key}['\"]\s*=>\s*)([^,]+),/"; // prepare the value and replace it $replacementValue = var_export($newValue, true); diff --git a/app/pages/config.php b/app/pages/config.php index f16c577..17e4d2c 100644 --- a/app/pages/config.php +++ b/app/pages/config.php @@ -22,7 +22,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { // editing the config file if (isset($_POST['item']) && $_POST['item'] === 'config_file') { - $result = $configObject->editConfigFile($_POST); + $result = $configObject->editConfigFile($_POST, $config_file); if ($result === true) { $_SESSION['notice'] = "The config file is edited."; } else {