本文整理汇总了PHP中Current_User::user方法的典型用法代码示例。如果您正苦于以下问题:PHP Current_User::user方法的具体用法?PHP Current_User::user怎么用?PHP Current_User::user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Current_User
的用法示例。
在下文中一共展示了Current_User::user方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
if ($user = Current_User::user()) {
redirect("inicio");
}
$data["content"] = "home";
$this->load->view("index", $data);
}
示例2: index
public function index()
{
if (Current_User::user()) {
if (!empty($_GET['logoff'])) {
$this->logout();
header("location:login.html");
} else {
include 'admin_registration.view.php';
// @ session already active
// $arr = array('status' => true, 'message' => $ACL_LANG['SESSION_ACTIVE'], 'url' => SUCCESS_URL);
// $json_arr = json_encode($arr);
// echo $json_arr;
}
} else {
// load data to the view if there are some data needed
//include('login.view.php');
//@ session not active
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
//@ first load
$arr = array('status' => false, 'message' => $acl->form());
$json_arr = json_encode($arr);
echo $json_arr;
} else {
//@ form submission
$u = !empty($_POST['u']) ? trim($_POST['u']) : false;
// retrive user var
$p = !empty($_POST['p']) ? trim($_POST['p']) : false;
// retrive password var
// @ try to signin
$is_auth = Current_User::authenticate($u, $p);
if ($is_auth) {
//@ success
$arr = array('status' => true, 'message' => $ACL_LANG['LOGIN_SUCCESS'], 'url' => SUCCESS_URL);
$json_arr = json_encode($arr);
echo $json_arr;
} else {
//@ failed
$arr = array('status' => false, 'message' => $ACL_LANG['LOGIN_FAILED']);
$json_arr = json_encode($arr);
echo $json_arr;
}
}
}
}
示例3: authenticate
/**
* Authenticate and validate the user.
* @param $username
* @param $password
* @return unknown_type
*/
public static function authenticate($username, $password)
{
global $db_config;
$result = FALSE;
$db = NULL;
if ($username && $password) {
$db = @mysql_connect($db_config['server'], $db_config['user'], $db_config['pass']);
if (!$db) {
return FALSE;
}
$opendb = @mysql_select_db($db_config['name'], $db);
if (!$opendb) {
return FALSE;
}
$sql = "SELECT * FROM " . $db_config['users'] . " WHERE ";
switch (LOGIN_METHOD) {
case 'both':
$sql .= "(username='" . mysql_real_escape_string($username) . "' OR useremail='" . mysql_real_escape_string($username) . "')";
break;
case 'email':
$sql .= "useremail='" . mysql_real_escape_string($username) . "'";
break;
default:
$sql .= "username='" . mysql_real_escape_string($username) . "'";
break;
}
$sql .= " AND userpassword = '" . md5($password) . "'";
$rs = @mysql_query($sql, $db);
if (!$rs) {
return FALSE;
}
if (mysql_num_rows($rs)) {
$u = new stdClass();
//$u->user_id
self::$user = $u;
self::setSession(array_merge(mysql_fetch_assoc($rs), array('expires' => time() + 45 * 60)));
$result = TRUE;
}
mysql_free_result($rs);
mysql_close($db);
unset($rs, $sql);
}
return $result;
}
示例4: login
public static function login($username, $password)
{
$CI =& get_instance();
$sql = "select * from admusers where active=1 and username='" . $CI->db->escape_str($username) . "'";
$query = $CI->db->query($sql);
$u = $query->result();
if (isset($u[0])) {
$CI->load->model("user_model");
// password match (comparing encrypted passwords)
if ($u[0]->password == $CI->user_model->transform_password($password)) {
//$CI =& get_instance();
$CI->load->library('session');
$CI->session->set_userdata('user_id', $u[0]->id);
self::$user = $u[0];
return TRUE;
}
}
// login failed
return FALSE;
}
示例5: login
public static function login($username, $password)
{
// get User object by username
if ($u = Doctrine::getTable('User')->findOneByUsername($username)) {
// this mutates (encrypts) the input password
$u_input = new User();
$u_input->password = $password;
// password match (comparing encrypted passwords)
if ($u->password == $u_input->password) {
unset($u_input);
$CI =& get_instance();
$CI->session->set_userdata('user_id', $u->id);
self::$user = $u;
return TRUE;
}
unset($u_input);
}
// login failed
return FALSE;
}
示例6: login
public static function login($username, $password)
{
// get User object by username
if ($u = Doctrine::getTable('User')->findOneByUsername($username)) {
// to ge the mutated version of the input password
$u_input = new User();
$u_input->password = $password;
// password match
if ($u->password == $u_input->password && $u->status == 1) {
unset($u_input);
$CI =& get_instance();
$CI->load->library('session');
$CI->session->set_userdata('user_id', $u->id);
self::$user = $u;
return TRUE;
}
unset($u_input);
}
// login failed
return FALSE;
}
示例7: base_url
<title>Home</title>
<link rel="stylesheet" href="<?php
echo base_url();
?>
css/style.css"
type="text/css" media="all">
</head>
<body>
<div>
<?php
if (Current_User::user()) {
?>
<h1>Hello <em><?php
echo Current_User::user()->username;
?>
</em>.</h1>
<h3><?php
echo anchor('logout', 'Logout');
?>
</h3>
<?php
} else {
?>
<h2>New Users: <?php
echo anchor('signup', 'Create an Account');
?>
.</h2>
<h2>Members: <?php
echo anchor('login', 'Login');
示例8: anchor
?>
/js/behaviour.js"></script>
</head>
<body>
<!--[if !IE]>start wrapper<![endif]-->
<div id="wrapper">
<!--[if !IE]>start head<![endif]-->
<div id="head">
<div class="inner">
<h1 id="logo"><a href="#">Voltxion</a></h1>
<!--[if !IE]>start user details<![endif]-->
<br />
<ul id="user_details_menu">
<?php
if ($user = Current_User::user()) {
?>
<li class="first">Welcome <strong><?php
echo $user->username;
?>
</strong></li>
<li><a href="#">My Account</a></li>
<li class="last"><?php
echo anchor('logout', 'Logout');
?>
</li>
<?php
} else {
?>
<li><?php
echo anchor('login', 'Login');
示例9: verified_login
public static function verified_login()
{
if (!($user = Current_User::user())) {
redirect('home');
}
}
示例10: addnew
public function addnew()
{
if ($this->_submit_validateUsuario() === FALSE) {
$this->add();
return;
} else {
$usuario = Current_User::user();
$record = array('name' => $this->input->post("name"), 'lastname' => $this->input->post("lastname"), 'username' => $this->input->post("username"), 'password' => User_model::transform_password($this->input->post("password")), 'date_created' => date("Ymd"), 'created_by' => $usuario->username);
$this->db->insert("admusers", $record);
$this->addpermisos($this->db->insert_id());
redirect("usuario/addSuccess");
}
redirect("usuario");
}