Joomla Fireboard Forum to PHPBB

This is an archive of the phpBB 2.0.x convertors forum. Support for phpBB2 has now ended.
Forum rules
Following phpBB2's EoL, this forum is now archived for reference purposes only.
Please see the following announcement for more information: viewtopic.php?f=14&t=1385785
zuze
Registered User
Posts: 7
Joined: Wed May 07, 2008 11:49 am

Re: Joomla Fireboard Forum to PHPBB

Post by zuze » Wed May 07, 2008 11:53 am

Just installed and ran Xmas Script 02., and got this message

Connecting to Database... OK
Populating Categories...
Invalid query:
TRUNCATE TABLE phpbb_categories
Table 'db23751xxxx.phpbb_categories' doesn't exist


I have Joomla 1.0.15, and Community Builder. This is my fist attempt, and I was looking to use Mehd'is php Bridge, but have not set it up yet.
Anyone has any insight on this?

edited... I was converting to phpBB3, instead to phpBB2
Last edited by zuze on Wed May 07, 2008 8:14 pm, edited 1 time in total.

zuze
Registered User
Posts: 7
Joined: Wed May 07, 2008 11:49 am

Re: Joomla Fireboard Forum to PHPBB

Post by zuze » Wed May 07, 2008 12:12 pm

I did run query in phpMyAdmin as suggested earlier by mkruer

Code: Select all

SELECT id, name, ordering*10 FROM jos_fb_categories
I gave me the list of categories in table. Then I ran convert.php , still got the same message as in above post.
there is no table in db under this name phpbb_categories.

zuze
Registered User
Posts: 7
Joined: Wed May 07, 2008 11:49 am

Re: Joomla Fireboard Forum to PHPBB

Post by zuze » Wed May 07, 2008 8:40 pm

I uploaded phpBB 2.023 version, but I get blank screen when I try to run board's installation. I tried several times. Did not get anywhere with phpBB2 :(
*solved: installation for phpBB2 is from different directory :)
Last edited by zuze on Wed May 07, 2008 9:43 pm, edited 1 time in total.

cwknox
Registered User
Posts: 9
Joined: Mon Apr 07, 2008 6:01 am

Re: Joomla Fireboard Forum to PHPBB

Post by cwknox » Wed May 07, 2008 9:32 pm

I was able to do it with phpBB version 2.0.22 (I believe). Support for that conversion script is very thin. I am not a programmer and know just enough about PHP and phpBB to be dangerous. I consider myself lucky to have got the thing working.

Some things that I did that I think made my migration successful:
  • Installed phpBB 2.0.22 using a prefix of php2 for the tables.
    Got the phpBB2 working first.
  • Read error messages carefully and correlated them against table names viewed through MySQL tools.
  • Searched with Google using text of error messages.
  • Posted my questions here and answers when I discovered things on my own.
No one should mistake this for support. Just comparing notes.

phreak_02
Registered User
Posts: 18
Joined: Thu Jun 19, 2008 1:46 pm

Re: Joomla Fireboard Forum to PHPBB

Post by phreak_02 » Thu Jun 19, 2008 1:58 pm

Hi there,

I'm trying to switch from Fireboard too (tried it already with a FB > SMF > PHPBB3 Conversion).

I achieve following error when i use the XMas Script 2. I've read the previous posts but it doesn't lead me to a solution. Is there someone who can tell me, what the Error in the SQL Syntax could be about. I'm using mySQL 5.0.27.

Thanx for help,
phreak
Importing data from Fireboard

Connecting to Database... OK
Populating Categories...
Inserted 18 Rows... OK
Populating Forums...
Invalid query:
INSERT INTO phpbb2_forums (forum_id, cat_id, forum_name, forum_desc, forum_status, forum_order, forum_posts, forum_topics, forum_last_post_id, prune_next, prune_enable, auth_view, auth_read, auth_post, auth_reply, auth_edit,auth_delete, auth_sticky, auth_announce, auth_vote, auth_pollcreate, auth_attachments) SELECT id, parent, name, description, 0, ordering, c.posts, b.topics, d.last, NULL, 0, 0, 1, 1, 1, 1, 1, 3, 3, 1, 1, 0 FROM jos_fb_categories LEFT JOIN (SELECT catid, COUNT(*) AS topics FROM jos_fb_messages WHERE id=thread GROUP BY catid) b ON jos_fb_categories.id=b.catid LEFT JOIN (SELECT catid, COUNT(*) AS posts FROM jos_fb_messages GROUP BY catid) c ON jos_fb_categories.id=c.catid LEFT JOIN (SELECT catid, MAX(id) AS last FROM jos_fb_messages GROUP BY catid) d ON jos_fb_categories.id=d.catid WHERE parent != 0 GROUP BY id;
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT catid, COUNT(*) AS topics FROM jos_fb_messages WHERE id=

User avatar
mkruer
Registered User
Posts: 74
Joined: Mon Apr 28, 2003 7:49 pm

Re: Joomla Fireboard Forum to PHPBB

Post by mkruer » Thu Jun 19, 2008 7:21 pm

Did you install phpbb2.0.22 or 2.0.23? if you use the 23 version it will not work.

phreak_02
Registered User
Posts: 18
Joined: Thu Jun 19, 2008 1:46 pm

Re: Joomla Fireboard Forum to PHPBB

Post by phreak_02 » Sat Jun 21, 2008 12:17 pm

Hi mkruer,

No, its running 2.0.22.

Maybe it has something to do with the Database which runs MySQL 5.0.27 ?

Thanx for help,
phreak

User avatar
mkruer
Registered User
Posts: 74
Joined: Mon Apr 28, 2003 7:49 pm

Re: Joomla Fireboard Forum to PHPBB

Post by mkruer » Fri Jun 27, 2008 7:07 am

Perhaps. You might want to check the previous posts I think someone else had the same error. if you know how to use phpmyadmin you should be able to run the query manual, with out the insert. At the very least it should tell you better what is missing.

fourteen007
Registered User
Posts: 2
Joined: Tue Jul 22, 2008 8:58 pm

Re: Joomla Fireboard Forum to PHPBB

Post by fourteen007 » Tue Jul 22, 2008 9:02 pm

Hi All,

thanks mkuser for the great code, I tested this on Joomla 1.0.15/FB 1.0.4/phpBB 2.0.23 and all worked great even I can still login with my admin account from FB to the new phpbb admin panel!!!!!!!!!!!!!!!

I only needed to comment this line in your code because of slashes issues and signatures exported excellent :
$signature = preg_replace ('/\'/', '\\\'', $signature);

I then installed phpBB3.0.2 and used the built in converter and all went very smooth but users cant login anymore, so I need to investigate this but so far you are the man!!! :D

fourteen007
Registered User
Posts: 2
Joined: Tue Jul 22, 2008 8:58 pm

Re: Joomla Fireboard Forum to PHPBB

Post by fourteen007 » Tue Jul 22, 2008 9:29 pm

sorry, my mistake, users can login at the phpBB3!!!!! ;)

phreak_02
Registered User
Posts: 18
Joined: Thu Jun 19, 2008 1:46 pm

Re: Joomla Fireboard Forum to PHPBB

Post by phreak_02 » Wed Aug 13, 2008 4:32 pm

Hi all,

I finally got one step ahead. I used the Xmas Script 0.2 and the converter gives me the feedback that everything is ok and "Completed...".

When i call my pbpBB 2.0.22 the frontpage looks ok, just latest post usernames are missing, but when i click on one of the forums there are no threads behind. it seems like it has soemthing todo with the converted users, as there are no users in the phpbb user table. The converter even says "Inserted 1 Users... OK".

My board got around 250 users and they are not converted. Did anybody come across this issue or knows how to fix it in the code ?

Thanx a lot
phreak_02

PS: I found out that the ' sign troubles the converter as well, so if anyone has a problem with the converter try to eliminate all ' signs in your database message texts.

Code: Select all

<?php
/*
Fireboard 1.0.x to phbBB2 2.0.x converter
Based on the phpbb2tosb.php script by Olle Johansson http://mambo.theyard.org/ and from Marcos Osorno http://www.blort.com
Based upon updated script from http://www.phpbb.com/community/viewtopic.php?f=10&t=371271&p=2026820

* Tested on: phpBB 2.0.22, Joomla 1.0.13 w/ Fireboard 1.0.3, PHP 5.2.3, MySQL 5.0.45
* Tested by executing from within the phpBB directory
* Will DESTROY all the data in your phpBB db and replace it with SB data! Does not append!

-------------Config---------------------*/
//MySQL Database host - usually 'localhost'
    $host='localhost';

//MySQL Database user
   $user='xxxxxx';

//MySQL Database password
   $pass='xxxxxx';

//MySQL Database name
   $db='xxxxxx';

// Mambo database prefix
    $mosConfig_dbprefix = "jos_";

// phpBB2 database prefix
    $phpbb_dbprefix = "phpbb_";

