Example #1
0
function plugin_jugemkey_action()
{
    global $vars, $auth_api, $_jugemkey_msg;
    if (!$auth_api['jugemkey']['use']) {
        return '';
    }
    // LOGIN
    if (isset($vars['login'])) {
        Utility::redirect(plugin_jugemkey_jump_url());
        die;
    }
    $obj = new AuthJugem();
    // LOGOUT
    if (isset($vars['logout'])) {
        $obj->unsetSession();
        Utility::redirect();
    }
    // Get token info
    if (isset($vars['userinfo'])) {
        $rc = $obj->get_userinfo($vars['token']);
        if ($rc['rc'] != 200) {
            $msg = empty($rc['error']) ? '' : ' (' . $rc['error'] . ')';
            Utility::dieMessage('JugemKey: RC=' . $rc['rc'] . $msg);
        }
        $body = '<h3>' . $_jugemkey_msg['msg_userinfo'] . '</h3>' . '<strong>' . $_jugemkey_msg['msg_user_name'] . ': ' . $rc['title'] . '</strong>';
        return array('msg' => 'JugemKey', 'body' => $body);
    }
    // AUTH
    $rc = $obj->auth($vars['frob']);
    if ($rc['rc'] != 200) {
        $msg = empty($rc['error']) ? '' : ' (' . $rc['error'] . ')';
        Utility::dieMessage('JugemKey: ' . $rc['rc'] . $msg);
    }
    $obj->setSession();
    Utility::redirect();
    die;
}
function plugin_jugemkey_action()
{
    global $vars, $auth_api, $_jugemkey_msg;
    if (!$auth_api['jugemkey']['use']) {
        return '';
    }
    if (!function_exists('pkwk_session_start')) {
        return '';
    }
    if (pkwk_session_start() == 0) {
        return '';
    }
    $page = empty($vars['page']) ? '' : $vars['page'];
    $die_message = PLUS_PROTECT_MODE ? 'die_msg' : 'die_message';
    // LOGIN
    if (isset($vars['login'])) {
        header('Location: ' . plugin_jugemkey_jump_url());
        die;
    }
    $obj = new auth_jugemkey();
    // LOGOUT
    if (isset($vars['logout'])) {
        $obj->auth_session_unset();
        header('Location: ' . get_page_location_uri($page));
        die;
    }
    // Get token info
    if (isset($vars['userinfo'])) {
        $rc = $obj->get_userinfo($vars['token']);
        if ($rc['rc'] != 200) {
            $msg = empty($rc['error']) ? '' : ' (' . $rc['error'] . ')';
            $die_message('JugemKey: RC=' . $rc['rc'] . $msg);
        }
        $body = '<h3>' . $_jugemkey_msg['msg_userinfo'] . '</h3>' . '<strong>' . $_jugemkey_msg['msg_user_name'] . ': ' . $rc['title'] . '</strong>';
        return array('msg' => 'JugemKey', 'body' => $body);
    }
    // AUTH
    $rc = $obj->auth($vars['frob']);
    if ($rc['rc'] != 200) {
        $msg = empty($rc['error']) ? '' : ' (' . $rc['error'] . ')';
        $die_message('JugemKey: ' . $rc['rc'] . $msg);
    }
    $obj->auth_session_put();
    header('Location: ' . get_page_location_uri($page));
    die;
}