Esempio n. 1
1
 public static function scan($param)
 {
     list($data) = $param;
     self::_init();
     global $_G;
     if (!$_G['wechat']['setting']['wsq_allow']) {
         return;
     }
     $authcode = C::t('#wechat#mobile_wechat_authcode')->fetch_by_code($data['key']);
     if (!$authcode || $authcode['status']) {
         //			echo WeChatServer::getXml4Txt(lang('plugin/wechat', 'wechat_response_text_codeerror'));
     } else {
         if ($authcode['uid']) {
             $member = getuserbyuid($authcode['uid'], 1);
             if ($member['adminid'] == 0 && !$_G['wechat']['setting']['wechat_confirmtype']) {
                 C::t('#wechat#mobile_wechat_authcode')->update($authcode['sid'], array('uid' => $member['uid'], 'status' => 1));
                 $authcode['sid'] = '';
             }
         } else {
             $wechatuser = C::t('#wechat#common_member_wechat')->fetch_by_openid($data['from']);
             if ($wechatuser) {
                 $member = getuserbyuid($wechatuser['uid'], 1);
                 if ($member['adminid'] == 0 && !$_G['wechat']['setting']['wechat_confirmtype']) {
                     C::t('#wechat#mobile_wechat_authcode')->update($authcode['sid'], array('uid' => $member['uid'], 'status' => 1));
                     $authcode['sid'] = '';
                 }
             } elseif ($_G['wechat']['setting']['wechat_allowregister'] && $_G['wechat']['setting']['wechat_allowfastregister'] && $_G['wechat']['setting']['wechat_mtype'] == 2) {
                 require_once DISCUZ_ROOT . './source/plugin/wechat/wechat.class.php';
                 require_once libfile('function/member');
                 $uid = WeChat::register(WeChat::getnewname($data['from']), 1);
                 if ($uid) {
                     WeChatHook::bindOpenId($uid, $data['from'], 1);
                     C::t('#wechat#mobile_wechat_authcode')->update($authcode['sid'], array('uid' => $uid, 'status' => 1));
                 }
                 wsq::report('register');
                 $authcode['sid'] = '';
             }
         }
         wsq::report('scanqr');
         self::_show('scan', $data['from'] . "\t" . $authcode['sid']);
     }
 }
Esempio n. 2
0
} elseif ($wechatuser) {
    $member = getuserbyuid($wechatuser['uid'], 1);
    setloginstatus($member, 1296000);
    wechat_setloginstatus($wechatuser['uid'], true);
}
if ($ac == 'bind' && $_G['wechat']['setting']['wechat_qrtype']) {
    if (!$_G['uid'] && IN_WECHAT && $_G['wechat']['setting']['wechat_allowfastregister']) {
        $ac = 'wxregister';
    }
    list($_GET['username'], $wxopenid) = explode("\t", base64_decode($_GET['username']));
    $_GET['username'] = substr(WeChatEmoji::clear($_GET['username']), 0, 15);
}
if ($ac == 'bind') {
    define('IN_MOBILE', 2);
    if ($_G['wechat']['setting']['wechat_mtype'] == 2) {
        $defaultusername = WeChat::getnewname($openid);
    } else {
        $defaultusername = $_G['wechat']['setting']['wechat_qrtype'] ? $_GET['username'] : '******' . random(5);
    }
    $defaultusername = htmlspecialchars($defaultusername);
    $connecturl = $_G['setting']['connect']['allow'] && !$_G['setting']['bbclosed'] ? $_G['siteurl'] . 'connect.php?mod=login&op=init&referer=' . urlencode($selfurl . 'qqbind') . '&statfrom=login_simple' : '';
    if (IN_WECHAT) {
        if (!$_G['uid']) {
            include template('wechat:wechat_bind');
        } else {
            $redirect = WeChat::redirect();
            if ($redirect) {
                dheader('location: ' . $redirect);
            } else {
                dheader('location: ' . $_G['siteurl']);
            }