本文整理汇总了PHP中login_user函数的典型用法代码示例。如果您正苦于以下问题:PHP login_user函数的具体用法?PHP login_user怎么用?PHP login_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了login_user函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index_login
/**
* Permet de connecter un utilisateur
* @global type $tpl
* @global type $pdo
*/
function index_login()
{
global $tpl;
$tpl->assign('msg', false);
//Tentative de connexion
if (isset($_POST['login'])) {
if (isset($_POST['otp_code'])) {
$result = login_user($_POST['login'], $_POST['password'], $_POST['otp_code']);
} else {
$result = login_user($_POST['login'], $_POST['password']);
}
if ($result === true) {
$url = explode('/', $_REQUEST['redirect'], 3);
$opt = array();
if (isset($url[2])) {
parse_str($url[2], $opt);
}
redirect($url[0], $url[1], $opt);
}
if ($result === -1) {
//Erreur µ-1 = OTP requis
if (isset($_POST['otp_code'])) {
$tpl->assign('msg', 'Code erroné.');
}
$tpl->display('index_login_otp.tpl');
quit();
}
// Et oui, pas de redirection = erreur de login ...
$tpl->assign('msg', 'Utilisateur ou mot de passe erroné.');
}
$_SESSION['random'] = md5(uniqid());
$tpl->assign('random', $_SESSION['random']);
$tpl->display('index_login.tpl');
quit();
}
示例2: LoginParticulier
public function LoginParticulier()
{
$this->mLayout = "empty";
$this->mTheme = 'login-page';
$this->mViewFile = 'loginparticulier';
if (validate_form()) {
$username = $this->input->post('username');
$password = $this->input->post('password');
$this->load->model('User_model', 'user_model');
$user = $this->user_model->get_by('email', $username);
// only admin and staff can login
/*if ( verify_role(['admin', 'staff'], $user) )
{*/
// password correct
if (verify_pw($password, $user['password'])) {
// limited fields to store in session
$fields = array('id', 'role', 'email', 'first_name', 'last_name', 'created_at');
$user_data = elements($fields, $user);
login_user($user);
// success
set_alert('success', 'Connexion réussie');
redirect('home');
exit;
}
//}
// failed
set_alert('danger', 'Nom d\'utilisateur ou Mot de passe incorrect');
redirect('/login/Loginparticulier');
}
}
示例3: login
public function login()
{
$this->mTitle = "Login";
$this->mViewFile = 'account/login';
if (validate_form()) {
$email = $this->input->post('email');
$password = $this->input->post('password');
$user = $this->users->get_by(['email' => $email, 'active' => 1]);
if (!empty($user)) {
// "remember me"
if ($this->input->post('remember')) {
$this->session->sess_expire_on_close = FALSE;
$this->session->sess_update();
}
// check password
if (verify_pw($password, $user['password'])) {
// limited fields to store in session
$fields = array('id', 'role', 'first_name', 'last_name', 'email', 'created_at');
$user_data = elements($fields, $user);
login_user($user_data);
// success
set_alert('success', 'Login success.');
redirect('home');
exit;
}
}
// failed
$this->session->set_flashdata('form_fields', ['email' => $email]);
set_alert('danger', 'Invalid Login.');
redirect('account/login');
}
}
示例4: index
public function index()
{
$this->mLayout = "empty";
$this->mTheme = 'login-page';
$this->mViewFile = 'login';
if (validate_form()) {
$username = $this->input->post('username');
$password = $this->input->post('password');
$this->load->model('Backend_user_model', 'backend_users');
$user = $this->backend_users->get_by('username', $username);
// only admin and staff can login
if (verify_role(['admin', 'staff-1', 'staff-2', 'staff-3'], $user)) {
// password correct
if (verify_pw($password, $user['password'])) {
// limited fields to store in session
$fields = array('id', 'role', 'username', 'full_name', 'created_at');
$user_data = elements($fields, $user);
login_user($user);
// success
set_alert('success', 'Login success');
redirect('home');
exit;
}
}
// failed
set_alert('danger', 'Invalid Login');
redirect('login');
}
}
示例5: main
function main()
{
// создаем сессию
session_start();
if (is_current_user()) {
// если пользователь уже залогинен, то отправляем его на глапную
redirect('./');
}
if (is_postback()) {
// обрабатываем отправленную форму
$dbh = db_connect();
$post_result = login_user($dbh, $user, $errors);
db_close($dbh);
if ($post_result) {
// перенаправляем на главную
redirect('./');
} else {
// информация о пользователе заполнена неправильно, выведем страницу с ошибками
render('login_form', array('form' => $_POST, 'errors' => $errors));
}
} else {
// отправляем пользователю чистую форму для входа
render('login_form', array('form' => array(), 'errors' => array()));
}
}
示例6: login
function login()
{
global $vars, $day, $month, $year, $phpc_script;
$html = tag('div');
//Check password and username
if (isset($vars['username'])) {
$user = $vars['username'];
$password = $vars['password'];
if (login_user($user, $password)) {
$string = "{$phpc_script}?";
$arguments = array();
if (!empty($vars['lastaction'])) {
$arguments[] = "action={$vars['lastaction']}";
}
if (!empty($vars['year'])) {
$arguments[] = "year={$year}";
}
if (!empty($vars['month'])) {
$arguments[] = "month={$month}";
}
if (!empty($vars['day'])) {
$arguments[] = "day={$day}";
}
redirect($string . implode('&', $arguments));
return tag('h2', _('Logged in.'));
}
$html->add(tag('h2', _('Sorry, Invalid Login')));
}
$html->add(login_form());
return $html;
}
示例7: validate_user_login
function validate_user_login()
{
$errors = [];
$min = 3;
$max = 20;
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_POST['email']) && isset($_POST['password'])) {
$email = clean($_POST['email']);
$password = clean($_POST['password']);
if (empty($email)) {
$errors[] = "Email field cannot be empty";
}
if (empty($password)) {
$errors[] = "Password cannot be empty";
}
}
if (!empty($errors)) {
foreach ($errors as $error) {
echo validation_errors($error);
}
} else {
if (login_user($email, $password)) {
redirect("admin.php");
} else {
echo validation_errors("Your credentials are not correct");
}
}
}
}
示例8: login
function login()
{
global $vars, $phpc_script;
$html = tag('div');
//Check password and username
if (isset($vars['username'])) {
$user = $vars['username'];
if (!isset($vars['password'])) {
message(__("No password specified."));
} else {
$password = $vars['password'];
if (login_user($user, $password)) {
$url = $phpc_script;
if (!empty($vars['lasturl'])) {
$url .= '?' . urldecode($vars['lasturl']);
}
redirect($url);
return tag('h2', __('Logged in.'));
}
$html->add(tag('h2', __('Sorry, Invalid Login')));
}
}
$html->add(login_form());
return $html;
}
示例9: edit_avatar
public function edit_avatar()
{
$this->theme->setBreadcrumb("切换头像");
$this->theme->setTitle("切换头像");
$this->__view("User/header.php");
$user = login_user();
$this->__view("User/edit_avatar.php", ['type' => $user->getAvatarSql(), 'avatar' => $user->getAvatar()]);
$this->__view("User/footer.php");
}
示例10: do_login
function do_login()
{
$status = "";
if (!empty($_POST['openid_identifier'])) {
$sreg = new Zend_OpenId_Extension_Sreg(array('nickname' => false, 'email' => false, 'fullname' => false), null, 1.1);
$consumer = new Zend_OpenId_Consumer();
if (!$consumer->login($_POST['openid_identifier'], '', null, $sreg)) {
$status = "FAILED";
}
} else {
if (isset($_GET['openid_mode'])) {
if ($_GET['openid_mode'] == "id_res") {
$consumer = new Zend_OpenId_Consumer();
$sreg = new Zend_OpenId_Extension_Sreg(array('nickname' => false, 'email' => false, 'fullname' => false), null, 1.1);
if ($consumer->verify($_GET, $id, $sreg)) {
$_SESSION['logged_in_user'] = true;
$status = true;
$open_id_addr = $_GET['openid_identity'];
if (strpos($open_id_addr, 'https') === 1) {
$open_id_addr = str_replace('https', 'http', $open_id_addr);
}
//$_SESSION['user_info'] = array();
//$_SESSION['user_info']['open_id'] = $_GET['openid_identity'];
/*
$data = $sreg->getProperties();
if (isset($data['nickname'])) {
$status .= "<br>nickname: " . htmlspecialchars($data['nickname']) . "<br>\n";
$_SESSION['user_info']['nickname'] = htmlspecialchars($data['nickname']);
}
if (isset($data['email'])) {
$status .= "email: " . htmlspecialchars($data['email']) . "<br>\n";
$_SESSION['user_info']['email'] = htmlspecialchars($data['email']);
}
if (isset($data['fullname'])) {
$status .= "fullname: " . htmlspecialchars($data['fullname']) . "<br>\n";
$_SESSION['user_info']['fullname'] = htmlspecialchars($data['fullname']);
}
*/
login_user($open_id_addr);
} else {
$status = "INVALID " . htmlspecialchars($id);
}
} else {
if ($_GET['openid_mode'] == "cancel") {
$status = "CANCELED";
}
}
}
}
return $status;
}
示例11: __construct
public function __construct()
{
parent::__construct();
if (!is_login()) {
redirect(array("Home", "login"));
} else {
if (!login_user()->Permission("Control")) {
redirect(array('Home', 'permission'));
}
}
header("Content-Type: text/html; charset: utf-8");
}
示例12: handleLogin
public static function handleLogin()
{
//login user or display loginForm with errors
$username = $_POST["username"];
$password = $_POST["password"];
if (!login_user($username, $password)) {
self::displayLoginForm(array("error" => "Wrong username/password combination please try again!"));
} else {
//redirect to homepage on success
header("Location: /");
}
}
示例13: doAdminLoginAction
public function doAdminLoginAction()
{
$username = $this->request->getParam("username");
$pwd = $this->request->getParam("password");
$login_result = login_user($username, $pwd);
if (!$login_result["ok"]) {
$this->flash->setError("Invalid username/password");
$this->render(null, "admin_login");
} else {
$this->redirect_to(admin_index_path());
}
}
示例14: portal_login
function portal_login($portal_auth, $user_name, $application_name)
{
$error = new SoapError();
$contact = new Contact();
$result = login_user($portal_auth);
if ($result == 'fail' || $result == 'sessions_exceeded') {
if ($result == 'sessions_exceeded') {
$error->set_error('sessions_exceeded');
} else {
$error->set_error('no_portal');
}
return array('id' => -1, 'error' => $error->get_soap_array());
}
global $current_user;
if ($user_name == 'lead') {
session_start();
$_SESSION['is_valid_session'] = true;
$_SESSION['ip_address'] = query_client_ip();
$_SESSION['portal_id'] = $current_user->id;
$_SESSION['type'] = 'lead';
login_success();
return array('id' => session_id(), 'error' => $error->get_soap_array());
} else {
if ($user_name == 'portal') {
session_start();
$_SESSION['is_valid_session'] = true;
$_SESSION['ip_address'] = query_client_ip();
$_SESSION['portal_id'] = $current_user->id;
$_SESSION['type'] = 'portal';
$GLOBALS['log']->debug("Saving new session");
login_success();
return array('id' => session_id(), 'error' => $error->get_soap_array());
} else {
$contact = $contact->retrieve_by_string_fields(array('portal_name' => $user_name, 'portal_active' => '1', 'deleted' => 0));
if ($contact != null) {
session_start();
$_SESSION['is_valid_session'] = true;
$_SESSION['ip_address'] = query_client_ip();
$_SESSION['user_id'] = $contact->id;
$_SESSION['portal_id'] = $current_user->id;
$_SESSION['type'] = 'contact';
$_SESSION['assigned_user_id'] = $contact->assigned_user_id;
login_success();
build_relationship_tree($contact);
return array('id' => session_id(), 'error' => $error->get_soap_array());
}
}
}
$error->set_error('invalid_login');
return array('id' => -1, 'error' => $error->get_soap_array());
}
示例15: hook_bootstrap
/**
* Before the framework run.
*
* @return void
*/
function hook_bootstrap()
{
global $rublon, $config;
// Create the Rublon object:
require_once './extended/MyRublon.php';
require_once './extended/MyCallback.php';
$rublon = new MyRublon($config['rublon']['systemToken'], $config['rublon']['secretKey']);
if (!empty($_GET['rublon']) and $_GET['rublon'] == 'callback') {
// Rublon Callback URL
try {
$confirmResult = null;
// Create instance of MyCallback which is the extended Rublon2FactorCallback class.
$callback = new MyCallback($rublon);
$callback->call(function ($userId, Rublon2FactorCallback $callback) use(&$confirmResult) {
// <--- needed if this is a transaction confirmation.
login_user($userId);
$confirmResult = $callback->getCredentials()->getConfirmResult();
// Save deviceId for remote logout:
$response = $callback->getCredentials()->getResponse();
// var_dump($response);exit;
if (isset($response['result']['deviceId'])) {
$_SESSION['rublonDeviceId'] = $response['result']['deviceId'];
}
}, function (Rublon2FactorCallback $callback) {
if (!empty($_GET['custom']) and $_GET['custom'] == 'confirm') {
die('canceled');
} else {
redirect('./?rublon=cancel');
}
});
if (!is_null($confirmResult)) {
transaction_confirm_result($confirmResult == RublonAPICredentials::CONFIRM_RESULT_YES, $withRublon = true);
exit;
} else {
redirect($config['websiteUrl'] . '?rublonLogin=success');
}
} catch (Exception $e) {
// Remember to utilize your own error handler.
if (!empty($_GET['error']) and $_GET['error'] == 'timeout') {
die('timeout error');
}
var_dump(get_class($e));
echo $e->getMessage();
var_dump($e->getPrevious());
exit;
}
}
}