![](https://iknow-base.cdn.bcebos.com/lxb/notice.png)
php 如何调用discuz x3.1的用户注册接口
3个回答
展开全部
phpsso与ucenter通信成功后,XXX_ucenter_member表中的用户已经同步成功但是在 XXX_common_member中并没有此用户,所以只要在xxx_common_member中插入此用户就可以了,所以修改discuz/api /uc.php下的synlogin函数就可以了,修改为
PHP Code复制内容到剪贴板
function synlogin($get, $post) {
global $_G;
if(!API_SYNLOGIN) {
return API_RETURN_FORBIDDEN;
}
header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
$cookietime = 31536000;
$uid = intval($get['uid']);
$query = DB::query("SELECT uid, username, password FROM ".DB::table('common_member')." WHERE uid='$uid'");
if ($member = DB::fetch($query))
{
dsetcookie('auth', authcode("$member[password]\t$member[uid]", 'ENCODE'), $cookietime);
}else
{
$username = $get['username'];
$query = DB::query("SELECT uid, username, password, email FROM ".DB::table('ucenter_members')." WHERE username='$username'");
$member = DB::fetch($query);
$password = $member['password'];
$email = $member['email'];
$ip = $_SERVER['REMOTE_ADDR'];
$time = time();
$userdata = array(
'uid'=>$uid,
'username'=>$username,
'password'=>$password,
'email'=>$email,
'adminid'=>0,
'groupid'=>10,
'regdate'=>$time,
'credits'=>0,
'timeoffset'=>9999
);
DB::insert('common_member', $userdata);
$status_data = array(
'uid' => $uid,
'regip' => $ip,
'lastip' => $ip,
'lastvisit' => $time,
'lastactivity' => $time,
'lastpost' => 0,
'lastsendmail' => 0
);
DB::insert('common_member_status', $status_data);
DB::insert('common_member_profile', array('uid' => $uid));
DB::insert('common_member_field_forum', array('uid' => $uid));
DB::insert('common_member_field_home', array('uid' => $uid));
DB::insert('common_member_count', array('uid' => $uid));
DB::query('UPDATE '.DB::table('common_setting')." SET svalue='$username' WHERE skey='lastmember'");
$query = DB::query("SELECT uid, username, password FROM ".DB::table('common_member')." WHERE uid='$uid'");
if ($member = DB::fetch($query))
{
dsetcookie('auth', authcode("$member[password]\t$member[uid]", 'ENCODE'), $cookietime);
}
}
}
这样在phpcms中注册后去discuz中就可以不用激活就自动登录了
PHP Code复制内容到剪贴板
function synlogin($get, $post) {
global $_G;
if(!API_SYNLOGIN) {
return API_RETURN_FORBIDDEN;
}
header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
$cookietime = 31536000;
$uid = intval($get['uid']);
$query = DB::query("SELECT uid, username, password FROM ".DB::table('common_member')." WHERE uid='$uid'");
if ($member = DB::fetch($query))
{
dsetcookie('auth', authcode("$member[password]\t$member[uid]", 'ENCODE'), $cookietime);
}else
{
$username = $get['username'];
$query = DB::query("SELECT uid, username, password, email FROM ".DB::table('ucenter_members')." WHERE username='$username'");
$member = DB::fetch($query);
$password = $member['password'];
$email = $member['email'];
$ip = $_SERVER['REMOTE_ADDR'];
$time = time();
$userdata = array(
'uid'=>$uid,
'username'=>$username,
'password'=>$password,
'email'=>$email,
'adminid'=>0,
'groupid'=>10,
'regdate'=>$time,
'credits'=>0,
'timeoffset'=>9999
);
DB::insert('common_member', $userdata);
$status_data = array(
'uid' => $uid,
'regip' => $ip,
'lastip' => $ip,
'lastvisit' => $time,
'lastactivity' => $time,
'lastpost' => 0,
'lastsendmail' => 0
);
DB::insert('common_member_status', $status_data);
DB::insert('common_member_profile', array('uid' => $uid));
DB::insert('common_member_field_forum', array('uid' => $uid));
DB::insert('common_member_field_home', array('uid' => $uid));
DB::insert('common_member_count', array('uid' => $uid));
DB::query('UPDATE '.DB::table('common_setting')." SET svalue='$username' WHERE skey='lastmember'");
$query = DB::query("SELECT uid, username, password FROM ".DB::table('common_member')." WHERE uid='$uid'");
if ($member = DB::fetch($query))
{
dsetcookie('auth', authcode("$member[password]\t$member[uid]", 'ENCODE'), $cookietime);
}
}
}
这样在phpcms中注册后去discuz中就可以不用激活就自动登录了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
看下discuz的注册表的方法啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
去看discuz x3.1的接口手册吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询