Converting drupal to phpbb

Converting from other board software? Good decision! Need help? Have a question about a convertor? Wish to offer a convertor package? Post here.
Scam Warning
Locked
Azaxiel
Registered User
Posts: 10
Joined: Sun Jan 24, 2010 3:59 am

Converting drupal to phpbb

Post by Azaxiel »

I'm working on setting up a script to convert my users from Drupal (6.8) to phpBB3 (3.0.6). I've got the basics of how to do it, I just need to figure out some of the other pieces of information in phpbb's user table. I was wondering if anyone familiar with phpbb could explain what some of the fields are, and whats necessary to generate that data, since it's not something in Drupal. The fields in question are: user_form_salt, user_email_hash, user_sig_bbcode_uid, user_sig_bbcode_bitfield. Beyond that, unless someone has a better idea, since drupal and phpbb use a different system for encrypting passwords, I plan on forcing all users to reactivate and thus reset their passwords when they first visit the site. Any help, or a direction on where I might be able to find it would be appreciated. Thanks.
Azaxiel
Registered User
Posts: 10
Joined: Sun Jan 24, 2010 3:59 am

Re: Converting drupal to phpbb

Post by Azaxiel »

Anyone have an answer or know where I might be able to find one?
Azaxiel
Registered User
Posts: 10
Joined: Sun Jan 24, 2010 3:59 am

Re: Converting drupal to phpbb

Post by Azaxiel »

Ok, with some help from the IRC rooms, I was able to hack together some code to convert the users over. Works like a charm for me. Since drupal and phpBB use entirely different methods of encrypting passwords, the script simply generates a random 10 digit password and for the converted phpbb user. Users will have to reset their password before logging in. I would recommend double checking everything in the code to make sure it fits your particular configuration before using.

Disclaimer: I consider myself a novice with PHP, so I wouldn't recommend using this on a production site, and I would definitely back up your databases before using.

Code: Select all

<?php
$fromsqlserver = 'db server where your drupal db is located';
$fromdb = 'the name of your drupal db';
$fromdbuser = 'your drupal db username';
$fromdbpass = 'your drupal db pass';
$fromusertable = 'your drupal user table';
$usercount = 'how many users in your drupal db';
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
include($phpbb_root_path . 'includes/functions_user.php');
function generateRandStr($length){
      $randstr = "";
      for($i=0; $i<$length; $i++){
         $randnum = mt_rand(0,61);
         if($randnum < 10){
            $randstr .= chr($randnum+48);
         }else if($randnum < 36){
            $randstr .= chr($randnum+55);
         }else{
            $randstr .= chr($randnum+61);
         }
      }
      return $randstr;
   }
$drupal = mysql_connect($fromsqlserver,$fromdbuser,$fromdbpass);
mysql_select_db($fromdb,$drupal);
$query = "SELECT * FROM $fromusertable LIMIT $usercount";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
$user_row = array(
'username'          => $row['name'],
'user_password'   => phpbb_hash(generateRandStr('10')),
'user_email'          => $row['mail'],
'user_sig'              => $row['signature'],
'group_id'             => '2',
'user_type'           => '0',
);
$user_id = user_add($user_row);
if ($user_id != false) { echo "User " .  $row['name'] . " with the uid of " . $row['uid'] . " has been successfully transferred to phpbb and now has the new uid of " . $user_id . "<br>"; }
}
mysql_free_result($result);
?>
Locked

Return to “[3.0.x] Convertors”