Esempio n. 1
0
require_once '/data/project/xtools/modules/OAuth.php';
if (isset($_GET['action'])) {
    start_session();
    if ($_GET['action'] == "login") {
        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']);
        if (!$OAuth->Authorize()) {
            session_write_close();
            die("Failed to initiate Authorization!<br>Returned error:<br>" . $OAuth->getError());
        } else {
            session_write_close();
            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'];