Exemplo 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']);
     }
 }
Exemplo n.º 2
1
        wsq::report('bind');
        $url = wsq::wxuserregisterUrl($result['member']['uid']);
        showmessage('wechat:wechat_member_bind_succeed', $url);
    }
} elseif (($ac == 'register' && submitcheck('submit') || $ac == 'wxregister') && $_G['wechat']['setting']['wechat_allowregister']) {
    if ($wechatuser) {
        showmessage('wechat:wechat_openid_exists');
    } else {
        if ($ac == 'wxregister') {
            loaducenter();
            $user = uc_get_user($_GET['username']);
            if (!empty($user)) {
                $_GET['username'] = substr($_GET['username'], 0, 9) . '_' . random(5);
            }
        }
        $uid = WeChat::register($_GET['username']);
        if (!$_G['wechat']['setting']['wechat_qrtype']) {
            WeChatHook::bindOpenId($uid, $openid, 1);
            wsq::report('register');
            showmessage('wechat:wechat_member_register_succeed', $selfurl . 'bind&confirm=yes');
        } else {
            C::t('#wechat#common_member_wechatmp')->insert(array('uid' => $uid, 'openid' => $wxopenid ? $wxopenid : $_GET['wxopenid'], 'status' => 0), false, true);
            wsq::report('register');
            $url = wsq::wxuserregisterUrl($uid);
            if ($ac == 'wxregister') {
                dheader('location: ' . $url);
            } else {
                showmessage('wechat:wechat_member_register_succeed', $url);
            }
        }
    }
Exemplo n.º 3
0
            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';
        $defaultusername = WeChatEmoji::clear($_GET['nickname']);
        if (!$_G['wechat']['setting']['wechat_allowfastregister']) {
            redirectregister($defaultusername);
        }
        loaducenter();
        $user = uc_get_user($defaultusername);
        if (!empty($user)) {
            $defaultusername = cutstr($defaultusername, 7, '') . '_' . random(5);
        }
        $uid = WeChat::register($defaultusername, 1, 8);
        if (!$uid) {
            redirectregister($defaultusername);
        }
        C::t('#wechat#common_member_wechatmp')->insert(array('uid' => $uid, 'openid' => $_GET['openid'], 'status' => 0), false, true);
        $url = wsq::userregisterUrl($uid, $_GET['openid'], $_GET['openidsign'], $_GET['referer']);
        dheader('location: ' . $url);
    }
} elseif ($ac == 'regcallback' && $_G['uid']) {
    list($openid, $openidsign, $qrreferer) = explode("\t", authcode(base64_decode($_GET['auth']), 'DECODE'));
    if (!$openid) {
        showmessage('wechat:wechat_member_auth_fail');
    }
    C::t('#wechat#common_member_wechatmp')->insert(array('uid' => $_G['uid'], 'openid' => $openid, 'status' => 1), false, true);
    $url = wsq::userregisterUrl($_G['uid'], $openid, $openidsign, $qrreferer);
    dheader('location: ' . $url);
Exemplo n.º 4
0
                 showmessage('wechat:wechat_member_register_succeed', $url);
             }
         }
     }
 }
 if (DISCUZ_VERSION < 'X3.0' && $_G['inajax']) {
     $_GET['username'] = WeChatEmoji::clear($_GET['username']);
 }
 if ($ac == 'wxregister') {
     loaducenter();
     $user = uc_get_user($_GET['username']);
     if (!empty($user)) {
         $_GET['username'] = cutstr($_GET['username'], 7, '') . '_' . random(5);
     }
 }
 $uid = WeChat::register($_GET['username'], $ac == 'wxregister');
 if ($uid && $_GET['avatar']) {
     WeChat::syncAvatar($uid, $_GET['avatar']);
 }
 if (!$_G['wechat']['setting']['wechat_qrtype']) {
     WeChatHook::bindOpenId($uid, $openid, 1);
     wsq::report('register');
     showmessage('wechat:wechat_member_register_succeed', $selfurl . 'bind&confirm=yes');
 } else {
     C::t('#wechat#common_member_wechatmp')->insert(array('uid' => $uid, 'openid' => $wxopenid ? $wxopenid : $_GET['wxopenid'], 'status' => 0), false, true);
     wsq::report('register');
     $url = wsq::wxuserregisterUrl($uid);
     if ($ac == 'wxregister') {
         dheader('location: ' . $url);
     } else {
         showmessage('wechat:wechat_member_register_succeed', $url);