konakona
pbdigg与uchome完美整合方法(头像+同步登陆+对应ID)
pbdigg与uchome完美整合方法(头像+同步登陆+对应ID)

今天帮客户整合(http://pbdigg.31.sql.sh.cn)pbdigg和uchome,逐找出了这个方法。

前提.必须已经安装ucenter和uchome.并且能正常运行.

版本:

pbdigg 2.0 UCenter_Home_1.5RC2

第一步:

不同方式的通行证登陆.

PBDIGG外部应用登陆,如uchome,ecshop等通过通行证登陆.

打开PBDIGG目录下api目录下的uc.php

找到

sCookie(‘pb_auth’, PEncode(($member[‘uid’].”\t”.$member[‘password’]), $pb_sitehash), 0);

改成

sCookie(‘pb_auth’, PEncode(($member[‘uid’].”\t”.$member[‘password’].”\t”.$member[‘ucuid’]), $pb_sitehash), 0);

正常登陆,通过login.php

打开PBDIGG目录下login.php

找到

sCookie(‘pb_auth’, PEncode(($autoid.”\t”.$password), $pb_sitehash), $cookietime);

改成
sCookie(‘pb_auth’, PEncode(($autoid.”\t”.$password.”\t”.$uc_return[0]), $pb_sitehash), $cookietime);

新注册用户登陆由系统自动登陆,文件register.php

打开Includes/下member.class.php文件

找到

$this->setNewUser(array($autoid,$username,$password,$md5password,$email,’uc_login’=>$uc_login));

改成

$this->setNewUser(array($autoid,$username,$password,$md5password,$email,’uc_login’=>$uc_login,$uc_uid));

打开PBDIGG目录下文件register.php

找到

sCookie(‘pb_auth’, PEncode($newmember[0].”\t”.$newmember[3],$pb_sitehash), 0);

改成

sCookie(‘pb_auth’, PEncode($newmember[0].”\t”.$newmember[3].”\t”.$newmember[5], $pb_sitehash), 0);

修改密码后重新登陆:member.php

打开PBDIGG目录下的member.php

找到

$DB->db_query(“UPDATE {$db_prefix}members SET password = ‘$newpw_md5’ WHERE uid = $m_uid AND password = ‘$oldpw_md5′”);

它下面加一行

$UCUid=$DB->db_fetch_one_array(“SELECT ucuid From {$db_prefix}memberdata WHERE uid = $m_uid”);

找到

sCookie(‘pb_auth’, PEncode($m_uid.”\t”.$newpw_md5, $pb_sitehash));

改成

sCookie(‘pb_auth’, PEncode($m_uid.”\t”.$newpw_md5.”\t”.$UCUid[‘ucuid’], $pb_sitehash));

第二步

打开PBDIGG目录下include/common.inc.php

找到

$customer = array(‘sid’=>”,’uid’=>’0′,’username’=>”,’pw’=>”,’groupid’=>’5’, ‘adminid’=>’0’, ‘online’=>’0’, ‘avatar’=>”, ‘tdigg’=>”, ‘cdigg’=>”, ‘tbury’=>”, ‘cbury’=>”);

改成

$customer = array(‘sid’=>”,’uid’=>’0′,’username’=>”,’pw’=>”,’groupid’=>’5’, ‘adminid’=>’0’, ‘online’=>’0’, ‘avatar’=>”, ‘tdigg’=>”, ‘cdigg’=>”, ‘tbury’=>”, ‘cbury’=>”,’ucuid’=>’0’);

再找到

list($p_uid, $p_pw) = explode(“\t”, PDecode($p_auth, $pb_sitehash));
if (is_numeric($p_uid))
{
$customer[‘uid’] = (int)$p_uid;
$customer[‘pw’] = addslashes($p_pw);
}

改成

list($p_uid, $p_pw, $p_ucuid) = explode(“\t”, PDecode($p_auth, $pb_sitehash));
if (is_numeric($p_uid))
{
$customer[‘uid’] = (int)$p_uid;
$customer[‘pw’] = addslashes($p_pw);
$customer[‘ucuid’] = $p_ucuid;
}

第三步

进入后台,修改模版header.html

找到
{#$customer.username#} | 我的空间

改成

| 我的空间

头像整合

打开member.php

找到

elseif ($action == ‘avatar’)
{
if ($_FILES[‘uploadavatar’][‘name’])
{
if ($allowavatar && $pb_selfavat && $pb_avatupload)
{
//upload avatar
require_once(PBDIGG_ROOT.’include/Upload.class.php’);
$ext = array(‘gif’, ‘jpeg’, ‘jpg’, ‘png’);
$rsavatar = array();
$UPLOAD = new Upload();
if ($UPLOAD->_count)
{
$files = & $UPLOAD->getFiles();
$filepath = PBDIGG_ROOT.’images/avatars/’;
foreach ($files as $file)
{
if ($ck = $file->checkFile($ext, $pb_avatsize))
{
showMsg($ck, $actionurl);
}
else
{
$rsavatar = $DB->db_fetch_one_array(“SELECT avatar FROM {$db_prefix}memberexp WHERE uid = ‘$m_uid'”);
if (preg_match(‘/^[0-9a-z]{1,32}\.(gif|jpg|jpeg|png)$/i’, $rsavatar[‘avatar’]))
{
PDel(PBDIGG_ROOT.’images/avatars/’.$rsavatar[‘avatar’]);
}
if ($ck = $file->moveFile($filepath, $m_uid))
{
showMsg($ck, $actionurl);
}
else
{
$DB->db_query(“UPDATE {$db_prefix}memberexp SET avatar = ‘”.$m_uid.’.’.$file->getExtName().”‘ WHERE uid = “.$m_uid);
redirect($member_message[‘mod_avatar_success’], $actionurl);
}
}
}
}
else
{
showMsg($member_message[‘mod_avatar_failed’], $actionurl);
}
}
else
{
showMsg($member_message[‘mod_avatar_failed’], $actionurl);
}
}
elseif ($allowavatar && $pb_selfavat && $linkavatar && $linkavatar != ‘http://’)
{
$ext = array(‘gif’, ‘jpeg’, ‘jpg’, ‘png’);
$linkavatar = trim($_POST[‘linkavatar’]);
if ($ck = checkAvatar($linkavatar))
{
showMsg($ck, $actionurl);
}
else
{
$rsavatar = $DB->db_fetch_one_array(“SELECT avatar FROM {$db_prefix}memberexp WHERE uid = ‘$m_uid'”);
if (preg_match(‘/^[0-9a-z]{1,32}\.(gif|jpg|jpeg|png)$/i’, $rsavatar[‘avatar’]))
{
PDel(PBDIGG_ROOT.’images/avatars/’.$rsavatar[‘avatar’]);
}
$DB->db_query(“UPDATE {$db_prefix}memberexp SET avatar = ‘”.$linkavatar.”‘ WHERE uid = “.$m_uid);
redirect($member_message[‘mod_avatar_success’], $actionurl);
}
}
elseif ($savatar)
{
$avatar_list = PListFile(PBDIGG_ROOT.’images/avatars/portrait’, array(‘gif’,’jpg’,’jpeg’,’png’));
$savatar = trim($_POST[‘savatar’]);
$savatar = substr($savatar, 0, strpos($savatar, ‘|’));
if (in_array($savatar, $avatar_list))
{
$rsavatar = $DB->db_fetch_one_array(“SELECT avatar FROM {$db_prefix}memberexp WHERE uid = ‘$m_uid'”);
if (preg_match(‘/^[0-9a-z]{1,32}\.(gif|jpg|jpeg|png)$/i’, $rsavatar[‘avatar’]))
{
PDel(PBDIGG_ROOT.’images/avatars/’.$rsavatar[‘avatar’]);
}
$DB->db_query(“UPDATE {$db_prefix}memberexp SET avatar = ‘portrait/”.$savatar.”‘ WHERE uid = “.$m_uid);
redirect($member_message[‘mod_avatar_success’], $actionurl);
}
else
{
showMsg($member_message[‘mod_avatar_illegal_avatar’], $actionurl);
}
}
else
{
$user[‘avatar’] = $customer[‘avatar’];
$seo[‘pagetitle’] = $seo[‘keywords’] = $seo[‘description’] = $member_message[‘mod_avatar’];
$avatar_list = PListFile(PBDIGG_ROOT.’images/avatars/portrait’, array(‘gif’,’jpg’,’jpeg’,’png’));
$TPL->assign(‘allowavatar’, ($allowavatar && $pb_selfavat));
$TPL->assign(‘allowuploadavatar’, $pb_avatupload);
$TPL->assign(‘avatar_list’, $avatar_list);
$TPL->assign(‘user’, $user);
}
}
else
{
$seo[‘pagetitle’] = $seo[‘keywords’] = $seo[‘description’] = $member_message[‘membercp’];
$type = ‘profile’;
$customer[‘lastvisit’] = gdate($customer[‘lastvisit’], ‘Y-m-d H:i’);
if ($customer[‘groupid’] == ‘6’)
{
$TPL->assign(‘show_notice’, ‘1’);
}
}

改成
elseif ($action == ‘avatar’)
{
//这行开始 主要是为了已经有会员信息的网站整合头像时用。如果是全新并且没有会员的PBDIGG这两句可以省略不写。不过对于一些新手来说建议写上。这样不不会有错误发生。
if(!$trs=$DB->db_fetch_one_array(“SELECT uid FROM {$db_prefix}memberexp where avatar='”.UC_API.”avatar.php?uid=”.$customer[‘ucuid’].”‘”))
{
$DB->db_fetch_one_array(“update {$db_prefix}memberexp set avatar='”.UC_API.”avatar.php?uid=”.$customer[‘ucuid’].”‘ WHERE uid = $m_uid”);
}
//这行结束
require_once PBDIGG_ROOT.’client/client.php’;
$uc_avatarflash = uc_avatar($customer[‘ucuid’]);
$user[‘avatar’] = $customer[‘avatar’];
$TPL->assign(‘user’, $user);
}
else
{
$seo[‘pagetitle’] = $seo[‘keywords’] = $seo[‘description’] = $member_message[‘membercp’];
$type = ‘profile’;
$customer[‘lastvisit’] = gdate($customer[‘lastvisit’], ‘Y-m-d H:i’);
if ($customer[‘groupid’] == ‘6’)
{
$TPL->assign(‘show_notice’, ‘1’);
}
$user[‘avatar’] = $customer[‘avatar’];
$TPL->assign(‘user’, $user);
}

再找到
$TPL->assign(‘seo’, $seo);
PBOutPut(‘member.html’);

改成

$TPL->assign(‘seo’, $seo);
$TPL->assign(‘uc_avatarflash’,$uc_avatarflash);
PBOutPut(‘member.html’);

进入后台。修改模版member.html

找到
{#elseif $action eq “avatar”#}

当前头像 {#$user.avatar#}
系统默认头像:您可以选择网站内置的图片作为您的头像。

{#foreach from=$avatar_list item=item name=avatar#}{#$PB_ENV.PB_URL#}images/avatars/portrait/{#$item#}{#/foreach#}

{#if $allowavatar eq “1”#}

链接头像:输入图片在其他站点中的地址,必须以http://开头。

{#if $allowuploadavatar eq “1”#}上传头像:从您的电脑上传本地图片。图片尺寸100 * 100效果最佳

{#/if#}
{#/if#}

改成

{#elseif $action eq “avatar”#}

当前头像(默认为中)小:{#$user.avatar#}&size=small中:{#$user.avatar#}&size=middle大:{#$user.avatar#}&size=big

上传头像:从您的电脑上传本地图片。图片尺寸100 * 100效果最佳

{#$uc_avatarflash#}

打开include/member.class.php

找到

$this->pbdb->db_query(“INSERT INTO {$db_prefix}memberexp (uid $i_field) VALUES ($autoid $v_field)”);

改成

$this->pbdb->db_query(“INSERT INTO {$db_prefix}memberexp (uid $i_field,avatar) VALUES ($autoid $v_field,'”.UC_API.”avatar.php?uid=”.$uc_uid.”‘)”);

头像这样就基本整合。只是有些地方头像大小还要调整。稍后将给出详细调整代码。。

这样就可以了..完美整合..

赞赏
没有标签
首页      程序开发      PHP      pbdigg与uchome完美整合方法(头像+同步登陆+对应ID)
https://secure.gravatar.com/avatar/3b712b34a0e1b689cfb524c9c6bcdc47?s=256&r=g

团哥

文章作者

继续玩我的CODE,让别人说去。 低调,就是这么自信。

konakona

pbdigg与uchome完美整合方法(头像+同步登陆+对应ID)
今天帮客户整合(http://pbdigg.31.sql.sh.cn)pbdigg和uchome,逐找出了这个方法。 前提.必须已经安装ucenter和uchome.并且能正常运行. 版本: pbdigg 2.0 UCenter_Home_1.5RC…
扫描二维码继续阅读
2009-06-14