Discuz registration and login process (User Center synchronization)

Source: Internet
Author: User
Tags php file

Registration process
Step 1:
/Source/class/class_member.php: on_register registration entry
L602 or so
If (! $ Activation) {// It is not null, indicating that the user has registered
// Register the user to the user center and call the uc_user_register method in step 2.
$ Uid = uc_user_register (addslashes ($ username), $ password, $ email, $ questionid, $ answer, $ _ G ['clientip']);

Step 2:
/Uc_client/client. php: uc_user_register
Step 3:
/Uc_client/control/user. php: onregister registers the user to the user Center and calls the add_user method in step 4.
Step 4:
/Uc_client/model/user. php: add_user: registers the user to ucenter and returns the user ID.
Step 5:
/Source/class/class_member.php:
Lines about L685 write user information to the common_member table. Registration completed
C: t ('Common _ member')-> insert ($ uid, $ username, $ password, $ email, $ _ G ['clientip'], $ groupinfo ['groupid'], $ init_arr );

Login process
Step 1:
/Source/class/class_member.php: on_login logon entry
About 87 rows. The method for calling userlogin is as follows:
$ Result = userlogin ($ _ GET ['username'], $ _ GET ['password'], $ _ GET ['questionid'], $ _ GET ['answer'], $ this-> setting ['autoidselect']? 'Auto': $ _ GET ['loginfield '], $ _ G ['clientip']);
Step 2:
/Source/function/function_member.php: logincheck
Call logincheck in around 72 lines, as shown below:
If (! ($ _ G ['Member _ loginperm'] = logincheck ($ _ GET ['username']) {
Showmessage ('login _ strike ');
}
Step 3:
/Source/function/function_member.php: userlogin user login query related table
The uc_user_login method is called between lines 3 and 40.
If ($ isuid = 3 ){
If (! Strcmp (dintval ($ username), $ username) & getglobal ('setting/uidlogin ')){
$ Return ['ucresresult'] = uc_user_login ($ username, $ password, 1, 1, $ questionid, $ answer, $ ip); // uc_client/client. php
} Elseif (isemail ($ username )){
$ Return ['ucresresult'] = uc_user_login ($ username, $ password, 2, 1, $ questionid, $ answer, $ ip); // uc_client/client. php
}
If ($ return ['ucresresult'] [0] <= 0 & $ return ['ucresresult'] [0]! =-3 ){
$ Return ['ucresresult'] = uc_user_login (addslashes ($ username), $ password, 0, 1, $ questionid, $ answer, $ ip );
}
} Else {
$ Return ['ucresresult'] = uc_user_login (addslashes ($ username), $ password, $ isuid, 1, $ questionid, $ answer, $ ip );

}

 

/Uc_client/client. php: all methods starting with uc _, for example, uc_user_login.
/Uc_client/control/user. php: onlogin logs in based on the conditions, and 114-120 queries the query conditions to query ucenter user information.
/Uc_client/model/user. php contains get_user_by_uid, get_user_by_username, and other methods to query the common_member table in around 50th rows, as shown below:
$ Member = getuserbyuid ($ return ['ucresresult'] ['uid'], 1 );

Return to the on_login method of the/source/class/class_member.php file

95th-106 rows or so will write the common_member table according to the condition $ result ['status'] =-1, and query the write information
C: t ('Common _ member')-> insert ($ uid, $ result ['ucresresult'] ['username'], md5 (random (10 )), $ result ['cresresult'] ['email '], $ _ G ['clientip'], $ groupid, $ init_arr );
$ Result ['member'] = getuserbyuid ($ uid );

-----------------------------
Ps: All the above methods will be executed first
/Source/class/discuz/discuz_application.php: _ init_user
Therefore, if you want to write checklogin by yourself, consider starting with the _ init_user method.

If it is connected to its own platform as a bbs.
You can call the registration interface of your own platform in step 1 for registration. Register the user and return the user ID. Write to ucenter
/Uc_client/model/user. php: In the add_user method

Before calling the uc_user_login method,
1. Call your own platform interface to query user information
2. Check whether the user in ucenter exists
3. If no insert data entry exists
4. common_member can be written or not written. If $ result ['status'] =-1 is not written at this time, it will be written in rows around class_member 95-106.
If you are logged on to your own platform and on bbs, you can start with the _ init_user method. Determine logon

Note the following when synchronous login fails:

1. Whether the application configuration information in the ucenter is completely correct and consistent with the ucenter interface configuration information in the background of the target station.

2. If the communication succeeds, but you cannot log on simultaneously, check whether the site information in uc_client/data/cache/apps. php is complete.

3. Pay attention to the garbled information returned by codes and BOM headers of the program.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.