作者:Trotter
邮箱:trotter@kekerde.net
出处:www.gbunix.com
转载请保持文档完整,注明出处。
前言
由于作者水平有限,目前只整合了用户数据,对于cookie还没有进行整合。也就是说当用户在登陆时,还是需要登陆两次。希望大家可以在这个文档的基础上,提出更好的整合方法,解决掉cookie的整合问题。在此,感谢作者朋友“蓝色的天空”对我的帮助,这个是他的网站(www.ioptional.com),也帮他AD一下吧。呵呵
整合方法
首先同步phparticle用户表pa546_user和phpBB用户表users。由于时间关系,我没有写同步数据库的程序。那位有空可以写一下。
整合思路
我们使用phpBB的注册程序。将phparticle设置成不允许用户注册,当用户注册时,首页在phpBB的users表中插入用户信息,当该用户收到系统通过Mail发送的激活账号信息时,点击激活账号链接,激活该用户的phpBB账号。同时给pa546_user表中插入该用户信息。当用户修改用户资料时,同时修改两张表中对应的信息。 php学习之家http://www.444p.com
修改程序
我们需要修改3个php文件,分别是phparticle的member.php, phpBB的usercp_activate.php和usercp_register.php。
1.member.php
大概在212行,注释掉一下代码:
php学习之家http://www.444p.com
// email='".addslashes($email)."',
// sex='".addslashes($sex)."',
// homepage='".addslashes(htmlspecialchars(trim($_POST[homepage])))."',
// address='".addslashes(htmlspecialchars(trim($_POST[address])))."',
// qq='".addslashes(htmlspecialchars(trim($_POST[qq])))."',
// icq='".addslashes(htmlspecialchars(trim($_POST[icq])))."',
// msn='".addslashes(htmlspecialchars(trim($_POST[msn])))."',
// intro='".addslashes(htmlspecialchars(trim($_POST[intro])))."',
// tel='".addslashes(htmlspecialchars(trim($_POST[tel])))."',
// rememberpw='$rememberpw',
// timezoneoffset='".addslashes($_POST[timezoneoffset])."'
// WHERE userid='$pauserinfo[userid]'
// ");
在下面加入一下代码:
$DB->query("UPDATE ".$db_prefix."user SET
sex='".addslashes($sex)."',
homepage='".addslashes(htmlspecialchars(trim($_POST[homepage])))."',
address='".addslashes(htmlspecialchars(trim($_POST[address])))."',
qq='".addslashes(htmlspecialchars(trim($_POST[qq])))."',
icq='".addslashes(htmlspecialchars(trim($_POST[icq])))."',
msn='".addslashes(htmlspecialchars(trim($_POST[msn])))."',
intro='".addslashes(htmlspecialchars(trim($_POST[intro])))."',
tel='".addslashes(htmlspecialchars(trim($_POST[tel])))."', php学习之家
rememberpw='$rememberpw',
timezoneoffset='".addslashes($_POST[timezoneoffset])."'
WHERE userid='$pauserinfo[userid]'
");
$DB->query("UPDATE users SET
user_website='".addslashes(htmlspecialchars(trim($_POST[homepage])))."',
user_aim='".addslashes(htmlspecialchars(trim($_POST[qq])))."',
user_icq='".addslashes(htmlspecialchars(trim($_POST[icq])))."',
user_msnm='".addslashes(htmlspecialchars(trim($_POST[msn])))."'
WHERE username='$pauserinfo[username]'
");
php学习之家
// write by trotter for phpbb & phparticle
大概在311行,有如下代码:
www.444p.com版权所有
php学习之家http://www.444p.com
password='".md5($newpassword1)."'
WHERE userid='$pauserinfo[userid]'");
在代码后加入:
$DB->query("UPDATE users SET
user_password='".md5($newpassword1)."'
WHERE username='$pauserinfo[username]'");
// write by trotter for phpbb & phparticle
2.usercp_activate.php
大概在30行,注释掉如下代码:
php学习之家
// user_newpasswd, user_lang, user_actkey FROM " . USERS_TABLE . "
// WHERE user_id = " . intval($HTTP_GET_VARS[POST_USERS_URL]);
在后面加如下代码:
www.444p.com
$sql = "SELECT * FROM " . USERS_TABLE . "
WHERE user_id = " . intval($HTTP_GET_VARS[POST_USERS_URL]);
//write by trotter for phpbb & phparticle
搜索代码“if ( $row = $db->sql_fetchrow($result) ){”,大概在45行,在其后加:
php学习之家http://www.444p.com
$phpartice_username = $row['username'];
$phpartice_password = $row['user_password'];
$phpartice_email = $row['user_email'];
$phpartice_joindate = $row['user_regdate'];
$phpartice_homepage = $row['user_website'];
$phpartice_qq = $row['user_aim'];
$phpartice_icq = $row['user_icq'];
$phpartice_msn = $row['user_msnm'];
//write by trotter for phpbb & phparticle
大概在70行,注释掉如下代码:
www.444p.com
//. str_replace("\'", "''", $row['user_newpasswd']) . "', user_newpasswd = ''" : '';
//$sql = "UPDATE " . USERS_TABLE . "
// SET user_active = 1, user_actkey = ''" . $sql_update_pass . "
// WHERE user_id = " . $row['user_id'];
//if ( !($result = $db->sql_query($sql)) )
//{
// message_die(GENERAL_ERROR, 'Could not update users table', '', __LINE__
//, __FILE__, $sql_update);
//} www.444p.com版权所有
在其后加:
www.444p.com
//write by trotter for phpbb & phparticle php学习之家http://www.444p.com www.444p.com版权所有
// 判断字段中是否有新的密码,如果有,就认为是用户更新密码,更新两张表用户的密码即可。
// 如果没有新的密码,就是用户激活账号操作。
if ($row['user_newpasswd'] != ''){
$sql = "UPDATE " . USERS_TABLE . "
SET user_active = 1, user_actkey = '', user_password = '"
. str_replace("\'", "''", $row['user_newpasswd'])
."', user_newpasswd = '' WHERE user_id = " . $row['user_id'];
if ( !($result = $db->sql_query($sql)) ) www.444p.com php学习之家
{
message_die(GENERAL_ERROR, 'Could not update users table', '',
__LINE__, __FILE__, $sql_update);
}
$sqlphpartice = "update pa546_user set password = '"
. str_replace("\'", "''", $row['user_newpasswd'])
. "' where username = '" . $row['username'] . "'";
if ( !($result = $db->sql_query($sqlphpartice)) )
{
message_die(GENERAL_ERROR, 'Could not update users table', '',
__LINE__, __FILE__, $sql_update);
}
}else{
//激活bbs的用户账号;判断pa546_user表是否用相同名称的用户,如果没有,就给pa546_user表插
//入用户数据,如果有,就认为是用户更改了自己的email地址,需要激活账号。 www.444p.com
$sql = "UPDATE " . USERS_TABLE . "
SET user_active = 1, user_actkey = '' WHERE user_id = " . $row['user_id'];
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not update users table', '',
__LINE__, __FILE__, $sql_update);
}
//当phpbb user表更改用户Email时,同时更新pa546_user表用户的Email地址
$sqlphpartice = "update pa546_user set email = '" . $row['user_email']
. "' where username = '" . $row['username'] . "'";
if ( !($result = $db->sql_query($sqlphpartice)) ) www.444p.com版权所有
{
message_die(GENERAL_ERROR, 'Could not update users table', '',
__LINE__, __FILE__, $sql_update);
}
//查询pa546_user表中是否有当前用户信息
$count_user = "select count(*) as phparticle_user_count from pa546_user
where username = '" . $row['username'] . "'"; if ( !($result = $db->sql_query($count_user)) )
{
message_die(GENERAL_ERROR, 'Could not update users table', '',
__LINE__, __FILE__, $sql_update);
} if ( $row = $db->sql_fetchrow($result) ){
if (intval($row['phparticle_user_count']) == 0)
{
$sql = "SELECT * FROM " . USERS_TABLE . " WHERE user_id = "
. intval($HTTP_GET_VARS[POST_USERS_URL]); if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain user information', '',
__LINE__, __FILE__, $sql);
} $sqlphpartice = "INSERT INTO pa546_user(username,usergroupid,password,email
,joindate,homepage,qq,icq,msn) VALUES('" . $phpartice_username . "','3',
'" . $phpartice_password . "','" . $phpartice_email . "','" . $phpartice_joindate
. "','" . $phpartice_homepage . "','" . $phpartice_qq . "','" . $phpartice_icq
. "','" . $phpartice_msn . "')";
if ( !($result = $db->sql_query($sqlphpartice)) )
{
message_die(GENERAL_ERROR, 'Could not update users table', '',
__LINE__, __FILE__, $sql_update);
}
}
}
}
//write by trotter for phpbb & phparticle 本文来自 www.444p.com
3.usercp_register.php
搜索代码“$passwd_sql = '';”,大概在289行。在其后加:
$phparticle_passwd_sql = '';
// write by trotter for phpbb & phparticle
搜索代码“$passwd_sql = '';”,大概在314行。在其后加:
$phparticle_passwd_sql = '';
// write by trotter for phpbb & phparticle
搜索代码“$passwd_sql = "user_password = '$new_password', ";”,大概在357行,在其后加:
www.444p.com
$phparticle_passwd_sql = "password = '$new_password', ";
// write by trotter for phpbb & phparticle
搜索代码“$sql = "UPDATE " . USERS_TABLE . "”,大概在568行。在其后加:
www.444p.com php学习之家
// phpbb 会员修改个人资料
$phparticle_sql = "UPDATE pa546_user SET " . $phparticle_passwd_sql
. " email = '" . str_replace("\'", "''", $email) . "', icq = '"
. str_replace("\'", "''", $icq) ."', homepage = '"
. str_replace("\'", "''", $website) . "', qq = '"
. str_replace("\'", "''", str_replace(' ', '+', $aim))
. "', msn = '" . str_replace("\'", "''", $msn) . "'
WHERE username = '" . $userdata['username'] . "'";
if ( !($result = $db->sql_query($phparticle_sql)) ) www.444p.com版权所有
{
message_die(GENERAL_ERROR, 'Could not update users table', '',
__LINE__, __FILE__, $sql);
}
// write by trotter for phpbb & phparticle
修改phparticle模版
由于大家使用的模版都不一样,修改模版的方法我就不进行说明了,这个很简单,修改模版中有关注册部分的链接为phpBB的注册页面。
注意事项
使用该MOD时,请关闭你的phparticle的注册功能。同时,打开phpBB注册账号修改激活选项。
















