您现在的位置是:首页 > cms教程 > Ecshop商城教程Ecshop商城教程
ecshop会员怎么整合UC
冰旋2024-12-10Ecshop商城教程已有人查阅
导读ECSHOP后台会员整合,只允许整合一个应用。如果想整合多个应用,就需要先和UCenter整合,之后再通过UCenter去整合更多的应用。整合之后工作流程:
ECSHOP后台会员整合,只允许整合一个应用。
如果想整合多个应用,就需要先和UCenter整合,之后再通过UCenter去整合更多的应用。
整合之后工作流程:
1.首先在ini.php文件中使用 ini_user()函数来判断整合插件名称,此函数定义在lib_common.php文件中。
并生成相应的插件对象,方便以后调用。
比如ec和pw整合,就以PW为主库,将ec的会员信息全部导入到pw会员表中。
之后在ecshop登陆的时候,会通过user.php中的$user->login($username, $password)函数,
和integrates/integrate.php中的sync()函数判断该用户是否在ecshop中存在,
如果不存在,则从PW中拷贝一条记录过来。
具体分析从ecshop登陆的过程:
1:检查username是否在pw_members表存在,如果存在,通过if($this->need_sync)判断是否需要同步登陆,
如果需要同步登陆,则调用$this->sync()函数。具体参考login函数.
首先通过 get_profile_by_name 函数从pw_members表中来获得用户基本信息。
SQL语句如下:
如果信息为空,则表明ecshop中不存在该用户,就将该用户的信息插入到ecs_users表中。
如果信息不为空,则判断ecs_users表中和pw_members表中的用户信息是否一致,
如果不一致,则以pw_members表中的数据为准,进而需要update下ecs_users表中的信息数据,使其与pw中数据一致。
ECSHOP所需的cookies是通过integrate/integrate.php中的 set_cookies来完成设置
PHPwind所需的是通过整合接口文件phpwind.php中的set_cookies来完成设置
分析登陆过程
if ($user->login($username,$password))用户登陆 (./user.php 275)
$user 为./includes/modules/integrates/ecshop.php 类文件实例化对象
list($uid,$uname,$pwd,$email,$repeat) = uc_call("uc_user_login",array($username,$password)); $user对象会通过uc_call来验证登陆信息是否正确,uc_call(./includes/lib_common.php 3173) 会调用./uc_center/client.php文件中的uc_user_login函数,
./uc_center/client.php 286
同步操作与uc_center客户端与uc_center的用户信息验证 的同步操作大致相同
$this->ucdata = uc_call("uc_user_synlogin",array($uid));($user对象78)处理通过验证后同步
69 生成post 数据
如果想整合多个应用,就需要先和UCenter整合,之后再通过UCenter去整合更多的应用。
整合之后工作流程:
1.首先在ini.php文件中使用 ini_user()函数来判断整合插件名称,此函数定义在lib_common.php文件中。
并生成相应的插件对象,方便以后调用。
$user=new$ini_user();
/**
* 初始化会员数据整合类
*
* @access public
* @return object
*/
function&init_users()
{
$set_modules=false;
static$cls=null;
if ($cls!=null)
{
return$cls;
}
include_once(ROOT_PATH . ‘includes/modules/integrates/’ .$GLOBALS['_CFG']['integrate_code'] . ‘.php’);
$cfg=unserialize($GLOBALS['_CFG']['integrate_config']);
$cls=new$GLOBALS['_CFG']['integrate_code']($cfg);
return$cls;
}
ecshop整合过程将需要整合的应用数据库看做主库。比如ec和pw整合,就以PW为主库,将ec的会员信息全部导入到pw会员表中。
之后在ecshop登陆的时候,会通过user.php中的$user->login($username, $password)函数,
和integrates/integrate.php中的sync()函数判断该用户是否在ecshop中存在,
如果不存在,则从PW中拷贝一条记录过来。
具体分析从ecshop登陆的过程:
1:检查username是否在pw_members表存在,如果存在,通过if($this->need_sync)判断是否需要同步登陆,
如果需要同步登陆,则调用$this->sync()函数。具体参考login函数.
function login($username,$password)
{
if ($this->check_user($username,$password) >0)
{
if ($this->need_sync)
{
$this->sync($username,$password);
}
$this->set_session($username); //同步登陆成功后,设置session
$this->set_cookie($username); //同步登陆成功后,设置cookie,保存登陆状态。
returntrue;
}
else
{
returnfalse;
}
}
2:同步登陆 sync 函数分析:首先通过 get_profile_by_name 函数从pw_members表中来获得用户基本信息。
SQL语句如下:
SELECT uid AS user_id,username AS user_name,email AS email,gender AS,
bday AS birthday,regdate AS reg_time, password AS password
FROM `phpwind_53`.`pw_members` WHERE username=’测试’;
然后从ecs_users表中根据 username 来获取用户信息,如果信息为空,则表明ecshop中不存在该用户,就将该用户的信息插入到ecs_users表中。
如果信息不为空,则判断ecs_users表中和pw_members表中的用户信息是否一致,
如果不一致,则以pw_members表中的数据为准,进而需要update下ecs_users表中的信息数据,使其与pw中数据一致。
/**
* 会员同步
*
* @access public
* @param
*
* @return void
*/
function sync ($username,$password=”,$md5password=”)
{
if ((!empty($password)) &&empty($md5password))
{
$md5password=md5($password);
}
$main_profile=$this->get_profile_by_name($username);
if (empty($main_profile))
{
returnfalse;
}
$sql= “SELECT user_name, email, password,, birthday”.
” FROM ” .$GLOBALS['ecs']->table(‘users’).
” WHERE user_name = ‘$username’”;
$profile=$GLOBALS['db']->getRow($sql);
if (empty($profile))
{
/* 向商城表插入一条新记录 */
if (empty($md5password))
{
$sql= “INSERT INTO ” .$GLOBALS['ecs']->table(‘users’).
“(user_name, email,, birthday, reg_time)”.
” VALUES(‘$username’, ‘” .$main_profile['email'].”‘,’”.
$main_profile['sex'] . “‘,’” .$main_profile['birthday'] . “‘,’” .$main_profile['reg_time'] . “‘)”;
}
else
{
$sql= “INSERT INTO ” .$GLOBALS['ecs']->table(‘users’).
“(user_name, email,, birthday, reg_time, password)”.
” VALUES(‘$username’, ‘” .$main_profile['email'].”‘,’”.
$main_profile['sex'] . “‘,’” .$main_profile['birthday'] . “‘,’” .
$main_profile['reg_time'] . “‘, ‘$md5password’)”;
}
$GLOBALS['db']->query($sql);
returntrue;
}
else
{
$values=array();
if ($main_profile['email'] !=$profile['email'])
{
$values[] = “email=’” .$main_profile['email'] . “‘”;
}
if ($main_profile['sex'] !=$profile['sex'])
{
$values[] = “ =’” .$main_profile['sex'] . “‘”;
}
if ($main_profile['birthday'] !=$profile['birthday'])
{
$values[] = “birthday=’” .$main_profile['birthday'] . “‘”;
}
if ((!empty($md5password)) && ($md5password!=$profile['password']))
{
$values[] = “password=’” .$md5password. “‘”;
}
if (empty($values))
{
returntrue;
}
else
{
$sql= “UPDATE ” .$GLOBALS['ecs']->table(‘users’).
” SET ” .implode(“, “,$values).
” WHERE user_name=’$username’”;
$GLOBALS['db']->query($sql);
returntrue;
}
}
}
3.设置cookiesECSHOP所需的cookies是通过integrate/integrate.php中的 set_cookies来完成设置
PHPwind所需的是通过整合接口文件phpwind.php中的set_cookies来完成设置
分析登陆过程
if ($user->login($username,$password))用户登陆 (./user.php 275)
$user 为./includes/modules/integrates/ecshop.php 类文件实例化对象
list($uid,$uname,$pwd,$email,$repeat) = uc_call("uc_user_login",array($username,$password)); $user对象会通过uc_call来验证登陆信息是否正确,uc_call(./includes/lib_common.php 3173) 会调用./uc_center/client.php文件中的uc_user_login函数,
./uc_center/client.php 286
function uc_user_login($username,$password,$isuid=0) {
$isuid=intval($isuid);
$return=call_user_func(UC_API_FUNC,'user','login',array('username'=>$username,'password'=>$password,'isuid'=>$isuid));
return UC_CONNECT =='mysql'?$return: uc_unserialize($return);
}
$return=call_user_func(UC_API_FUNC,'user','login',array('username'=>$username,'password'=>$password,'isuid'=>$isuid));会调用由./uc_client/control/user.php 实例化的对象的onlogin($arr)方法,$user=$_ENV['user']->get_user_by_uid($username);通过这种方法验证用户信息同步操作与uc_center客户端与uc_center的用户信息验证 的同步操作大致相同
$this->ucdata = uc_call("uc_user_synlogin",array($uid));($user对象78)处理通过验证后同步
./uc_center/client.php 292
function uc_user_synlogin($uid) {
return uc_api_post('user','synlogin',array('uid'=>$uid));
}
./uc_center/client.php 58
function uc_api_post($module,$action,$arg=array()) {
$s=$sep='';
foreach($argas$k=>$v) {
if(is_array($v)) {
$s2=$sep2='';
foreach($vas$k2=>$v2) {
$s2.="$sep2{$k}[$k2]=".urlencode(uc_stripslashes($v2));
$sep2='&';
}
$s.=$sep.$s2;
} else {
$s.="$sep$k=".urlencode(uc_stripslashes($v));
}
$sep='&';
}
$postdata= uc_api_requestdata($module,$action,$s);
return uc_fopen2(UC_API.'/index.php',500000,$postdata,'',TRUE, UC_IP,20);
}
53-65 行循环将数组编码并以&号连接69 生成post 数据
function uc_api_requestdata($module,$action,$arg='',$extra='') {
$input= uc_api_input($arg);
$post="m=$module&a=$action&inajax=2&input=$input&appid=".UC_APPID.$extra;
return$post;
}
75 生成url UC_API在./data/config.php中定义为uc_center的连接地址
function uc_api_url($module,$action,$arg='',$extra='') {
$url= UC_API.'/index.php?'.uc_api_requestdata($module,$action,$arg,$extra);
return$url;
}
发出数据
function uc_fopen2($url,$limit=0,$post='',$cookie='',$bysocket=FALSE,$ip='',$timeout=15,$block=TRUE) {
$__times__=isset($_GET['__times__']) ?intval($_GET['__times__']) +1:1;
if($__times__>2) {
return'';
}
$url.= (strpos($url,'?') ===FALSE?'?':'&')."__times__=$__times__";
return uc_fopen($url,$limit,$post,$cookie,$bysocket,$ip,$timeout,$block);
}
function uc_fopen($url,$limit=0,$post='',$cookie='',$bysocket=FALSE,$ip='',$timeout=15,$block=TRUE) {
$return='';
$matches=parse_url($url);
$host=$matches['host'];
$path=$matches['path'] ?$matches['path'].($matches['query'] ?'?'.$matches['query'] :'') :'/';
$port=!empty($matches['port']) ?$matches['port'] :80;
if($post) {
$out="POST $path HTTP/1.0\r\n";
$out.="Accept: */*\r\n";
//$out .= "Referer: $boardurl\r\n";
$out.="Accept-Language: zh-cn\r\n";
$out.="Content-Type: application/x- -form-urlencoded\r\n";
$out.="User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n";
$out.="Host: $host\r\n";
$out.='Content-Length: '.strlen($post)."\r\n";
$out.="Connection: Close\r\n";
$out.="Cache-Control: no-cache\r\n";
$out.="Cookie: $cookie\r\n\r\n";
$out.=$post;
} else {
$out="GET $path HTTP/1.0\r\n";
$out.="Accept: */*\r\n";
//$out .= "Referer: $boardurl\r\n";
$out.="Accept-Language: zh-cn\r\n";
$out.="User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n";
$out.="Host: $host\r\n";
$out.="Connection: Close\r\n";
$out.="Cookie: $cookie\r\n\r\n";
}
$fp= @fsockopen(($ip?$ip:$host),$port,$errno,$errstr,$timeout);
if(!$fp) {
return'';
} else {
stream_set_blocking($fp,$block);
stream_set_timeout($fp,$timeout);
@fwrite($fp,$out);
$status=stream_get_meta_data($fp);
if(!$status['timed_out']) {
while (!feof($fp)) {
if(($header= @fgets($fp)) && ($header=="\r\n"||$header=="\n")) {
break;
}
}
$stop=false;
while(!feof($fp) &&!$stop) {
$data=fread($fp, ($limit==0||$limit>8192?8192:$limit));
$return.=$data;
if($limit) {
$limit-=strlen($data);
$stop=$limit<=0;
}
}
}
@fclose($fp);
return$return;
}
}
本文标签:
很赞哦! ()
下一篇:ecshop结构数据说明
相关教程
- ecshop会员中心增加订单搜索功能
- ecshop会员添加权限不允许看到其他会员信息
- ecshop会员登陆后可见价格,ecshop会员登陆后显示价格实例
- ecshop会员中心我的收藏的商品图片和时间怎么修改
- ecshop会员列表,ecshop会员资料使用说明
- ecshop在线调查,ecshop会员访问在线调查
- ecshop会员等级,ecshop会员注册等级
- ecshop会员价格登陆才显示和只显示和自己等级相符合的价格
- ecshop会员注册成功以后自动升级为对应会员等级实例教程
- ecshop会员注册订单分成推荐设置说明教程
- ecshop导出会员,ecshop会员批量导出邮箱教程
- ecshop会员登录赠送等级积分和消费积分插件
图文教程
ecshop首页商品水印best,hot,new怎么删除
注意:此教程只对ECSHOP默认模板有效,其他模板也许根本就没这几个水印1)、打开 /themes/default/library/recommend_best.lbi 文件
ecshop和ucenter的整合的方法
按照网上的教材,一直提示数据库、密码错误,开始怀疑代码错了,毕竟都是两个老古董。于是开始调试,居然调试也不能很好的支持,点击下一步后就卡死了
ecshop商品详情页怎么增加自定义title标题
在ECSHOP后台自定义每个商品详情页的TITLE, 该如何来实现呢?(听说这样会对SEO更有利)下面就来讲一讲具体的修改方法:
ecshop模板的修改方法
ecshop模板如何修改?很多人在问这个问题,今天就以图解的方式给大家详细说下。相信学完之后,你会很清楚如何修改ecshop模板,不管你是初学者还是程序高手。
相关源码
-
帝国CMS游戏应用APP推广下载站模板免费下载本模板为移动应用推广、手机游戏推广行业设计,集成H5游戏平台与APP下载功能,支持PC端与移动端自适应访问。专注于为应用开发商、游戏发行商提供专业的线上推广展示平台。查看源码 -
帝国CMS7.5小说推荐公众号导航带wap手机站+带采集工具本模板为小说导航类网站设计开发,基于帝国CMS7.5内核构建,针对小说阅读领域的分类聚合需求进行深度优化。通过智能分类系统和用户行为分析,实现小说资源的精准推荐与导航功能。查看源码 -
(PC+WAP)激光水幕音乐喷泉设备工程网站源码下载本模板基于PbootCMS系统开发,为喷泉设备工程类企业设计,特别适合展示音乐喷泉、激光水幕等水景艺术项目。采用响应式技术,确保各类工程案例在不同设备上都能呈现视觉效果。查看源码 -
(自适应响应式)高端家用办公家具家居桌椅pbootcms模板下载为办公家具企业设计的响应式网站模板,涵盖产品展示、案例呈现、企业介绍等核心模块。通过可视化后台可快速发布实木桌椅、系统家具、办公屏风等产品信息,帮助客户直观了解材质参数与空间搭配方案。查看源码 -
自适应黑色建筑装饰设计公司个人工作室pbootcms模板基于PbootCMS内核开发的黑金风格模板,为建筑装饰、工程设计类企业打造,采用开源架构,支持跨行业快速适配,核心优势如下: 查看源码 -
(自适应响应式)门窗定制门业带视频功能pbootcms模板下载本模板采用PbootCMS内核开发,为门窗制造、定制安装企业打造,通过可视化后台管理系统快速构建品牌官网。自适应设计确保在手机、平板、电脑等设备上均能获得优质浏览体验查看源码
| 分享笔记 (共有 篇笔记) |
