function oxd_openid_end_session()
    {
        session_start();
        $config_option = get_option('oxd_config');
        if (!empty($_SESSION['user_oxd_id_token'])) {
            if (get_option('oxd_id') && $_SESSION['user_oxd_id_token']) {
                if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
                    if (exec('netstat -aon |find/i "listening" |find "' . $config_option['oxd_host_port'] . '"')) {
                        $logout = new Logout();
                        $logout->setRequestOxdId(get_option('oxd_id'));
                        $logout->setRequestIdToken($_COOKIE['user_oxd_id_token']);
                        $logout->setRequestPostLogoutRedirectUri($config_option['logout_redirect_uri']);
                        $logout->setRequestSessionState($_COOKIE['session_states']);
                        $logout->setRequestState($_COOKIE['states']);
                        $logout->request();
                        echo '<script>
						var delete_cookie = function(name) {
							document.cookie = name + \'=;expires=Thu, 01 Jan 1970 00:00:01 GMT;\';
						};
						delete_cookie(\'user_oxd_access_token\');
						delete_cookie(\'user_oxd_id_token\');
						delete_cookie(\'session_states\');
						delete_cookie(\'states\');
					</script>';
                        unset($_SESSION['user_oxd_access_token']);
                        unset($_SESSION['user_oxd_id_token']);
                        unset($_SESSION['session_states']);
                        unset($_SESSION['states']);
                        unset($_COOKIE['user_oxd_access_token']);
                        unset($_COOKIE['user_oxd_id_token']);
                        unset($_COOKIE['session_states']);
                        unset($_COOKIE['states']);
                        wp_redirect($logout->getResponseObject()->data->uri);
                        exit;
                    }
                } else {
                    if (exec('netstat -tulpn | grep :' . $config_option['oxd_host_port'])) {
                        $logout = new Logout();
                        $logout->setRequestOxdId(get_option('oxd_id'));
                        $logout->setRequestIdToken($_COOKIE['user_oxd_id_token']);
                        $logout->setRequestPostLogoutRedirectUri($config_option['logout_redirect_uri']);
                        $logout->setRequestSessionState($_COOKIE['session_states']);
                        $logout->setRequestState($_COOKIE['states']);
                        $logout->request();
                        echo '<script>
						var delete_cookie = function(name) {
							document.cookie = name + \'=;expires=Thu, 01 Jan 1970 00:00:01 GMT;\';
						};
						delete_cookie(\'user_oxd_access_token\');
						delete_cookie(\'user_oxd_id_token\');
						delete_cookie(\'session_states\');
						delete_cookie(\'states\');
					</script>';
                        unset($_SESSION['user_oxd_access_token']);
                        unset($_SESSION['user_oxd_id_token']);
                        unset($_SESSION['session_states']);
                        unset($_SESSION['states']);
                        unset($_COOKIE['user_oxd_access_token']);
                        unset($_COOKIE['user_oxd_id_token']);
                        unset($_COOKIE['session_states']);
                        unset($_COOKIE['states']);
                        wp_redirect($logout->getResponseObject()->data->uri);
                        exit;
                    }
                }
            }
        }
    }
예제 #2
0
<?php

/*
 * Created by Vlad Karapetyan
*/
session_start();
if (!empty($_SESSION['state']) and !empty($_SESSION['user_oxd_id_token']) and !empty($_SESSION['session_state'])) {
    //var_dump($_SESSION);exit;
    echo '<p>User login process via OpenID.</p>';
    require_once '../Logout.php';
    echo '<p>Logout.</p>';
    $logout = new Logout();
    $logout->setRequestOxdId($_SESSION['oxd_id']);
    $logout->setRequestPostLogoutRedirectUri(Oxd_RP_config::$post_logout_redirect_uri);
    $logout->setRequestIdToken($_SESSION['user_oxd_id_token']);
    $logout->setRequestSessionState($_SESSION['session_state']);
    $logout->setRequestState($_SESSION['state']);
    $logout->request();
    session_destroy();
    header("Location: " . $logout->getResponseObject()->data->uri);
    exit;
} else {
    header("Location: https://client.example.com/");
}