From 3217b73d08e1b76193f02d2d912134320ef40bfe Mon Sep 17 00:00:00 2001 From: "o.pinke" Date: Thu, 22 Apr 2021 11:15:21 +0200 Subject: [PATCH] add client path for configuration --- includes/functions.mod_rewrite.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/includes/functions.mod_rewrite.php b/includes/functions.mod_rewrite.php index 42c645f..d93dd73 100644 --- a/includes/functions.mod_rewrite.php +++ b/includes/functions.mod_rewrite.php @@ -673,9 +673,25 @@ function mr_getConfiguration($clientId) { * @return bool */ function mr_setConfiguration($clientId, array $config) { - global $cfg; - - $file = $cfg['path']['contenido'] . $cfg['path']['plugins'] . 'cl-mod-rewrite/includes/config.mod_rewrite_' . $clientId . '.php'; + $sClientPath = cRegistry::getClientConfig(cRegistry::getClientId())['path']['frontend']; + $sConfigClientPath = $sClientPath.'/data/config/'.CL_ENVIRONMENT.'/'; + + if (is_writable($sClientPath) && !file_exists($sConfigClientPath)) { + try { + mkdir($sConfigClientPath, 0777, true); + } catch (Exception $ex) { + $oWriter = cLogWriter::factory("File", array('destination' => 'contenido.log')); + $oLog = new cLog($oWriter); + $oLog->log($ex->getFile() . " (" . $ex->getLine() . "): " . $ex->getMessage(), cLog::WARN); + } + } + + if(file_exists($sConfigClientPath) && is_writable($sConfigClientPath)) { + $file = $sConfigClientPath. 'config.mod_rewrite.php'; + } else { + $file = cRegistry::getConfigValue('path', 'contenido') . cRegistry::getConfigValue('path', 'plugins') . 'cl-mod-rewrite/includes/config.mod_rewrite_' . cRegistry::getClientId() . '.php'; + } + $result = file_put_contents($file, serialize($config)); return ($result) ? true : false; }