http://my.oschina.net/banbo/blog/311691
应用整合 UCenter,同步注册到 Discuz 的用户,在 Discuz 登录时得手动激活,用户体验很不好,不过解决方法很简单~
修改应用下的 ./uc_client/model/user.php 文件,大概在 138 行(UCenter 1.6)处的 function add_user 函数里添加代码:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
function add_user( $username , $password , $email , $uid = 0, $questionid = '' , $answer = '' , $regip = '' ) { $regip = empty ( $regip ) ? $this ->base->onlineip : $regip ; $salt = substr (uniqid(rand()), -6); $password = md5(md5( $password ). $salt ); $sqladd = $uid ? "uid='" . intval ( $uid ). "'," : '' ; $sqladd .= $questionid > 0 ? " secques='" . $this ->quescrypt( $questionid , $answer ). "'," : " secques=''," ; $this ->db->query( "INSERT INTO " .UC_DBTABLEPRE. "members SET $sqladd username='$username', password='$password', email='$email', regip='$regip', regdate='" . $this ->base->time. "', salt='$salt'" ); $uid = $this ->db->insert_id(); $this ->db->query( "INSERT INTO " .UC_DBTABLEPRE. "memberfields SET uid='$uid'" ); // BEGIN $this ->db->query( "INSERT INTO " .DISCUZ_DBTABLEPRE. "common_member SET uid='$uid', username='$username', password='$password', email='$email', adminid='0', groupid='10', regdate='" . $this ->base->time. "', credits='0', timeoffset='9999'" ); $this ->db->query( "INSERT INTO " .DISCUZ_DBTABLEPRE. "common_member_status SET uid='$uid', regip='$regip', lastip='$regip', lastvisit='" . $this ->base->time. "', lastactivity='" . $this ->base->time. "', lastpost='0', lastsendmail='0'" ); $this ->db->query( "INSERT INTO " .DISCUZ_DBTABLEPRE. "common_member_profile SET uid='$uid'" ); $this ->db->query( "INSERT INTO " .DISCUZ_DBTABLEPRE. "common_member_field_forum SET uid='$uid'" ); $this ->db->query( "INSERT INTO " .DISCUZ_DBTABLEPRE. "common_member_field_home SET uid='$uid'" ); $this ->db->query( "INSERT INTO " .DISCUZ_DBTABLEPRE. "common_member_count SET uid='$uid', extcredits1='0', extcredits2='0', extcredits3='0', extcredits4='0', extcredits5='0', extcredits6='0', extcredits7='0', extcredits8='0'" ); // END return $uid ; } |
注意这些表都是 Discuz 的表,不是 UCenter 的表,不能使用 UC_DBTABLEPRE ! 我自己在 UCenter 配置文件 config.inc.php 中定义了 DISCUZ_DBTABLEPRE:
1
|
define( 'DISCUZ_DBTABLEPRE' , '`ultrax`.pre_' ); |