Integrate Zencart 1.3.8 with phpbb3

用于收藏精华贴子、网友共享的资料等。可以回复,不能发新贴。

版主: daimadaquan

版面规则
本版面不能发新贴,可以回复

Integrate Zencart 1.3.8 with phpbb3

帖子cjc108 » 2008-11-20 10:44

These are steps to integrate zencart 1.3.8 with phpBB 3.0.1. These steps will ensure if a user create an account in Zencart, an account for the phpBB will also be created and your phpbb3 display appropriate Total number of user and Newest Member nickname at the board index.

1. Install your phpbb3 and ensure it runs perfectly.

2. Open your configure.php inside /includes folder of your Zen-Cart installation and edit this configuration define(’DIR_WS_PHPBB’, ‘…..Your Path to your phpbb3 ….’); with correct physical path to your phpbb installation. It must be your physical path! NOT your relative path. For example of physical path see your ‘DIR_FS_CATALOG’ value inside the same configure.php (ensure you have ‘/’ at the end of the path).

3. Enable link to your phpbb3 from your zencart administrator. Inside your zencart administrator go to “Configuration” -> “My Store” and set “Enable phpBB Linkage?” to TRUE.

4. edit class.phpbb.php inside your …/includes/classes folders. Try to find phpbb_create_account function and replace with the following code.
代码: 全选
function phpbb_create_account($nick, $password, $email_address) {
   if ($this->phpBB['installed'] != true || !zen_not_null($password) || !zen_not_null($email_address) || !zen_not_null($nick)) return false;
   if ($this->phpbb_check_for_duplicate_email($email_address) == 'already_exists') {
      // $this->phpbb_change_email($old_email, $email_address);
   } else {
      $sql = "select max(user_id) as total from " . $this->phpBB['users_table'];
      $phpbb_users = $this->db_phpbb->Execute($sql);

      $user_id = ($phpbb_users->fields['total'] + 1);
      $sql = "insert into " . $this->phpBB['users_table'] . "(user_id, group_id, username, username_clean, user_password, user_email, user_regdate) values ('" . (int)$user_id . "',2, '" . $nick . "', '" . $nick . "', '" . md5($password) . "', '" . $email_address . "', '" . time() ."')";
      $this->db_phpbb->Execute($sql);

      $sql = "update phpbb_config SET config_value = '{$user_id}' WHERE config_name = 'newest_user_id'";
      $this->db_phpbb->Execute($sql);

      $sql = "update phpbb_config SET config_value = '{$nick}' WHERE config_name = 'newest_username'";
      $this->db_phpbb->Execute($sql);

      $sql = "update phpbb_config SET config_value = config_value + 1 WHERE config_name = 'num_users'";
      $this->db_phpbb->Execute($sql);

      $sql = "INSERT INTO " . $this->phpBB['user_group_table'] . " (user_id, group_id, user_pending) VALUES ($user_id, 2, 0)";
      $this->db_phpbb->Execute($sql);
   }
}

5. Enjoy your nicely integrated phpbb3 forum with zencart. From now on, if a user register an account in Zen-Cart, they will be registered in PHPBB as well.

If you have follow my instruction correctly, now when you create new account in Zen-Cart you will be asked to provide “Forum Nick Name”. You can login in the forum using the Forum Nick Name you have provided and your Zencart password.

Optional: You can manually copy Zen-Cart account that has been setup previously to phpbb user database to integrate them. Next, you can create theme that reflect your store for your phpBB forum. I will not go into detail in here and ZC developers should be able to do these. PS: if you find better solution please let me know :)
cjc108
新手上路
新手上路
 
帖子: 11
注册: 2008-11-16 17:32

Re: Integrate Zencart 1.3.8 with phpbb3

帖子cjc108 » 2008-11-20 10:56

关于同步的问题,可以参考?
http://www.phpx.com/happy/thread-147849-1-6.html
cjc108
新手上路
新手上路
 
帖子: 11
注册: 2008-11-16 17:32

Re: Integrate Zencart 1.3.8 with phpbb3

帖子cjc108 » 2008-11-20 11:14

phpBB2的一种简单整合方案
基本思想:
最简单化设计,采用一个页面内2个iframe来解决注册、登陆、修改密码的同步。
phpBB的帐号系统和原系统得完全独立,因此不需要任何修改

在登录前自动先注销论坛帐号

注册:
<IFRAME name="register" src="register.php" width=100% height=300></IFRAME>
<IFRAME name="bbsregister" src="phpBB2/profile.php?mode=register&agreed=true" width=1px height=1px></IFRAME>

Register.php 原系统得注册程序
原系统注册提交按钮
<input type="button" value="提交" onClick="checkForm(this.form)">

function checkForm(form) {

parent.bbsregister.document.forms[0].username.value=form.username.value;
parent.bbsregister.document.forms[0].email.value=form.email.value;
parent.bbsregister.document.forms[0].new_password.value=form.password.value;
parent.bbsregister.document.forms[0].password_confirm.value=form.password.value;
parent.bbsregister. document.forms[0].submit();

document.form.submit(); // un-comment to submit form
}

登录成功后,系统跳出原来的iframe回到主iframe
echo "<script>parent.location='***.php'</script>";

