Exemplo n.º 1
0
if ($ac == 'login') {
    $qrauth = $_G['cookie']['qrauth'] ? authcode(base64_decode($_G['cookie']['qrauth']), 'DECODE', $_G['config']['security']['authkey']) : '';
    if ($_G['uid'] && !$qrauth) {
        $showtip = true;
        if (in_array('qqconnect', $_G['setting']['plugins']['available'])) {
            $connect = C::t('#qqconnect#common_member_connect')->fetch($_G['uid']);
            if ($connect['conisregister']) {
                $showtip = false;
            }
        }
        if ($showtip) {
            dsetcookie('qrauth', '', -1);
            showmessage('wechat:wechat_member_bind_qrauth_lost');
        }
    }
    $url = wsq::qrconnectUrl($_G['uid'], dreferer());
    dheader('location: ' . $url);
} elseif ($ac == 'callback') {
    if (!wsq::checksign($_GET) || $_G['uid'] && $_GET['siteuid'] != $_G['uid']) {
        showmessage('wechat:wechat_member_auth_fail');
    }
    require_once libfile('function/member');
    if ($_GET['siteuid'] && ($member = getuserbyuid($_GET['siteuid'], 1))) {
        setloginstatus($member, 1296000);
        if (!C::t('#wechat#common_member_wechatmp')->fetch($member['uid'])) {
            C::t('#wechat#common_member_wechatmp')->insert(array('uid' => $_G['uid'], 'openid' => $_GET['openid'], 'status' => $_G['cookie']['qrauth'] ? 1 : 0), false, true);
        }
        dheader('location: ' . ($_GET['referer'] ? $_GET['referer'] : $_G['siteurl']));
    } else {
        require_once DISCUZ_ROOT . './source/plugin/wechat/wechat.class.php';
        require_once DISCUZ_ROOT . './source/plugin/wechat/wechat.lib.class.php';