From f041514bfeacfe65d773a9d3a6300e31ad38c905 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 14 Mar 2019 16:10:30 +0100 Subject: [locationinfo] Add black/whitelist stuff for URL panels --- .../locationinfo/inc/infopanel.inc.php | 8 ++--- .../locationinfo/inc/locationinfo.inc.php | 39 +++++++++++++--------- 2 files changed, 27 insertions(+), 20 deletions(-) (limited to 'modules-available/locationinfo/inc') diff --git a/modules-available/locationinfo/inc/infopanel.inc.php b/modules-available/locationinfo/inc/infopanel.inc.php index fdc253f0..7b0c6fe0 100644 --- a/modules-available/locationinfo/inc/infopanel.inc.php +++ b/modules-available/locationinfo/inc/infopanel.inc.php @@ -19,13 +19,14 @@ class InfoPanel return false; } + $config = LocationInfo::defaultPanelConfig($panel['paneltype']); + if ($panel['paneltype'] === 'URL') { // Shortcut for URL redirect - $config = json_decode($panel['panelconfig'], true); + $config = json_decode($panel['panelconfig'], true) + $config; return $panel['paneltype']; } - $config = LocationInfo::defaultPanelConfig($panel['paneltype']); $locations = Location::getLocationsAssoc(); $overrides = false; @@ -37,9 +38,6 @@ class InfoPanel $overrides = $json['overrides']; } unset($json['overrides']); - if (!isset($json['roomplanner'])) { - $config['roomplanner'] = false; - } $config = $json + $config; } } diff --git a/modules-available/locationinfo/inc/locationinfo.inc.php b/modules-available/locationinfo/inc/locationinfo.inc.php index 6cc71b3e..47872481 100644 --- a/modules-available/locationinfo/inc/locationinfo.inc.php +++ b/modules-available/locationinfo/inc/locationinfo.inc.php @@ -114,6 +114,14 @@ class LocationInfo 'panelupdate' => 60, ); } + if ($type === 'URL') { + return array( + 'iswhitelist' => 0, + 'urllist' => '', + 'insecure-ssl' => 0, + 'reload-minutes' => 0, + ); + } return array(); } @@ -136,29 +144,30 @@ class LocationInfo */ public static function configHook($machineUuid, $panelUuid) { - $row = Database::queryFirst('SELECT paneltype, panelconfig FROM locationinfo_panel WHERE paneluuid = :uuid', - array('uuid' => $panelUuid)); - if ($row === false) { - // TODO: Invalid panel - what should we do? - } elseif ($row['paneltype'] === 'URL') { + $type = InfoPanel::getConfig($panelUuid, $data); + if ($type === false) + return; // TODO: Invalid panel - what should we do? + if ($type === 'URL') { // Check if we should set the insecure SSL mode (accept invalid/self signed certs etc.) - $data = json_decode($row['panelconfig'], true); - if (is_array($data)) { - if (isset($data['insecure-ssl']) && $data['insecure-ssl']) { - ConfigHolder::add('SLX_BROWSER_INSECURE', '1'); - } - if (isset($data['reload-minutes']) && $data['reload-minutes']) { - ConfigHolder::add('SLX_BROWSER_RELOAD_SECS', $data['reload-minutes'] * 60); - } + if ($data['insecure-ssl'] !== 0) { + ConfigHolder::add('SLX_BROWSER_INSECURE', '1'); + } + if ($data['reload-minutes'] > 0) { + ConfigHolder::add('SLX_BROWSER_RELOAD_SECS', $data['reload-minutes'] * 60); } + ConfigHolder::add('SLX_BROWSER_URL', $data['url']); + ConfigHolder::add('SLX_BROWSER_URLLIST', $data['urllist']); + ConfigHolder::add('SLX_BROWSER_IS_WHITELIST', $data['iswhitelist']); + } else { + // Not URL panel + ConfigHolder::add('SLX_BROWSER_URL', 'http://' . $_SERVER['SERVER_ADDR'] . '/panel/' . $panelUuid); + ConfigHolder::add('SLX_BROWSER_INSECURE', '1'); // TODO: Sat server might redirect to HTTPS, which in turn could have a self-signed cert - push to client } - ConfigHolder::add('SLX_BROWSER_URL', 'http://' . $_SERVER['SERVER_ADDR'] . '/panel/' . $panelUuid); ConfigHolder::add('SLX_ADDONS', '', 1000); ConfigHolder::add('SLX_LOGOUT_TIMEOUT', '', 1000); ConfigHolder::add('SLX_SCREEN_STANDBY_TIMEOUT', '', 1000); ConfigHolder::add('SLX_SYSTEM_STANDBY_TIMEOUT', '', 1000); ConfigHolder::add('SLX_AUTOLOGIN', '1', 1000); - ConfigHolder::add('SLX_BROWSER_INSECURE', '1'); // TODO: Sat server might redirect to HTTPS, which in turn could have a self-signed cert - push to client } } -- cgit v1.2.3-55-g7522