Exemplo n.º 1
0
 public static function getnewname($openid)
 {
     global $_G;
     if (!$_G['wechat']['setting']) {
         $_G['wechat']['setting'] = unserialize($_G['setting']['mobilewechat']);
     }
     $wechat_client = new WeChatClient($_G['wechat']['setting']['wechat_appId'], $_G['wechat']['setting']['wechat_appsecret']);
     $userinfo = $wechat_client->getUserInfoById($openid);
     if ($userinfo) {
         $defaultusername = substr(WeChatEmoji::clear($userinfo['nickname']), 0, 15);
         loaducenter();
         $user = uc_get_user($defaultusername);
         if (!empty($user)) {
             $defaultusername = cutstr($defaultusername, 7, '') . '_' . random(5);
         }
     } else {
         $defaultusername = '******' . random(5);
     }
     return $defaultusername;
 }
Exemplo n.º 2
0
            $wechatuser = C::t('#wechat#common_member_wechat')->fetch_by_openid($openid);
            wechat_setloginstatus($authcode['uid'], true);
            wsq::report('authorized');
        }
    }
} 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();
Exemplo n.º 3
0
    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';
        $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);
Exemplo n.º 4
0
     if ($mpmembers) {
         $memberfirst = array_shift($mpmembers);
         $member = getuserbyuid($memberfirst['uid'], 1);
         if ($member) {
             setloginstatus($member, 1296000);
             $url = wsq::wxuserregisterUrl($memberfirst['uid']);
             if ($ac == 'wxregister') {
                 dheader('location: ' . $url);
             } else {
                 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');