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 --- modules/https.inc.php | 60 ------------------------------- modules/webinterface.inc.php | 85 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 60 deletions(-) delete mode 100644 modules/https.inc.php create mode 100644 modules/webinterface.inc.php (limited to 'modules') 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', '') + )); + } + +} -- cgit v1.2.3-55-g7522