Пример #1
0
            die;
        }
    }
    if ($_GET['action'] == "logout") {
        if (isset($_GET['callto'])) {
            $_SESSION['callto'] = $_GET['callto'];
        } else {
            $_SESSION['callto'] = "https://www.mediawiki.org/w/api.php";
        }
        if (isset($_GET['returnto'])) {
            $_SESSION['returnto'] = $_GET['returnto'];
        } else {
            $_SESSION['returnto'] = "https://tools.wmflabs.org/xtools-articleinfo/index.php";
        }
        $OAuth = new OAuth2($_SESSION['callto']);
        $OAuth->logout();
        $returnstring = base64_encode(serialize($_SESSION));
        header("Location: {$_SESSION['returnto']}");
        unset($_SESSION['returnto'], $_SESSION['callto']);
        session_write_close();
        die;
    }
    if ($_GET['action'] == "getsession") {
        $returnstring = base64_encode(serialize($_SESSION));
        header("Location: {$_GET['returnto']}");
    }
}
//If we have a callback, it probably means the user executed the authorize function, so let's finish authorization by getting the access token.
if (isset($_GET['oauth_verifier']) && $_GET['oauth_verifier']) {
    start_session();
    $OAuth = new OAuth2($_SESSION['callto']);