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"); //同步退出
发现调用call_user_func_array 时必须要二个参数都要有,否则无法调用
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
}
最后,如果你发现2个程序的uc_client配置文件不一致的话,还要把ecshop程序下的 uc_clientdatacacheapps.php->覆盖到discuz程序下的uc_clientdatacacheapps.php版权声明: 本站资源均来自互联网或会员发布,如果侵犯了您的权益请与我们联系,我们将在24小时内删除!谢谢!