From 19ec20ab89bf938fe2dd1a99b62debc76e199425 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 5 Dec 2014 19:15:41 +0100 Subject: Add option to hide or show password fields --- inc/property.inc.php | 10 +++ inc/render.inc.php | 4 +- lang/de/templates/https/_page.json | 11 --- lang/de/templates/https/restart.json | 4 -- lang/de/templates/webinterface/httpd-restart.json | 4 ++ lang/de/templates/webinterface/https.json | 11 +++ lang/de/templates/webinterface/passwords.json | 7 ++ lang/en/templates/https/_page.json | 11 --- lang/en/templates/https/restart.json | 4 -- lang/en/templates/webinterface/httpd-restart.json | 4 ++ lang/en/templates/webinterface/https.json | 11 +++ lang/en/templates/webinterface/passwords.json | 7 ++ lang/pt/templates/https/_page.json | 3 - lang/pt/templates/https/restart.json | 3 - lang/pt/templates/webinterface/httpd-restart.json | 3 + lang/pt/templates/webinterface/https.json | 3 + lang/pt/templates/webinterface/passwords.json | 3 + modules/https.inc.php | 60 ---------------- modules/webinterface.inc.php | 85 +++++++++++++++++++++++ templates/https/_page.html | 54 -------------- templates/https/restart.html | 6 -- templates/webinterface/httpd-restart.html | 6 ++ templates/webinterface/https.html | 53 ++++++++++++++ templates/webinterface/passwords.html | 25 +++++++ 24 files changed, 235 insertions(+), 157 deletions(-) delete mode 100644 lang/de/templates/https/_page.json delete mode 100644 lang/de/templates/https/restart.json create mode 100644 lang/de/templates/webinterface/httpd-restart.json create mode 100644 lang/de/templates/webinterface/https.json create mode 100644 lang/de/templates/webinterface/passwords.json delete mode 100644 lang/en/templates/https/_page.json delete mode 100644 lang/en/templates/https/restart.json create mode 100644 lang/en/templates/webinterface/httpd-restart.json create mode 100644 lang/en/templates/webinterface/https.json create mode 100644 lang/en/templates/webinterface/passwords.json delete mode 100644 lang/pt/templates/https/_page.json delete mode 100644 lang/pt/templates/https/restart.json create mode 100644 lang/pt/templates/webinterface/httpd-restart.json create mode 100644 lang/pt/templates/webinterface/https.json create mode 100644 lang/pt/templates/webinterface/passwords.json delete mode 100644 modules/https.inc.php create mode 100644 modules/webinterface.inc.php delete mode 100644 templates/https/_page.html delete mode 100644 templates/https/restart.html create mode 100644 templates/webinterface/httpd-restart.html create mode 100644 templates/webinterface/https.html create mode 100644 templates/webinterface/passwords.html diff --git a/inc/property.inc.php b/inc/property.inc.php index 6a639dd2..c16c8ad7 100644 --- a/inc/property.inc.php +++ b/inc/property.inc.php @@ -171,5 +171,15 @@ class Property { return self::get('needs-setup'); } + + public static function setPasswordFieldType($value) + { + return self::set('password-type', $value); + } + + public static function getPasswordFieldType() + { + return self::get('password-type', 'password'); + } } diff --git a/inc/render.inc.php b/inc/render.inc.php index fc64203e..5827dcf9 100644 --- a/inc/render.inc.php +++ b/inc/render.inc.php @@ -179,8 +179,10 @@ class Render // Always add token to parameter list if (is_array($params) || $params === false || is_null($params)) $params['token'] = Session::get('token'); - // Likewise, add currently selected language ( its two letter code) to params + // Likewise, add currently selected language (its two letter code) to params $params['current_lang'] = LANG; + // Add desired password field type + $params['password_type'] = Property::getPasswordFieldType(); // Return rendered html return self::$mustache->render($html, array_merge($dictionary,$params)); } diff --git a/lang/de/templates/https/_page.json b/lang/de/templates/https/_page.json deleted file mode 100644 index 7e8c6020..00000000 --- a/lang/de/templates/https/_page.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "lang_caChain": "Optional k\u00f6nnen Sie hier die zum Zertifikat geh\u00f6rende Zertifikatkette (CA-Chain) einf\u00fcgen. Dies wird ben\u00f6tigt, wenn das Zertifikat nicht direkt von einer der in Browsern mitgeliferten CAs signiert wurde. Die Datei enth\u00e4lt ein oder meherere Zertifikatsbl\u00f6cke, im gleichen Format wie das oben gezeigte Zertifikat.", - "lang_certificate": "Bitte f\u00fcgen Sie hier das Zertifikat ein. Das Zertifikat wird im Base64-codierten x509-Format erwartet (manchmal pem genannt). Es sieht in etwa wie folgt aus:", - "lang_customCert": "Eigenes Zertifikat verwenden", - "lang_description": "Hier k\u00f6nnen Sie festlegen, ob das Web-Interface auch per HTTPS erreichbar sein soll, und welches Zertifikat daf\u00fcr verwendet werden soll.", - "lang_httpsSettings": "HTTPS-Konfiguration", - "lang_noHttps": "HTTPS deaktivieren", - "lang_privateKey": "Bitte f\u00fcgen Sie hier den privaten Schl\u00fcssel ein, der zum obigen Zertifikat geh\u00f6rt. Er muss ebenfalls im \u0022pem\u0022-Format vorliegen, und sieht wie folgt aus:", - "lang_randomCert": "Neues selbstsigniertes Zertifikat generieren", - "lang_save": "Speichern" -} \ No newline at end of file diff --git a/lang/de/templates/https/restart.json b/lang/de/templates/https/restart.json deleted file mode 100644 index e995a251..00000000 --- a/lang/de/templates/https/restart.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "lang_applyingSettings": "Anwenden der Einstellungen", - "lang_installAndRestart": "Zertifikat installieren und Webserver neustarten" -} \ No newline at end of file diff --git a/lang/de/templates/webinterface/httpd-restart.json b/lang/de/templates/webinterface/httpd-restart.json new file mode 100644 index 00000000..e995a251 --- /dev/null +++ b/lang/de/templates/webinterface/httpd-restart.json @@ -0,0 +1,4 @@ +{ + "lang_applyingSettings": "Anwenden der Einstellungen", + "lang_installAndRestart": "Zertifikat installieren und Webserver neustarten" +} \ No newline at end of file diff --git a/lang/de/templates/webinterface/https.json b/lang/de/templates/webinterface/https.json new file mode 100644 index 00000000..7e8c6020 --- /dev/null +++ b/lang/de/templates/webinterface/https.json @@ -0,0 +1,11 @@ +{ + "lang_caChain": "Optional k\u00f6nnen Sie hier die zum Zertifikat geh\u00f6rende Zertifikatkette (CA-Chain) einf\u00fcgen. Dies wird ben\u00f6tigt, wenn das Zertifikat nicht direkt von einer der in Browsern mitgeliferten CAs signiert wurde. Die Datei enth\u00e4lt ein oder meherere Zertifikatsbl\u00f6cke, im gleichen Format wie das oben gezeigte Zertifikat.", + "lang_certificate": "Bitte f\u00fcgen Sie hier das Zertifikat ein. Das Zertifikat wird im Base64-codierten x509-Format erwartet (manchmal pem genannt). Es sieht in etwa wie folgt aus:", + "lang_customCert": "Eigenes Zertifikat verwenden", + "lang_description": "Hier k\u00f6nnen Sie festlegen, ob das Web-Interface auch per HTTPS erreichbar sein soll, und welches Zertifikat daf\u00fcr verwendet werden soll.", + "lang_httpsSettings": "HTTPS-Konfiguration", + "lang_noHttps": "HTTPS deaktivieren", + "lang_privateKey": "Bitte f\u00fcgen Sie hier den privaten Schl\u00fcssel ein, der zum obigen Zertifikat geh\u00f6rt. Er muss ebenfalls im \u0022pem\u0022-Format vorliegen, und sieht wie folgt aus:", + "lang_randomCert": "Neues selbstsigniertes Zertifikat generieren", + "lang_save": "Speichern" +} \ No newline at end of file diff --git a/lang/de/templates/webinterface/passwords.json b/lang/de/templates/webinterface/passwords.json new file mode 100644 index 00000000..da63843f --- /dev/null +++ b/lang/de/templates/webinterface/passwords.json @@ -0,0 +1,7 @@ +{ + "lang_description": "Legen Sie fest, ob Passwortfelder in der Web-Schnittstelle maskiert sein sollen, oder ob Ihr Inhalt sichtbar sein soll. Wenn Sie die Schnittstelle in einer sicheren Umgebung nutzen (keine neugierigen Augen), kann dies den Komfort erh\u00f6hen. Das Passwortfeld der Anmeldemaske ist von dieser Einstellung ausgenommen.", + "lang_hidePasswords": "Passw\u00f6rter maskieren", + "lang_passwordFields": "Passwortfelder", + "lang_save": "Speichern", + "lang_showPasswords": "Passw\u00f6rter anzeigen" +} \ No newline at end of file diff --git a/lang/en/templates/https/_page.json b/lang/en/templates/https/_page.json deleted file mode 100644 index fc1e8e3e..00000000 --- a/lang/en/templates/https/_page.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "lang_caChain": "Here you can paste an optional certificate chain. It should only be required if you have a certificate that was not directly signed by a certificate authority known by the browsers. It should contain one or more certificate blocks, looking just like the certificate above.", - "lang_certificate": "Please paste your certificate below. It has to be in base64 encoded x509 format (sometimes called pem). It should look something like this:", - "lang_customCert": "Supply own certificate", - "lang_description": "Here you can set whether the web interface should be accessible via https. You can chose if you want to use a random self signed certificate, or supply your own.", - "lang_httpsSettings": "HTTPS settings", - "lang_noHttps": "Disable HTTPS", - "lang_privateKey": "Please paste the private key belonging to the certificate here. It has to be in \u0022pem\u0022 format too, which should look like this:", - "lang_randomCert": "Geenrate new self-signed certificate", - "lang_save": "Save" -} \ No newline at end of file diff --git a/lang/en/templates/https/restart.json b/lang/en/templates/https/restart.json deleted file mode 100644 index 0a7d4aea..00000000 --- a/lang/en/templates/https/restart.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "lang_applyingSettings": "Applying settings", - "lang_installAndRestart": "Installing certificate and restarting web server" -} \ No newline at end of file diff --git a/lang/en/templates/webinterface/httpd-restart.json b/lang/en/templates/webinterface/httpd-restart.json new file mode 100644 index 00000000..0a7d4aea --- /dev/null +++ b/lang/en/templates/webinterface/httpd-restart.json @@ -0,0 +1,4 @@ +{ + "lang_applyingSettings": "Applying settings", + "lang_installAndRestart": "Installing certificate and restarting web server" +} \ No newline at end of file diff --git a/lang/en/templates/webinterface/https.json b/lang/en/templates/webinterface/https.json new file mode 100644 index 00000000..fc1e8e3e --- /dev/null +++ b/lang/en/templates/webinterface/https.json @@ -0,0 +1,11 @@ +{ + "lang_caChain": "Here you can paste an optional certificate chain. It should only be required if you have a certificate that was not directly signed by a certificate authority known by the browsers. It should contain one or more certificate blocks, looking just like the certificate above.", + "lang_certificate": "Please paste your certificate below. It has to be in base64 encoded x509 format (sometimes called pem). It should look something like this:", + "lang_customCert": "Supply own certificate", + "lang_description": "Here you can set whether the web interface should be accessible via https. You can chose if you want to use a random self signed certificate, or supply your own.", + "lang_httpsSettings": "HTTPS settings", + "lang_noHttps": "Disable HTTPS", + "lang_privateKey": "Please paste the private key belonging to the certificate here. It has to be in \u0022pem\u0022 format too, which should look like this:", + "lang_randomCert": "Geenrate new self-signed certificate", + "lang_save": "Save" +} \ No newline at end of file diff --git a/lang/en/templates/webinterface/passwords.json b/lang/en/templates/webinterface/passwords.json new file mode 100644 index 00000000..c21ccc48 --- /dev/null +++ b/lang/en/templates/webinterface/passwords.json @@ -0,0 +1,7 @@ +{ + "lang_description": "Set whether password fields should be masked or not.", + "lang_hidePasswords": "Mask passwords", + "lang_passwordFields": "Password fields", + "lang_save": "Save", + "lang_showPasswords": "Show passwords" +} \ No newline at end of file diff --git a/lang/pt/templates/https/_page.json b/lang/pt/templates/https/_page.json deleted file mode 100644 index c44dc44f..00000000 --- a/lang/pt/templates/https/_page.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - -] \ No newline at end of file diff --git a/lang/pt/templates/https/restart.json b/lang/pt/templates/https/restart.json deleted file mode 100644 index c44dc44f..00000000 --- a/lang/pt/templates/https/restart.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - -] \ No newline at end of file diff --git a/lang/pt/templates/webinterface/httpd-restart.json b/lang/pt/templates/webinterface/httpd-restart.json new file mode 100644 index 00000000..c44dc44f --- /dev/null +++ b/lang/pt/templates/webinterface/httpd-restart.json @@ -0,0 +1,3 @@ +[ + +] \ No newline at end of file diff --git a/lang/pt/templates/webinterface/https.json b/lang/pt/templates/webinterface/https.json new file mode 100644 index 00000000..c44dc44f --- /dev/null +++ b/lang/pt/templates/webinterface/https.json @@ -0,0 +1,3 @@ +[ + +] \ No newline at end of file diff --git a/lang/pt/templates/webinterface/passwords.json b/lang/pt/templates/webinterface/passwords.json new file mode 100644 index 00000000..c44dc44f --- /dev/null +++ b/lang/pt/templates/webinterface/passwords.json @@ -0,0 +1,3 @@ +[ + +] \ No newline at end of file diff --git a/modules/https.inc.php b/modules/https.inc.php deleted file mode 100644 index c4ee0288..00000000 --- a/modules/https.inc.php +++ /dev/null @@ -1,60 +0,0 @@ -setOff(); - break; - case 'random': - $task = $this->setRandom(); - break; - case 'custom': - $task = $this->setCustom(); - break; - } - if (isset($task['id'])) { - Session::set('https-id', $task['id']); - Util::redirect('?do=Https&show=update'); - } - } - - protected function doRender() - { - if (Request::get('show') === 'update') { - Render::addTemplate('https/restart', array('taskid' => Session::get('https-id'))); - } - Render::addTemplate('https/_page'); - } - - private function setOff() - { - return Taskmanager::submit('LighttpdHttps', array()); - } - - private function setRandom() - { - return Taskmanager::submit('LighttpdHttps', array( - 'proxyip' => Property::getServerIp() - )); - } - - private function setCustom() - { - return Taskmanager::submit('LighttpdHttps', array( - 'importcert' => Request::post('certificate', 'bla'), - 'importkey' => Request::post('privatekey', 'bla'), - 'importchain' => Request::post('cachain', '') - )); - } - -} diff --git a/modules/webinterface.inc.php b/modules/webinterface.inc.php new file mode 100644 index 00000000..fcaf923b --- /dev/null +++ b/modules/webinterface.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('title-webinterface')); + if (Request::get('show') === 'httpsupdate') { + Render::addTemplate('webinterface/httpd-restart', array('taskid' => Session::get('https-id'))); + } + Render::addTemplate('webinterface/https'); + $data = array(); + if (Property::getPasswordFieldType() === 'text') + $data['selected_show'] = 'checked'; + else + $data['selected_hide'] = 'checked'; + Render::addTemplate('webinterface/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/templates/https/_page.html b/templates/https/_page.html deleted file mode 100644 index bf791526..00000000 --- a/templates/https/_page.html +++ /dev/null @@ -1,54 +0,0 @@ -