// Temp DB prefix used for temporary tables in the script
// set this to a prefix you are NOT using on your mySQL db
    $temp_dbprefix = "temp_";
/* ---------------------------------------*/
    define("BBCODE_UID_LEN", 10);
    $bbcode_on = 'true';

    ini_set("magic_quotes_gpc", "1");
    set_magic_quotes_runtime ( 0 );

   echo "<?xml version=\"1.0\"?>";
   echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
   echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
   echo "<head>";
   echo "<title>Importing data from Fireboard</title>";
   echo "<meta http-equiv=\"Content-Type\" content=\"text/html; iso-8859-1\" />";
   echo "</head>";
   echo "<body>";
   echo "<h1>Importing data from Fireboard</h1>"; flush();

//Connect to and select Database
    echo "Connecting to Database...\n"; flush();
    $lnk = mysql_connect($host, $user, $pass) or die ('Not connected: ' . mysql_error());
    mysql_select_db($db, $lnk) or die('Error: '.mysql_error());
    echo "OK\n"; flush();

// PHPBB Categories > Forums > Topics > Posts > Posts Text

// Part One - Populate Categories
    echo "<br />Populating Categories...\n"; flush();
// Import the main categories
// Prune those Fireboard categories which have a parent
// Multiply the ordering by 10 to conform to phpbb2 format
// if fb_categories.parent = 0 then category is a phpbb cateogory

//clear phpbb categories table
    $query = "TRUNCATE TABLE {$phpbb_dbprefix}categories";
    $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

// if fb_categories.parent = 0 then category is a category
    $query = "INSERT INTO {$phpbb_dbprefix}categories (cat_id, cat_title, cat_order)
           SELECT id, name, ordering*10
           FROM {$mosConfig_dbprefix}fb_categories
           WHERE {$mosConfig_dbprefix}fb_categories.parent = '0'
           ORDER by ordering";
    $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

//Count Rows Inserted
   $query = "SELECT COUNT(*)
           FROM {$phpbb_dbprefix}categories;";
    $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
    list($count) = mysql_fetch_row($result);
    echo "<br />Inserted $count Rows... OK"; flush();

// clear phpbb forums table
    $query = "TRUNCATE TABLE {$phpbb_dbprefix}forums";
    $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

// Part Two - Populate Forums
// phpbb2 considers category header messages as forums
// these are indicated in sb by setting fb_messages.id=sb_messages.thread
// the actual messages can be detected by seeing that fb_messages.parent != 0
   echo "<br />Populating Forums...\n"; flush();
    $query = "INSERT INTO {$phpbb_dbprefix}forums (forum_id, cat_id, forum_name, forum_desc, forum_status, forum_order, forum_posts, forum_topics, forum_last_post_id, prune_next, prune_enable, auth_view, auth_read, auth_post, auth_reply, auth_edit,auth_delete, auth_sticky, auth_announce, auth_vote, auth_pollcreate, auth_attachments)
           SELECT id, parent, name, description, 0, ordering, c.posts, b.topics, d.last, NULL, 0, 0, 1, 1, 1, 1, 1, 3, 3, 1, 1, 0
           FROM {$mosConfig_dbprefix}fb_categories
           LEFT JOIN (SELECT catid, COUNT(*) AS topics FROM {$mosConfig_dbprefix}fb_messages WHERE id=thread GROUP BY catid) b
           ON {$mosConfig_dbprefix}fb_categories.id=b.catid
           LEFT JOIN (SELECT catid, COUNT(*) AS posts FROM {$mosConfig_dbprefix}fb_messages GROUP BY catid) c
           ON {$mosConfig_dbprefix}fb_categories.id=c.catid
           LEFT JOIN (SELECT catid, MAX(id) AS last FROM {$mosConfig_dbprefix}fb_messages GROUP BY catid) d
           ON {$mosConfig_dbprefix}fb_categories.id=d.catid
           WHERE parent != 0
           GROUP BY id;";
    $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

//Count Rows Inserted
   $query = "SELECT COUNT(*)
           FROM {$phpbb_dbprefix}forums;";
    $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
    list($count) = mysql_fetch_row($result);
    echo "<br />Inserted $count Rows... OK"; flush();

// Part Three - Populate Topics
// if fb_messages.parent = 0 then messages is a topic
   echo "<br />Populating Topics...\n"; flush();
    $query = "TRUNCATE TABLE {$phpbb_dbprefix}topics";
    $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

       // Some messages still had the single quote in them without a \
    // which was causing import problems so we
    // removed the single quote and replaced it with HTML for the quote
   // Run a query taking simple board messages and finding which are topics by thread=id then merge with count table above
    // also subtract one from the reply count because it counts itself under this algorithm
    $query = "SELECT m.id, m.catid, m.userid, m.subject, m.time, m.hits, reply - 1 AS reply, locked, '0', '0', c.min, c.max, '0'
           FROM {$mosConfig_dbprefix}fb_messages AS m
           JOIN (SELECT thread, MIN(id) AS min, MAX(id) as max, COUNT(id) as reply
           FROM {$mosConfig_dbprefix}fb_messages GROUP BY thread) c
           WHERE m.thread=m.id AND m.parent=0 AND c.thread=m.thread";
    $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

    while ( $row = mysql_fetch_object( $result ) ) {
      $subject = stripslashes( $row->subject );
      $subject = preg_replace ('/\'/', '\\\'', $subject);
      $query = "INSERT INTO {$phpbb_dbprefix}topics(topic_id, forum_id, topic_poster, topic_title, topic_time,topic_views, topic_replies, topic_status, topic_vote, topic_type,topic_first_post_id, topic_last_post_id, topic_moved_id)VALUES ('$row->id', '$row->catid', '$row->userid', '$subject', '$row->time','$row->hits', '$row->reply', '$row->locked', '0', '','$row->min', '$row->max', '0')";
      $updateresult = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
    }
    mysql_free_result($result);

//Count Rows Inserted
   $query = "SELECT COUNT(*)
           FROM {$phpbb_dbprefix}topics;";
    $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
    list($count) = mysql_fetch_row($result);
    echo "<br />Inserted $count Rows... OK\n"; flush();

// Part Four - Populate Messages Table
    echo "<br />Populating Posts...\n"; flush();
    $query = "TRUNCATE TABLE {$phpbb_dbprefix}posts";
    $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

    $query = "INSERT INTO {$phpbb_dbprefix}posts (post_id, topic_id, forum_id, poster_id, post_time, poster_ip, post_username, enable_bbcode, enable_html, enable_smilies, enable_sig, post_edit_time, post_edit_count)
           SELECT id, thread, catid, userid, time, HEX(INET_ATON(ip)), name, 1, 0, topic_emoticon, 1, NULL, 0 FROM {$mosConfig_dbprefix}fb_messages";
    $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

   $query = "SELECT COUNT(*) FROM {$phpbb_dbprefix}posts;";
    $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
    list($count) = mysql_fetch_row($result);
    echo "<br />Inserted $count Rows... OK"; flush();

//Populate Messages_Text Table
    echo "<br />Populating Post Text & Converting Fireboard Syntax to phhBB Syntax... (This may take a while)\n"; flush();
    $query = "TRUNCATE TABLE {$phpbb_dbprefix}posts_text";
    $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

   $query = "SELECT m.id, m.subject, t.message
           FROM {$mosConfig_dbprefix}fb_messages_text AS t, {$mosConfig_dbprefix}fb_messages AS m WHERE m.id = t.mesid";
    $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

// uses phpbb's bbcode encoder to make a uid for each message
// which is required for the bbcode to work in phpbb
    while ( $row = mysql_fetch_object( $result ) ) {
      $bbcode_uid = ( $bbcode_on ) ? make_bbcode_uid() : '';
      $message = prep ( $row->message);
      $message = fixquotes ($message);
      $subject = stripslashes( $row->subject );
      $subject = preg_replace ('/\'/', '\\\'', $subject);
      $query = "INSERT INTO {$phpbb_dbprefix}posts_text (post_id, bbcode_uid, post_subject, post_text)
              VALUES ('$row->id','$bbcode_uid', '$subject', '$message')";
       $updateresult = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
    }
    mysql_free_result($result);

//Count Rows Inserted
   $query = "SELECT COUNT(*) FROM {$phpbb_dbprefix}posts_text;";
    $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
    list($count) = mysql_fetch_row($result);
    echo "<br />Inserted $count Rows... OK\n"; flush();

