创意电子
标题:
Discuz!X3.4 QQ互联登陆跳过完善资料或绑定账号无感知登陆教程
[打印本页]
作者:
创意电子
时间:
2022-4-27 17:49
标题:
Discuz!X3.4 QQ互联登陆跳过完善资料或绑定账号无感知登陆教程
网上有很多 关于discuz中QQ互联登录跳过完善资料直接登录的教材,但实际使用时,发现各个方法要么不成功,要么收费,要么存在缺陷,比如:
1. 使用该功能必须关闭注册时的验证码,否则无法生效!
2. 本方法在DISCUZ X3.4及以下下测试完全正常,其他版本慎用。还有很多比如百度文库的 修改默认用户组为普通之类的 根本不会成功.现本人通过研究得出的操作结果,教材发布出来
说明:
(1)本教材适合dzX3.4以下任何版本
(2)本方法无需关闭注册验证码之类
(3)登录用户名默认是QQ昵称,如果注册不成功会自动加上时间戳保证用户名唯一再注册
(4)由于QQ快捷登录是不能获得邮箱的,所以以唯一时间戳数字@qq.com方式填入,注册成功后用户可以自行修改
(5)代码重点:在DZ中如何代码实现自动添加账号并登录成功!
操作简单:
(1)成功安装QQ互联!
(2)直接复制代码到 \source\plugin\qqconnect\connect\connect_login.php 行366 else里面
代码如下:
loaducenter();
//创建账号并登陆,
$username = trim(dhtmlspecialchars($insert_arr['conqqnick']))
if($username==''){$username = 'qquser_'.time();}
$password = md5(random(10));
$email = 'hl'.time() . '@qq.com';
$uid = uc_user_register($username, $password, $email);
if ($uid <= 0) {
if ($uid == -1 || $uid == -3) {
$username .= time();
$uid = uc_user_register($username, $password, $email);
if ($uid <= 0) {
$username = 'qquser_'.time();
$uid = uc_user_register($username, $password, $email);
if($uid <=0){
showmessage("$username注册UC失败",$referer);exit();
}
}
} elseif ($uid == -2) {
showmessage('包含不允许注册的词语',$referer);
} elseif ($uid == -4) {
showmessage('Email 格式有误',$referer);
} elseif ($uid == -5) {
showmessage('Email 不允许注册',$referer);
} else {
showmessage('其他错误',$referer);
}
}
//插入common_member
$init_arr = array('credits' => explode(',', $_G['setting']['initcredits']));
$groupid = 10 ;//默认新手上路组
C::t('common_member')->insert($uid, $username, $password, $email, $_G['clientip'], $groupid, $init_arr);
//会员绑定openid
C::t('#qqconnect#common_member_connect')->insert(
!$_G['setting']['connect']['oauth2'] ? array(
'uid' => $uid,
'conuin' => $conuin,
'conuinsecret' => $conuinsecret,
'conopenid' => $conopenid,
'conispublishfeed' => $conispublishfeed,
'conispublisht' => $conispublisht,
'conisregister' => 0,
'conisfeed' => 1,
'conisqqshow' => $isqqshow,
) : array(
'uid' => $uid,
'conuin' => '',
'conuintoken' => $conuintoken,
'conopenid' => $conopenid,
'conispublishfeed' => $conispublishfeed,
'conispublisht' => $conispublisht,
'conisregister' => 0,
'conisfeed' => 1,
'conisqqshow' => $isqqshow,
)
);
//更新是否绑定
C::t('common_member')->update($uid, array('conisbind' => '1'));
//模拟登录
$connect_member = C::t('#qqconnect#common_member_connect')->fetch_fields_by_openid($conopenid, $fields);
connect_login($connect_member);
//最后一次登录状态
C::t('common_member_status')->update($uid, array('lastip' => $_G['clientip'], 'lastvisit' => TIMESTAMP, 'lastactivity' => TIMESTAMP));
C::t('#qqconnect#common_connect_guest')->delete($conopenid);
//更新新注册用户缓存
if(!function_exists('build_cache_userstats')) { require_once libfile('cache/userstats', 'function'); }
build_cache_userstats();
//省去用户绑定的话,这里可以直接创建一个账号并绑定
//$referer = 'member.php?mod=connect&referer='.urlencode($referer);
$utilService->redirect($referer);
复制代码
欢迎光临 创意电子 (https://wxcydz.cc/)
Powered by Discuz! X3.4