Fixes config editing
parent
c00c1845f6
commit
a65ead94ad
|
@ -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);
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue