Home > php教程 > php手册 > body text

DZ注册和登陆流程的简单梳理

WBOY
Release: 2016-06-06 20:12:16
Original
2098 people have browsed it

注册流程 第一步: /source/class/class_member.php: on_register注册入口 L602 左右 if(!$activation) {//不为空,说明用户已经注册过 //将用户注册到用户中心,调用第二步uc_user_register方法 $uid = uc_user_register(addslashes($username), $password,

注册流程
第一步:
/source/class/class_member.php: on_register注册入口
L602 左右
if(!$activation) {//不为空,说明用户已经注册过
//将用户注册到用户中心,调用第二步uc_user_register方法
$uid = uc_user_register(addslashes($username), $password, $email, $questionid, $answer, $_G['clientip']);

第二步:
/uc_client/client.php: uc_user_register 调用将用户注册到用户中心的方法,调用第三步的onregister方法
第三步:
/uc_client/control/user.php: onregister 将用户注册到用中心,调用第四步add_user方法
第四步:
/uc_client/model/user.php:add_user 将用户注册到ucenter返回用户id
第五步:
/source/class/class_member.php:
L685行 左右,会把用户信息写到common_member表。注册结束
C::t(‘common_member’)->insert($uid, $username, $password, $email, $_G['clientip'], $groupinfo['groupid'], $init_arr);

登陆流程
第一步:
/source/class/class_member.php: on_login ?登陆入口
87行左右,调用userlogin方法如下:
$result = userlogin($_GET['username'], $_GET['password'], $_GET['questionid'], $_GET['answer'], $this->setting['autoidselect'] ? ‘auto’ : $_GET['loginfield'], $_G['clientip']);
第二步:
/source/function/function_member.php: logincheck
72行左右 调用 logincheck,如下:
if(!($_G['member_loginperm'] = logincheck($_GET['username']))) {
showmessage(‘login_strike’);
}
第三步:
/source/function/function_member.php: userlogin ?用户登陆查询相关表
第29行-40行左右会用调用uc_user_login方法
if($isuid == 3) {
if(!strcmp(dintval($username), $username) && getglobal(‘setting/uidlogin’)) {
$return['ucresult'] = uc_user_login($username, $password, 1, 1, $questionid, $answer, $ip);// uc_client/client.php
} elseif(isemail($username)) {
$return['ucresult'] = uc_user_login($username, $password, 2, 1, $questionid, $answer, $ip);// uc_client/client.php
}
if($return['ucresult'][0] $return['ucresult'] = uc_user_login(addslashes($username), $password, 0, 1, $questionid, $answer, $ip);
}
} else {
$return['ucresult'] = uc_user_login(addslashes($username), $password, $isuid, 1, $questionid, $answer, $ip);

}

/uc_client/client.php: 包含uc_开头的全部方法,例uc_user_login
/uc_client/control/user.php: onlogin 根据条件判断登陆,114-120 判断查询条件查询出ucenter用户信息
/uc_client/model/user.php 包含有get_user_by_uid,get_user_by_username 等方法 第50行左右查询common_member表,如下:
$member = getuserbyuid($return['ucresult']['uid'], 1);

回到/source/class/class_member.php文件on_login方法

第95-106 行左右会根据条件$result['status']==-1 ,写common_member表,并查询出写入信息
C::t(‘common_member’)->insert($uid, $result['ucresult']['username'], md5(random(10)), $result['ucresult']['email'], $_G['clientip'], $groupid, $init_arr);
$result['member'] = getuserbyuid($uid);

————————————————————————————-
ps:以上所有方法都会先执行
/source/class/discuz/discuz_application.php: _init_user
所以如果要自己写checklogin 可以考虑从_init_user 方法入手

如果与自己的平台做bbs的打通。
注册可以考虑在第4步做操作,调用自己平台的注册接口。注册用户,并将用户id返回。写入到ucenter
/uc_client/model/user.php:add_user 方法内

登陆打通可以考虑在 第三步调用 uc_user_login 方法前,
1.调用自己平台接口查询用户相关信息
2.查询ucenter中用户是否存在
3.如果不存在insert一条数据
4.common_member可以写也可以不写 ,如此时不写 $result['status']==-1 会在class_member 95-106 行左右写入
如果在自己平台处于登陆状态,在bbs也为登陆状态,则可以考虑从_init_user 方法入手。做登录判断

无法同步登陆需要注意检查的地方

1.ucenter中应用的配置信息是否完全正确,并与目标站后台的ucenter接口配置信息一致。

2.如果遇到通信成功,但是一边能登陆一边无法同步登陆的情况,请首先检查 uc_client/data/cache/apps.php中的站点信息是否完全。

3.请注意编码以及程序的BOM头导致返回信息乱码的情况。

discuz快速找回管理员密码的方法

在网站根目录下的子目录uc_server/data中找到文件config.inc.php,打开它,找到类似以下代码:

define(‘UC_FOUNDERPW’, ’256955f2e034sad74f0e2953572ea360′);

define(‘UC_FOUNDERSALT’, ’217804′);

然后用以下代码替换上述代码:

define(‘UC_FOUNDERPW’, ’047099adb883dc19616dae0ef2adc5b6′);

define(‘UC_FOUNDERSALT’, ’311254′);

修改完后,Ucenter创始人的密码就变为:? 123456789 ,

这时可以登录到Ucenter里再把密码改为自己想要的就可以了。

其实方法有很多种,不过这种是最方便的。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!