Ejemplo n.º 1
0
function current_user()
{
    static $user;
    if ($user) {
        return $user;
    }
    if (!$_SESSION['user_id']) {
        return null;
    }
    $user = db_execute('SELECT id, account_name, nick_name, email FROM users WHERE id=?', array($_SESSION['user_id']))->fetch();
    if (!$user) {
        $_SESSION['user_id'] = null;
        abort_authentication_error();
    }
    return $user;
}
Ejemplo n.º 2
0
function current_user()
{
    static $user;
    if ($user) {
        return $user;
    }
    if (!isset($_SESSION['user_id'])) {
        return null;
    }
    $user = db_execute('SELECT * FROM user WHERE id=?', array($_SESSION['user_id']))->fetch();
    if (!$user) {
        $_SESSION['user_id'] = null;
        abort_authentication_error();
    }
    return $user;
}