diff options
author | Simon Rettberg | 2014-12-05 19:15:41 +0100 |
---|---|---|
committer | Simon Rettberg | 2014-12-05 19:15:41 +0100 |
commit | 19ec20ab89bf938fe2dd1a99b62debc76e199425 (patch) | |
tree | fb084493aed19cc481b2276dff5063ac796c7a65 | |
parent | Use different icons for client log entries (incomplete) (diff) | |
download | slx-admin-19ec20ab89bf938fe2dd1a99b62debc76e199425.tar.gz slx-admin-19ec20ab89bf938fe2dd1a99b62debc76e199425.tar.xz slx-admin-19ec20ab89bf938fe2dd1a99b62debc76e199425.zip |
Add option to hide or show password fields
16 files changed, 142 insertions, 64 deletions
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/restart.json b/lang/de/templates/webinterface/httpd-restart.json index e995a251..e995a251 100644 --- a/lang/de/templates/https/restart.json +++ b/lang/de/templates/webinterface/httpd-restart.json diff --git a/lang/de/templates/https/_page.json b/lang/de/templates/webinterface/https.json index 7e8c6020..7e8c6020 100644 --- a/lang/de/templates/https/_page.json +++ b/lang/de/templates/webinterface/https.json 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/restart.json b/lang/en/templates/webinterface/httpd-restart.json index 0a7d4aea..0a7d4aea 100644 --- a/lang/en/templates/https/restart.json +++ b/lang/en/templates/webinterface/httpd-restart.json diff --git a/lang/en/templates/https/_page.json b/lang/en/templates/webinterface/https.json index fc1e8e3e..fc1e8e3e 100644 --- a/lang/en/templates/https/_page.json +++ b/lang/en/templates/webinterface/https.json 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/webinterface/httpd-restart.json index c44dc44f..c44dc44f 100644 --- a/lang/pt/templates/https/_page.json +++ b/lang/pt/templates/webinterface/httpd-restart.json diff --git a/lang/pt/templates/https/restart.json b/lang/pt/templates/webinterface/https.json index c44dc44f..c44dc44f 100644 --- a/lang/pt/templates/https/restart.json +++ b/lang/pt/templates/webinterface/https.json 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 @@ -<?php - -class Page_Https extends Page -{ - - protected function doPreprocess() - { - User::load(); - if (!User::hasPermission('superadmin')) { - Message::addError('no-permission'); - Util::redirect('?do=Main'); - } - $task = false; - switch (Request::post('mode')) { - case 'off': - $task = $this->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 @@ +<?php + +class Page_WebInterface extends Page +{ + + protected function doPreprocess() + { + User::load(); + if (!User::hasPermission('superadmin')) { + Message::addError('no-permission'); + Util::redirect('?do=Main'); + } + switch (Request::post('action')) { + case 'https': + $this->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/restart.html b/templates/webinterface/httpd-restart.html index cc84aafb..cc84aafb 100644 --- a/templates/https/restart.html +++ b/templates/webinterface/httpd-restart.html diff --git a/templates/https/_page.html b/templates/webinterface/https.html index bf791526..ca2a9d04 100644 --- a/templates/https/_page.html +++ b/templates/webinterface/https.html @@ -1,7 +1,6 @@ -<h1>{{lang_httpsSettings}}</h1> - -<form action="?do=Https" method="post"> +<form action="?do=WebInterface" method="post"> <input type="hidden" name="token" value="{{token}}"> + <input type="hidden" name="action" value="https"> <div class="panel panel-default"> <div class="panel-heading">{{lang_httpsSettings}}</div> <div class="panel-body"> 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 @@ +<form action="?do=WebInterface" method="post"> + <input type="hidden" name="token" value="{{token}}"> + <input type="hidden" name="action" value="password"> + <div class="panel panel-default"> + <div class="panel-heading">{{lang_passwordFields}}</div> + <div class="panel-body"> + <p>{{lang_description}}</p> + <div class="input-group" onclick="$('#pmshow').prop('checked', true)"> + <span class="input-group-addon"><input id="pmshow" type="radio" name="mode" value="show" {{selected_show}}></span> + <span class="form-control"> + {{lang_showPasswords}} + </span> + </div> + <div class="input-group" onclick="$('#pmhide').prop('checked', true)"> + <span class="input-group-addon"><input id="pmhide" type="radio" name="mode" value="hide" {{selected_hide}}></span> + <span class="form-control"> + {{lang_hidePasswords}} + </span> + </div> + <div class="pull-right"> + <button type="submit" class="btn btn-primary">{{lang_save}}</button> + </div> + </div> + </div> +</form> |