Fork me on GitHub

Convert PNphpBB2 to Dizkus  Bottom

  • I went through the upgrade of PNphpBB2 (PNphpBB2-1.2i-patch4-RC2.zip) which got it working in 764 so I could upgrade to Zikula 1.1.2 -- then I started reading about problems with going to 2.1 and since Zafenio doesn't seem to have any momentum I wrote a PHP script to take my data from PNphpBB2 to a fresh install of Dizkus 3.0.


    Enjoy!


    Code

    <?

    $DBhost = "localhost";
    $DBuser = "your-db-user-name";
    $DBpass = "your-db-password";
    $DBname = "your-db-name";

    $prefix = "zk";

    /* Connecting, selecting database */
    $link = mysql_connect($DBhost, $DBuser, $DBpass) or
                               die("Could not connect");
    // print "Connected successfully";
    mysql_select_db($DBname) or die("Could not select database");

      // Categories
      $sql="SELECT cat_id, cat_title, cat_order
            FROM "
    .$prefix."_phpbb_categories";

      $result = mysql_query($sql);
      if ($result && mysql_numrows($result) > 0)
        while ($row = mysql_fetch_array($result)) {

          list($cat_id, $cat_title, $cat_order) = $row;

          $query = "INSERT INTO ".$prefix."_dizkus_categories
                           (cat_id, cat_title, cat_order)
                    VALUES ("
    .$cat_id.", '".addslashes($cat_title)."', '".$cat_order."')";
          $res = mysql_query($query);
          if (!$res) {
             echo "Could not successfully run query ($query) from DB: " . mysql_error();
             exit;
          }

        } print "Added categories...\n";

      // Forums
      $sql="SELECT forum_id, cat_id, forum_name, forum_desc, forum_order,
                   forum_posts, forum_topics, forum_last_post_id
            FROM "
    .$prefix."_phpbb_forums";

      $result = mysql_query($sql);
      if ($result && mysql_numrows($result) > 0)
        while ($row = mysql_fetch_array($result)) {

          list($forum_id, $cat_id, $forum_name, $forum_desc, $forum_order,
                   $forum_posts, $forum_topics, $forum_last_post_id) = $row;

          $query = "INSERT INTO ".$prefix."_dizkus_forums
                           (forum_id, cat_id, forum_name, forum_desc, forum_order,
                   forum_posts, forum_topics, forum_last_post_id)
                    VALUES ("
    .$forum_id.", ".$cat_id.", '".addslashes($forum_name)."', '".addslashes($forum_desc)."', ".$forum_order.", ".$forum_posts.", ".$forum_topics.", ".$forum_last_post_id.")";
          $res = mysql_query($query);
          if (!$res) {
             echo "Could not successfully run query ($query) from DB: " . mysql_error();
             exit;
          }

        } print "Added forums...\n";

      // Posts
      $sql="SELECT post_id, topic_id, forum_id, poster_id, post_time, poster_ip
            FROM "
    .$prefix."_phpbb_posts";

      $result = mysql_query($sql);
      if ($result && mysql_numrows($result) > 0)
        while ($row = mysql_fetch_array($result)) {

          list($post_id, $topic_id, $forum_id, $poster_id, $post_time, $poster_ip) = $row;

          $query = "INSERT INTO ".$prefix."_dizkus_posts
                           (post_id, topic_id, forum_id, poster_id, post_time, poster_ip)
                    VALUES ("
    .$post_id.", ".$topic_id.", ".$forum_id.", ".$poster_id.", '".date('Y-m-d H:i', $post_time)."', '".$poster_ip."')";
          $res = mysql_query($query);
          if (!$res) {
             echo "Could not successfully run query ($query) from DB: " . mysql_error();
             exit;
          }

        } print "Added posts...\n";

      // Posts text
      $sql="SELECT post_id, post_text
            FROM "
    .$prefix."_phpbb_posts_text";

      $result = mysql_query($sql);
      if ($result && mysql_numrows($result) > 0)
        while ($row = mysql_fetch_array($result)) {

          list($post_id, $post_text) = $row;

          $query = "INSERT INTO ".$prefix."_dizkus_posts_text
                           (post_id, post_text)
                    VALUES ("
    .$post_id.", '".addslashes($post_text)."')";
          $res = mysql_query($query);
          if (!$res) {
             echo "Could not successfully run query ($query) from DB: " . mysql_error();
             exit;
          }

        } print "Added posts text...\n";

      // Topics
      $sql="SELECT topic_id, forum_id, topic_title, topic_poster, topic_time,
                   topic_views, topic_replies, topic_status, topic_last_post_id
            FROM "
    .$prefix."_phpbb_topics";

      $result = mysql_query($sql);
      if ($result && mysql_numrows($result) > 0)
        while ($row = mysql_fetch_array($result)) {

          list($topic_id, $forum_id, $topic_title, $topic_poster, $topic_time,
               $topic_views, $topic_replies, $topic_status, $topic_last_post_id) = $row;

          $query = "INSERT INTO ".$prefix."_dizkus_topics
                           (topic_id, forum_id, topic_title, topic_poster, topic_time,
                   topic_views, topic_replies, topic_status, topic_last_post_id)
                    VALUES ("
    .$topic_id.", ".$forum_id.", '".addslashes($topic_title)."', ".$topic_poster.", '".date('Y-m-d H:i', $topic_time)."', ".$topic_views.", ".$topic_replies.", ".$topic_status.", ".$topic_last_post_id.")";
          $res = mysql_query($query);
          if (!$res) {
             echo "Could not successfully run query ($query) from DB: " . mysql_error();
             exit;
          }

        } print "Added topics...\n";

      // topic subscription
      $sql="SELECT W.topic_id, W.user_id, T.forum_id
            FROM "
    .$prefix."_phpbb_topics_watch AS W, ".$prefix."_phpbb_topics AS T
            WHERE W.topic_id = T.topic_id"
    ;

      $result = mysql_query($sql);
      if ($result && mysql_numrows($result) > 0)
        while ($row = mysql_fetch_array($result)) {

          list($topic_id, $user_id, $forum_id) = $row;

          $query = "INSERT INTO ".$prefix."_dizkus_topic_subscription
                           (topic_id, user_id, forum_id)
                    VALUES ("
    .$topic_id.", ".$user_id.", ".$forum_id.")";
          $res = mysql_query($query);
          if (!$res) {
             echo "Could not successfully run query ($query) from DB: " . mysql_error();
             exit;
          }

        } print "Added topic subscription...\n";

      // Users
      $sql="SELECT user_id, user_posts, user_rank
            FROM "
    .$prefix."_phpbb_users";

      $result = mysql_query($sql);
      if ($result && mysql_numrows($result) > 0)
        while ($row = mysql_fetch_array($result)) {

          list($user_id, $user_posts, $user_rank) = $row;

        if ($user_id > 0) {
          $query = "INSERT INTO ".$prefix."_dizkus_users
                           (user_id, user_posts, user_rank)
                    VALUES ("
    .$user_id.", ".$user_posts.", ".$user_rank.")";
          $res = mysql_query($query);
          if (!$res) {
             echo "Could not successfully run query ($query) from DB: " . mysql_error();
             exit;
          }

        }
        } print "Added users...\n";


    print "Done.\n";
    ?>
  • Wow, thanks for sharing. This should become part of the official Dizkus repository icon_smile

    --
    Guite | ModuleStudio
  • Yea, thanks a lot!
    Useful for many of the users of the spanish community!
    already added to our Wiki icon_smile

    --
    - Mateo T. -
    Mis principios... son mis fines
  • Thanks indeed, this will be very useful for many users
  • Did you take a look at pnForum_Tools_2.00a.zip?
    I used this script some (long) time ago for the dutch community website, to convert from PNphpBB2 to pnForum, and it worked as a charme at that time.

    Maybe these two can be migrated to one new, working, up-to-date and final import script?

    --
    -- Teb
    -- Dutch Zikula Community


    Support questions in a Personal Message will be ignored. Use the forums at all times!
  • Transfering the latest SVN of Dizkus (3.1), and installing according to docs. I grabed the code above and did run it as is. It did add all the categories and it did show totals for posts and topics but there were no topics created. Maybe the script is broken due to it being pasted into the topic above?

    I got the below error running the script.

    Code

    Added categories... Added forums... Added posts... Could not successfully run query (INSERT INTO zk_dizkus_posts_text (post_id, post_text) VALUES (246, 'Some of the problems that revolve around Snort not detecting traffic are caused by a faulty WinPcap installation. WinPcap is the Packet Capture filter for Windows and Snort will do all kinds of strange things if it’s corrupt. Some problems are caused when there has been an older version installed and the instructions were not followed for the removal. It is imperative you do NOT install a NEW WinPcap over the top of an OLD WinPcap. Doing this will leave some of the files intact from the OLD WinPcap and will not allow the NEW WinPcap to deposit its new files. In short you will be using some of the OLD WinPcap files along with some of the NEW WinPcap files, and this will cause all sorts of problems with Snort. This is the method I use to make absolutely sure WinPcap is completely removed before installing a new version: 1) Go into services and stop and disable the Snort service (if installed) 2) Uninstall WinPcap from the Add/Remove applet 3) Search ALL of C:\ drive for packet.dll and remove any if found 4) Reboot 5) Install the Release version of WinPcap 5) Go back into services and set the Snort service back to Automatic 7) Reboot This method guarantees the complete removal. Normally you don\'t have to go to these extremes to remove WinPcap. Normally you would use the uninstall WinPcap from the add/remove applet in Windows.')) from DB: Table 'winsnort_db.zk_dizkus_posts_text' doesn't exist




    edited by: mesteele101, datetimebrief
  • I am not sure what the difference is from Dizkus 3.0 to 3.1 but it seems that the dizkus_posts_text table has been removed. Try installing Dizkus 3.0 and running the script... I tried it again and it works on Dizkus 3.0 I didn't try 3.1 --- but I am sure they have an upgrade path from 3.0 to 3.1.



    edited by: mjturn, datetimebrief
  • Dizkus 3.1 changed the database structure...
    This works for Dizkus 3.0 only, then you can upgrade the module when its ready

    --
    - Mateo T. -
    Mis principios... son mis fines
  • Yes, going back to 3.0 and then upgrading to 3.1 did the trick.

    Thank you...



    edited by: mesteele101, datetimebrief
  • Has anyone that has converted their PNphpBB2 tables to Dizkus 3.0 using the above script had this problem:

    After the conversion; export all the Zikula tables using phpMyAdmin and then import all the tables back. The import fails for me, making me believe that if you are relying on any backup of your tables you may be out of luck after using this script

    I did post, asking about this here
  • Hi Guys, I have run the script, thanks mjturn, worked very well.
    all the image tags was modified during the copy to Dizkus, [img:0aaeb52d09]http://i790.photobucket.com/albums/yy189/daniew/DSC02104.jpg[/img:0aaeb52d09]
    all instances have the same tag

    Is it possible to run a script on the table to change [img:0aaeb52d09] to [img] and [/img:0aaeb52d09] to [img] and could you help me in writing such a query please.

    thanks
    johan
  • You will find that there are more then the bbcode and BBSMILE tags that re not being converted properly with the above script. You can use your favotite UTF-8 editor and globaly change a lot of these problems.

    Why are you converting? PNphpBB2 is playing vey nicely with Zikula 1.2.1 at this time.
  • Thanks in that case I will stay with phpBB2 Very good news thanks ?
    I wanted to upgrade to Zikula 1.2 and did not know if PNphpBB2 will work.

    Thanks for the info.
  • You will eventually need to do a conversion in the future and Dizkus will be the prefered forum to convert to. However the conversion script is far from perfect. I would guess that if someone took the script and made it convert PNphpBB2 to Dizkus 3.1 properly and 100%, I for one would convert, and I'm sure a LOT of the users running PNphpBB2 would follow.

    For now, PNphpBB2 works at around 95% with Zikula.

This list is based on users active over the last 60 minutes.