From b512f045446942f802740764d5b4178c97205a37 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Mon, 2 Sep 2013 03:19:42 +0200 Subject: switch from json config to ini config --- utility/config.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'utility') diff --git a/utility/config.php b/utility/config.php index e00ad940f..7841b3f5f 100644 --- a/utility/config.php +++ b/utility/config.php @@ -111,10 +111,10 @@ class Config { } else { $content = $this->fileSystem->file_get_contents($configPath); - $configValues = json_decode($content, true); + $configValues = parse_ini_string($content); - if($configValues === null) { - $this->api->log('Configuration contains invalid JSON' , 'warn'); + if($configValues === false || count($configValues) === 0) { + $this->api->log('Configuration invalid. Ignoring values.' , 'warn'); } else { foreach($configValues as $key => $value) { @@ -132,15 +132,15 @@ class Config { public function write($configPath) { - $json = json_encode(array( - "autoPurgeMinimumInterval" => $this->autoPurgeMinimumInterval, - "autoPurgeCount" => $this->autoPurgeCount, - "simplePieCacheDuration" => $this->simplePieCacheDuration, - "feedFetcherTimeout" => $this->feedFetcherTimeout, - "useCronUpdates" => $this->useCronUpdates, - ), JSON_PRETTY_PRINT); - - $this->fileSystem->file_put_contents($configPath, $json); + $ini = + "autoPurgeMinimumInterval = " . $this->autoPurgeMinimumInterval . "\n" . + "autoPurgeCount = " . $this->autoPurgeCount . "\n" . + "simplePieCacheDuration = " . $this->simplePieCacheDuration . "\n" . + "feedFetcherTimeout = " . $this->feedFetcherTimeout . "\n" . + "useCronUpdates = " . var_export($this->useCronUpdates, true) + ; + + $this->fileSystem->file_put_contents($configPath, $ini); } -- cgit v1.2.3