//Populate Users Table , Note user_sig_bbcode_uid is a radom, md5 checksum
    echo "<br />Populating Users Table From Joomla...\n";
    $query = "TRUNCATE TABLE {$phpbb_dbprefix}users";
    $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

    $query = "INSERT INTO {$phpbb_dbprefix}users (user_id, user_active, username, user_password, user_session_time, user_lastvisit, user_regdate, user_level, user_dateformat, user_email)
           SELECT id,
            CASE block
               WHEN 0 THEN 1
               ELSE 0 END,
            username,
            password,
            UNIX_TIMESTAMP(lastvisitDate),
            UNIX_TIMESTAMP(lastvisitDate),
            UNIX_TIMESTAMP(registerDate),
            CASE gid
               WHEN 25 THEN 1
               WHEN 24 THEN 1
               ELSE 0 END,
               'd M Y H:i',
               email
         FROM {$mosConfig_dbprefix}users ORDER by id;";
   $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

   $query = "SELECT COUNT(*) FROM {$phpbb_dbprefix}users;";
    $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
    list($count) = mysql_fetch_row($result);
    echo "<br />Inserted $count Users... OK\n"; flush();

//Update Info From Fireboard
   echo "<br />Updating Users Table From Fireboard...\n";
    $query = "UPDATE {$phpbb_dbprefix}users, {$mosConfig_dbprefix}fb_users
           SET user_posts=posts, user_avatar=avatar, user_icq=ICQ, user_website=websitename, user_from=location, user_sig=signature, user_aim=AIM, user_yim=YIM, user_msnm=MSN, user_interests=personalText
           WHERE user_id=userid;";
   $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

// uses phpbb's bbcode encoder to make a uid for each message
// which is required for the bbcode to work in phpbb
// clean up bbcode in signatures and ad bbcode_uid
    $query = "SELECT user_id, user_sig
           FROM {$phpbb_dbprefix}users
           ORDER BY user_id;";
    $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

    while ( $row = mysql_fetch_object( $result ) ) {
      $bbcode_uid = ( $bbcode_on ) ? make_bbcode_uid() : '';
      $signature = prep ( $row->user_sig);
    //  $signature = preg_replace ('/\'/', '\\\'', $signature);
      $query = "UPDATE {$phpbb_dbprefix}users
              SET user_sig='$signature', user_sig_bbcode_uid='$bbcode_uid'
              WHERE user_id=$row->user_id";
      $updateresult = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
    }
    mysql_free_result($result);

   $query = "SELECT COUNT(*) FROM {$phpbb_dbprefix}users;";
    $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
    list($count) = mysql_fetch_row($result);

//Clean up avatar, only for off site avatar, Onsite Avatars will be deleted
    echo "<br />Updated $count Users... OK\n"; flush();
    $query = "UPDATE {$phpbb_dbprefix}users
           SET user_avatar_type = 3
           WHERE user_avatar LIKE 'http://%';";
   $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

   $query = "UPDATE {$phpbb_dbprefix}users
           SET user_avatar_type = 0, user_avatar = NULL
           WHERE user_avatar NOT LIKE 'http://%';";
   $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

   // create a group for each user
   echo "<br />Updating Users Groups...\n"; flush();
    $query = "TRUNCATE TABLE {$phpbb_dbprefix}groups";
    $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

    $query = "INSERT INTO {$phpbb_dbprefix}groups (group_id, group_type, group_name, group_description, group_moderator, group_single_user)
           SELECT user_id, '1', '', 'Personal User', '0', '1'
           FROM {$phpbb_dbprefix}users ORDER BY user_id";
    $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

// have each user join their own group
    $query = "TRUNCATE TABLE {$phpbb_dbprefix}user_group";
    $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
    $query = "INSERT INTO {$phpbb_dbprefix}user_group (group_id, user_id, user_pending)
           SELECT user_id, user_id, '0'
           FROM {$phpbb_dbprefix}users
           ORDER BY user_id";
    $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
    echo "OK\n"; flush();

//insert ranks
   echo "<br />Inserting User Ranks...\n"; flush();
    $query = "TRUNCATE TABLE {$phpbb_dbprefix}ranks";
    $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
    $query = "INSERT INTO {$phpbb_dbprefix}ranks (rank_id, rank_title, rank_min, rank_special, rank_image) SELECT rank_id, rank_title, rank_min, rank_special, rank_image
           FROM {$mosConfig_dbprefix}fb_ranks
           ORDER BY rank_id";
    $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

    echo "OK\n"; flush();
    echo "<br />Complete...\n"; flush();

   echo "</body>";
   echo "</html>"; flush();

    //--- Function to prepare strings for MySQL storage ---/
    function prep($s) {
    // Insert bbcode_uid necessary for bbcode to be recognized by phpbb2
        global $bbcode_uid;

        // <strong> </strong>
        $s = preg_replace('/\[b\]/', '[b:'.$bbcode_uid.']', $s);
        $s = preg_replace('/\[\/b\]/', '[/b:'.$bbcode_uid.']', $s);

        // <em> </em>
        $s = preg_replace('/\[i\]/', '[i:'.$bbcode_uid.']', $s);
        $s = preg_replace('/\[\/i\]/', '[/i:'.$bbcode_uid.']', $s);

        // <u> </u>
        $s = preg_replace('/\[u\]/', '[u:'.$bbcode_uid.']', $s);
        $s = preg_replace('/\[\/u\]/', '[/u:'.$bbcode_uid.']', $s);

        // quote
        $s = preg_replace('/\[quote\]/', '[quote:'.$bbcode_uid.']', $s);
        $s = preg_replace('/\[\/quote\]/', '[/quote:'.$bbcode_uid.']', $s);

        // url with "
        $s = preg_replace('/\[url=\\\&quot\;(.*?)\\\&quot\;\](.*?)/', '[url=\\1]\\2', $s);

        // image
        $s = preg_replace('/\[img(.*?)\](.*?)\[\/img(.*?)\]/si', '[img:'.$bbcode_uid.']'.'\\2[/img:'.$bbcode_uid.']', $s);

        // color
        $s = preg_replace('/\[color=(.*?)\]/', '[color=\\1:'.$bbcode_uid.']', $s);
        $s = preg_replace('/\[\/color\]/', '[/color:'.$bbcode_uid.']', $s);

        // size fb uses size 1 to 5,  phpbb2 uses size 1 to 29; will use 1 = 7, 2=9, 3=12, 4=18, 5=24
        $s = preg_replace('/\[size=1\]/', '[size=7:'.$bbcode_uid.']', $s);
        $s = preg_replace('/\[size=2\]/', '[size=9:'.$bbcode_uid.']', $s);
        $s = preg_replace('/\[size=3\]/', '[size=12:'.$bbcode_uid.']', $s);
        $s = preg_replace('/\[size=4\]/', '[size=18:'.$bbcode_uid.']', $s);
        $s = preg_replace('/\[size=5\]/', '[size=24:'.$bbcode_uid.']', $s);
        $s = preg_replace('/\[\/size\]/', '[/size:'.$bbcode_uid.']', $s);

        // code
        $s = preg_replace('/\[code(.*?)\]/','[code:'.$bbcode_uid.']', $s);
        $s = preg_replace('/\[\/code(.*?)\]/', '[/code:'.$bbcode_uid.']', $s);

        // lists
        $s = preg_replace('/\[ul\]/', '[list:'.$bbcode_uid.']', $s);
      $s = preg_replace('/\[\/ul\]/', '[/list:u:'.$bbcode_uid.']', $s);
        $s = preg_replace('/\[ol\]/', '[list=1:'.$bbcode_uid.']', $s);
      $s = preg_replace('/\[\/ol\]/', '[/list:o:'.$bbcode_uid.']', $s);
        $s = preg_replace('/\[li\]/', '[*:'.$bbcode_uid.']', $s);
        $s = preg_replace('/\[\/li\]/', '', $s);

        return $s;
    }

// fixed the quotes.
   function fixquotes($q) {
        global $bbcode_uid;
      $q = preg_replace('/\[b:'.$bbcode_uid.'\](.*?) wrote:\[\/b:'.$bbcode_uid.'\]\r\n\[quote:'.$bbcode_uid.'\]/', '[quote:'.$bbcode_uid.'="\\1"]', $q );
      return $q;
    }

// function taken from phpbb2 functions file Unique ID for this message..
    function make_bbcode_uid()
    {
            $uid = md5(mt_rand());
            $uid = substr($uid, 0, BBCODE_UID_LEN);
            return $uid;
    }

