diff --git a/app/helpers/render.php b/app/helpers/render.php index 418d4f9..eba0822 100644 --- a/app/helpers/render.php +++ b/app/helpers/render.php @@ -1,23 +1,37 @@ "; +function renderConfig($config, $indent) { +?> +
+ $config_value) { - echo "\n\t\t\t\t\t\t
  • "; - echo htmlspecialchars($config_item) . ': '; - +?> +
    +
    + : +
    + + +
    + +
    +'; +?> +
    +"; +echo '
  • '; } ?> diff --git a/app/pages/config.php b/app/pages/config.php index 407f7b8..02e2212 100644 --- a/app/pages/config.php +++ b/app/pages/config.php @@ -2,14 +2,45 @@ $action = $_REQUEST['action'] ?? ''; -switch ($action) { +// if a form is submitted, it's from the edit page +if ($_SERVER['REQUEST_METHOD'] == 'POST') { - case 'edit': - include('../app/templates/config-edit-platform.php'); - break; + // load the config file and initialize a copy + $content = file_get_contents($config_file); + $updatedContent = $content; - default: - include('../app/templates/config-list.php'); + foreach ($_POST as $key => $value) { + + $config['platforms'][$platform_id][$key] = $value; + // search pattern for the old value + $oldValue = "/('$platform_id'\s*=>\s*\[\s*'$key'\s*=>\s*)'[^']*'/"; + // new value + $newValue = "$1'$value'"; + + $updatedContent = preg_replace($oldValue, $newValue, $updatedContent); + } + + if (file_put_contents($config_file, $updatedContent) !== false) { + // update successful + $_SESSION['notice'] = "Configuration for {$_POST['name']} is updated."; + } else { + // unsuccessful + $_SESSION['error'] = 'Error updating the config'; + } +// FIXME the new file is not loaded on first page load + unset($config); + header("Location: $app_root?platform=$platform_id&page=config"); + exit(); + +// no form submitted, show the templates +} else { + switch ($action) { + case 'edit': + include('../app/templates/config-edit-platform.php'); + break; + default: + include('../app/templates/config-list.php'); + } } ?> diff --git a/app/templates/config-edit-platform.php b/app/templates/config-edit-platform.php index 6eff33c..27eeb20 100644 --- a/app/templates/config-edit-platform.php +++ b/app/templates/config-edit-platform.php @@ -1,4 +1,24 @@ - + +
    +

    Jilo web configuration for Jitsi platform""

    +
    +

    edit the platform details:

    +
    + $config_value) { ?> +
    +
    + + * +
    +
    + +
    +
    + +
     
    + +
    +
    +
    + diff --git a/app/templates/config-list.php b/app/templates/config-list.php index b38a3f3..ab081b2 100644 --- a/app/templates/config-list.php +++ b/app/templates/config-list.php @@ -1,11 +1,14 @@ -
    -

    Jilo web configuration

    +
    +

    Jilo web configuration

    +
    +

    platform variables

    +
    diff --git a/app/templates/page-menu.php b/app/templates/page-menu.php index 09acaa5..6c7ac91 100644 --- a/app/templates/page-menu.php +++ b/app/templates/page-menu.php @@ -16,10 +16,14 @@
  • participants
  • components -
  • meet.example.com
  • +
  • + + + +
  • - - + +
  • diff --git a/public_html/index.php b/public_html/index.php index 94e1c80..48f571e 100644 --- a/public_html/index.php +++ b/public_html/index.php @@ -11,6 +11,10 @@ * Version: 0.1.1 */ +// we start output buffering and. +// flush it later only when there is no redirect +ob_start(); + // error reporting, comment out in production ini_set('display_errors', 1); ini_set('display_startup_errors', 1); @@ -130,6 +134,9 @@ if (in_array($page, $allowed_urls)) { } include '../app/templates/page-footer.php'; +// flush the output buffer and show the page +ob_end_flush(); + // clear errors and notices before next page just in case unset($_SESSION['error']); unset($_SESSION['notice']);