Exemple #1
0
function open_init()
{
    load_plugin_textdomain('open-social', '', dirname(plugin_basename(__FILE__)) . '/lang');
    $GLOBALS['open_arr'] = array('qq' => __('QQ', 'open-social'), 'sina' => __('Sina', 'open-social'), 'baidu' => __('Baidu', 'open-social'), 'google' => __('Google', 'open-social'), 'live' => __('Microsoft', 'open-social'), 'douban' => __('Douban', 'open-social'), 'renren' => __('RenRen', 'open-social'), 'kaixin' => __('Kaixin001', 'open-social'), 'xiaomi' => __('XiaoMi', 'open-social'), 'csdn' => __('CSDN', 'open-social'), 'oschina' => __('OSChina', 'open-social'), 'facebook' => __('Facebook', 'open-social'), 'twitter' => __('Twitter', 'open-social'), 'github' => __('Github', 'open-social'), 'wechat' => __('WeChat', 'open-social'));
    $GLOBALS['open_share_arr'] = array('weibo' => array(__('Share with Weibo', 'open-social'), "http://v.t.sina.com.cn/share/share.php?url=%URL%&title=%TITLE%&pic=%PIC%&appkey=" . osop('SINA_AKEY') . "&ralateUid=" . osop('share_sina_user') . "&language=zh_cn&searchPic=false"), 'qqzone' => array(__('Share with QQZone', 'open-social'), "http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=%URL%&title=%TITLE%&desc=&summary=&site=&pics=%PIC%"), 'qqweibo' => array(__('Share with QQWeibo', 'open-social'), "http://share.v.t.qq.com/index.php?c=share&a=index&url=%URL%&title=%TITLE%&pic=%PIC%&appkey=" . osop('share_qqt_appkey')), 'youdao' => array(__('Share with YoudaoNote', 'open-social'), "http://note.youdao.com/memory/?url=%URL%&title=%TITLE%&sumary=&pic=%PIC%&product="), 'wechat' => array(__('Share with WeChat', 'open-social'), "QRCODE"), 'qqemail' => array(__('QQEmail Me', 'open-social'), "http://mail.qq.com/cgi-bin/qm_share?t=qm_mailme&email=" . osop('share_qq_email')), 'qqchat' => array(__('QQChat Me', 'open-social'), 'http://wpa.qq.com/msgrd?v=3&uin=' . osop('share_qq_talk') . '&site=' . get_bloginfo('name') . '&menu=yes'), 'twitter' => array(__('Share with Twitter', 'open-social'), "http://twitter.com/home/?status=%TITLE%:%URL%"), 'facebook' => array(__('Share with Facebook', 'open-social'), "http://www.facebook.com/sharer.php?u=%URL%&t=%TITLE%"), 'google' => array(__('Google Translation', 'open-social'), "http://translate.google.com.hk/translate?hl=" . (isset($_SESSION['WPLANG_LOCALE']) ? $_SESSION['WPLANG_LOCALE'] : 'en_US') . "&sl=zh-CN&tl=" . (isset($_SESSION['WPLANG_LOCALE']) ? substr($_SESSION['WPLANG_LOCALE'], 0, 2) : 'en') . "&u=%URL%"));
    if (isset($_GET['connect'])) {
        define('OPEN_TYPE', $_GET['connect']);
        if (in_array(OPEN_TYPE, array_keys($GLOBALS['open_arr']))) {
            $open_class = strtoupper(OPEN_TYPE) . '_CLASS';
            $os = new $open_class();
        } else {
            exit;
        }
        if ($_GET['action'] == 'login') {
            if ($_GET['back']) {
                $_SESSION['back'] = $_GET['back'];
            }
            $os->open_login();
        } else {
            if ($_GET['action'] == 'callback') {
                if (!isset($_GET['code']) || isset($_GET['error']) || isset($_GET['error_code']) || isset($_GET['error_description'])) {
                    header('Location:' . home_url());
                    exit;
                }
                $os->open_callback($_GET['code']);
                open_action($os);
            } else {
                if ($_GET['action'] == 'unbind') {
                    if ($_GET['back']) {
                        $_SESSION['back'] = $_GET['back'];
                    }
                    open_unbind();
                } else {
                    if ($_GET['action'] == 'update') {
                        if (OPEN_TYPE == 'sina' && isset($_GET['text'])) {
                            open_update_test($_GET['text']);
                        }
                    }
                }
            }
        }
    } else {
        if (isset($_GET['code']) && isset($_GET['state'])) {
            if ($_GET['state'] == 'profile' && osop('GOOGLE')) {
                header('Location:' . home_url('/') . '?connect=google&action=callback&' . http_build_query($_GET));
            }
            //for google
            if (strlen($_GET['state']) == 32 && osop('DOUBAN')) {
                header('Location:' . home_url('/') . '?connect=douban&action=callback&' . http_build_query($_GET));
            }
            //for douban
            exit;
        }
    }
}
Exemple #2
0
function open_init()
{
    load_plugin_textdomain('open-social', '', dirname(plugin_basename(__FILE__)) . '/lang');
    $GLOBALS['open_str'] = array('qq' => __('QQ', 'open-social'), 'sina' => __('Sina', 'open-social'), 'baidu' => __('Baidu', 'open-social'), 'google' => __('Google', 'open-social'), 'live' => __('Microsoft Live', 'open-social'), 'douban' => __('Douban', 'open-social'), 'renren' => __('RenRen', 'open-social'), 'kaixin' => __('Kaixin001', 'open-social'), 'xiaomi' => __('XiaoMi', 'open-social'), 'csdn' => __('CSDN', 'open-social'), 'oschina' => __('OSChina', 'open-social'), '163' => __('163', 'open-social'), '360' => __('360', 'open-social'), 'taobao' => __('Taobao', 'open-social'), 'facebook' => __('Facebook', 'open-social'), 'twitter' => __('Twitter', 'open-social'), 'instagram' => __('Instagram', 'open-social'), 'github' => __('Github', 'open-social'), 'wechat' => __('WeChat', 'open-social'), 'login' => __('Login with %OPEN_TYPE%', 'open-social'), 'unbind' => __('Unbind with %OPEN_TYPE%', 'open-social'), 'share_weibo' => __('Share with Sina', 'open-social'), 'share_qzone' => __('Share with QQZone', 'open-social'), 'share_qqt' => __('Share with QQWeiBo', 'open-social'), 'share_youdao' => __('Share with YoudaoNote', 'open-social'), 'share_email' => __('Email to Me', 'open-social'), 'share_qq' => __('Chat with Me', 'open-social'), 'share_weixin' => __('Share with WeiXin', 'open-social'), 'share_google' => __('Google Translation', 'open-social'), 'share_twitter' => __('Share with Twitter', 'open-social'), 'share_facebook' => __('Share with Facebook', 'open-social'), 'share_language' => __('Language Switcher', 'open-social'), 'setting_menu' => __('Open Social', 'open-social'), 'setting_menu_adv' => __('Account Setting', 'open-social'), 'about_info' => __('if you like this plugin', 'open-social'), 'about_alipay' => __('Scan me a drink', 'open-social'), 'about_link' => __('Or leave me a link', 'open-social'), 'about_plugin' => __('Or give me Five', 'open-social'), 'widget_title' => __('Open Social Login', 'open-social'), 'widget_name' => __('Howdy', 'open-social'), 'widget_desc' => __('Display your Open Social login button', 'open-social'), 'widget_share_title' => __('Open Social Share', 'open-social'), 'widget_share_name' => __('Connect', 'open-social'), 'widget_share_desc' => __('Display your Open Social share button', 'open-social'), 'widget_float_title' => __('Floating Button', 'open-social'), 'widget_float_desc' => __('Some floating useful buttons', 'open-social'), 'err_other_openid' => __('This account has been bound by other user.', 'open-social'), 'err_other_user' => __('You can only bind to one account at a time.', 'open-social'), 'err_other_email' => __('Your EMAIL has been registered by other user.', 'open-social'), 'osop_login_button' => __('Login Buttons', 'open-social'), 'osop_show_login_form1' => __('Before comment form', 'open-social'), 'osop_show_login_form2' => __('After comment form', 'open-social'), 'osop_show_login_page' => __('Show in Login page', 'open-social'), 'osop_share_button' => __('Share Buttons', 'open-social'), 'osop_show_share_content' => __('Show in Post pages', 'open-social'), 'osop_share_sina_user' => __('Sina weibo related UserID', 'open-social'), 'osop_share_qqt_appkey' => __('QQ weibo share AppKey', 'open-social'), 'osop_share_qq_email' => __('QQ EmailMe code', 'open-social'), 'osop_share_qq_talk' => __('QQ Number for chat online', 'open-social'), 'osop_delete_setting' => __('Delete all configurations on this page after plugin deleted, NOT RECOMMENDED!', 'open-social'), 'open_social_hide_text' => __('Login to check this hidden content out', 'open-social'), 'open_social_email_hello' => __('Hello', 'open-social'), 'open_social_email_title' => __('New reply to your comment', 'open-social'), 'open_social_email_text1' => __('Go check it out', 'open-social'), 'open_social_email_text2' => __('Receive reply email notification', 'open-social'), 'open_social_username_text' => __('Length of Username between 4 and 20, Lowercase letters included; Or you already change it ', 'open-social'), 'osop_extend_function' => __('Extensions', 'open-social'), 'osop_extend_show_nickname' => __('Show nickname in users list', 'open-social'), 'open_social_edit_profile' => __('Please update your profile before commenting, thx:)', 'open-social'), 'osop_extend_email_login' => __('Allow to login with email address', 'open-social'), 'osop_extend_button_tooltip' => __('Add jQuery.tooltip to the buttons', 'open-social'), 'osop_extend_user_transfer' => __('Transfer &ltwp-connect&gt users data to be compatible with Open-Social', 'open-social'), 'osop_extend_user_transfer_ok' => __('Users Data Transfer Complete', 'open-social'), 'osop_extend_guest_comment' => __('Regexp Anti-SPAM when guest can comment', 'open-social'), 'osop_extend_gravatar_disabled' => __('Disable Gravatar with a default blank avatar', 'open-social'), 'osop_proxy_function' => __('Proxy', 'open-social'), 'osop_proxy_text' => __('Proxy & reverse proxy for Facebook/Twitter/Google', 'open-social'));
    $GLOBALS['open_arr'] = array('qq', 'sina', 'baidu', 'google', 'live', 'douban', 'renren', 'kaixin', 'xiaomi', 'csdn', 'oschina', 'facebook', 'twitter', 'github', 'wechat');
    $GLOBALS['open_share_arr'] = array('weibo' => "http://v.t.sina.com.cn/share/share.php?url=%URL%&title=%TITLE%&pic=%PIC%&appkey=" . osop('SINA_AKEY') . "&ralateUid=" . osop('share_sina_user') . "&language=zh_cn&searchPic=false", 'qzone' => "http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=%URL%&title=%TITLE%&desc=&summary=&site=&pics=%PIC%", 'qqt' => "http://share.v.t.qq.com/index.php?c=share&a=index&url=%URL%&title=%TITLE%&pic=%PIC%&appkey=" . osop('share_qqt_appkey'), 'youdao' => "http://note.youdao.com/memory/?url=%URL%&title=%TITLE%&sumary=&pic=%PIC%&product=", 'weixin' => "", 'email' => "http://mail.qq.com/cgi-bin/qm_share?t=qm_mailme&email=" . osop('share_qq_email'), 'qq' => 'http://wpa.qq.com/msgrd?v=3&uin=' . osop('share_qq_talk') . '&site=' . get_bloginfo('name') . '&menu=yes', 'twitter' => "http://twitter.com/home/?status=%TITLE%:%URL%", 'facebook' => "http://www.facebook.com/sharer.php?u=%URL%&t=%TITLE%", 'google' => "http://translate.google.com.hk/translate?hl=" . (isset($_SESSION['WPLANG_LOCALE']) ? $_SESSION['WPLANG_LOCALE'] : 'en_US') . "&sl=zh-CN&tl=" . (isset($_SESSION['WPLANG_LOCALE']) ? reset(str_split($_SESSION['WPLANG_LOCALE'], 2)) : 'en') . "&u=%URL%");
    if (isset($_GET['connect'])) {
        define('OPEN_TYPE', $_GET['connect']);
        if (in_array(OPEN_TYPE, $GLOBALS['open_arr'])) {
            $open_class = strtoupper(OPEN_TYPE) . '_CLASS';
            $os = new $open_class();
        } else {
            exit;
        }
        if ($_GET['action'] == 'login') {
            if ($_GET['back']) {
                $_SESSION['back'] = $_GET['back'];
            }
            $os->open_login();
        } else {
            if ($_GET['action'] == 'callback') {
                if (!isset($_GET['code']) || isset($_GET['error']) || isset($_GET['error_code']) || isset($_GET['error_description'])) {
                    header('Location:' . home_url());
                    exit;
                }
                $os->open_callback($_GET['code']);
                open_action($os);
            } else {
                if ($_GET['action'] == 'unbind') {
                    open_unbind();
                } else {
                    if ($_GET['action'] == 'update') {
                        if (OPEN_TYPE == 'sina' && isset($_GET['text'])) {
                            open_update_test($_GET['text']);
                        }
                    }
                }
            }
        }
    } else {
        if (isset($_GET['code']) && isset($_GET['state'])) {
            if ($_GET['state'] == 'profile' && osop('GOOGLE')) {
                header('Location:' . home_url('/') . '?connect=google&action=callback&' . http_build_query($_GET));
            }
            //for google
            if (strlen($_GET['state']) == 32 && osop('DOUBAN')) {
                header('Location:' . home_url('/') . '?connect=douban&action=callback&' . http_build_query($_GET));
            }
            //for douban
            exit;
        }
    }
}