public static function getForm($errors = array()) { global $cfg; if (LOGGED) { redirect(REFERER); } $note = new Notifier(); $err = new Error(); if ($errors) { $note->error($errors); } if ($_POST['login'] && $_POST['module']) { $form = array('logname' => $_POST['logname-session'] ? filter($_POST['logname-session'], 100) : '', 'password' => $_POST['password-session'] ? filter($_POST['password-session'], 100) : ''); $err->setError('empty_logname', t('Logname field is required.'))->condition(!$form['logname']); $err->setError('logname_not_exists', t('The logname you used isn't registered.'))->condition($form['logname'] && !User::loginNameRegistered($form['logname'])); $err->setError('password_empty', t('Password field is required.'))->condition(!$form['password']); $err->setError('password_invalid', t('Password is invalid.'))->condition($form['password'] && !User::loginPasswordCorrect($form['password'])); $err->noErrors() ? redirect(REFERER) : $note->restore()->error($err->toArray()); } $tpl = new PHPTAL('modules/login/form.html'); $tpl->form = $form; $tpl->err = $err->toArray(); $tpl->note = $note; echo $tpl->execute(); }
public function getContent() { // User is logged in if (LOGGED) { $this->subcodename = 'logged'; $tpl = new PHPTAL('blocks/user_panel/logged.html'); $tpl->user = User::format(User::$id, User::$nickname, User::$groupId); $pm_item = User::$pmNew ? array(t('Messages <strong>(New: %new)</strong>', array('%new' => $user->pm_new)), 'pm/inbox') : array(t('Messages'), 'pm'); $tpl->items = items(array($pm_item[0] => HREF . $pm_item[1], t('Administration') => HREF . 'admin', t('Edit profile') => HREF . 'edit_profile', t('Log out') => HREF . 'logout')); return $tpl->execute(); } else { $err = new Error(); $note = new Notifier('note-user_panel'); $this->subcodename = 'not_logged'; $form = array('logname' => null, 'password' => null); if ($_POST['login'] && $_POST['user_panel']) { $form['logname'] = $_POST['logname-session'] ? filter($_POST['logname-session'], 100) : ''; $form['password'] = $_POST['password-session'] ? $_POST['password-session'] : ''; $err->setError('logname_empty', t('Logname field is required.'))->condition(!$form['logname']); $err->setError('logname_not_exists', t('Entered logname is not registered.'))->condition(!User::loginNameRegistered($form['logname'])); $err->setError('password_empty', t('Password field is required.'))->condition(!$form['password']); $err->setError('password_incorrect', t('ERROR_PASS_INCORRECT'))->condition($form['password'] && !User::loginPasswordCorrect($form['password'])); if ($err->noErrors()) { redirect('./'); } else { $note->error($err->toArray()); } } $tpl = new PHPTAL('blocks/user_panel/not_logged.html'); $tpl->note = $note; $tpl->form = $form; $tpl->err = $err->toArray(); return $tpl->execute(); } }