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 +++++++++++++--------- modules-available/locationinfo/page.inc.php | 4 +++ .../templates/page-config-panel-url.html | 24 +++++++++++++ 4 files changed, 55 insertions(+), 20 deletions(-) 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 } } diff --git a/modules-available/locationinfo/page.inc.php b/modules-available/locationinfo/page.inc.php index b082c0f4..3e17976d 100644 --- a/modules-available/locationinfo/page.inc.php +++ b/modules-available/locationinfo/page.inc.php @@ -391,6 +391,8 @@ class Page_LocationInfo extends Page 'url' => Request::post('url', 'https://www.bwlehrpool.de/', 'string'), 'insecure-ssl' => Request::post('insecure-ssl', 0, 'int'), 'reload-minutes' => max(0, Request::post('reloadminutes', 0, 'int')), + 'iswhitelist' => Request::post('iswhitelist', 0, 'int'), + 'urllist' => preg_replace("/[\r\n\\s]+/ms", ' ', Request::post('urllist', '', 'string')), ); return array('config' => $conf, 'locationids' => []); } @@ -988,6 +990,8 @@ class Page_LocationInfo extends Page 'url' => $config['url'], 'ssl_checked' => $config['insecure-ssl'] ? 'checked' : '', 'reloadminutes' => (int)$config['reload-minutes'], + 'iswhitelist_' . $config['iswhitelist'] . '_checked' => 'checked', + 'urllist' => str_replace(' ', "\r\n", $config['urllist']), )); } else { Render::addTemplate('page-config-panel-summary', array( diff --git a/modules-available/locationinfo/templates/page-config-panel-url.html b/modules-available/locationinfo/templates/page-config-panel-url.html index 1187c19f..dbf50fb6 100644 --- a/modules-available/locationinfo/templates/page-config-panel-url.html +++ b/modules-available/locationinfo/templates/page-config-panel-url.html @@ -84,6 +84,30 @@ +
+
+
+
+ + +
+
+ + +
+
+
+ +

{{lang_urlListHelp}}

+
+
+
+
+ -- cgit v1.2.3-55-g7522