Topic: Converter: MiniBB -> PunBB b3

Since we've talked alot about it in this thread and I've released a beta now, it needs an own topic here :) The converter is based on the same code as the PhpBB->PunBB converter, so it's pretty much the same settings and layout.

Since PunRes is down, I've put the files on the temporary server.

Screenshot:
   http://www.etek.chalmers.se/~e0mool/punbb/files/minibb.jpg

Re: Converter: MiniBB -> PunBB b3

Sweet! Maybe we should put these babies up on the download page?

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: Converter: MiniBB -> PunBB b3

PunRes 2.1 will have a Converter category ;)

And, not much left now. Just have to get the latest databases and update them. Then it's pretty much finished. But that lazy bamsefar don't fix the server so I can get them..

Re: Converter: MiniBB -> PunBB b3

Rickard wrote:

Sweet! Maybe we should put these babies up on the download page?

Yes, good idea! Can you take good care of my babies then? ;) Cactus page suck bigtime atm :P You could maybe have a converter-category, that links to PunRes. I think many people check your page for converters, and not PunRes.

Jansson wrote:

PunRes 2.1 will have a Converter category ;)

And, not much left now. Just have to get the latest databases and update them. Then it's pretty much finished. But that lazy bamsefar don't fix the server so I can get them..

Hehe, okay :) Would be great if it could be online sometime soon... and I know how it is to try to get other people to do something =/

Re: Converter: MiniBB -> PunBB b3

If I could just get the databases and PunRes files it could be online tonight. If everything goes smooth...

Re: Converter: MiniBB -> PunBB b3

Mods will stay "off site" (at punres that is), but the converters really should be here. I'll have a look at it tonight.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: Converter: MiniBB -> PunBB b3

Rickard wrote:

Mods will stay "off site" (at punres that is), but the converters really should be here. I'll have a look at it tonight.

Well, I don't mind having them on your server :)

More PunBB to the people!

Re: Converter: MiniBB -> PunBB b3

Chacmool,

You've saved me loads of time by writing this converter, thank you very much! smile

Here's my contribution ...

The converter was only doing a half-perfect job of converting the message contents in posts - you seem to have overlooked the fact that carriage return and linefeed in MiniBB posts don't mean anything? In PunBB they do - thus, you must first discard any carriage returns and linefeeds before you convert <br> to linefeed, otherwise you get excess whitespace in some messages. The font color tag was not handled. After converting everything possible, I would strip and wipe any excess HTML at the end - this should maybe be optional, for those who allowed HTML in their posts when they were running MiniBB. And finally, for those using "hack_smilies.php" with MiniBB (I was), I made a little conversion function, which will detect smilie images and translate them back to ordinary smilies for PunBB to display.

Here's the modified "functions.php":

