Discuz ucenter connection problem summary

Source: Internet
Author: User

1. login users need to activate discuz/API/UC. php

/***
* Activation
*/
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]", 'encoding'), $ cookietime );
} Else {
// The user does not exist.
$ 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,
'Credit' => 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]", 'encoding'), $ cookietime );
}
}
}

Cause: it is connected to the ucenter user. When a Website user logs on to the forum for the first time, the user needs to be registered to the ucenter, And the API writes data to the ucenter User table. The data is not immediately sent to the discuz User table, when a discuz login request is sent, discuz will require a prompt, resulting in direct logon failure. Solution: when a user requests a log on (synlogin) and the user is no longer there, the user is requested to query the user table in the ucenter and then written to discuz.

2. Change the password for timely synchronization

After the password is changed, discuz transmits the password and email information to the ucenter through ucclient. After receiving the message, the ucenter stores the message in the cdb_uc_notelist table, and then retrieves a record close to 0 from cdb_uc_notelist, send password change notifications to applications one by one. Only when a user logs on to the ucenter can he send a command to the application,

Solution:

In the uc_client \ Client. php file

Function uc_user_edit ($ username, $ oldpw, $ newpw, $ email, $ ignoreoldpw = 0, $ questionid = '', $ answer = ''){
Return call_user_func (uc_api_func, 'user', 'edit', array ('username' => $ username, 'oldpw' => $ oldpw, 'newpw '=> $ newpw, 'email '=> $ email, 'ignoreoldpw' => $ ignoreoldpw, 'questionid' => $ questionid, 'answer' => $ answer ));
}

// Change

Function uc_user_edit ($ username, $ oldpw, $ newpw, $ email, $ ignoreoldpw = 0, $ questionid = '', $ answer = ''){
Return call_user_func ('uc _ api_post ', 'user', 'edit', array ('username' => $ username, 'oldpw' => $ oldpw, 'newpw '=> $ newpw, 'email' => $ email, 'ignoreoldpw' => $ ignoreoldpw, 'questionid' => $ questionid, 'answer' => $ answer ));
}

In the onedit () method of the uc_server \ Control \ User. php file

01. $ _ env ['note']-> Add ('updatepw', 'username = '. urlencode ($ username).' & Password = ');
// Change

$ _ Env ['note']-> Add ('updatepw', 'username = '. urlencode ($ username ). '& Password = '. urlencode ($ newpw ). '& Email = '. urlencode ($ email ));

Note the following two lines in the send () method in the uc_server \ model \ note. php file:

$closenote = FALSE;
break;

 

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.