Ejemplo n.º 1
0
/**
 * Find whether the current member is logged in via httpauth.
 *
 * @return boolean		Whether the current member is logged in via httpauth
 */
function is_httpauth_login()
{
    if (get_forum_type() != 'ocf') {
        return false;
    }
    if (is_guest()) {
        return false;
    }
    require_code('ocf_members');
    return array_key_exists('PHP_AUTH_USER', $_SERVER) && !is_null(ocf_authusername_is_bound_via_httpauth($_SERVER['PHP_AUTH_USER']));
}
/**
 * Try and login via HTTP authentication. This function is only called if HTTP authentication is currently active. With HTTP authentication we trust the PHP_AUTH_USER setting.
 *
 * @return ?MEMBER		Logged in member (NULL: no login happened)
 */
function try_httpauth_login()
{
    global $LDAP_CONNECTION;
    require_code('ocf_members');
    require_code('ocf_groups');
    require_lang('ocf');
    $member = ocf_authusername_is_bound_via_httpauth($_SERVER['PHP_AUTH_USER']);
    if (is_null($member) && (running_script('index') || running_script('execute_temp'))) {
        require_code('ocf_members_action');
        require_code('ocf_members_action2');
        if (trim(post_param('email_address', '')) == '' && get_value('no_finish_profile') !== '1') {
            @ob_end_clean();
            if (!function_exists('do_header')) {
                require_code('site');
            }
            $middle = ocf_member_external_linker_ask($_SERVER['PHP_AUTH_USER'], get_option('windows_auth_is_enabled', true) != '1' || is_null($LDAP_CONNECTION) ? 'httpauth' : 'ldap');
            $tpl = globalise($middle, NULL, '', true);
            $tpl->evaluate_echo();
            exit;
        } else {
            $member = ocf_member_external_linker($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_USER'], get_option('windows_auth_is_enabled', true) != '1' || is_null($LDAP_CONNECTION) ? 'httpauth' : 'ldap');
        }
    }
    if (!is_null($member)) {
        create_session($member, 1, isset($_COOKIE[get_member_cookie() . '_invisible']) && $_COOKIE[get_member_cookie() . '_invisible'] == '1');
    }
    // This will mark it as confirmed
    return $member;
}