//last minute accounts to be added note phpbb2admin password is "admn" Besure to remove once you have tested the  site.
   $query = "INSERT INTO {$phpbb_dbprefix}users (user_id, user_active, username, user_password, user_session_time, user_session_page, user_lastvisit, user_regdate, user_level, user_posts, user_timezone, user_style, user_lang, user_dateformat, user_new_privmsg, user_unread_privmsg, user_last_privmsg, user_login_tries, user_last_login_try, user_emailtime, user_viewemail, user_attachsig, user_allowhtml, user_allowbbcode, user_allowsmile, user_allowavatar, user_allow_pm, user_allow_viewonline, user_notify, user_notify_pm, user_popup_pm, user_rank, user_avatar, user_avatar_type, user_email, user_icq, user_website, user_from, user_sig, user_sig_bbcode_uid, user_aim, user_yim, user_msnm, user_occ, user_interests, user_actkey, user_newpasswd) VALUES
         (-1, 0, 'Anonymous', '', 0, 0, 0, 0, 0, 0, 0.00, NULL, '', '', 0, 0, 0, 0, 0, NULL, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, NULL, '', 0, '', '', '', '', '', NULL, '', '', '', '', '', '', ''),
         (2, 1, 'phpbb2admin', '21232f297a57a5a743894a0e4a801fc3', 1198282415, 0, 1198282415, 0, 1, 1, 0.00, 1, 'english', 'd M Y h:i a', 0, 0, 0, 0, 0, NULL, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, '', 0, 'admin@yourdomain.com', '', '', '', '', NULL, '', '', '', '', '', '', '');";
    $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

   $query = "INSERT INTO {$phpbb_dbprefix}user_group (group_id, user_id, user_pending) VALUES
         (1, -1, 0),
         (2, 2, 0);";
   $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

?>

digitalni
Registered User
Posts: 2
Joined: Fri Aug 29, 2008 9:42 am

Re: Joomla Fireboard Forum to PHPBB

Post by digitalni » Fri Aug 29, 2008 9:45 am

Can someone please modify the code so it drops or deals with this character: '
When it reaches this character in posts_text it dies... I'm trying to convert a fireboard forum which has over 20000 posts :(

Thanks!!!

digitalni
Registered User
Posts: 2
Joined: Fri Aug 29, 2008 9:42 am

Re: Joomla Fireboard Forum to PHPBB

Post by digitalni » Fri Aug 29, 2008 11:09 am

I modified the script to use mysql_real_escape_string on post text so it would not run into mysql error due to this char: '

