public function index() { if (strlen($this->registry->core->getParam()) > 0) { $result = App::getModel('login')->authProccessSha($this->registry->core->getParam()); if ($result == 1) { Session::setActiveLoginError(null); Session::setActiveUserid($result); App::getModel('login')->checkInstanceIsValid(); App::getModel('login')->setLoginTime(); App::getModel('login')->getUserData(); App::getModel('login')->setDefaultView($result); App::redirect(__ADMINPANE__ . '/mainside'); } } if (Session::getActiveUserid() != null) { App::redirect(__ADMINPANE__ . '/mainside'); } $form = new FormEngine\Elements\Form(array('name' => 'login', 'action' => '', 'method' => 'post', 'class' => 'login-form', 'csrf' => false)); $form->AddChild(new FormEngine\Elements\TextField(array('name' => 'login', 'label' => _('TXT_EMAIL_FORM_LOGIN'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_EMAIL_FORM_LOGIN')))))); $form->AddChild(new FormEngine\Elements\Password(array('name' => 'password', 'label' => _('TXT_LOGIN_FORM_PASSWORD'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_LOGIN_FORM_PASSWORD')))))); $form->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'autologin', 'label' => _('TXT_AUTOLOGIN')))); $form->AddChild(new FormEngine\Elements\Submit(array('name' => 'log_in', 'label' => _('TXT_LOG_IN')))); $form->AddChild(new FormEngine\Elements\StaticText(array('text' => '<a href="' . App::getURLAdress() . 'forgotlogin">' . _('TXT_LOGIN_FORM_RESET_PASSWORD') . '</a>'))); $form->AddFilter(new FormEngine\Filters\Trim()); $form->AddFilter(new FormEngine\Filters\NoCode()); if ($form->Validate(FormEngine\FE::SubmittedData())) { $loginValues = $form->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT); $result = App::getModel('login')->authProccess($loginValues['login'], $loginValues['password']); if ($result == 0) { Session::setVolatileLoginError(1, false); } else { if (isset($loginValues['autologin']) && $loginValues['autologin'] == 1) { App::getModel('login')->setAdminAutologinKey($result); } else { App::getModel('login')->destroyAdminAutologinKey(); } Session::setActiveLoginError(null); Session::setActiveUserid($result); App::getModel('login')->checkInstanceIsValid(); App::getModel('login')->setLoginTime(); App::getModel('login')->getUserData(); App::getModel('login')->setDefaultView($result); App::redirect(__ADMINPANE__ . '/mainside'); } } $error = Session::getVolatileLoginError(); if ($error[0] == 1) { $this->registry->template->assign('error', _('ERR_BAD_LOGIN_OR_PASSWORD')); } $languages = App::getModel('language')->getLanguages(); $this->registry->xajax->processRequest(); $this->registry->template->assign('xajax', $this->registry->xajax->getJavascript()); $this->registry->template->assign('form', $form->Render()); $this->registry->template->assign('languages', json_encode($languages)); $this->registry->template->display($this->loadTemplate('index.tpl')); }