{{lang_httpsSettings}}

- -
- -
-
{{lang_httpsSettings}}
-
-

{{lang_description}}

-
- - - {{lang_noHttps}} - -
-
- - - {{lang_randomCert}} - -
-
- - - {{lang_customCert}} - -
- -
- -
-
-
-
diff --git a/templates/https/restart.html b/templates/https/restart.html deleted file mode 100644 index cc84aafb..00000000 --- a/templates/https/restart.html +++ /dev/null @@ -1,6 +0,0 @@ -
-
{{lang_applyingSettings}}
-
-
{{lang_installAndRestart}}
-
-
diff --git a/templates/webinterface/httpd-restart.html b/templates/webinterface/httpd-restart.html new file mode 100644 index 00000000..cc84aafb --- /dev/null +++ b/templates/webinterface/httpd-restart.html @@ -0,0 +1,6 @@ +
+
{{lang_applyingSettings}}
+
+
{{lang_installAndRestart}}
+
+
diff --git a/templates/webinterface/https.html b/templates/webinterface/https.html new file mode 100644 index 00000000..ca2a9d04 --- /dev/null +++ b/templates/webinterface/https.html @@ -0,0 +1,53 @@ +
+ + +
+
{{lang_httpsSettings}}
+
+

{{lang_description}}

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

{{lang_description}}

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