亲测:此教程能实现小京东移动端与discuz同步注册,同步登陆
1.下载安装ucenter1.6.0
1.选择自己需要的版本自行下载
2.将解压后upload文件夹整个考到小京东根目录,将upload重命名为ucenter(这是服务端程序)
3.将advanced/uc_client文件夹复制到小京东根目录(这是客户端程序)
4.在浏览器访问ucenter文件夹,会提示安装ucenter,按照提示安装即可
5.至此,ucenter安装完成
2.下载安装discuz3.3
1.选择自己需要的版本自行下载
2.将解压后upload文件夹整个考到小京东根目录,将upload重命名为discuz(这是论坛程序)
3.用小京东根目录中的uc_client文件夹将discuz中的uc_client文件夹替换掉(使所有应用的客户端程序保持一致)
4.在浏览器访问ucenter文件夹,会提示安装discuz,按照提示安装即可
5.至此,discuz安装完成
3.整合PC端数据
在小京东后台,会员管理>会员整合>ucenter,按照提示填写ucenter地址和创始人密码,完成整合(选择ecshop会回到默认设置)
至此,pc端与discuz已经整合完成,接下来是移动端整合
4.在移动端安装ucenter客户端
1.将小京东根目录下uc_client文件夹复制到mobile根目录下
2.用ucenter压缩包中advanced/examples/api/uc.php将mobile/api/uc.php替换掉
3.修改mobile/includes/lib_common.php,将所需文件引入
if (!defined('IN_ECS'))
{
die('Hacking attempt');
}
include_once ROOT_PATH.'/config.inc.php';
include_once ROOT_PATH.'/include/db_mysql.class.php';
$db = new dbstuff;
$db->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
unset($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
include_once ROOT_PATH.'/uc_client/client.php';4.将小京东根目录下admin/integrate.php复制到mobile/admin目录下,将其中所有$ecs->table(‘shop_config’)替换为”ecs_ecsmart_shop_config”
5.将小京东根目录下admin/templates下的integrate开头的模板文件复制到mobile/admin/templates目录下6.浏览器访问mobile/admin/integrate.php,完成整合
7.至此4个应用(ucenter,discuz,小京东pc,小京东Mobile)应该可以正确通信成功(ucenter默认不显示)
5.实现小京东移动端与discuz同步注册与同步登陆
1.实现同步注册:将mobile/uc_client/model/user.php中的add_user方法修改为
function add_user($username, $password, $email, $uid = 0, $questionid = '', $answer = '', $regip = '') {
$regip = empty($regip) ? $this->base->onlineip : $regip;
$salt = substr(uniqid(rand()), -6);
$password = md5(md5($password).$salt);
$sqladd = $uid ? "uid='".intval($uid)."'," : '';
$sqladd .= $questionid > 0 ? " secques='".$this->quescrypt($questionid, $answer)."'," : " secques='',";
$this->db->query("INSERT INTO ".UC_DBTABLEPRE."members SET $sqladd username='$username', password='$password', email='$email', regip='$regip', regdate='".$this->base->time."', salt='$salt'");
$uid = $this->db->insert_id();
$this->db->query("INSERT INTO ".UC_DBTABLEPRE."memberfields SET uid='$uid'");
// BEGIN
$this->db->query("INSERT INTO `ultrax`.pre_common_member SET uid='$uid', username='$username', password='$password', email='$email', adminid='0', groupid='10', regdate='".$this->base->time."', credits='0', timeoffset='9999'");
$this->db->query("INSERT INTO `ultrax`.pre_common_member_status SET uid='$uid', regip='$regip', lastip='$regip', lastvisit='".$this->base->time."', lastactivity='".$this->base->time."', lastpost='0', lastsendmail='0'");
$this->db->query("INSERT INTO `ultrax`.pre_common_member_profile SET uid='$uid'");
$this->db->query("INSERT INTO `ultrax`.pre_common_member_field_forum SET uid='$uid'");
$this->db->query("INSERT INTO `ultrax`.pre_common_member_field_home SET uid='$uid'");
$this->db->query("INSERT INTO `ultrax`.pre_common_member_count SET uid='$uid', extcredits1='0', extcredits2='0', extcredits3='0', extcredits4='0', extcredits5='0', extcredits6='0', extcredits7='0', extcredits8='0'");
// END
return $uid;
}2.实现同步登陆修改mobile/includes/lib_passport.php,大约204行,在注册成功后添加如下代码
// 注册成功 /* 设置成登录状态 */ $user=$GLOBALS['user']; if($user->login($username, $password)) { update_user_info(); // 更新用户信息 $ucdata = isset($user->ucdata) ? $user->ucdata : ''; echo $ucdata; }
参考:
Discuz_X3.0和ecshop2.73整合问题解决
http://bbs.ecshop.com/viewthread.php?tid=1132310&highlight=%D5%FB%BA%CF
解决整合 UCenter 首次注册同步登录与自动激活
http://wangyueheng88.blog.51cto.com/5498701/1538565/
Discuz UCenter通信原理与数据自动同步免用户激活
http://fity.cn/post/238/