Integrate Zencart 1.3.8 with phpbb3

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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 🙂

Tags: ,

15 Responses to “Integrate Zencart 1.3.8 with phpbb3”

  1. Tif Says:

    Thanks for the directions, however I still have a problem logging into my phpbb with the new user account. The user exists, but the password appears to be incorrect.

  2. admin Says:

    That is interesting. I have done integration ZC138 with PHPBB3 with one of my client and it works smoothly. Have you changed the user password via Zencart? If you can not login after you change the user’s password in ZC, then try to replace the “phpbb_change_password” function inside class.phpbb.php with this one:

    function phpbb_change_password($nick, $newpassword) {
    if ($this->phpBB[‘installed’] != true || !zen_not_null($nick) || $nick == ”) return false;
    $sql = “update ” . $this->phpBB[‘users_table’] . ” set user_password='” . md5($newpassword) . “‘
    where username = ‘” . $nick . “‘”;
    $phpbb_users = $this->db_phpbb->Execute($sql);
    }

  3. Tif Says:

    Hmm…I hadn’t changed the password at all — I tried creating a new user and then logging into the phpbb after they registered. It’s a completely clean install of both ZC and phpbb with no contributions or other code mods.

    I should also mention that your write up is perfect. I wish half the contributions were that clear. I’m thinking the problem has to do with the way the password is encrypted in the database.

  4. admin Says:

    I have just spent some time to investigate this. You are right, it turns out that PHPBB3 does not use md5 encryption for the password. It use some kind of Portable PHP password hashing framework (Written by Solar Designer at openwall.com). You can see the hash/encryption function at “includes\functions.php” file in your phpbb3 installation directory.

    However, I figured out that PHPBB3 also accept md5 hashing. Have a look at your “phpbb_check_hash” function inside “includes\functions.php”. My PHPBB version is 3.0.1 and the default function from phpbb looks like this:

    function phpbb_check_hash($password, $hash)
    {
    $itoa64 = ‘./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz’;
    if (strlen($hash) == 34)
    {
    return (_hash_crypt_private($password, $hash, $itoa64) === $hash) ? true : false;
    }

    return (md5($password) === $hash) ? true : false;
    }

    Note the last line code. What actually happen is if your password in database encrypted using md5() which is 32 characters long, it will still log you in then phpbb3 will replace the md5 hash with its hashing system (your password remain the same, it just rehash into its hashing system).

    I suspect there is something wrong with your class.phpbb.php at ZC.
    1. Well to make sure, just try to create new user in ZC with password = “admin” (do not include the quotes).
    2. Then browse your “users” table for your phpbb3 database. Find your new user data and the user_password field should have this value : “21232f297a57a5a743894a0e4a801fc3” (this is the md5 value for “admin”).
    If it does not try to fix your “class.phpbb.php” in ZC because there is something wrong with it 🙂

  5. Tif Says:

    Curiouser and curiouser. . . the hash value was correct. I tried to login and couldn’t — then I tried again and could. Then I tried again and couldn’t (with a new user name)…

    I’m now wondering if its a caching issue.

    Back to the drawing board!

  6. Tif Says:

    Okay, it\’s not a caching issue. The user is in the database. However the error given when attempting to login is that the username is not found. If I login my administrator account, the user is visible when I click on the find a member link — however if I search for the member their name is not found.

  7. Jessica Says:

    Hi,
    I am having the same problem as Tif. I’m not sure though where the users table is so that I can check to see if the password code is right. This is all very new to me sorry if that was a “duh” question.

  8. admin Says:

    Hi Jessica and Tif, Today I checked again and ensure I follow my steps as written in this blog. Guess what? It works seamlessly for me. I don’t know what happened with your installations. I think there could be a misunderstanding here, so I have updated my instructions and include more details. Have a look at let me know if it still does not work.

    If you are not ZC geek or editing zencart code sounds scary for you, you can download this phpbb class file for zencart and replace yours to ensure you perform the editing correctly: http://www.ferolen.com/project/zc138_phpbb3.zip

    Remember to backup the old file before you edit or replace.
    PS: You will not be able to login using account that already registered prior the integration!. These integration steps will ensure new ZC user registration will also register it to phpBB forum. You should manually copy the old ZC account database.

  9. Jessica Says:

    I tried the new stuff that you wrote and now I\’m getting an error on line 179. I guess that I\’m doing something wrong since you are getting it to work. I don\’t have a place to type in my forum nickname when they sign up as a new user. My ZC is a little older I\’m running version Zen Cart 1.3.7.1
    Database Patch Level: 1.3.7.1.
    Do I have to update my Zen Cart to get it to work?
    I had to set my configure.php settings to 444 so that I wouldn\’t get the error that my configure file is being written to.
    Please help I would really love to get this to work.

  10. Kabash Says:

    Hey,

    I tried your zip file but am not able to login to the forums with the nickname i chose when setting up a new user account in Zen cart , i am running Zen Cart 1.3.8a Database Patch Level: 1.3.8 and Download phpBB 3.0.1

  11. Kabash Says:

    Hey…me again…it worked, i kept on creating new users on the zen cart with same email address, went and deleted the user in the phpbb db and tried my luck one more time and voila!!!!!

    THANK YOU

  12. Ka Says:

    Hi there. I have phpbb 3.0 installed with zencart 1.3.8a. Both were installed using fantastico and were assigned separate databases.

    The directory to each install is as follows:

    /home/server_name/public_html/forum (for phpbb3)
    /home/server_name/public_html/store (for zencart 1.3.8a)

    Like many of you, I’m having issues integrating the login systems for the two applications. I’m not a database expert by any means so I was wondering if the installation could be my issue. Do the installations need to be in the same directory and share teh same database?

    Thanks in advance

  13. Ka Says:

    Hello.

    I’m also having trouble integrating my phpbb (v 3.0.0) forum along with my zencart (v 1.3.8a).

    My phpbb forum was installed into the following directory:
    /home/myserver/public_html/forum/

    My zencart was intalled afterwards into the following directory:
    /home/myserver/public_html/store/

    Both were installed with fantastico and assigned separate databases.

    I’ve made the changes you’ve suggested and the zencart registration requests for a forum nickname but the customer info does not transfer over to the phpbb tables. Zencart registration works fine. Could the installation and structure be causing the problem?

    Thanks in advance for the help!

  14. Marcus Says:

    I know this is a 4 year old blog, but, it appears quite high in the google listings for anyone searching about PHPBB3 integration with zen-cart. As posted, this blog is almost correct and will work with the latest phpbb3 and zen-cart 1.3.9 but ONLY if a serious oversight on 1 line of the code posted above is corrected.

    $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 . “‘, ‘” . strtolower($nick) . “‘, ‘” . md5($password) . “‘, ‘” . $email_address . “‘, ‘” . time() .”‘)”;

    Also, you need to ReplaceAll > with a grater than sign, something in this blog messed up the text formatting.

  15. green tea Says:

    Hello friends, good paragraph and good urging commented here, I am genuinely enjoying by these.

Leave a Reply

*