Code: Select all

    <?php
        /*
        Fireboard 1.0.x to phbBB2 2.0.x converter
        0.0  Based on the phpbb2tosb.php script by Olle Johansson http://mambo.theyard.org/ and from Marcos Osorno http://www.blort.com
        0.1  Based upon updated script from http://www.phpbb.com/community/viewtopic.php?f=10&t=371271&p=2026820
        0.2  The tweeks here are based on
             http://www.phpbb.com/community/viewtopic.php?f=10&t=588149#p3598205

        * Tested on: phpBB 2.0.22, Joomla 1.0.13 w/ Fireboard 1.0.3, PHP 5.2.3, MySQL 5.0.45
        * Tested by executing from within the phpBB directory
        * Will DESTROY all the data in your phpBB db and replace it with SB data! Does not append!

        -------------Config---------------------*/
        //MySQL Database host - usually 'localhost'
            $host='localhost';

        //MySQL Database user
           $user='dbu1084815';

        //MySQL Database password
           $pass='gorazdex';

        //MySQL Database name
           $db='db1084815-v3';

        // Mambo database prefix
            $mosConfig_dbprefix = "jos_";

        // phpBB2 database prefix
            $phpbb_dbprefix = "phpbb2_";

        // Temp DB prefix used for temporary tables in the script
        // set this to a prefix you are NOT using on your mySQL db
            $temp_dbprefix = "temp_";
        /* ---------------------------------------*/
            define("BBCODE_UID_LEN", 10);
            $bbcode_on = 'true';

            ini_set("magic_quotes_gpc", "1");
            set_magic_quotes_runtime ( 0 );

           echo "<?xml version=\"1.0\"?>";
           echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
           echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
           echo "<head>";
           echo "<title>Importing data from Fireboard</title>";
           echo "<meta http-equiv=\"Content-Type\" content=\"text/html; iso-8859-1\" />";
           echo "</head>";
           echo "<body>";
           echo "<h1>Importing data from Fireboard</h1>"; flush();

        //Connect to and select Database
            echo "Connecting to Database...\n"; flush();
            $lnk = mysql_connect($host, $user, $pass) or die ('Not connected: ' . mysql_error());
    $sqlFix = "SET SESSION SQL_BIG_SELECTS=1";
    $resFix = mysql_query($sqlFix);

            mysql_select_db($db, $lnk) or die('Error: '.mysql_error());
            echo "OK\n"; flush();

        // PHPBB Categories > Forums > Topics > Posts > Posts Text

        // Part One - Populate Categories
            echo "<br />Populating Categories...\n"; flush();
        // Import the main categories
        // Prune those Fireboard categories which have a parent
        // Multiply the ordering by 10 to conform to phpbb2 format
        // if fb_categories.parent = 0 then category is a phpbb cateogory

       //I did away with the pruning of Fireboard categories with a
       //parent.  I took the 0 out of the where clause and got
       //everything since I had child boards.  This is an area that
       //will need a clean up to go to phpBB3. 
        //clear phpbb categories table
            $query = "TRUNCATE TABLE {$phpbb_dbprefix}categories";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

        // if fb_categories.parent = 0 then category is a category
            $query = "INSERT INTO {$phpbb_dbprefix}categories (cat_id, cat_title, cat_order)
                   SELECT id, name, ordering*10
                   FROM {$mosConfig_dbprefix}fb_categories
                   ORDER by ordering";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

        //Count Rows Inserted
           $query = "SELECT COUNT(*)
                   FROM {$phpbb_dbprefix}categories;";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
            list($count) = mysql_fetch_row($result);
            echo "<br />Inserted $count Rows... OK"; flush();

        // clear phpbb forums table
            $query = "TRUNCATE TABLE {$phpbb_dbprefix}forums";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

        // Part Two - Populate Forums
        // phpbb2 considers category header messages as forums
        // these are indicated in sb by setting fb_messages.id=sb_messages.thread
        // the actual messages can be detected by seeing that fb_messages.parent != 0
           echo "<br />Populating Forums...\n"; flush();
            $query = "INSERT INTO {$phpbb_dbprefix}forums (forum_id, cat_id, forum_name, forum_desc, forum_status, forum_order, forum_posts, forum_topics, forum_last_post_id, prune_next, prune_enable, auth_view, auth_read, auth_post, auth_reply, auth_edit,auth_delete, auth_sticky, auth_announce, auth_vote, auth_pollcreate, auth_attachments)
                   SELECT id, parent, name, description, 0, ordering, c.posts, b.topics, d.last, NULL, 0, 0, 1, 1, 1, 1, 1, 3, 3, 1, 1, 0
                   FROM {$mosConfig_dbprefix}fb_categories
                   LEFT JOIN (SELECT catid, COUNT(*) AS topics FROM {$mosConfig_dbprefix}fb_messages WHERE id=thread GROUP BY catid) b
                   ON {$mosConfig_dbprefix}fb_categories.id=b.catid
                   LEFT JOIN (SELECT catid, COUNT(*) AS posts FROM {$mosConfig_dbprefix}fb_messages GROUP BY catid) c
                   ON {$mosConfig_dbprefix}fb_categories.id=c.catid
                   LEFT JOIN (SELECT catid, MAX(id) AS last FROM {$mosConfig_dbprefix}fb_messages GROUP BY catid) d
                   ON {$mosConfig_dbprefix}fb_categories.id=d.catid
                   WHERE parent != 0
                   GROUP BY id;";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

        //Count Rows Inserted
           $query = "SELECT COUNT(*)
                   FROM {$phpbb_dbprefix}forums;";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
            list($count) = mysql_fetch_row($result);
            echo "<br />Inserted $count Rows... OK"; flush();

        // Part Three - Populate Topics
        // if fb_messages.parent = 0 then messages is a topic
           echo "<br />Populating Topics...\n"; flush();
            $query = "TRUNCATE TABLE {$phpbb_dbprefix}topics";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

               // Some messages still had the single quote in them without a \
            // which was causing import problems so we
            // removed the single quote and replaced it with HTML for the quote
           // Run a query taking simple board messages and finding which are topics by thread=id then merge with count table above
            // also subtract one from the reply count because it counts itself under this algorithm
            $query = "SELECT m.id, m.catid, m.userid, m.subject, m.time, m.hits, reply - 1 AS reply, locked, '0', '0', c.min, c.max, '0'
                   FROM {$mosConfig_dbprefix}fb_messages AS m
                   JOIN (SELECT thread, MIN(id) AS min, MAX(id) as max, COUNT(id) as reply
                   FROM {$mosConfig_dbprefix}fb_messages GROUP BY thread) c
                   WHERE m.thread=m.id AND m.parent=0 AND c.thread=m.thread";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

            while ( $row = mysql_fetch_object( $result ) ) {
              $subject = stripslashes( $row->subject );
              $subject = preg_replace ('/\'/', '\\\'', $subject);
              $query = "INSERT INTO {$phpbb_dbprefix}topics(topic_id, forum_id, topic_poster, topic_title, topic_time,topic_views, topic_replies, topic_status, topic_vote, topic_type,topic_first_post_id, topic_last_post_id, topic_moved_id)VALUES ('$row->id', '$row->catid', '$row->userid', '$subject', '$row->time','$row->hits', '$row->reply', '$row->locked', '0', '','$row->min', '$row->max', '0')";
              $updateresult = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
            }
            mysql_free_result($result);

        //Count Rows Inserted
           $query = "SELECT COUNT(*)
                   FROM {$phpbb_dbprefix}topics;";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
            list($count) = mysql_fetch_row($result);
            echo "<br />Inserted $count Rows... OK\n"; flush();

        // Part Four - Populate Messages Table
            echo "<br />Populating Posts...\n"; flush();
            $query = "TRUNCATE TABLE {$phpbb_dbprefix}posts";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

            $query = "INSERT INTO {$phpbb_dbprefix}posts (post_id, topic_id, forum_id, poster_id, post_time, poster_ip, post_username, enable_bbcode, enable_html, enable_smilies, enable_sig, post_edit_time, post_edit_count)
                   SELECT id, thread, catid, userid, time, HEX(INET_ATON(ip)), name, 1, 0, topic_emoticon, 1, NULL, 0 FROM {$mosConfig_dbprefix}fb_messages";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

           $query = "SELECT COUNT(*) FROM {$phpbb_dbprefix}posts;";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
            list($count) = mysql_fetch_row($result);
            echo "<br />Inserted $count Rows... OK"; flush();

        //Populate Messages_Text Table
            echo "<br />Populating Post Text & Converting Fireboard Syntax to phhBB Syntax... (This may take a while)\n"; flush();
            $query = "TRUNCATE TABLE {$phpbb_dbprefix}posts_text";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

           $query = "SELECT m.id, m.subject, t.message
                   FROM {$mosConfig_dbprefix}fb_messages_text AS t, {$mosConfig_dbprefix}fb_messages AS m WHERE m.id = t.mesid";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

        // uses phpbb's bbcode encoder to make a uid for each message
        // which is required for the bbcode to work in phpbb
            while ( $row = mysql_fetch_object( $result ) ) {
              $bbcode_uid = ( $bbcode_on ) ? make_bbcode_uid() : '';
              $message = prep ( $row->message);
              $message = fixquotes ($message);
              $message = mysql_real_escape_string ($message);
              $subject = stripslashes( $row->subject );
              $subject = preg_replace ('/\'/', '\\\'', $subject);              
              $query = "INSERT INTO {$phpbb_dbprefix}posts_text (post_id, bbcode_uid, post_subject, post_text)
                      VALUES ('$row->id','$bbcode_uid', '$subject', '$message')";
               $updateresult = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
            }
            mysql_free_result($result);

        //Count Rows Inserted
           $query = "SELECT COUNT(*) FROM {$phpbb_dbprefix}posts_text;";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
            list($count) = mysql_fetch_row($result);
            echo "<br />Inserted $count Rows... OK\n"; flush();

        //Populate Users Table , Note user_sig_bbcode_uid is a radom, md5 checksum
            echo "<br />Populating Users Table From Joomla...\n";
            $query = "TRUNCATE TABLE {$phpbb_dbprefix}users";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

            $query = "INSERT INTO {$phpbb_dbprefix}users (user_id, user_active, username, user_password, user_session_time, user_lastvisit, user_regdate, user_level, user_dateformat, user_email)
                   SELECT id,
                    CASE block
                       WHEN 0 THEN 1
                       ELSE 0 END,
                    username,
                    password,
                    UNIX_TIMESTAMP(lastvisitDate),
                    UNIX_TIMESTAMP(lastvisitDate),
                    UNIX_TIMESTAMP(registerDate),
                    CASE gid
                       WHEN 25 THEN 1
                       WHEN 24 THEN 1
                       ELSE 0 END,
                       'd M Y H:i',
                       email
                 FROM {$mosConfig_dbprefix}users ORDER by id;";
           $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

           $query = "SELECT COUNT(*) FROM {$phpbb_dbprefix}users;";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
            list($count) = mysql_fetch_row($result);
            echo "<br />Inserted $count Users... OK\n"; flush();

        //Update Info From Fireboard
           echo "<br />Updating Users Table From Fireboard...\n";
            $query = "UPDATE {$phpbb_dbprefix}users, {$mosConfig_dbprefix}fb_users
                   SET user_posts=posts, user_avatar=avatar, user_icq=ICQ, user_website=websitename, user_from=location, user_sig=signature, user_aim=AIM, user_yim=YIM, user_msnm=MSN, user_interests=personalText
                   WHERE user_id=userid;";
           $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

        // uses phpbb's bbcode encoder to make a uid for each message
        // which is required for the bbcode to work in phpbb
        // clean up bbcode in signatures and ad bbcode_uid
       // Fireboard had inserted backslashes \\ everywhere which was
       // causing lots of trouble.  I punted
       // and selected the signature as null, in effect, leaving it
       // behind.  Not worth the trouble for me to clean it up.  Users
       // can put their sigs back themselves.
            //$query = "SELECT user_id, signature
            $query = "SELECT user_id, NULL
                   FROM {$phpbb_dbprefix}users
                   ORDER BY user_id;";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

            while ( $row = mysql_fetch_object( $result ) ) {
              $bbcode_uid = ( $bbcode_on ) ? make_bbcode_uid() : '';
              $signature = prep ( $row->user_sig);
              $signature = preg_replace ('/\'/', '\\\'', $signature);
              $query = "UPDATE {$phpbb_dbprefix}users
                      SET user_sig='$signature', user_sig_bbcode_uid='$bbcode_uid'
                      WHERE user_id=$row->user_id";
              $updateresult = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
            }
            mysql_free_result($result);

           $query = "SELECT COUNT(*) FROM {$phpbb_dbprefix}users;";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
            list($count) = mysql_fetch_row($result);

        //Clean up avatar, only for off site avatar, Onsite Avatars will be deleted
            echo "<br />Updated $count Users... OK\n"; flush();
            $query = "UPDATE {$phpbb_dbprefix}users
                   SET user_avatar_type = 3
                   WHERE user_avatar LIKE 'http://%';";
           $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

           $query = "UPDATE {$phpbb_dbprefix}users
                   SET user_avatar_type = 0, user_avatar = NULL
                   WHERE user_avatar NOT LIKE 'http://%';";
           $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

           // create a group for each user
           echo "<br />Updating Users Groups...\n"; flush();
            $query = "TRUNCATE TABLE {$phpbb_dbprefix}groups";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

            $query = "INSERT INTO {$phpbb_dbprefix}groups (group_id, group_type, group_name, group_description, group_moderator, group_single_user)
                   SELECT user_id, '1', '', 'Personal User', '0', '1'
                   FROM {$phpbb_dbprefix}users ORDER BY user_id";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

        // have each user join their own group
            $query = "TRUNCATE TABLE {$phpbb_dbprefix}user_group";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
            $query = "INSERT INTO {$phpbb_dbprefix}user_group (group_id, user_id, user_pending)
                   SELECT user_id, user_id, '0'
                   FROM {$phpbb_dbprefix}users
                   ORDER BY user_id";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
            echo "OK\n"; flush();

        //insert ranks
           echo "<br />Inserting User Ranks...\n"; flush();
            $query = "TRUNCATE TABLE {$phpbb_dbprefix}ranks";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
            $query = "INSERT INTO {$phpbb_dbprefix}ranks (rank_id, rank_title, rank_min, rank_special, rank_image) SELECT rank_id, rank_title, rank_min, rank_special, rank_image
                   FROM {$mosConfig_dbprefix}fb_ranks
                   ORDER BY rank_id";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

            echo "OK\n"; flush();
            echo "<br />Complete...\n"; flush();

           echo "</body>";
           echo "</html>"; flush();

            //--- Function to prepare strings for MySQL storage ---/
            function prep($s) {
            // Insert bbcode_uid necessary for bbcode to be recognized by phpbb2
                global $bbcode_uid;

                // <strong> </strong>
                $s = preg_replace('/\[b\]/', '[b:'.$bbcode_uid.']', $s);
                $s = preg_replace('/\[\/b\]/', '[/b:'.$bbcode_uid.']', $s);

                // <em> </em>
                $s = preg_replace('/\[i\]/', '[i:'.$bbcode_uid.']', $s);
                $s = preg_replace('/\[\/i\]/', '[/i:'.$bbcode_uid.']', $s);

                // <u> </u>
                $s = preg_replace('/\[u\]/', '[u:'.$bbcode_uid.']', $s);
                $s = preg_replace('/\[\/u\]/', '[/u:'.$bbcode_uid.']', $s);

                // quote
                $s = preg_replace('/\[quote\]/', '[quote:'.$bbcode_uid.']', $s);
                $s = preg_replace('/\[\/quote\]/', '[/quote:'.$bbcode_uid.']', $s);

                // url with "
                $s = preg_replace('/\[url=\\\&quot\;(.*?)\\\&quot\;\](.*?)/', '[url=\\1]\\2', $s);

                // image
                $s = preg_replace('/\[img(.*?)\](.*?)\[\/img(.*?)\]/si', '[img:'.$bbcode_uid.']'.'\\2[/img:'.$bbcode_uid.']', $s);

                // color
                $s = preg_replace('/\[color=(.*?)\]/', '[color=\\1:'.$bbcode_uid.']', $s);
                $s = preg_replace('/\[\/color\]/', '[/color:'.$bbcode_uid.']', $s);

                // size fb uses size 1 to 5,  phpbb2 uses size 1 to 29; will use 1 = 7, 2=9, 3=12, 4=18, 5=24
                $s = preg_replace('/\[size=1\]/', '[size=7:'.$bbcode_uid.']', $s);
                $s = preg_replace('/\[size=2\]/', '[size=9:'.$bbcode_uid.']', $s);
                $s = preg_replace('/\[size=3\]/', '[size=12:'.$bbcode_uid.']', $s);
                $s = preg_replace('/\[size=4\]/', '[size=18:'.$bbcode_uid.']', $s);
                $s = preg_replace('/\[size=5\]/', '[size=24:'.$bbcode_uid.']', $s);
                $s = preg_replace('/\[\/size\]/', '[/size:'.$bbcode_uid.']', $s);

                // code
                $s = preg_replace('/\[code(.*?)\]/','[code:'.$bbcode_uid.']', $s);
                $s = preg_replace('/\[\/code(.*?)\]/', '[/code:'.$bbcode_uid.']', $s);

                // lists
                $s = preg_replace('/\[ul\]/', '[list:'.$bbcode_uid.']', $s);
              $s = preg_replace('/\[\/ul\]/', '[/list:u:'.$bbcode_uid.']', $s);
                $s = preg_replace('/\[ol\]/', '[list=1:'.$bbcode_uid.']', $s);
              $s = preg_replace('/\[\/ol\]/', '[/list:o:'.$bbcode_uid.']', $s);
                $s = preg_replace('/\[li\]/', '[*:'.$bbcode_uid.']', $s);
                $s = preg_replace('/\[\/li\]/', '', $s);

                return $s;
            }

        // fixed the quotes.
           function fixquotes($q) {
                global $bbcode_uid;
              $q = preg_replace('/\[b:'.$bbcode_uid.'\](.*?) wrote:\[\/b:'.$bbcode_uid.'\]\r\n\[quote:'.$bbcode_uid.'\]/', '[quote:'.$bbcode_uid.'="\\1"]', $q );
              return $q;
            }

        // function taken from phpbb2 functions file Unique ID for this message..
            function make_bbcode_uid()
            {
                    $uid = md5(mt_rand());
                    $uid = substr($uid, 0, BBCODE_UID_LEN);
                    return $uid;
            }

        //last minute accounts to be added note phpbb2admin password is "admn" Besure to remove once you have tested the  site.
       //After doing this, I'd suggest copying the admin password from
       //a known quantity, not this one.  It didn't work for me and
       //phpbb2admin had to do the forgot password thing like everyone
       //else.  Also, I'd suggest making the email address (just below
       //here) a variable for the config lines at the beginning.
       //--Chris
           $query = "INSERT INTO {$phpbb_dbprefix}users (user_id, user_active, username, user_password, user_session_time, user_session_page, user_lastvisit, user_regdate, user_level, user_posts, user_timezone, user_style, user_lang, user_dateformat, user_new_privmsg, user_unread_privmsg, user_last_privmsg, user_login_tries, user_last_login_try, user_emailtime, user_viewemail, user_attachsig, user_allowhtml, user_allowbbcode, user_allowsmile, user_allowavatar, user_allow_pm, user_allow_viewonline, user_notify, user_notify_pm, user_popup_pm, user_rank, user_avatar, user_avatar_type, user_email, user_icq, user_website, user_from, user_sig, user_sig_bbcode_uid, user_aim, user_yim, user_msnm, user_occ, user_interests, user_actkey, user_newpasswd) VALUES
                 (-1, 0, 'Anonymous', '', 0, 0, 0, 0, 0, 0, 0.00, NULL, '', '', 0, 0, 0, 0, 0, NULL, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, NULL, '', 0, '', '', '', '', '', NULL, '', '', '', '', '', '', ''),
                 (2, 1, 'phpbb2admin', '21232f297a57a5a743894a0e4a801fc3', 1198282415, 0, 1198282415, 0, 1, 1, 0.00, 1, 'english', 'd M Y h:i a', 0, 0, 0, 0, 0, NULL, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, '', 0, 'myadmin@my_site.com', '', '', '', '', NULL, '', '', '', '', '', '', '');";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

           $query = "INSERT INTO {$phpbb_dbprefix}user_group (group_id, user_id, user_pending) VALUES
                 (1, -1, 0),
                 (2, 2, 0);";
           $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

        ?>

