コード例 #1
0
ファイル: util.php プロジェクト: himmelex/NTW
function common_current_user()
{
    global $_cur;
    if (!_have_config()) {
        return null;
    }
    if ($_cur === false) {
        if (isset($_COOKIE[session_name()]) || isset($_GET[session_name()]) || isset($_SESSION['userid']) && $_SESSION['userid']) {
            common_ensure_session();
            $id = isset($_SESSION['userid']) ? $_SESSION['userid'] : false;
            if ($id) {
                $user = User::staticGet($id);
                if ($user) {
                    $_cur = $user;
                    return $_cur;
                }
            }
        }
        // that didn't work; try to remember; will init $_cur to null on failure
        $_cur = common_remembered_user();
        if ($_cur) {
            // XXX: Is this necessary?
            $_SESSION['userid'] = $_cur->id;
        }
    }
    return $_cur;
}
コード例 #2
0
ファイル: util.php プロジェクト: Br3nda/laconica
function common_current_user()
{
    global $_cur;
    if (!_have_config()) {
        return null;
    }
    if ($_cur === false) {
        if (isset($_REQUEST[session_name()]) || isset($_SESSION['userid']) && $_SESSION['userid']) {
            common_ensure_session();
            $id = isset($_SESSION['userid']) ? $_SESSION['userid'] : false;
            if ($id) {
                $_cur = User::staticGet($id);
                return $_cur;
            }
        }
        // that didn't work; try to remember; will init $_cur to null on failure
        $_cur = common_remembered_user();
        if ($_cur) {
            common_debug("Got User " . $_cur->nickname);
            common_debug("Faking session on remembered user");
            // XXX: Is this necessary?
            $_SESSION['userid'] = $_cur->id;
        }
    }
    return $_cur;
}