安裝UCenter第三步,測試同步登陸和同步退出" />
if(($member = getuserbyuid($uid, 1))) {
dsetcookie('auth', authcode("$member[password]t$member[uid]", 'ENCODE'), $cookietime);}
修改成
if(($member = getuserbyuid($uid, 1))) {
dsetcookie('auth', authcode("$member[password]t$member[uid]", 'ENCODE'), $cookietime);}else{
//下面為增加部分
$username = $get['username'];
$password = md5(time().rand(100000, 999999));
$email = $get['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));
$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);
}}
最后,更新3個后臺的緩存,ecshop后臺,discuz后臺,Ucenter后臺。再來注冊或者登陸,可以同步登陸了。
$this->ucdata = uc_call("uc_user_synlogout"); ? //同步退出
發(fā)現(xiàn)調用call_user_func_array 時必須要二個參數(shù)都要有,否則無法調用
function set_cookie($user_id='', $user_name = '', $email = ''){
if (empty($user_id))
{
/* 摧毀cookie */
$time = time() - 3600;
//setcookie('ECS[user_id]', ?'', $time);
//setcookie('ECS[username]', '', $time);
//setcookie('ECS[email]', ? ?'', $time);
setcookie('ECS[user_id]', '', $time, $GLOBALS['cookie_path'], $GLOBALS['cookie_domain']);
setcookie('ECS[username]', '', $time, $GLOBALS['cookie_path'], $GLOBALS['cookie_domain']);
setcookie('ECS[email]', '', $time, $GLOBALS['cookie_path'], $GLOBALS['cookie_domain']);
}
else
{
/* 設置cookie */
$time = time() + 3600 * 24 * 30;
setcookie("ECS[user_id]", ?$user_id, ? $time, $GLOBALS['cookie_path'], $GLOBALS['cookie_domain']);
setcookie("ECS[username]", $user_name, $time, $GLOBALS['cookie_path'], $GLOBALS['cookie_domain']);
setcookie("ECS[email]", ? ?$email, ? ? $time, $GLOBALS['cookie_path'], $GLOBALS['cookie_domain']);
}}
還有要修改ecshop的 ucenter插件,includes/modules/integrates/ucenter.php
function ucenter($cfg)
{
parent::integrate(array());
$this->user_table = 'users';
$this->field_id = 'user_id';
$this->field_name = 'user_name';
$this->field_pass = 'password';
$this->field_email = 'email';
$this->field_gender = 'sex';
$this->field_bday = 'birthday';
$this->field_reg_date = 'reg_time';
$this->need_sync = false;
$this->is_ecshop = 1;
$this->cookie_path = $GLOBALS['cookie_path'];//wuruhua
$this->cookie_domain = $GLOBALS['cookie_domain'];//wuruhua
function set_cookie($username='')
{
if (empty($username))
{
/* 摧毀cookie */
$time = time() - 3600;
//setcookie("ECS[user_id]", ?'', $time, $this->cookie_path);
//setcookie("ECS[password]", '', $time, $this->cookie_path);
setcookie("ECS[user_id]", ?'', $time, $this->cookie_path, $this->cookie_domain); ?//wuruhua
setcookie("ECS[password]", '', $time, $this->cookie_path, $this->cookie_domain);//wuruhua
}
最后,如果你發(fā)現(xiàn)2個程序的uc_client配置文件不一致的話,還要把ecshop程序下的 uc_clientdatacacheapps.php->覆蓋到discuz程序下的uc_clientdatacacheapps.php版權聲明: 本站資源均來自互聯(lián)網(wǎng)或會員發(fā)布,如果侵犯了您的權益請與我們聯(lián)系,我們將在24小時內刪除!謝謝!