Fixes config editing
parent
c00c1845f6
commit
a65ead94ad
|
@ -3,7 +3,7 @@
|
||||||
class Config {
|
class Config {
|
||||||
|
|
||||||
// edit the config file
|
// edit the config file
|
||||||
public function editConfigFile($updatedConfig) {
|
public function editConfigFile($updatedConfig, $config_file) {
|
||||||
// first we get a fresh config file contents as text
|
// first we get a fresh config file contents as text
|
||||||
$config_contents = file_get_contents($config_file);
|
$config_contents = file_get_contents($config_file);
|
||||||
if (!$config_contents) {
|
if (!$config_contents) {
|
||||||
|
@ -15,7 +15,7 @@ class Config {
|
||||||
// we look for 'option' => value
|
// we look for 'option' => value
|
||||||
// option is always in single quotes
|
// option is always in single quotes
|
||||||
// value is without quotes, because it could be true/false
|
// value is without quotes, because it could be true/false
|
||||||
$patterm = "/(['\"]{$key}['\"]\s*=>\s*)([^,]+),/"
|
$patterm = "/(['\"]{$key}['\"]\s*=>\s*)([^,]+),/";
|
||||||
|
|
||||||
// prepare the value and replace it
|
// prepare the value and replace it
|
||||||
$replacementValue = var_export($newValue, true);
|
$replacementValue = var_export($newValue, true);
|
||||||
|
|
|
@ -22,7 +22,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
|
|
||||||
// editing the config file
|
// editing the config file
|
||||||
if (isset($_POST['item']) && $_POST['item'] === 'config_file') {
|
if (isset($_POST['item']) && $_POST['item'] === 'config_file') {
|
||||||
$result = $configObject->editConfigFile($_POST);
|
$result = $configObject->editConfigFile($_POST, $config_file);
|
||||||
if ($result === true) {
|
if ($result === true) {
|
||||||
$_SESSION['notice'] = "The config file is edited.";
|
$_SESSION['notice'] = "The config file is edited.";
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue