diff --git a/app/classes/config.php b/app/classes/config.php index 7dd8716..0d00fb3 100644 --- a/app/classes/config.php +++ b/app/classes/config.php @@ -8,7 +8,7 @@ class Config { } // loading the config.js - public function getPlatformConfigjs($platformDetails) { + public function getPlatformConfigjs($platformDetails, $raw = false) { // constructing the URL $configjsFile = $platformDetails['jitsi_url'] . '/config.js'; @@ -28,12 +28,20 @@ class Config { $fileContent = @file_get_contents($configjsFile, false, $context); if ($fileContent !== false) { - // remove block comments - $platformConfigjs = preg_replace('!/\*.*?\*/!s', '', $fileContent); - // remove single-line comments - $platformConfigjs = preg_replace('/\/\/[^\n]*/', '', $platformConfigjs); - // remove empty lines - $platformConfigjs = preg_replace('/^\s*[\r\n]/m', '', $platformConfigjs); + + // when we need only uncommented values + if ($raw === false) { + // remove block comments + $platformConfigjs = preg_replace('!/\*.*?\*/!s', '', $fileContent); + // remove single-line comments + $platformConfigjs = preg_replace('/\/\/[^\n]*/', '', $platformConfigjs); + // remove empty lines + $platformConfigjs = preg_replace('/^\s*[\r\n]/m', '', $platformConfigjs); + + // when we need the full file as it is + } else { + $platformConfigjs = $fileContent; + } } return $platformConfigjs; @@ -42,7 +50,7 @@ class Config { // loading the interface_config.js - public function getPlatformInterfaceConfigjs($platformDetails) { + public function getPlatformInterfaceConfigjs($platformDetails, $raw = false) { // constructing the URL $interfaceConfigjsFile = $platformDetails['jitsi_url'] . '/interface_config.js'; @@ -62,12 +70,20 @@ class Config { $fileContent = @file_get_contents($interfaceConfigjsFile, false, $context); if ($fileContent !== false) { - // remove block comments - $platformInterfaceConfigjs = preg_replace('!/\*.*?\*/!s', '', $fileContent); - // remove single-line comments - $platformInterfaceConfigjs = preg_replace('/\/\/[^\n]*/', '', $platformInterfaceConfigjs); - // remove empty lines - $platformInterfaceConfigjs = preg_replace('/^\s*[\r\n]/m', '', $platformInterfaceConfigjs); + + // when we need only uncommented values + if ($raw === false) { + // remove block comments + $platformInterfaceConfigjs = preg_replace('!/\*.*?\*/!s', '', $fileContent); + // remove single-line comments + $platformInterfaceConfigjs = preg_replace('/\/\/[^\n]*/', '', $platformInterfaceConfigjs); + // remove empty lines + $platformInterfaceConfigjs = preg_replace('/^\s*[\r\n]/m', '', $platformInterfaceConfigjs); + + // when we need the full file as it is + } else { + $platformInterfaceConfigjs = $fileContent; + } } return $platformInterfaceConfigjs; diff --git a/app/pages/config.php b/app/pages/config.php index 322902e..0f22991 100644 --- a/app/pages/config.php +++ b/app/pages/config.php @@ -101,18 +101,25 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { // no form submitted, show the templates } else { + + // $item - config.js and interface_config.js are special case; remote loaded files switch ($item) { case 'configjs': + $mode = $_REQUEST['mode'] ?? ''; + $raw = ($mode === 'raw'); $platformDetails = $configure->getPlatformDetails($config, $platform_id); - $platformConfigjs = $configure->getPlatformConfigjs($platformDetails); + $platformConfigjs = $configure->getPlatformConfigjs($platformDetails, $raw); include('../app/templates/config-list-configjs.php'); break; case 'interfaceconfigjs': + $mode = $_REQUEST['mode'] ?? ''; + $raw = ($mode === 'raw'); $platformDetails = $configure->getPlatformDetails($config, $platform_id); - $platformInterfaceConfigjs = $configure->getPlatformInterfaceConfigjs($platformDetails); + $platformInterfaceConfigjs = $configure->getPlatformInterfaceConfigjs($platformDetails, $raw); include('../app/templates/config-list-interfaceconfigjs.php'); break; + // if there is no $item, we work on the local config file default: switch ($action) { case 'add': diff --git a/app/templates/config-list-configjs.php b/app/templates/config-list-configjs.php index b2abccf..49da179 100644 --- a/app/templates/config-list-configjs.php +++ b/app/templates/config-list-configjs.php @@ -3,8 +3,15 @@

Configuration of the Jitsi platform

-

URL:

-

config.js

+

+ URL: + FILE: config.js + + view only active lines + + view raw file contents + +

 
                     

Configuration of the Jitsi platform

-

URL:

-

interface_config.js

+

+ URL: + FILE: interface_config.js + + view only active lines + + view raw file contents + +