function login() { // already log in ? if (AuthUser::isLoggedIn()) { redirect(get_url()); } $data = isset($_POST['login']) ? $_POST['login'] : array('username' => '', 'password' => ''); Flash::set('username', $data['username']); if (AuthUser::login($data['username'], $data['password'], isset($data['remember']))) { $this->_checkVersion(); // redirect to defaut controller and action redirect(get_url()); } else { Flash::set('error', __('Login failed. Please check your login data and try again.')); } // not find or password is wrong redirect(get_url('login')); }
function loginAction() { //如果已经登陆 跳转 //判断登陆 if (isset($_POST['submit']) && $_SERVER['REQUEST_METHOD'] == 'POST') { if (AuthUser::login($_POST['username'], $_POST['password'])) { //监听 记录日志 //如果有记录URL则跳转 //跳转到来源页面 //header('location:index.php?job=admin_article'); //暂时测试用的跳转 go_redirect('index.php?job=admin_article'); //echo '<font color=green>Success</font>'; } else { //否则记录用户名 //提示登陆失败 //echo '<font color=red>Please try again</font>'; header('location:index.php?job=login'); } //如果没找到url活密码 } }
/** * Allows a user to login. */ function login() { $redirect = ''; if (Flash::get('redirect') != null) { $redirect = Flash::get('redirect'); } elseif (Flash::get('HTTP_REFERER') != null) { $redirect = trim(Flash::get('HTTP_REFERER')); } // Allow plugins to handle login Observer::notify('login_requested', $redirect); // already log in ? if (AuthUser::isLoggedIn()) { if ($redirect != '') { redirect(self::sanitizeRedirect($redirect)); } else { redirect(get_url()); } } if (get_request_method() == 'POST') { $data = isset($_POST['login']) ? $_POST['login'] : array('username' => '', 'password' => ''); Flash::set('username', $data['username']); if (AuthUser::login($data['username'], $data['password'], isset($data['remember']))) { Observer::notify('admin_login_success', $data['username']); $this->_checkVersion(); // redirect to defaut controller and action if ($data['redirect'] != null && $data['redirect'] != 'null') { redirect(self::sanitizeRedirect($data['redirect'])); } else { redirect(get_url()); } } else { Flash::set('error', __('Login failed. Check your username and password.<br/>If you tried to login more than :attempts times, you will have to wait at least :delay seconds before trying again.', array(':attempts' => DELAY_FIRST_AFTER, ':delay' => DELAY_ONCE_EVERY))); Observer::notify('admin_login_failed', $data['username']); } } // not find or password is wrong if ($data['redirect'] != null && $data['redirect'] != 'null') { redirect(self::sanitizeRedirect($data['redirect'])); } else { redirect(get_url('login')); } }
/** * Allows a user to login. */ function login() { // already log in ? if (AuthUser::isLoggedIn()) { if (Flash::get('redirect') != null) { redirect(Flash::get('redirect')); } else { redirect(get_url()); } } if (get_request_method() == 'POST') { $data = isset($_POST['login']) ? $_POST['login'] : array('username' => '', 'password' => ''); Flash::set('username', $data['username']); if (AuthUser::login($data['username'], $data['password'], isset($data['remember']))) { Observer::notify('admin_login_success', $data['username']); $this->_checkVersion(); // redirect to defaut controller and action if ($data['redirect'] != null && $data['redirect'] != 'null') { redirect($data['redirect']); } else { redirect(get_url()); } } else { Flash::set('error', __('Login failed. Please check your login data and try again.')); Observer::notify('admin_login_failed', $data['username']); } } // not find or password is wrong if ($data['redirect'] != null && $data['redirect'] != 'null') { redirect($data['redirect']); } else { redirect(get_url('login')); } }
* @Version: 1.0 */ define('APP_PATH', dirname(__FILE__)); define('DS', '/'); include_once 'includes' . DS . 'elfic.ini.php'; $smarty = new Elfic_Smarty(); $auth = new AuthUser(); $msg = isset($_REQUEST['msg']) ? $_REQUEST['msg'] : ''; // set the current action and do $_action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'login'; $_task = isset($_REQUEST['task']) ? $_REQUEST['task'] : ''; $login = isset($_REQUEST['login']) ? $_REQUEST['login'] : false; $passwd = isset($_REQUEST['passwd']) ? $_REQUEST['passwd'] : false; $action = isset($_REQUEST['login']) ? $_REQUEST['login'] : false; if (!$auth->isLoggedIn()) { $auth->login($login, $passwd); } $utils = new Utils(); switch ($_action) { case 'submit': if ($auth->isLoggedIn()) { $utils->cosRedirect('index2.php'); } else { $utils->cosRedirect('index.php', NO_LOGIN); } break; case 'login': if ($auth->isLoggedIn()) { $utils->cosRedirect('index2.php'); } else { $smarty->assign('msg', $msg);
<?php /** * Created by PhpStorm. * User: Admin * Date: 23.02.2015 * Time: 0:24 */ require_once __DIR__ . '/../models/AuthUser.php'; require_once __DIR__ . '/../classes/Error.php'; $err = new Error(); if (empty($_POST['login']) || empty($_POST['pass'])) { $ErrText = "Вы не заполнили необходимые поля"; echo $ErrText; $err->SetError($ErrText); } $login = isset($_POST['login']) ? $_POST['login'] : null; $password = isset($_POST['pass']) ? $_POST['pass'] : null; $remember = isset($_POST['remember']) ? $_POST['remember'] : null; $AuthObj = new AuthUser(); //Если логин и пароль верны, то логинимся if ($AuthObj->CheckAuthParams($login, $password)) { $AuthObj->login($login, $password); header("Location: ./news.php"); } else { $ErrMessage = "Неверный логин или пароль"; $err->SetError($ErrMessage); header("Location: ../index.php"); }