<?
    function generatedtime($start, $finish){
        list( $start1, $start2 ) = explode( ' ', $start );
        list( $finish1, $finish2 ) = explode( ' ', $finish );
        return sprintf( "%.2f", ($finish1 + $finish2) - ($start1 + $start2) );
    } // end function generatedtime

    function html_stuff($message){
        $pattern = array(
            '/>/i',
            '/</i',
            '/&/i',
            '/"/i',
            '/'/i'
        );

        $replace = array(
            '>',
            '<',
            '&',
            '"',
            "'"
        );
        
        return addslashes(preg_replace($pattern, $replace, $message));
    }

    function convert_smilies($message) {
        $smilie_path = '/img/emos/'; // images in this folder will be converted to smilies - this path must including trailing and leading slashes, and may be partial (e.g. you can specify simply "/images/smilies/" instead of "http://www.mysite.com/myforum/images/smilies/")
        
        // map of which GIFs to convert to what smilies:
        $smilie_map = array(
            'grin.gif'     =>  ":)",
            'sad.gif'      =>  ":(",
            'shock.gif'    =>  ":o",
            'lol.gif'      =>  ":D",
            'wink.gif'     =>  ";)",
            'tongue.gif'   =>  ":p",
            'biglol.gif'   =>  ":biglol:",
            'confused.gif' =>  ":confused:",
            'grin.gif'     =>  ":grin:",
            'mad.gif'      =>  ":mad:",
            'sad.gif'      =>  ":sad:",
            'wink.gif'     =>  ":wink:",
            'sad.gif'      =>  ":cry:",
            'lol.gif'      =>  ":lol:",
            'cool.gif'     =>  ":cool:",
            'hihi.gif'     =>  ":hihi:",
            'biglol.gif'   =>  ":rofl:",
            'tongue.gif'   =>  ":tongue:",
            'shame.gif'    =>  ":shame:",
            'shock.gif'    =>  ":eek:",
            'rolleyes.gif' =>  ":rolleyes:",
            'idea.gif'     =>  ":idea:",
            'neutral.gif'  =>  ":|"
        );
        
        $smilie_path = preg_replace('/\//i', '\\\/', $smilie_path); // escape slashes
        
        foreach($smilie_map as $img => $smilie)
        {
            $img = preg_replace('/\./i', '\\\.', $img); // escape dots
            $message = preg_replace('/\[img\][^\[]*'.$smilie_path.$img.'\[\/img\]/im', $smilie, $message);
        }
        
        return($message);
    }

    function convert_posts($message){
        $pattern = array(
            // returns and linefeeds
            '/\r/i',
            '/\n/i',
            
            // <br>
            '/<br>/im',
            
            // bold, italic, underline
            '/<b>/i', '/<\/b>/i',
            '/<i>/i', '/<\/i>/i',
            '/<u>/i', '/<\/u>/i',

            // Mail
            '/<a href="mailto:([^"]+)">([^<]+)<\/a>/im',

            // URLs
            '/<a href="http:([^"]+)"(?:[^>]*)>([^<]+)<\/a>/im',
            
            // Images
            '/<img src="([^"]+)"(?:[^>]*)>/im',
            
            // Font color
            '/<font color="(#[0-9,a-f,A-F]{6})">([^<]*)<\/font>/im',
            
            // Illegal HTML
            '/<[^>]*>/'
        );
        
        $replace = array(
            // returns and linefeeds
             '',
             '',
             
             // <br>
             "\n",
             
            // bold, italic, underline
            '[b]', '[/b]',
            '[i]', '[/i]',
            '[u]', '[/u]',
            
            // Mail
            '[email=$1]$2[/email]',
            
            // URLs
            '[url=http:$1]$2[/url]',
            
            // Images
            '[img]$1[/img]',
            
            // Font color
            '[color=$1]$2[/color]',
            
            // Illegal HTML
            ''
        );

        return html_stuff(convert_smilies(preg_replace($pattern, $replace, $message)));
    }
?>

I only added convert_smilies() and modified the two arrays in convert_posts(), so if you already made other changes (mine is based on beta 3), you can simply copy/paste those.

Woot smile

Re: Converter: MiniBB -> PunBB b3

Oh, I forgot to mention, the convert_smilies() function of course needs to be customized in advance before converting your forum, since different people use different smilies. Might of course be useful if the converter could actually read and interpret the smilies config file from MiniBB and use that instead, but might also be overkill - and also, I was too lazy. big_smile

Re: Converter: MiniBB -> PunBB b3

mindplay wrote:

The converter was only doing a half-perfect job of converting the message contents in posts - you seem to have overlooked the fact that carriage return and linefeed in MiniBB posts don't mean anything? In PunBB they do - thus, you must first discard any carriage returns and linefeeds before you convert <br> to linefeed, otherwise you get excess whitespace in some messages. The font color tag was not handled. After converting everything possible, I would strip and wipe any excess HTML at the end - this should maybe be optional, for those who allowed HTML in their posts when they were running MiniBB.

Which version of MiniBB do you run? I've had no problem with this when I've tested the converter with miniBB 1.7d. Also, is the font-bb-code installed by default, or is it just another hack?

mindplay wrote:

And finally, for those using "hack_smilies.php" with MiniBB (I was), I made a little conversion function, which will detect smilie images and translate them back to ordinary smilies for PunBB to display.

Hehe, okay, I might look at it. Though, since punbb doesn't use that many smileys, it seems better to just leave the mileys as they are. I looked at your code, and saw that for example "tongue.gif" was replaced by ":P", does this mean that  smiley in MiniBB is only saved as a filename of the smiley?

Re: Converter: MiniBB -> PunBB b3

I'm running MiniBB v1.6 - I found it impossible to upgrade to v1.7, because I was forced to customize the board extensively to make it fit into our site's design; there was no simple way to customize MiniBB's looks with CSS in v1.6...

The font color BB tag was there by default.

The hack_smilies.php plugin for MiniBB is a quick and dirty hack, which translates smilies to <img src="..."> tags BEFORE writing into the database. (I hear there's a death penalty for writing this sort of code in some countries, but I wouldn't be shy to take the law into my own hands regardless)

In the updated code I posted, all images (including smilies) will first be translated to [img] tags ... then, it will look for those images that represent smilies, and translate them back.

Re: Converter: MiniBB -> PunBB b3

(note, you may have missed the font color feature, because it's only available to admins)

13

Re: Converter: MiniBB -> PunBB b3

hey, do i have to have punBB first before converting?

Re: Converter: MiniBB -> PunBB b3

of course - you need a working PunBB installation, including a ready database.