There you go, worked for me :)

phreak_02
Registered User
Posts: 18
Joined: Thu Jun 19, 2008 1:46 pm

Re: Joomla Fireboard Forum to PHPBB

Post by phreak_02 » Sun Aug 31, 2008 11:53 am

Super digitalini,

Lets call the script: XMAS Script 0.3

Code: Select all

<?php
        /*
        Fireboard 1.0.x to phbBB2 2.0.x converter
        0.0  Based on the phpbb2tosb.php script by Olle Johansson http://mambo.theyard.org/ and from Marcos Osorno http://www.blort.com
        0.1  Based upon updated script from http://www.phpbb.com/community/viewtopic.php?f=10&t=371271&p=2026820
        0.2  The tweeks here are based on
             http://www.phpbb.com/community/viewtopic.php?f=10&t=588149#p3598205
        0.3 Slight change to avoid the ' issue (breaking the script if ' appears)

        * Tested on: phpBB 2.0.22, Joomla 1.0.13 w/ Fireboard 1.0.3, PHP 5.2.3, MySQL 5.0.45
        * Tested by executing from within the phpBB directory
        * Will DESTROY all the data in your phpBB db and replace it with SB data! Does not append!

        -------------Config---------------------*/
        //MySQL Database host - usually 'localhost'
            $host='localhost';

        // Your MySQL Database user
           $user='xxxx';

        // Your MySQL Database password
           $pass='xxxx';

        // Your MySQL Database name
           $db='xxxx';

        // Joomla database prefix - Use existing Prefix
            $mosConfig_dbprefix = "jos_";

        // phpBB2 database prefix - Use existing Prefix
            $phpbb_dbprefix = "phpbb2_";

        // Temp DB prefix used for temporary tables in the script
        // set this to a prefix you are NOT using on your mySQL db
            $temp_dbprefix = "temp_";
        /* ---------------------------------------*/
            define("BBCODE_UID_LEN", 10);
            $bbcode_on = 'true';

            ini_set("magic_quotes_gpc", "1");
            set_magic_quotes_runtime ( 0 );

           echo "<?xml version=\"1.0\"?>";
           echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
           echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
           echo "<head>";
           echo "<title>Importing data from Fireboard</title>";
           echo "<meta http-equiv=\"Content-Type\" content=\"text/html; iso-8859-1\" />";
           echo "</head>";
           echo "<body>";
           echo "<h1>Importing data from Fireboard</h1>"; flush();

        //Connect to and select Database
            echo "Connecting to Database...\n"; flush();
            $lnk = mysql_connect($host, $user, $pass) or die ('Not connected: ' . mysql_error());
    $sqlFix = "SET SESSION SQL_BIG_SELECTS=1";
    $resFix = mysql_query($sqlFix);

            mysql_select_db($db, $lnk) or die('Error: '.mysql_error());
            echo "OK\n"; flush();

        // PHPBB Categories > Forums > Topics > Posts > Posts Text

        // Part One - Populate Categories
            echo "<br />Populating Categories...\n"; flush();
        // Import the main categories
        // Prune those Fireboard categories which have a parent
        // Multiply the ordering by 10 to conform to phpbb2 format
        // if fb_categories.parent = 0 then category is a phpbb cateogory

       //I did away with the pruning of Fireboard categories with a
       //parent.  I took the 0 out of the where clause and got
       //everything since I had child boards.  This is an area that
       //will need a clean up to go to phpBB3. 
        //clear phpbb categories table
            $query = "TRUNCATE TABLE {$phpbb_dbprefix}categories";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

        // if fb_categories.parent = 0 then category is a category
            $query = "INSERT INTO {$phpbb_dbprefix}categories (cat_id, cat_title, cat_order)
                   SELECT id, name, ordering*10
                   FROM {$mosConfig_dbprefix}fb_categories
                   ORDER by ordering";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

        //Count Rows Inserted
           $query = "SELECT COUNT(*)
                   FROM {$phpbb_dbprefix}categories;";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
            list($count) = mysql_fetch_row($result);
            echo "<br />Inserted $count Rows... OK"; flush();

        // clear phpbb forums table
            $query = "TRUNCATE TABLE {$phpbb_dbprefix}forums";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

        // Part Two - Populate Forums
        // phpbb2 considers category header messages as forums
        // these are indicated in sb by setting fb_messages.id=sb_messages.thread
        // the actual messages can be detected by seeing that fb_messages.parent != 0
           echo "<br />Populating Forums...\n"; flush();
            $query = "INSERT INTO {$phpbb_dbprefix}forums (forum_id, cat_id, forum_name, forum_desc, forum_status, forum_order, forum_posts, forum_topics, forum_last_post_id, prune_next, prune_enable, auth_view, auth_read, auth_post, auth_reply, auth_edit,auth_delete, auth_sticky, auth_announce, auth_vote, auth_pollcreate, auth_attachments)
                   SELECT id, parent, name, description, 0, ordering, c.posts, b.topics, d.last, NULL, 0, 0, 1, 1, 1, 1, 1, 3, 3, 1, 1, 0
                   FROM {$mosConfig_dbprefix}fb_categories
                   LEFT JOIN (SELECT catid, COUNT(*) AS topics FROM {$mosConfig_dbprefix}fb_messages WHERE id=thread GROUP BY catid) b
                   ON {$mosConfig_dbprefix}fb_categories.id=b.catid
                   LEFT JOIN (SELECT catid, COUNT(*) AS posts FROM {$mosConfig_dbprefix}fb_messages GROUP BY catid) c
                   ON {$mosConfig_dbprefix}fb_categories.id=c.catid
                   LEFT JOIN (SELECT catid, MAX(id) AS last FROM {$mosConfig_dbprefix}fb_messages GROUP BY catid) d
                   ON {$mosConfig_dbprefix}fb_categories.id=d.catid
                   WHERE parent != 0
                   GROUP BY id;";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

        //Count Rows Inserted
           $query = "SELECT COUNT(*)
                   FROM {$phpbb_dbprefix}forums;";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
            list($count) = mysql_fetch_row($result);
            echo "<br />Inserted $count Rows... OK"; flush();

        // Part Three - Populate Topics
        // if fb_messages.parent = 0 then messages is a topic
           echo "<br />Populating Topics...\n"; flush();
            $query = "TRUNCATE TABLE {$phpbb_dbprefix}topics";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

               // Some messages still had the single quote in them without a \
            // which was causing import problems so we
            // removed the single quote and replaced it with HTML for the quote
           // Run a query taking simple board messages and finding which are topics by thread=id then merge with count table above
            // also subtract one from the reply count because it counts itself under this algorithm
            $query = "SELECT m.id, m.catid, m.userid, m.subject, m.time, m.hits, reply - 1 AS reply, locked, '0', '0', c.min, c.max, '0'
                   FROM {$mosConfig_dbprefix}fb_messages AS m
                   JOIN (SELECT thread, MIN(id) AS min, MAX(id) as max, COUNT(id) as reply
                   FROM {$mosConfig_dbprefix}fb_messages GROUP BY thread) c
                   WHERE m.thread=m.id AND m.parent=0 AND c.thread=m.thread";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

            while ( $row = mysql_fetch_object( $result ) ) {
              $subject = stripslashes( $row->subject );
              $subject = preg_replace ('/\'/', '\\\'', $subject);
              $query = "INSERT INTO {$phpbb_dbprefix}topics(topic_id, forum_id, topic_poster, topic_title, topic_time,topic_views, topic_replies, topic_status, topic_vote, topic_type,topic_first_post_id, topic_last_post_id, topic_moved_id)VALUES ('$row->id', '$row->catid', '$row->userid', '$subject', '$row->time','$row->hits', '$row->reply', '$row->locked', '0', '','$row->min', '$row->max', '0')";
              $updateresult = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
            }
            mysql_free_result($result);

        //Count Rows Inserted
           $query = "SELECT COUNT(*)
                   FROM {$phpbb_dbprefix}topics;";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
            list($count) = mysql_fetch_row($result);
            echo "<br />Inserted $count Rows... OK\n"; flush();

        // Part Four - Populate Messages Table
            echo "<br />Populating Posts...\n"; flush();
            $query = "TRUNCATE TABLE {$phpbb_dbprefix}posts";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

            $query = "INSERT INTO {$phpbb_dbprefix}posts (post_id, topic_id, forum_id, poster_id, post_time, poster_ip, post_username, enable_bbcode, enable_html, enable_smilies, enable_sig, post_edit_time, post_edit_count)
                   SELECT id, thread, catid, userid, time, HEX(INET_ATON(ip)), name, 1, 0, topic_emoticon, 1, NULL, 0 FROM {$mosConfig_dbprefix}fb_messages";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

           $query = "SELECT COUNT(*) FROM {$phpbb_dbprefix}posts;";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
            list($count) = mysql_fetch_row($result);
            echo "<br />Inserted $count Rows... OK"; flush();

        //Populate Messages_Text Table
            echo "<br />Populating Post Text & Converting Fireboard Syntax to phhBB Syntax... (This may take a while)\n"; flush();
            $query = "TRUNCATE TABLE {$phpbb_dbprefix}posts_text";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

           $query = "SELECT m.id, m.subject, t.message
                   FROM {$mosConfig_dbprefix}fb_messages_text AS t, {$mosConfig_dbprefix}fb_messages AS m WHERE m.id = t.mesid";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

        // uses phpbb's bbcode encoder to make a uid for each message
        // which is required for the bbcode to work in phpbb
            while ( $row = mysql_fetch_object( $result ) ) {
              $bbcode_uid = ( $bbcode_on ) ? make_bbcode_uid() : '';
              $message = prep ( $row->message);
              $message = fixquotes ($message);
              $message = mysql_real_escape_string ($message);
              $subject = stripslashes( $row->subject );
              $subject = preg_replace ('/\'/', '\\\'', $subject);              
              $query = "INSERT INTO {$phpbb_dbprefix}posts_text (post_id, bbcode_uid, post_subject, post_text)
                      VALUES ('$row->id','$bbcode_uid', '$subject', '$message')";
               $updateresult = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
            }
            mysql_free_result($result);

        //Count Rows Inserted
           $query = "SELECT COUNT(*) FROM {$phpbb_dbprefix}posts_text;";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
            list($count) = mysql_fetch_row($result);
            echo "<br />Inserted $count Rows... OK\n"; flush();

        //Populate Users Table , Note user_sig_bbcode_uid is a radom, md5 checksum
            echo "<br />Populating Users Table From Joomla...\n";
            $query = "TRUNCATE TABLE {$phpbb_dbprefix}users";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

            $query = "INSERT INTO {$phpbb_dbprefix}users (user_id, user_active, username, user_password, user_session_time, user_lastvisit, user_regdate, user_level, user_dateformat, user_email)
                   SELECT id,
                    CASE block
                       WHEN 0 THEN 1
                       ELSE 0 END,
                    username,
                    password,
                    UNIX_TIMESTAMP(lastvisitDate),
                    UNIX_TIMESTAMP(lastvisitDate),
                    UNIX_TIMESTAMP(registerDate),
                    CASE gid
                       WHEN 25 THEN 1
                       WHEN 24 THEN 1
                       ELSE 0 END,
                       'd M Y H:i',
                       email
                 FROM {$mosConfig_dbprefix}users ORDER by id;";
           $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

           $query = "SELECT COUNT(*) FROM {$phpbb_dbprefix}users;";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
            list($count) = mysql_fetch_row($result);
            echo "<br />Inserted $count Users... OK\n"; flush();

        //Update Info From Fireboard
           echo "<br />Updating Users Table From Fireboard...\n";
            $query = "UPDATE {$phpbb_dbprefix}users, {$mosConfig_dbprefix}fb_users
                   SET user_posts=posts, user_avatar=avatar, user_icq=ICQ, user_website=websitename, user_from=location, user_sig=signature, user_aim=AIM, user_yim=YIM, user_msnm=MSN, user_interests=personalText
                   WHERE user_id=userid;";
           $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

        // uses phpbb's bbcode encoder to make a uid for each message
        // which is required for the bbcode to work in phpbb
        // clean up bbcode in signatures and ad bbcode_uid
       // Fireboard had inserted backslashes \\ everywhere which was
       // causing lots of trouble.  I punted
       // and selected the signature as null, in effect, leaving it
       // behind.  Not worth the trouble for me to clean it up.  Users
       // can put their sigs back themselves.
            //$query = "SELECT user_id, signature
            $query = "SELECT user_id, NULL
                   FROM {$phpbb_dbprefix}users
                   ORDER BY user_id;";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

            while ( $row = mysql_fetch_object( $result ) ) {
              $bbcode_uid = ( $bbcode_on ) ? make_bbcode_uid() : '';
              $signature = prep ( $row->user_sig);
              $signature = preg_replace ('/\'/', '\\\'', $signature);
              $query = "UPDATE {$phpbb_dbprefix}users
                      SET user_sig='$signature', user_sig_bbcode_uid='$bbcode_uid'
                      WHERE user_id=$row->user_id";
              $updateresult = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
            }
            mysql_free_result($result);

           $query = "SELECT COUNT(*) FROM {$phpbb_dbprefix}users;";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
            list($count) = mysql_fetch_row($result);

        //Clean up avatar, only for off site avatar, Onsite Avatars will be deleted
            echo "<br />Updated $count Users... OK\n"; flush();
            $query = "UPDATE {$phpbb_dbprefix}users
                   SET user_avatar_type = 3
                   WHERE user_avatar LIKE 'http://%';";
           $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

           $query = "UPDATE {$phpbb_dbprefix}users
                   SET user_avatar_type = 0, user_avatar = NULL
                   WHERE user_avatar NOT LIKE 'http://%';";
           $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

           // create a group for each user
           echo "<br />Updating Users Groups...\n"; flush();
            $query = "TRUNCATE TABLE {$phpbb_dbprefix}groups";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

            $query = "INSERT INTO {$phpbb_dbprefix}groups (group_id, group_type, group_name, group_description, group_moderator, group_single_user)
                   SELECT user_id, '1', '', 'Personal User', '0', '1'
                   FROM {$phpbb_dbprefix}users ORDER BY user_id";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

        // have each user join their own group
            $query = "TRUNCATE TABLE {$phpbb_dbprefix}user_group";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
            $query = "INSERT INTO {$phpbb_dbprefix}user_group (group_id, user_id, user_pending)
                   SELECT user_id, user_id, '0'
                   FROM {$phpbb_dbprefix}users
                   ORDER BY user_id";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
            echo "OK\n"; flush();

        //insert ranks
           echo "<br />Inserting User Ranks...\n"; flush();
            $query = "TRUNCATE TABLE {$phpbb_dbprefix}ranks";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());
            $query = "INSERT INTO {$phpbb_dbprefix}ranks (rank_id, rank_title, rank_min, rank_special, rank_image) SELECT rank_id, rank_title, rank_min, rank_special, rank_image
                   FROM {$mosConfig_dbprefix}fb_ranks
                   ORDER BY rank_id";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

            echo "OK\n"; flush();
            echo "<br />Complete...\n"; flush();

           echo "</body>";
           echo "</html>"; flush();

            //--- Function to prepare strings for MySQL storage ---/
            function prep($s) {
            // Insert bbcode_uid necessary for bbcode to be recognized by phpbb2
                global $bbcode_uid;

                // <strong> </strong>
                $s = preg_replace('/\[b\]/', '[b:'.$bbcode_uid.']', $s);
                $s = preg_replace('/\[\/b\]/', '[/b:'.$bbcode_uid.']', $s);

                // <em> </em>
                $s = preg_replace('/\[i\]/', '[i:'.$bbcode_uid.']', $s);
                $s = preg_replace('/\[\/i\]/', '[/i:'.$bbcode_uid.']', $s);

                // <u> </u>
                $s = preg_replace('/\[u\]/', '[u:'.$bbcode_uid.']', $s);
                $s = preg_replace('/\[\/u\]/', '[/u:'.$bbcode_uid.']', $s);

                // quote
                $s = preg_replace('/\[quote\]/', '[quote:'.$bbcode_uid.']', $s);
                $s = preg_replace('/\[\/quote\]/', '[/quote:'.$bbcode_uid.']', $s);

                // url with "
                $s = preg_replace('/\[url=\\\&quot\;(.*?)\\\&quot\;\](.*?)/', '[url=\\1]\\2', $s);

                // image
                $s = preg_replace('/\[img(.*?)\](.*?)\[\/img(.*?)\]/si', '[img:'.$bbcode_uid.']'.'\\2[/img:'.$bbcode_uid.']', $s);

                // color
                $s = preg_replace('/\[color=(.*?)\]/', '[color=\\1:'.$bbcode_uid.']', $s);
                $s = preg_replace('/\[\/color\]/', '[/color:'.$bbcode_uid.']', $s);

                // size fb uses size 1 to 5,  phpbb2 uses size 1 to 29; will use 1 = 7, 2=9, 3=12, 4=18, 5=24
                $s = preg_replace('/\[size=1\]/', '[size=7:'.$bbcode_uid.']', $s);
                $s = preg_replace('/\[size=2\]/', '[size=9:'.$bbcode_uid.']', $s);
                $s = preg_replace('/\[size=3\]/', '[size=12:'.$bbcode_uid.']', $s);
                $s = preg_replace('/\[size=4\]/', '[size=18:'.$bbcode_uid.']', $s);
                $s = preg_replace('/\[size=5\]/', '[size=24:'.$bbcode_uid.']', $s);
                $s = preg_replace('/\[\/size\]/', '[/size:'.$bbcode_uid.']', $s);

                // code
                $s = preg_replace('/\[code(.*?)\]/','[code:'.$bbcode_uid.']', $s);
                $s = preg_replace('/\[\/code(.*?)\]/', '[/code:'.$bbcode_uid.']', $s);

                // lists
                $s = preg_replace('/\[ul\]/', '[list:'.$bbcode_uid.']', $s);
              $s = preg_replace('/\[\/ul\]/', '[/list:u:'.$bbcode_uid.']', $s);
                $s = preg_replace('/\[ol\]/', '[list=1:'.$bbcode_uid.']', $s);
              $s = preg_replace('/\[\/ol\]/', '[/list:o:'.$bbcode_uid.']', $s);
                $s = preg_replace('/\[li\]/', '[*:'.$bbcode_uid.']', $s);
                $s = preg_replace('/\[\/li\]/', '', $s);

                return $s;
            }

        // fixed the quotes.
           function fixquotes($q) {
                global $bbcode_uid;
              $q = preg_replace('/\[b:'.$bbcode_uid.'\](.*?) wrote:\[\/b:'.$bbcode_uid.'\]\r\n\[quote:'.$bbcode_uid.'\]/', '[quote:'.$bbcode_uid.'="\\1"]', $q );
              return $q;
            }

        // function taken from phpbb2 functions file Unique ID for this message..
            function make_bbcode_uid()
            {
                    $uid = md5(mt_rand());
                    $uid = substr($uid, 0, BBCODE_UID_LEN);
                    return $uid;
            }

        //last minute accounts to be added note phpbb2admin password is "admn" Besure to remove once you have tested the  site.
       //After doing this, I'd suggest copying the admin password from
       //a known quantity, not this one.  It didn't work for me and
       //phpbb2admin had to do the forgot password thing like everyone
       //else.  Also, I'd suggest making the email address (just below
       //here) a variable for the config lines at the beginning.
       //--Chris
           $query = "INSERT INTO {$phpbb_dbprefix}users (user_id, user_active, username, user_password, user_session_time, user_session_page, user_lastvisit, user_regdate, user_level, user_posts, user_timezone, user_style, user_lang, user_dateformat, user_new_privmsg, user_unread_privmsg, user_last_privmsg, user_login_tries, user_last_login_try, user_emailtime, user_viewemail, user_attachsig, user_allowhtml, user_allowbbcode, user_allowsmile, user_allowavatar, user_allow_pm, user_allow_viewonline, user_notify, user_notify_pm, user_popup_pm, user_rank, user_avatar, user_avatar_type, user_email, user_icq, user_website, user_from, user_sig, user_sig_bbcode_uid, user_aim, user_yim, user_msnm, user_occ, user_interests, user_actkey, user_newpasswd) VALUES
                 (-1, 0, 'Anonymous', '', 0, 0, 0, 0, 0, 0, 0.00, NULL, '', '', 0, 0, 0, 0, 0, NULL, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, NULL, '', 0, '', '', '', '', '', NULL, '', '', '', '', '', '', ''),
                 (2, 1, 'phpbb2admin', '21232f297a57a5a743894a0e4a801fc3', 1198282415, 0, 1198282415, 0, 1, 1, 0.00, 1, 'english', 'd M Y h:i a', 0, 0, 0, 0, 0, NULL, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, '', 0, 'myadmin@my_site.com', '', '', '', '', NULL, '', '', '', '', '', '', '');";
            $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

           $query = "INSERT INTO {$phpbb_dbprefix}user_group (group_id, user_id, user_pending) VALUES
                 (1, -1, 0),
                 (2, 2, 0);";
           $result = mysql_query($query) or die("<br />Invalid query:<br />$query<br />" . mysql_error());

        ?>
It will definitly not work for everyone. I think we have another PHP 5 issue here that is breaking the script for seome people. But i hope people can use it.

Greetz
phreak

kjelle79
Registered User
Posts: 1
Joined: Tue Sep 09, 2008 2:09 pm

Re: Joomla Fireboard Forum to PHPBB

Post by kjelle79 » Tue Sep 09, 2008 2:36 pm

hello after i convert and my username and password been lost fore me howe can i create new or repair it

Locked

Return to “[2.0.x] Convertors”

Who is online

Users browsing this forum: No registered users and 4 guests