Exemplo n.º 1
0
 function addLang(NForm $form)
 {
     try {
         if ($form->isValid()) {
             $v = $form->getValues();
             dibi::query("INSERT INTO [lang]", array('name' => $v['lang'], 'iso' => $v['iso'], 'active' => 1));
         }
         header('Location: admin.php?setting_action=lang');
     } catch (Exception $e) {
         $form->addError($e->getMessage());
     }
 }
Exemplo n.º 2
0
 function showLogin()
 {
     $user = NEnvironment::getUser();
     if (!isset($this->session['time'])) {
         $this->session['time'] = date('d.m.Y H:i:s');
     }
     //pouzit iba jeden CSS
     MT::addCss('/require_modules/authentication/css/auth.css');
     MT::addScripts('/jscripts/mootools/mootools1.2b2.js', 'mootools');
     MT::addScripts('/jscripts/mootools/mootools_DWrequest.js', 'mootools_adds');
     $form = new NForm('LoginForm');
     $form->getElementPrototype()->id = 'LoginForm';
     $renderer = $form->getRenderer();
     $renderer->wrappers['controls']['container'] = 'div';
     $renderer->wrappers['pair']['container'] = 'div';
     $renderer->wrappers['label']['container'] = NULL;
     $renderer->wrappers['control']['container'] = NULL;
     $form->addGroup();
     $form->addText('login', 'Prihlasovacie meno')->addRule(NForm::FILLED, 'Prihlasovacie meno musí byť vyplnené.')->addRule(NForm::MAX_LENGTH, 'Maximálny počet znakov je %s', 20);
     $form->addPassword('password', 'Heslo')->addRule(NForm::FILLED, 'Prihlasovacie meno musí byť vyplnené.')->addRule(NForm::MAX_LENGTH, 'Maximálny počet znakov je %s', 30);
     $form->addSubmit('submit_login', 'Log In');
     $form->addProtection('Sedenie vypršalo. Proším obnovte prihlasovací formulár a zadajte údaje znovu.', 1800);
     $form['login']->getControlPrototype()->class = 'text';
     $form['login']->getLabelPrototype()->id = 'loginLabel';
     $form['password']->getControlPrototype()->class = 'text';
     $form['password']->getLabelPrototype()->id = 'passwordLabel';
     $form['submit_login']->getControlPrototype()->class = 'btnLogin';
     if ($form->isSubmitted()) {
         if ($form->isValid()) {
             $values = $form->getValues();
             try {
                 if (self::getCountOfUnautorizedAccess() > 10) {
                     throw new NAuthenticationException('Prihlásenie bolo zablokované na 10 minút.');
                 }
                 Log::addGlobalLog(1);
                 $user->setExpiration('+ 2 days', FALSE);
                 //	        	$user->setAuthenticationHandler( new Login() );
                 $user->login($values['login'], $values['password']);
                 $form->setValues(array(), TRUE);
                 header('Location: ' . $_SERVER['REQUEST_URI']);
                 exit;
             } catch (NAuthenticationException $e) {
                 $form->addError($e->getMessage());
             }
         }
     }
     MT::addTemplate(dirname(__FILE__) . '/login.phtml', 'authentication');
     MT::addVar('authentication', 'error_msg', $this->error_msg);
     MT::addVar('authentication', 'loginForm', $form);
     echo MT::renderHeader();
     echo MT::renderContentHolder();
     exit;
 }