From dbc0d9614421e064cc62aacf116ebb783c83f2f3 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Fri, 1 Apr 2016 16:50:13 +0200 Subject: [merge] merging c3sl / fr - initial commit --- modules/webinterface/config.json | 4 ++ modules/webinterface/module.inc.php | 85 +++++++++++++++++++++++ modules/webinterface/templates/httpd-restart.html | 6 ++ modules/webinterface/templates/https.html | 60 ++++++++++++++++ modules/webinterface/templates/passwords.html | 25 +++++++ 5 files changed, 180 insertions(+) create mode 100644 modules/webinterface/config.json create mode 100644 modules/webinterface/module.inc.php create mode 100644 modules/webinterface/templates/httpd-restart.html create mode 100644 modules/webinterface/templates/https.html create mode 100644 modules/webinterface/templates/passwords.html (limited to 'modules/webinterface') diff --git a/modules/webinterface/config.json b/modules/webinterface/config.json new file mode 100644 index 00000000..4e7fa5fb --- /dev/null +++ b/modules/webinterface/config.json @@ -0,0 +1,4 @@ +{ + "category":"content", + "enabled":"true" +} diff --git a/modules/webinterface/module.inc.php b/modules/webinterface/module.inc.php new file mode 100644 index 00000000..c301dec9 --- /dev/null +++ b/modules/webinterface/module.inc.php @@ -0,0 +1,85 @@ +actionConfigureHttps(); + break; + case 'password': + $this->actionShowHidePassword(); + break; + } + } + + private function actionConfigureHttps() + { + $task = false; + switch (Request::post('mode')) { + case 'off': + $task = $this->setHttpsOff(); + break; + case 'random': + $task = $this->setHttpsRandomCert(); + break; + case 'custom': + $task = $this->setHttpsCustomCert(); + break; + } + if (isset($task['id'])) { + Session::set('https-id', $task['id']); + Util::redirect('?do=WebInterface&show=httpsupdate'); + } + } + + private function actionShowHidePassword() + { + Property::setPasswordFieldType(Request::post('mode') === 'show' ? 'text' : 'password'); + Util::redirect('?do=WebInterface'); + } + + protected function doRender() + { + Render::setTitle(Dictionary::translate('lang_titleWebinterface')); + if (Request::get('show') === 'httpsupdate') { + Render::addTemplate('httpd-restart', array('taskid' => Session::get('https-id'))); + } + Render::addTemplate('https', array('httpsEnabled' => file_exists('/etc/lighttpd/server.pem'))); + $data = array(); + if (Property::getPasswordFieldType() === 'text') + $data['selected_show'] = 'checked'; + else + $data['selected_hide'] = 'checked'; + Render::addTemplate('passwords', $data); + } + + private function setHttpsOff() + { + return Taskmanager::submit('LighttpdHttps', array()); + } + + private function setHttpsRandomCert() + { + return Taskmanager::submit('LighttpdHttps', array( + 'proxyip' => Property::getServerIp() + )); + } + + private function setHttpsCustomCert() + { + return Taskmanager::submit('LighttpdHttps', array( + 'importcert' => Request::post('certificate', 'bla'), + 'importkey' => Request::post('privatekey', 'bla'), + 'importchain' => Request::post('cachain', '') + )); + } + +} diff --git a/modules/webinterface/templates/httpd-restart.html b/modules/webinterface/templates/httpd-restart.html new file mode 100644 index 00000000..cc84aafb --- /dev/null +++ b/modules/webinterface/templates/httpd-restart.html @@ -0,0 +1,6 @@ +
+
{{lang_applyingSettings}}
+
+
{{lang_installAndRestart}}
+
+
diff --git a/modules/webinterface/templates/https.html b/modules/webinterface/templates/https.html new file mode 100644 index 00000000..c6161cd6 --- /dev/null +++ b/modules/webinterface/templates/https.html @@ -0,0 +1,60 @@ +
+ + +
+
{{lang_httpsSettings}}
+
+

{{lang_description}}

+ {{^httpsEnabled}} +

{{lang_HttpsIsDisabled}}

+ {{/httpsEnabled}} + {{#httpsEnabled}} +
+ + + {{lang_noHttps}} + +
+ {{/httpsEnabled}} +
+ + + {{lang_randomCert}} + +
+
+ + + {{lang_customCert}} + +
+ +
+ +
+
+
+
diff --git a/modules/webinterface/templates/passwords.html b/modules/webinterface/templates/passwords.html new file mode 100644 index 00000000..f9fda016 --- /dev/null +++ b/modules/webinterface/templates/passwords.html @@ -0,0 +1,25 @@ +
+ + +
+
{{lang_passwordFields}}
+
+

{{lang_description}}

+
+ + + {{lang_showPasswords}} + +
+
+ + + {{lang_hidePasswords}} + +
+
+ +
+
+
+
-- cgit v1.2.3-55-g7522