MyBB Community Forums

Full Version: [B] Converting PunBB 1.32 to MyBB 1.44 - problem with encoding
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I know that PunBB 1.32 is not officialy supported, but all you need to do conversion is replace $db->escape_string() with mysql_escape_string() function in 1219 line of punbb.php.
BUG: Still there is problem with encoding. Polish diactric signs (śąćęł) are lost and after conversion there are '?' instead.

I've also tested the old 1.0 RC3 converter and it is encoding signs properly, but have other problems like wrong thread IDs

Original forum PunBB 1.32: http://www.pcmod.pl
My MyBB 1.44: http://redbike.pl/mybb/

If you have more questions and need details about bug, just ask Wink.

EDIT:
This time it will not cause SQL injections.
Please don't post threads in the fixed bugs forum. This forum is for the developers to know what reported issues have been fixed. You can post in the Merge System Bug Report forum to report an issue.
(2009-04-01, 01:43 PM)Raga Wrote: [ -> ]I know that PunBB 1.32 is not officialy supported, but all you need to do conversion is delete (mysql_escape_string()) function from 1219 line of punbb.php.

No, that's bad. That could cause SQL Injections
I did not posted it as fix, just I want inform you that your converter works well with 1.32 and only need to have encoding fixed.
It was abuse to make converter running and check does it really support 1.32 (officialy not).

You mean SQL Injections caused by content of username (containing ', " etc.) or just unauthorized try of SQL Injection?
For self usage it works well as my users dont have (' " etc) in their names.

EDIT:
It is more likely like request.
Are you able to fix that please? When?
I've written simple code that updates posts and thread content (subject and post content only) with correct encoding.
Remember general idea of this converter is really bad. It compares two databases by time parameter (posted, dateline). If you have two posts in your forum written in same second the one of them will be lost during conversion.

1. It needs your post and threads already converted by Merge Tool.
2. This tool is designed as test tool, becarefull before using it. Make backups, it can screw up your databases !

<?php

$connect = mysql_connect ("hostname", "user", "password"); // database connection details
mysql_query ("SET NAMES utf8"); // encoding

mysql_select_db ('punbb_forum'); // source database name (PunBB 1.32)



$posts_query = mysql_query ("SELECT message, posted FROM punbb_posts"); // replace punbb table prefix for your own
$topics_query = mysql_query ("SELECT subject, posted FROM punbb_topics"); // replace punbb table prefix for your own

echo ("Reading posts.<br>");
$i=0;
while($item = mysql_fetch_row($topics_query))
{
	$topics[0][$i] = mysql_escape_string($item[0]);
	$topics[1][$i] = $item[1];
	if ($i % 100 == 0) echo $i . '<br>';
	$i++;
}
echo $i . '<br>';

echo ("Reading topics.<br>");
$j=0;
while($item = mysql_fetch_row($posts_query))
{
	$posts[0][$j] = mysql_escape_string($item[0]);
	$posts[1][$j] = $item[1];
	if ($j % 200 == 0) echo $j . '<br>';
	$j++;
}
echo $j . '<br>';
mysql_select_db ('mybb'); // destination database name (MyBB 1.44)


for ($b=0; $b < $i; $b++)
{	
	$err = mysql_query ("UPDATE `mybb_threads` SET `subject` = '".$topics[0][$b]."' WHERE `dateline` = '".$topics[1][$b]."'"); // replace mybb table prefix for your own
	if ($b % 200 == 0) echo $b . '<br>';
	if (!$err) {echo "mybb_threads error"; exit();}	
}

for ($a=0; $a < $j; $a++)
{
	$err = mysql_query ("UPDATE `mybb_posts` SET `subject` = '".$topics[0][$a]."', `message` = '".$posts[0][$a]."'  WHERE `dateline` = '".$posts[1][$a]."'"); // replace mybb table prefix for your own
	if ($a % 100 == 0) echo $a . '<br>';
	if (!$err) {echo "mybb_posts error"; exit();}
}

?>

Still need help with other things like categories, forums, signatures etc., but you can even do it manually it is not as hard as repairing post, topics etc. Wink

... or maybe someone figured out how to fix existing converter encoding?
I am not definitely MySQL encoding and collates master Wink.

Where can I get the realtime support, where I can discuss problem with developers and get some help, also try to help fix it. Wink