slhlp = plugin_load('helper', $this->getPluginName()); if(!$this->slhlp) msg('Loading the '.$this->getPluginName().' helper failed. Make sure that the '.$this->getPluginName().' plugin is installed.', -1); } /** * return sort order for position in admin menu */ function getMenuSort() { return 999; } function getMenuText($lang) { return $this->getLang('securelogin_conf'); } /** * handle user request */ function handle() { if(!$this->slhlp->canWork()) msg("You need openssl php module for this plugin work!", -1); elseif($this->slhlp->haveKey() && !$this->slhlp->workCorrect()) msg("Your version of dokuwiki not generate AUTH_LOGIN_CHECK event, plugin not work!"); $fn = $_REQUEST['fn']; if (is_array($fn)) { $cmd = key($fn); $param = $fn[$cmd]; } else { $cmd = $fn; $param = null; } switch($cmd) { case "newkey": $this->slhlp->generateKey($param); break; case "test": msg(urldecode($this->slhlp->decrypt($param['message']))); break; } } /** * output appropriate html */ function html() { if(!$this->slhlp->canWork()) { print $this->locale_xhtml('needopenssl'); return; } elseif($this->slhlp->haveKey() && !$this->slhlp->workCorrect()) print $this->locale_xhtml('needpatch'); ptln('
'); $this->_html_generateKey(); if($this->slhlp->haveKey()) { $this->_html_test(); // print $this->render("===== ".$this->getLang('public_key')." ===== \n". // "\n". // $this->slhlp->getPublicKey(). // "", // $format='xhtml'); } ptln('
'); } function _html_generateKey() { global $ID; $form = new Doku_Form('generate__key', wl($ID,'do=admin,page='.$this->getPluginName(), false, '&')); $form->startFieldset($this->getLang('generate_key')); $form->addElement(form_makeMenuField('fn[newkey]', $this->slhlp->getKeyLengths(), $this->slhlp->getKeyLength(), $this->getLang('key_length'), 'key__length', 'block', array('class' => 'edit'))); $form->addElement(form_makeButton('submit', '', $this->getLang('generate'))); $form->endFieldset(); ptln('
'); html_form('generate', $form); ptln('
'); } function _html_test() { global $ID; $form = new Doku_Form('test__publicKey', wl($ID,'do=admin,page='.$this->getPluginName(), false, '&')); $form->startFieldset($this->getLang('test_key')); $form->addElement(form_makeTextField('fn[test][message]', $this->getLang('sample_message'), $this->getLang('test_message'), 'test__message', 'block')); $form->addElement(form_makeButton('submit', '', $this->getLang('test'))); $form->endFieldset(); html_form('test__publicKey', $form); } }