phpBB2的profile.php?mode=register&agreed=true中由于存在name=submit的submit按钮,所以会影响submit()函数的执行。需要修改模板文件
template/profile_add_body.tpl
<input type="hidden" name="submit1" value="{L_SUBMIT}" class="mainoption" />
<input type="submit" name="submit2" value="{L_SUBMIT}" class="mainoption" />
将原来的name=submit改为name=submit2,由于执行submit()函数的时候submit按钮的值并不会提交,所以再增加一个hidden的name=submit1,方便后台判断
Include/usercp_register.php
所有的$HTTP_POST_VARS['submit']替换为$HTTP_POST_VARS['submit1']

这样在name=submit1的hidden值POST以后系统即会注册

登录
<IFRAME name="login" src="login.php" width=100% height=300></IFRAME>
<IFRAME name="bbslogin" src="phpBB2/login.php" width=1 height=1></IFRAME>

login.php
<input type="button" value="登录" onclick="checkLogin(this.form)">

function checkLogin(form) {
if (!checkUserName(form)) return;
if (!checkPass(form)) return;

parent.bbslogin.document.forms[0].username.value=form.username.value;
parent.bbslogin.document.forms[0].password.value=form.password.value;
parent.bbslogin.document.forms[0].submit();

document.form.submit(); // un-comment to submit form
}

在login.php提交到验证后,跳出iframe到顶级窗口
echo "<script>parent.location='***.php'</script>";

由于phpBB2登录模块默认目标为_top,所以要修改模板文件
Template/login_body.tpl
<form action="{S_LOGIN_ACTION}" method="post" target="_top">为
<form action="{S_LOGIN_ACTION}" method="post" target="_self">

同时此模板的submit按钮name=login,所以不必另行处理。


退出phpbb2用户session
logout.php
在原来的注销登录文件中除了原有的语句外,加入
<IFRAME name="bbsregister" src="phpBB2/login.php?logout=true" width=1px height=1px></IFRAME>
okgo("退出系统成功","index.php");

即可同时注销phpBB2帐号

当然在修改用户密码、删除用户的时候也要作同步动作,同时在phpBB2的程序中也要禁止用户进行修改密码、注册等行为,确保这些帐号修改只能在主用户表进行。
cjc108
新手上路
新手上路
 
帖子: 11
注册: 2008-11-16 17:32

Re: Integrate Zencart 1.3.8 with phpbb3

帖子sunrise » 2009-07-09 11:16

you need use this code, the last code seems have some error.

代码: 全选
function phpbb_create_account($nick, $password, $email_address) {
if ($this->phpBB['installed'] != true || !zen_not_null($password) || !zen_not_null($email_address) || !zen_not_null($nick)) return false;
if ($this->phpbb_check_for_duplicate_email($email_address) == 'already_exists') {
// $this->phpbb_change_email($old_email, $email_address);
} else {
$sql = "select max(user_id) as total from " . $this->phpBB['users_table'];
$phpbb_users = $this->db_phpbb->Execute($sql);
$user_id = ($phpbb_users->fields['total'] + 1);
$sql = "insert into " . $this->phpBB['users_table'] . "
( username,username_clean, user_password, user_email, user_regdate)
values
( '" . $nick . "','" . $nick . "', '" . md5($password) . "', '" . $email_address . "', '" . time() ."')";
$this->db_phpbb->Execute($sql);
//could do a check here to see if Insert_ID() matches $user_id...


// @TODO: MySQL5

//$sql = "INSERT INTO " . $this->phpBB['groups_table'] . " (group_name, group_desc, group_single_user, group_moderator)
// VALUES (0, 'Personal User', 1, 0)";
//$this->db_phpbb->Execute($sql);
//$group_id = $this->db_phpbb->Insert_ID();
$sql = "INSERT INTO " . $this->phpBB['user_group_table'] . " (user_id, group_id, user_pending)
VALUES ($user_id, 2, 0)";
$this->db_phpbb->Execute($sql);
//might optionally send an extra email welcoming them to the phpBB forum, reminding them of their nickname?
}
}
sunrise
高级会员
高级会员
 
帖子: 162
注册: 2007-12-27 10:23

Re: Integrate Zencart 1.3.8 with phpbb3

帖子TANDEM_GURU » 2009-07-16 5:12

Hi,

Right now, I can create a new account in phpbb3 when I create/register a new account in Zencart.

Now, the problem that I have is that user still needs to LOGIN to phpbb3 in order to post. This caused extra step for user, and does not have this 'integrated' feeling.

I have disabled the registration function in phpbb3 so that user has to register in ZenCart.

I tried a few solutions to this problem provided by other Zenners online, but still have not found an easy solution.

Has anyone successfully implemented this integration? I am willing to pay for an easy solution to this problem.

General requirement:

1) When user registered/created an account in Zencart (with nickname), a user is also created in phpbb3 (with nickname and the same password).

2) When user registered/created or login in Zencart, it should automatically login phpbb3.

3) When user updates password in Zencard, it should also update the same password in phpbb3

4) When user logoff from Zencard, it should also automatically logoff from phpbb3.


Please share any successful stories/solutions on this forum.

Thanks,

Tandem_Guru
TANDEM_GURU
初来乍到
初来乍到
 
帖子: 1
注册: 2009-07-07 12:57
地址: NEW YORK CITY, USA


回到 精华共享

 


  • 相关话题
    回复总数
    阅读次数
    最新文章

在线用户

正在浏览此版面的用户:没有注册用户 和 1 位游客