Adds config.js capability

main
Yasen Pramatarov 2024-08-28 12:59:13 +03:00
parent 1780233778
commit cf7d417193
7 changed files with 166 additions and 16 deletions

View File

@ -0,0 +1,80 @@
<?php
class Config {
public function getPlatformDetails($config, $platform_id) {
$platformDetails = $config['platforms'][$platform_id];
return $platformDetails;
}
// loading the config.js
public function getPlatformConfigjs($platformDetails) {
// constructing the URL
$configjsFile = $platformDetails['jitsi_url'] . '/config.js';
// default content, if we can't get the file contents
$platformConfigjs = "The file $configjsFile can't be loaded.";
// ssl options
$contextOptions = [
'ssl' => [
'verify_peer' => true,
'verify_peer_name' => true,
],
];
$context = stream_context_create($contextOptions);
// get the file
$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);
}
return $platformConfigjs;
}
// loading the interface_config.js
public function getPlatformInterfaceConfigjs($platformDetails) {
// constructing the URL
$interfaceConfigjsFile = $platformDetails['jitsi_url'] . '/interface_config.js';
// default content, if we can't get the file contents
$platformInterfaceConfigjs = "The file $interfaceConfigjsFile can't be loaded.";
// ssl options
$contextOptions = [
'ssl' => [
'verify_peer' => true,
'verify_peer_name' => true,
],
];
$context = stream_context_create($contextOptions);
// get the file
$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);
}
return $platformInterfaceConfigjs;
}
}
?>

View File

@ -38,7 +38,7 @@ return [
'platforms' => [
'0' => [
'name' => 'meet1',
'jitsi_url' => 'https://meet.example.com',
'jitsi_url' => 'https://meet.lindeas.com',
'jilo_database' => '../../jilo/jilo.db',
],
'1' => [

View File

@ -1,9 +1,12 @@
<?php
$action = $_REQUEST['action'] ?? '';
require_once '../app/classes/config.php';
require '../app/helpers/errors.php';
require '../app/helpers/config.php';
$configure = new Config();
// if a form is submitted, it's from the edit page
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
@ -98,6 +101,19 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// no form submitted, show the templates
} else {
switch ($item) {
case 'configjs':
$platformDetails = $configure->getPlatformDetails($config, $platform_id);
$platformConfigjs = $configure->getPlatformConfigjs($platformDetails);
include('../app/templates/config-list-configjs.php');
break;
case 'interfaceconfigjs':
$platformDetails = $configure->getPlatformDetails($config, $platform_id);
$platformInterfaceConfigjs = $configure->getPlatformInterfaceConfigjs($platformDetails);
include('../app/templates/config-list-interfaceconfigjs.php');
break;
default:
switch ($action) {
case 'add':
include('../app/templates/config-add-platform.php');
@ -112,5 +128,6 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
include('../app/templates/config-list.php');
}
}
}
?>

View File

@ -0,0 +1,15 @@
<!-- widget "config" -->
<div class="card text-center w-75 mx-lef">
<p class="h4 card-header">Configuration of the Jitsi platform <strong><?= htmlspecialchars($platformDetails['name']) ?></strong></p>
<div class="card-body">
<p class="card-text">URL: <?= htmlspecialchars($platformDetails['jitsi_url']) ?></p>
<p class="card-text">config.js</p>
<pre style="text-align: left;">
<?php
echo htmlspecialchars($platformConfigjs);
?>
</pre>
</div>
</div>
<!-- /widget "config" -->

View File

@ -0,0 +1,14 @@
<!-- widget "config" -->
<div class="card text-center w-75 mx-lef">
<p class="h4 card-header">Jilo web configuration</p>
<div class="card-body">
<p class="card-text">platform variables</p>
<?php
include '../app/helpers/render.php';
renderConfig($config, '0');
echo "\n";
?>
</div>
</div>
<!-- /widget "config" -->

View File

@ -5,6 +5,9 @@
<div class="col-4"><button class="btn btn-sm btn-info toggle-sidebar-button" type="button" id="toggleSidebarButton" value=">>"></button></div>
<div class="sidebar-content card ml-3 mt-3">
<ul class="list-group">
<li class="list-group-item bg-light" style="border: none;"><p class="text-end mb-0"><small>statistics</small></p></li>
<a href="<?= $app_root ?>?platform=<?= $platform_id ?>&page=front">
<li class="list-group-item<?php if ($page === 'front') echo ' list-group-item-secondary'; else echo ' list-group-item-action'; ?>">
<i class="fas fa-chart-line" data-toggle="tooltip" data-placement="right" data-offset="30.0" title="general jitsi stats"></i>general stats
@ -25,9 +28,11 @@
<i class="fas fa-puzzle-piece" data-toggle="tooltip" data-placement="right" data-offset="30.0" title="components"></i>components
</li>
</a>
<li class="list-group-item bg-light" style="border-left: none; border-right: none;"></li>
<li class="list-group-item bg-light" style="border: none;"><p class="text-end mb-0"><small>jilo-web config</small></p></li>
<a href="<?= $app_root ?>?page=config">
<li class="list-group-item<?php if ($page === 'config') echo ' list-group-item-secondary'; else echo ' list-group-item-action'; ?>">
<li class="list-group-item<?php if ($page === 'config' && $item === '') echo ' list-group-item-secondary'; else echo ' list-group-item-action'; ?>">
<i class="fas fa-wrench" data-toggle="tooltip" data-placement="right" data-offset="30.0" title="configuration"></i>config
</li>
</a>
@ -36,6 +41,19 @@
<i class="fas fa-list" data-toggle="tooltip" data-placement="right" data-offset="30.0" title="logs"></i>logs
</li>
</a>
<li class="list-group-item bg-light" style="border: none;"><p class="text-end mb-0"><small>current Jitsi platform</small></p></li>
<a href="<?= $app_root ?>?platform=<?= $platform_id ?>&page=config&item=configjs">
<li class="list-group-item<?php if ($page === 'config' && $item === 'configjs') echo ' list-group-item-secondary'; else echo ' list-group-item-action'; ?>">
<i class="fas fa-tv" data-toggle="tooltip" data-placement="right" data-offset="30.0" title="configuration"></i>config.js
</li>
</a>
<a href="<?= $app_root ?>?platform=<?= $platform_id ?>&page=config&item=interfaceconfigjs">
<li class="list-group-item<?php if ($page === 'config' && $item === 'interfaceconfigjs') echo ' list-group-item-secondary'; else echo ' list-group-item-action'; ?>">
<i class="fas fa-th" data-toggle="tooltip" data-placement="right" data-offset="30.0" title="configuration"></i>interface_config.js
</li>
</a>
</ul>
</div>
</div>

View File

@ -67,6 +67,12 @@ if (isset($_REQUEST['page'])) {
} else {
$page = 'front';
}
if (isset($_REQUEST['item'])) {
$item = $_REQUEST['item'];
} else {
$item = '';
}
// check if logged in
unset($user);