Compare commits
2 Commits
7d85c9181d
...
dc9462260d
Author | SHA1 | Date |
---|---|---|
Yasen Pramatarov | dc9462260d | |
Yasen Pramatarov | b60208bea7 |
|
@ -6,6 +6,9 @@ All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Jitsi platforms config moved from file to SQLite database
|
||||||
|
|
||||||
#### Links
|
#### Links
|
||||||
- upstream: https://code.lindeas.com/lindeas/jilo-web/compare/v0.2...HEAD
|
- upstream: https://code.lindeas.com/lindeas/jilo-web/compare/v0.2...HEAD
|
||||||
- codeberg: https://codeberg.org/lindeas/jilo-web/compare/v0.2...HEAD
|
- codeberg: https://codeberg.org/lindeas/jilo-web/compare/v0.2...HEAD
|
||||||
|
|
|
@ -2,15 +2,10 @@
|
||||||
|
|
||||||
class Config {
|
class Config {
|
||||||
|
|
||||||
public function getPlatformDetails($config, $platform_id) {
|
|
||||||
$platformDetails = $config['platforms'][$platform_id];
|
|
||||||
return $platformDetails;
|
|
||||||
}
|
|
||||||
|
|
||||||
// loading the config.js
|
// loading the config.js
|
||||||
public function getPlatformConfigjs($platformDetails, $raw = false) {
|
public function getPlatformConfigjs($jitsiUrl, $raw = false) {
|
||||||
// constructing the URL
|
// constructing the URL
|
||||||
$configjsFile = $platformDetails['jitsi_url'] . '/config.js';
|
$configjsFile = $jitsiUrl . '/config.js';
|
||||||
|
|
||||||
// default content, if we can't get the file contents
|
// default content, if we can't get the file contents
|
||||||
$platformConfigjs = "The file $configjsFile can't be loaded.";
|
$platformConfigjs = "The file $configjsFile can't be loaded.";
|
||||||
|
@ -50,9 +45,9 @@ class Config {
|
||||||
|
|
||||||
|
|
||||||
// loading the interface_config.js
|
// loading the interface_config.js
|
||||||
public function getPlatformInterfaceConfigjs($platformDetails, $raw = false) {
|
public function getPlatformInterfaceConfigjs($jitsiUrl, $raw = false) {
|
||||||
// constructing the URL
|
// constructing the URL
|
||||||
$interfaceConfigjsFile = $platformDetails['jitsi_url'] . '/interface_config.js';
|
$interfaceConfigjsFile = $jitsiUrl . '/interface_config.js';
|
||||||
|
|
||||||
// default content, if we can't get the file contents
|
// default content, if we can't get the file contents
|
||||||
$platformInterfaceConfigjs = "The file $interfaceConfigjsFile can't be loaded.";
|
$platformInterfaceConfigjs = "The file $interfaceConfigjsFile can't be loaded.";
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require '../app/helpers/errors.php';
|
|
||||||
|
|
||||||
class Database {
|
class Database {
|
||||||
private $pdo;
|
private $pdo;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,97 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class Platform {
|
||||||
|
private $db;
|
||||||
|
|
||||||
|
public function __construct($database) {
|
||||||
|
$this->db = $database->getConnection();
|
||||||
|
}
|
||||||
|
|
||||||
|
// get details of a specified platform ID (or all)
|
||||||
|
public function getPlatformDetails($platform_id = '') {
|
||||||
|
$sql = 'SELECT * FROM platforms';
|
||||||
|
if ($platform_id !== '') {
|
||||||
|
$sql .= ' WHERE id = :platform_id';
|
||||||
|
$query = $this->db->prepare($sql);
|
||||||
|
$query->bindParam(':platform_id', $platform_id);
|
||||||
|
} else {
|
||||||
|
$query = $this->db->prepare($sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
$query->execute();
|
||||||
|
|
||||||
|
return $query->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
}
|
||||||
|
|
||||||
|
// add new platform
|
||||||
|
public function addPlatform($newPlatform) {
|
||||||
|
try {
|
||||||
|
$sql = 'INSERT INTO platforms
|
||||||
|
(name, jitsi_url, jilo_database)
|
||||||
|
VALUES
|
||||||
|
(:name, :jitsi_url, :jilo_database)';
|
||||||
|
|
||||||
|
$query = $this->db->prepare($sql);
|
||||||
|
$query->execute([
|
||||||
|
':name' => $newPlatform['name'],
|
||||||
|
':jitsi_url' => $newPlatform['jitsi_url'],
|
||||||
|
':jilo_database' => $newPlatform['jilo_database'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$query->execute();
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// edit an existing platform
|
||||||
|
public function editPlatform($platform_id, $updatedPlatform) {
|
||||||
|
try {
|
||||||
|
$sql = 'UPDATE platforms SET
|
||||||
|
name = :name,
|
||||||
|
jitsi_url = :jitsi_url,
|
||||||
|
jilo_database = :jilo_database
|
||||||
|
WHERE
|
||||||
|
id = :platform_id';
|
||||||
|
|
||||||
|
$query = $this->db->prepare($sql);
|
||||||
|
$query->execute([
|
||||||
|
':name' => $updatedPlatform['name'],
|
||||||
|
':jitsi_url' => $updatedPlatform['jitsi_url'],
|
||||||
|
':jilo_database' => $updatedPlatform['jilo_database'],
|
||||||
|
':platform_id' => $platform_id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$query->execute();
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// delete a platform
|
||||||
|
public function deletePlatform($platform_id) {
|
||||||
|
try {
|
||||||
|
$sql = 'DELETE FROM platforms
|
||||||
|
WHERE
|
||||||
|
id = :platform_id';
|
||||||
|
|
||||||
|
$query = $this->db->prepare($sql);
|
||||||
|
$query->bindParam(':platform_id', $platform_id);
|
||||||
|
|
||||||
|
$query->execute();
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -31,27 +31,6 @@ return [
|
||||||
// development has verbose error messages, production has not
|
// development has verbose error messages, production has not
|
||||||
'environment' => 'development',
|
'environment' => 'development',
|
||||||
|
|
||||||
// *************************************
|
|
||||||
// Maintained by the app, edit with care
|
|
||||||
// *************************************
|
|
||||||
|
|
||||||
'platforms' => [
|
|
||||||
'0' => [
|
|
||||||
'name' => 'lindeas',
|
|
||||||
'jitsi_url' => 'https://meet.lindeas.com',
|
|
||||||
'jilo_database' => '../../jilo/jilo-meet.lindeas.db',
|
|
||||||
],
|
|
||||||
'1' => [
|
|
||||||
'name' => 'meet.example.com',
|
|
||||||
'jitsi_url' => 'https://meet.example.com',
|
|
||||||
'jilo_database' => '../../jilo/jilo.db',
|
|
||||||
],
|
|
||||||
'2' => [
|
|
||||||
'name' => 'test3',
|
|
||||||
'jitsi_url' => 'https://test3.example.com',
|
|
||||||
'jilo_database' => '../../jilo/jilo2.db',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
];
|
];
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
// Function to format arrays with square brackets
|
|
||||||
function formatArray(array $array, $indentLevel = 2) {
|
|
||||||
$indent = str_repeat(' ', $indentLevel); // 4 spaces per indent level
|
|
||||||
$output = "[\n";
|
|
||||||
|
|
||||||
foreach ($array as $key => $value) {
|
|
||||||
$output .= $indent . "'" . $key . "'" . ' => ';
|
|
||||||
|
|
||||||
if (is_array($value)) {
|
|
||||||
$output .= formatArray($value, $indentLevel + 1);
|
|
||||||
} else {
|
|
||||||
$output .= var_export($value, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
$output .= ",\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
$output .= str_repeat(' ', $indentLevel - 1) . ']';
|
|
||||||
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
|
@ -1,14 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// connect to database
|
// connect to database
|
||||||
function connectDB($config, $database = '', $platform_id = '') {
|
function connectDB($config, $database = '', $dbFile = '', $platformId = '') {
|
||||||
|
|
||||||
// connecting ti a jilo sqlite database
|
// connecting ti a jilo sqlite database
|
||||||
if ($database === 'jilo') {
|
if ($database === 'jilo') {
|
||||||
try {
|
try {
|
||||||
$dbFile = $config['platforms'][$platform_id]['jilo_database'] ?? null;
|
|
||||||
if (!$dbFile || !file_exists($dbFile)) {
|
if (!$dbFile || !file_exists($dbFile)) {
|
||||||
throw new Exception(getError("Invalid platform ID \"{$platform_id}\", database file \"{$dbFile}\"not found."));
|
throw new Exception(getError("Invalid platform ID \"{$platformId}\", database file \"{$dbFile}\" not found."));
|
||||||
}
|
}
|
||||||
$db = new Database([
|
$db = new Database([
|
||||||
'type' => 'sqlite',
|
'type' => 'sqlite',
|
||||||
|
|
|
@ -4,40 +4,14 @@
|
||||||
function renderConfig($configPart, $indent, $platform=false, $parent='') {
|
function renderConfig($configPart, $indent, $platform=false, $parent='') {
|
||||||
global $app_root;
|
global $app_root;
|
||||||
global $config;
|
global $config;
|
||||||
if ($parent === 'platforms') {
|
|
||||||
?>
|
|
||||||
<div class="col-md-8 text-start">
|
|
||||||
<a class="btn btn-secondary" style="padding: 0px;" href="<?= $app_root ?>?page=config&action=add">add</a>
|
|
||||||
</div>
|
|
||||||
<div class="border bg-light" style="padding-left: <?= $indent ?>px; padding-bottom: 20px; padding-top: 20px;">
|
|
||||||
<?php } else {
|
|
||||||
?>
|
?>
|
||||||
<div style="padding-left: <?= $indent ?>px; padding-bottom: 20px;">
|
<div style="padding-left: <?= $indent ?>px; padding-bottom: 20px;">
|
||||||
<?php
|
<?php foreach ($configPart as $config_item => $config_value) { ?>
|
||||||
}
|
|
||||||
foreach ($configPart as $config_item => $config_value) {
|
|
||||||
if ($parent === 'platforms') {
|
|
||||||
$indent = 0;
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<div class="row mb-1" style="padding-left: <?= $indent ?>px;">
|
<div class="row mb-1" style="padding-left: <?= $indent ?>px;">
|
||||||
<div class="col-md-4 text-end">
|
<div class="col-md-4 text-end">
|
||||||
<?= htmlspecialchars($config_item) ?>:
|
<?= htmlspecialchars($config_item) ?>:
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
if ($parent === 'platforms') { ?>
|
|
||||||
<div class="col-md-8 text-start">
|
|
||||||
<a class="btn btn-secondary" style="padding: 2px;" href="<?= $app_root ?>?platform=<?= htmlspecialchars($config_item) ?>&page=config&action=edit">edit</a>
|
|
||||||
<?php
|
|
||||||
// we don't delete the last platform
|
|
||||||
if (count($configPart) <= 1) { ?>
|
|
||||||
<span class="btn btn-light" style="padding: 2px;" href="#" data-toggle="tooltip" data-placement="right" data-offset="30.0" title="can't delete the last platform">delete</span>
|
|
||||||
<?php } else { ?>
|
|
||||||
<a class="btn btn-danger" style="padding: 2px;" href="<?= $app_root ?>?platform=<?= htmlspecialchars($config_item) ?>&page=config&action=delete">delete</a>
|
|
||||||
<?php } ?>
|
|
||||||
</div>
|
|
||||||
<?php }
|
|
||||||
|
|
||||||
if (is_array($config_value)) {
|
if (is_array($config_value)) {
|
||||||
// here we render recursively nested arrays
|
// here we render recursively nested arrays
|
||||||
$indent = $indent + 50;
|
$indent = $indent + 50;
|
||||||
|
@ -55,15 +29,11 @@ function renderConfig($configPart, $indent, $platform=false, $parent='') {
|
||||||
?>
|
?>
|
||||||
<div class="border col-md-8 text-start">
|
<div class="border col-md-8 text-start">
|
||||||
<?= htmlspecialchars($config_value ?? '')?>
|
<?= htmlspecialchars($config_value ?? '')?>
|
||||||
<?= $platform ?>
|
</div>
|
||||||
|
<?php } ?>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
}
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
echo '</div>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once '../app/classes/database.php';
|
|
||||||
require '../app/classes/component.php';
|
require '../app/classes/component.php';
|
||||||
|
|
||||||
// connect to database
|
// connect to database
|
||||||
require '../app/helpers/database.php';
|
$db = connectDB($config, 'jilo', $platformDetails[0]['jilo_database'], $platform_id);
|
||||||
$db = connectDB($config, 'jilo', $platform_id);
|
|
||||||
|
|
||||||
// specify time range
|
// specify time range
|
||||||
include '../app/helpers/time_range.php';
|
include '../app/helpers/time_range.php';
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once '../app/classes/database.php';
|
|
||||||
require '../app/classes/conference.php';
|
require '../app/classes/conference.php';
|
||||||
|
|
||||||
// connect to database
|
// connect to database
|
||||||
require '../app/helpers/database.php';
|
$db = connectDB($config, 'jilo', $platformDetails[0]['jilo_database'], $platform_id);
|
||||||
$db = connectDB($config, 'jilo', $platform_id);
|
|
||||||
|
|
||||||
// specify time range
|
// specify time range
|
||||||
include '../app/helpers/time_range.php';
|
include '../app/helpers/time_range.php';
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$action = $_REQUEST['action'] ?? '';
|
$action = $_REQUEST['action'] ?? '';
|
||||||
require_once '../app/classes/config.php';
|
require '../app/classes/config.php';
|
||||||
require '../app/helpers/errors.php';
|
|
||||||
require '../app/helpers/config.php';
|
|
||||||
|
|
||||||
$configure = new Config();
|
$configure = new Config();
|
||||||
|
|
||||||
|
@ -21,62 +19,26 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
'jitsi_url' => $_POST['jitsi_url'],
|
'jitsi_url' => $_POST['jitsi_url'],
|
||||||
'jilo_database' => $_POST['jilo_database'],
|
'jilo_database' => $_POST['jilo_database'],
|
||||||
];
|
];
|
||||||
|
$platformObject->addPlatform($newPlatform);
|
||||||
// Determine the next available index for the new platform
|
|
||||||
$nextIndex = count($config['platforms']);
|
|
||||||
|
|
||||||
// Add the new platform to the platforms array
|
|
||||||
$config['platforms'][$nextIndex] = $newPlatform;
|
|
||||||
|
|
||||||
// Rebuild the PHP array syntax for the platforms
|
|
||||||
$platformsArray = formatArray($config['platforms']);
|
|
||||||
|
|
||||||
// Replace the platforms section in the config file
|
|
||||||
$updatedContent = preg_replace(
|
|
||||||
'/\'platforms\'\s*=>\s*\[[\s\S]+?\],/s',
|
|
||||||
"'platforms' => {$platformsArray}",
|
|
||||||
$content
|
|
||||||
);
|
|
||||||
$updatedContent = preg_replace('/\s*\]\n/s', "\n", $updatedContent);
|
|
||||||
|
|
||||||
// deleting a platform
|
// deleting a platform
|
||||||
} elseif (isset($_POST['delete']) && $_POST['delete'] === 'true') {
|
} elseif (isset($_POST['delete']) && $_POST['delete'] === 'true') {
|
||||||
$platform = $_POST['platform'];
|
$platform = $_POST['platform'];
|
||||||
|
$platformObject->deletePlatform($platform);
|
||||||
$config['platforms'][$platform]['name'] = $_POST['name'];
|
|
||||||
$config['platforms'][$platform]['jitsi_url'] = $_POST['jitsi_url'];
|
|
||||||
$config['platforms'][$platform]['jilo_database'] = $_POST['jilo_database'];
|
|
||||||
|
|
||||||
$platformsArray = formatArray($config['platforms'][$platform], 3);
|
|
||||||
|
|
||||||
$updatedContent = preg_replace(
|
|
||||||
"/\s*'$platform'\s*=>\s*\[\s*'name'\s*=>\s*'[^']*',\s*'jitsi_url'\s*=>\s*'[^']*,\s*'jilo_database'\s*=>\s*'[^']*',\s*\],/s",
|
|
||||||
"",
|
|
||||||
$content
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
// an update to an existing platform
|
// an update to an existing platform
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$platform = $_POST['platform'];
|
$platform = $_POST['platform'];
|
||||||
|
$updatedPlatform = [
|
||||||
$config['platforms'][$platform]['name'] = $_POST['name'];
|
'name' => $_POST['name'],
|
||||||
$config['platforms'][$platform]['jitsi_url'] = $_POST['jitsi_url'];
|
'jitsi_url' => $_POST['jitsi_url'],
|
||||||
$config['platforms'][$platform]['jilo_database'] = $_POST['jilo_database'];
|
'jilo_database' => $_POST['jilo_database'],
|
||||||
|
];
|
||||||
$platformsArray = formatArray($config['platforms'][$platform], 3);
|
$platformObject->editPlatform($platform, $updatedPlatform);
|
||||||
|
|
||||||
$updatedContent = preg_replace(
|
|
||||||
"/\s*'$platform'\s*=>\s*\[\s*'name'\s*=>\s*'[^']*',\s*'jitsi_url'\s*=>\s*'[^']*',\s*'jilo_database'\s*=>\s*'[^']*',\s*\],/s",
|
|
||||||
"\n '{$platform}' => {$platformsArray},",
|
|
||||||
$content
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// check if file is writable
|
// check if file is writable
|
||||||
if (!is_writable($config_file)) {
|
if (!is_writable($config_file)) {
|
||||||
$_SESSION['error'] = getError('Configuration file is not writable.');
|
$_SESSION['error'] = getError('Configuration file is not writable.');
|
||||||
|
@ -107,15 +69,13 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
case 'configjs':
|
case 'configjs':
|
||||||
$mode = $_REQUEST['mode'] ?? '';
|
$mode = $_REQUEST['mode'] ?? '';
|
||||||
$raw = ($mode === 'raw');
|
$raw = ($mode === 'raw');
|
||||||
$platformDetails = $configure->getPlatformDetails($config, $platform_id);
|
$platformConfigjs = $configure->getPlatformConfigjs($platformDetails[0]['jitsi_url'], $raw);
|
||||||
$platformConfigjs = $configure->getPlatformConfigjs($platformDetails, $raw);
|
|
||||||
include('../app/templates/config-list-configjs.php');
|
include('../app/templates/config-list-configjs.php');
|
||||||
break;
|
break;
|
||||||
case 'interfaceconfigjs':
|
case 'interfaceconfigjs':
|
||||||
$mode = $_REQUEST['mode'] ?? '';
|
$mode = $_REQUEST['mode'] ?? '';
|
||||||
$raw = ($mode === 'raw');
|
$raw = ($mode === 'raw');
|
||||||
$platformDetails = $configure->getPlatformDetails($config, $platform_id);
|
$platformInterfaceConfigjs = $configure->getPlatformInterfaceConfigjs($platformDetails[0]['jitsi_url'], $raw);
|
||||||
$platformInterfaceConfigjs = $configure->getPlatformInterfaceConfigjs($platformDetails, $raw);
|
|
||||||
include('../app/templates/config-list-interfaceconfigjs.php');
|
include('../app/templates/config-list-interfaceconfigjs.php');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once '../app/classes/database.php';
|
|
||||||
require '../app/classes/conference.php';
|
require '../app/classes/conference.php';
|
||||||
require '../app/classes/participant.php';
|
require '../app/classes/participant.php';
|
||||||
|
|
||||||
// connect to database
|
// connect to database
|
||||||
require '../app/helpers/database.php';
|
$db = connectDB($config, 'jilo', $platformDetails[0]['jilo_database'], $platform_id);
|
||||||
$db = connectDB($config, 'jilo', $platform_id);
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once '../app/classes/database.php';
|
|
||||||
require '../app/classes/user.php';
|
require '../app/classes/user.php';
|
||||||
|
|
||||||
// clear the global error var before login
|
// clear the global error var before login
|
||||||
|
@ -9,10 +8,9 @@ unset($error);
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// connect to database
|
// connect to database
|
||||||
require '../app/helpers/database.php';
|
$dbWeb = connectDB($config);
|
||||||
$db = connectDB($config);
|
|
||||||
|
|
||||||
$user = new User($db);
|
$user = new User($dbWeb);
|
||||||
|
|
||||||
if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
|
if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
|
||||||
$username = $_POST['username'];
|
$username = $_POST['username'];
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once '../app/classes/database.php';
|
|
||||||
require '../app/classes/participant.php';
|
require '../app/classes/participant.php';
|
||||||
|
|
||||||
// connect to database
|
// connect to database
|
||||||
require '../app/helpers/database.php';
|
$db = connectDB($config, 'jilo', $platformDetails[0]['jilo_database'], $platform_id);
|
||||||
$db = connectDB($config, 'jilo', $platform_id);
|
|
||||||
|
|
||||||
// specify time range
|
// specify time range
|
||||||
include '../app/helpers/time_range.php';
|
include '../app/helpers/time_range.php';
|
||||||
|
|
|
@ -3,17 +3,15 @@
|
||||||
// registration is allowed, go on
|
// registration is allowed, go on
|
||||||
if ($config['registration_enabled'] === true) {
|
if ($config['registration_enabled'] === true) {
|
||||||
|
|
||||||
require_once '../app/classes/database.php';
|
|
||||||
require '../app/classes/user.php';
|
require '../app/classes/user.php';
|
||||||
unset($error);
|
unset($error);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// connect to database
|
// connect to database
|
||||||
require '../app/helpers/database.php';
|
$dbWeb = connectDB($config);
|
||||||
$db = connectDB($config);
|
|
||||||
|
|
||||||
$user = new User($db);
|
$user = new User($dbWeb);
|
||||||
|
|
||||||
if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
|
if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
|
||||||
$username = $_POST['username'];
|
$username = $_POST['username'];
|
||||||
|
|
|
@ -1,18 +1,21 @@
|
||||||
|
|
||||||
<!-- widget "config" -->
|
<!-- widget "config" -->
|
||||||
<div class="card text-center w-50 mx-auto">
|
<div class="card text-center w-50 mx-auto">
|
||||||
<p class="h4 card-header">Jilo web configuration for Jitsi platform "<?= htmlspecialchars($platform_id) ?>"</p>
|
<p class="h4 card-header">Jilo web configuration for Jitsi platform <strong>"<?= htmlspecialchars($platformDetails[0]['name']) ?>"</strong></p>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<p class="card-text">delete a platform:</p>
|
<p class="card-text">delete a platform:</p>
|
||||||
<form method="POST" action="<?= $app_root ?>?platform=<?= htmlspecialchars($platform_id) ?>&page=config">
|
<form method="POST" action="<?= $app_root ?>?platform=<?= htmlspecialchars($platform_id) ?>&page=config">
|
||||||
<?php foreach ($config['platforms'][$platform_id] as $config_item => $config_value) { ?>
|
<?php
|
||||||
|
foreach ($platformDetails[0] as $key => $value) {
|
||||||
|
if ($key === 'id') continue;
|
||||||
|
?>
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<div class="col-md-4 text-end">
|
<div class="col-md-4 text-end">
|
||||||
<label for="<?= htmlspecialchars($config_item) ?>" class="form-label"><?= htmlspecialchars($config_item) ?>:</label>
|
<label for="<?= htmlspecialchars($key) ?>" class="form-label"><?= htmlspecialchars($key) ?>:</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-8">
|
<div class="col-md-8">
|
||||||
<div class="text-start"><?= htmlspecialchars($config_value ?? '')?></div>
|
<div class="text-start"><?= htmlspecialchars($value ?? '')?></div>
|
||||||
<input type="hidden" name="<?= htmlspecialchars($config_item) ?>" value="<?= htmlspecialchars($config_value ?? '')?>" />
|
<input type="hidden" name="<?= htmlspecialchars($key) ?>" value="<?= htmlspecialchars($value ?? '')?>" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
|
@ -1,23 +1,26 @@
|
||||||
|
|
||||||
<!-- widget "config" -->
|
<!-- widget "config" -->
|
||||||
<div class="card text-center w-50 mx-auto">
|
<div class="card text-center w-50 mx-auto">
|
||||||
<p class="h4 card-header">Jilo web configuration for Jitsi platform "<?= htmlspecialchars($platform_id) ?>"</p>
|
<p class="h4 card-header">Jilo web configuration for Jitsi platform <strong>"<?= htmlspecialchars($platformDetails[0]['name']) ?>"</strong></p>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<p class="card-text">edit the platform details:</p>
|
<p class="card-text">edit the platform details:</p>
|
||||||
<form method="POST" action="<?= $app_root ?>?platform=<?= htmlspecialchars($platform_id) ?>&page=config">
|
<form method="POST" action="<?= $app_root ?>?platform=<?= htmlspecialchars($platform_id) ?>&page=config">
|
||||||
<?php foreach ($config['platforms'][$platform_id] as $config_item => $config_value) { ?>
|
<?php
|
||||||
|
foreach ($platformDetails[0] as $key => $value) {
|
||||||
|
if ($key === 'id') continue;
|
||||||
|
?>
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<div class="col-md-4 text-end">
|
<div class="col-md-4 text-end">
|
||||||
<label for="<?= htmlspecialchars($config_item) ?>" class="form-label"><?= htmlspecialchars($config_item) ?></label>
|
<label for="<?= htmlspecialchars($config_item) ?>" class="form-label"><?= htmlspecialchars($key) ?></label>
|
||||||
<span class="text-danger" style="margin-right: -12px;">*</span>
|
<span class="text-danger" style="margin-right: -12px;">*</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-8">
|
<div class="col-md-8">
|
||||||
<input class="form-control" type="text" name="<?= htmlspecialchars($config_item) ?>" value="<?= htmlspecialchars($config_value ?? '')?>" required />
|
<input class="form-control" type="text" name="<?= htmlspecialchars($key) ?>" value="<?= htmlspecialchars($value ?? '')?>" required />
|
||||||
<?php if ($config_item === 'name') { ?>
|
<?php if ($key === 'name') { ?>
|
||||||
<p class="text-start"><small>descriptive name for the platform</small></p>
|
<p class="text-start"><small>descriptive name for the platform</small></p>
|
||||||
<?php } elseif ($config_item === 'jitsi_url') { ?>
|
<?php } elseif ($key === 'jitsi_url') { ?>
|
||||||
<p class="text-start"><small>URL of the Jitsi Meet (used for checks and for loading config.js)</small></p>
|
<p class="text-start"><small>URL of the Jitsi Meet (used for checks and for loading config.js)</small></p>
|
||||||
<?php } elseif ($config_item === 'jilo_database') { ?>
|
<?php } elseif ($key === 'jilo_database') { ?>
|
||||||
<p class="text-start"><small>path to the database file (relative to the app root)</small></p>
|
<p class="text-start"><small>path to the database file (relative to the app root)</small></p>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
|
|
||||||
<!-- widget "config" -->
|
<!-- widget "config" -->
|
||||||
<div class="card text-center w-75 mx-lef">
|
<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>
|
<p class="h4 card-header">Configuration of the Jitsi platform <strong><?= htmlspecialchars($platformDetails[0]['name']) ?></strong></p>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<p class="card-text">
|
<p class="card-text">
|
||||||
<span class="m-3">URL: <?= htmlspecialchars($platformDetails['jitsi_url']) ?></span>
|
<span class="m-3">URL: <?= htmlspecialchars($platformDetails[0]['jitsi_url']) ?></span>
|
||||||
<span class="m-3">FILE: config.js</span>
|
<span class="m-3">FILE: config.js</span>
|
||||||
<?php if ($mode === 'raw') { ?>
|
<?php if ($mode === 'raw') { ?>
|
||||||
<span class="m-3"><a class="btn btn-light" href="<?= $app_root ?>?platform=<?= htmlspecialchars($platform_id) ?>&page=config&item=configjs">view only active lines</a></span>
|
<span class="m-3"><a class="btn btn-light" href="<?= $app_root ?>?platform=<?= htmlspecialchars($platform_id) ?>&page=config&item=configjs">view only active lines</a></span>
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
|
|
||||||
<!-- widget "config" -->
|
<!-- widget "config" -->
|
||||||
<div class="card text-center w-75 mx-lef">
|
<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>
|
<p class="h4 card-header">Configuration of the Jitsi platform <strong><?= htmlspecialchars($platformDetails[0]['name']) ?></strong></p>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<p class="card-text">
|
<p class="card-text">
|
||||||
<span class="m-3">URL: <?= htmlspecialchars($platformDetails['jitsi_url']) ?></span>
|
<span class="m-3">URL: <?= htmlspecialchars($platformDetails[0]['jitsi_url']) ?></span>
|
||||||
<span class="m-3">FILE: interface_config.js</span>
|
<span class="m-3">FILE: interface_config.js</span>
|
||||||
<?php if ($mode === 'raw') { ?>
|
<?php if ($mode === 'raw') { ?>
|
||||||
<span class="m-3"><a class="btn btn-light" href="<?= $app_root ?>?platform=<?= htmlspecialchars($platform_id) ?>&page=config&item=interfaceconfigjs">view only active lines</a></span>
|
<span class="m-3"><a class="btn btn-light" href="<?= $app_root ?>?platform=<?= htmlspecialchars($platform_id) ?>&page=config&item=interfaceconfigjs">view only active lines</a></span>
|
||||||
|
|
|
@ -3,12 +3,52 @@
|
||||||
<div class="card text-center w-75 mx-lef">
|
<div class="card text-center w-75 mx-lef">
|
||||||
<p class="h4 card-header">Jilo web configuration</p>
|
<p class="h4 card-header">Jilo web configuration</p>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<p class="card-text">platform variables</p>
|
<p class="card-text">main variables</p>
|
||||||
<?php
|
<?php
|
||||||
include '../app/helpers/render.php';
|
include '../app/helpers/render.php';
|
||||||
renderConfig($config, '0');
|
renderConfig($config, '0');
|
||||||
echo "\n";
|
echo "\n";
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
<p class="card-text">platforms configuration <a class="btn btn-secondary" style="padding: 0px;" href="/jilo-web/?page=config&action=add">add</a></p>
|
||||||
|
|
||||||
|
<?php foreach ($platformsAll as $platform_array) { ?>
|
||||||
|
|
||||||
|
<div class="row mb-3" style="padding-left: 0px;">
|
||||||
|
<div class="border bg-light" style="padding-left: 50px; padding-bottom: 20px; padding-top: 20px;">
|
||||||
|
<div class="row mb-1" style="padding-left: 0px;">
|
||||||
|
<div class="col-md-4 text-end">
|
||||||
|
<?= $platform_array['id'] ?>:
|
||||||
|
</div>
|
||||||
|
<div class="col-md-8 text-start">
|
||||||
|
<a class="btn btn-secondary" style="padding: 2px;" href="/jilo-web/?platform=<?= htmlspecialchars($platform_array['id']) ?>&page=config&action=edit">edit</a>
|
||||||
|
<?php if (count($platformsAll) <= 1) { ?>
|
||||||
|
<span class="btn btn-light" style="padding: 2px;" href="#" data-toggle="tooltip" data-placement="right" data-offset="30.0" title="can't delete the last platform">delete</span>
|
||||||
|
<?php } else { ?>
|
||||||
|
<a class="btn btn-danger" style="padding: 2px;" href="/jilo-web/?platform=<?= htmlspecialchars($platform_array['id'])?>&page=config&action=delete">delete</a>
|
||||||
|
<?php } ?>
|
||||||
|
</div>
|
||||||
|
<div style="padding-left: 100px; padding-bottom: 20px;">
|
||||||
|
<?php foreach ($platform_array as $key => $value) {
|
||||||
|
if ($key === 'id') continue;
|
||||||
|
?>
|
||||||
|
<div class="row mb-1" style="padding-left: 100px;">
|
||||||
|
<div class="col-md-4 text-end">
|
||||||
|
<?= $key ?>:
|
||||||
|
</div>
|
||||||
|
<div class="border col-md-8 text-start">
|
||||||
|
<?= $value ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- /widget "config" -->
|
<!-- /widget "config" -->
|
||||||
|
|
|
@ -12,9 +12,9 @@
|
||||||
|
|
||||||
<?php if ( isset($_SESSION['username']) ) { ?>
|
<?php if ( isset($_SESSION['username']) ) { ?>
|
||||||
|
|
||||||
<?php foreach ($config['platforms'] as $index => $platform) { ?>
|
<?php foreach ($platformsAll as $platform) { ?>
|
||||||
<li style="margin-right: 3px;">
|
<li style="margin-right: 3px;">
|
||||||
<a style="background-color: #111;" href="?platform=<?= htmlspecialchars($index) ?>&page=front">
|
<a style="background-color: #111;" href="?platform=<?= htmlspecialchars($platform['id']) ?>&page=front">
|
||||||
<?= htmlspecialchars($platform['name']) ?>
|
<?= htmlspecialchars($platform['name']) ?>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -3,3 +3,21 @@ CREATE TABLE users (
|
||||||
username TEXT NOT NULL UNIQUE,
|
username TEXT NOT NULL UNIQUE,
|
||||||
password TEXT NOT NULL
|
password TEXT NOT NULL
|
||||||
);
|
);
|
||||||
|
CREATE TABLE platforms (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
name TEXT NOT NULL UNIQUE,
|
||||||
|
jitsi_url TEXT NOT NULL,
|
||||||
|
jilo_database TEXT NOT NULL
|
||||||
|
);
|
||||||
|
CREATE TABLE jilo_agents (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
platform_id INTEGER NOT NULL,
|
||||||
|
type_id INTEGER NOT NULL,
|
||||||
|
url TEXT NOT NULL,
|
||||||
|
secret_key TEXT
|
||||||
|
);
|
||||||
|
CREATE TABLE jilo_agent_types (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
description TEXT,
|
||||||
|
endponts TEXT
|
||||||
|
);
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
// flush it later only when there is no redirect
|
// flush it later only when there is no redirect
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
require '../app/helpers/errors.php';
|
||||||
|
|
||||||
// error reporting, comment out in production
|
// error reporting, comment out in production
|
||||||
ini_set('display_errors', 1);
|
ini_set('display_errors', 1);
|
||||||
ini_set('display_startup_errors', 1);
|
ini_set('display_startup_errors', 1);
|
||||||
|
@ -96,8 +98,20 @@ if (isset($_SESSION['error'])) {
|
||||||
$error = $_SESSION['error'];
|
$error = $_SESSION['error'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// connect to db of Jilo Web
|
||||||
|
require '../app/classes/database.php';
|
||||||
|
require '../app/helpers/database.php';
|
||||||
|
$dbWeb = connectDB($config);
|
||||||
|
|
||||||
|
// get platforms details
|
||||||
|
require '../app/classes/platform.php';
|
||||||
|
$platformObject = new Platform($dbWeb);
|
||||||
|
$platformsAll = $platformObject->getPlatformDetails();
|
||||||
|
|
||||||
// by default we connect ot the first configured platform
|
// by default we connect ot the first configured platform
|
||||||
$platform_id = $_REQUEST['platform'] ?? '0';
|
$firstPlatform = $platformsAll[0]['id'];
|
||||||
|
$platform_id = $_REQUEST['platform'] ?? $firstPlatform;
|
||||||
|
$platformDetails = $platformObject->getPlatformDetails($platform_id);
|
||||||
|
|
||||||
// page building
|
// page building
|
||||||
if (in_array($page, $allowed_urls)) {
|
if (in_array($page, $allowed_urls)) {
|
||||||
|
|
Loading…
Reference in New Issue