MyBB 1.2.x ---> phpBB2.0.22 convertor

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
todespudel
Registered User
Posts: 37
Joined: Fri Oct 05, 2007 4:15 pm

MyBB 1.2.x ---> phpBB2.0.22 convertor

Post by todespudel » Sat Oct 06, 2007 5:23 pm

NOT SUPPORTED ANYMORE!




Upgrading to phpbb3 works fine.

28.2.08: new script version
# killed a minor bug
# gui included - not tested with Windows, so it is disabled by default. Enable it if you want to give it a try by setting gui to True in the script.

-------------
Note: passwords aren't really converted, as it is not possible technically. See post #5 for details and a solution.
---------------------
THIS IS NO SERVER-SIDE SCRIPT! YOU MUST RUN IT ON YOUR LOCAL MACHINE!


This version is still BETA, as I can only test it with my dump. It seems to work, though.

This convertor does not convert announcements, settings, attachments, ranks and other not so important stuff .

Supermoderators will be imported as normal mods and they will be set as moderator for every forum.

So if you want to give it a try:
You will most likely need phpmyadmin (the converter was only tested with phpmyadmin dumps...).

BEFORE CONVERTING:
Make sure that there is at least one regular admin (user_group 4). Any user who is subscribed to a custom user_group (>7) wil become a standard registered user in phpbb2.

So here we go:
0.) Create a new directory on your hard disk where you save all files related to this conversion.
1.) Make a DB dump. You MUST NOT use complete inserts!
phpymyadmin: select your db, click export, select the mybb tables, tick structure, tick 'simple quotes for table and field names' (or sth like that - again: I don't use the english version, sry), tick data, untick "extended inserts", untick "complete inserts", tick "send", click ok and save the file to your 'conversion' directory.
2.) Download the python script to the same directory as the db dump.]Download the script here.
3.) Open the script with some editor and adjust the settings.
4.) Linux: run the script
Windows: download Python and install it.
Open the command line and browse to the directory where you have installed Python. Start the script:

Code: Select all

python c:\\\\path\\\\to\\\\script_file\\\\script.py
5.) Make a clean (which means NO mods) phpBB 2.0.22 installation (on your server).
6.) Use bigdump.php or sth. else to import the created database file (phpbb2.sql) to your phpbb2 database (on your server).
7.) If you want to stay with phpbb2: see the next post. Edit login.php.
If you want to upgrade to phpbb3: run the phpbb3 update script and see post #5 for further information.
8.) Delete the whole conversion directory.
Last edited by todespudel on Tue May 27, 2008 4:38 pm, edited 32 times in total.

todespudel
Registered User
Posts: 37
Joined: Fri Oct 05, 2007 4:15 pm

Re: Python MyBBB 1.2.9 ---> phpBB2.0.22 convertor

Post by todespudel » Sun Oct 07, 2007 1:37 am

I've found a solution for the passwords.
background information
The converter creates a new table which is called prefix_mybb_passwords and which contains the fields username, (mybb)password, salt, new_pw_set.

If the user logs in and $password != $row['user_password'] it will create the mybb pw and check again. If the check is successfull, the phpbb2 password is rewritten and new_pw_set in prefix_mybb_passwords is set to 1 (You can then delete these entries manually with DROP TABLE prefix_mybb_passwords WHERE new_pass_set = 1; - I don't want to do it automatically)

So, please: the following code sucks, I need someone who is familiar with php and phpbb2 in order to review and to improve it.

For example, phpbb_mybb_password is hardcoded, it should be sth. like $prefix.'mybb_passwords'
/background information

Edit login.php:

Code: Select all

----------[AFTER LINE109, ADD]------------
				//mybb passwords
          		if( md5($password) !== $row['user_password'] && $row['user_active'] )
            	{
                  $sql = "SELECT * FROM phpbb_mybb_passwords WHERE username = '".$username."'";

                 if( !($result2 = $db->sql_query($sql)) )
                 {
                     message_die(GENERAL_ERROR, 'Password Error:<br />Please contact the board administrator immediately.', __LINE__, __FILE__, $sql);
                  }
                 $row2 = $db->sql_fetchrow($result2);
	              $mybb_pw =  md5(md5($row2['salt']).md5($password));
                  if ($mybb_pw == $row2['password'])
                  {
                  	$sql = "UPDATE '" . USERS_TABLE . "'  SET user_password = '".md5($password)."'";
                  	$db->sql_query($sql);
                  	$sql = "UPDATE phpbb_mybb_passwords SET new_pw_set = 1";
                  	$db->sql_query($sql);
                  	
            		$autologin = ( isset($HTTP_POST_VARS['autologin']) ) ? TRUE : 0;

					$admin = (isset($HTTP_POST_VARS['admin'])) ? 1 : 0;
					$session_id = session_begin($row['user_id'], $user_ip, PAGE_INDEX, FALSE, $autologin, $admin);

					// Reset login tries
					$db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_login_tries = 0, user_last_login_try = 0 WHERE user_id = ' . $row['user_id']);

					if( $session_id )
					{
						$url = ( !empty($HTTP_POST_VARS['redirect']) ) ? str_replace('&', '&', htmlspecialchars($HTTP_POST_VARS['redirect'])) : "index.$phpEx";
						redirect(append_sid($url, true));
					}
					else
					{
						message_die(CRITICAL_ERROR, "Couldn't start session : login", "", __LINE__, __FILE__);
					}
                  }
                 }
-----------------[ADJUST]---------------[phpbb_mybb_passwords] 
Last edited by todespudel on Sat Mar 22, 2008 5:30 pm, edited 3 times in total.

toykilla
Registered User
Posts: 1
Joined: Thu May 27, 2004 11:41 pm

Re: Python MyBBB 1.2.9 ---> phpBB2.0.22 convertor

Post by toykilla » Sun Oct 14, 2007 3:52 pm

This is amazing and just what I was looking for. What is the issue with the passwords?

todespudel
Registered User
Posts: 37
Joined: Fri Oct 05, 2007 4:15 pm

Re: Python MyBBB 1.2.9 ---> phpBB2.0.22 convertor

Post by todespudel » Sun Oct 14, 2007 10:10 pm

Well, did it work for you?

The password issue:
phpbb2 stores all password as the following: md5(password). Which means, the password is encrypted using the md5 algorithm.

Mybb stores them like that: md5(salt+md5(password))

The problem is that there is no way to decrypt it. So the only chance is to add one more table to phpbb2 as I described above. With the above changes of login.php, everythig will be fine after the first succesfull login of each user (as the password is stored again as md5(password) and you can remove the additional table.

todespudel
Registered User
Posts: 37
Joined: Fri Oct 05, 2007 4:15 pm

Mybb to phpbb3

Post by todespudel » Mon Nov 05, 2007 6:18 pm

So here we go:

After running the phpbb3 conversion script on your phpbb2 database you should be able to see all the forums and posts. If not, something went wrong.

So if everything seems to be fine and you try to login - well, it doesn't work :P

The following is a bad hack, but it works (I'd be happy if someone could improve it):

1. First: you will have to transfer the table prefix_mybb_passwords to the database which your phpbb3 installation is using. (phpmyadmin: click on the table, export it and import it again)
2. Edit includes/auth/auth_db

Find:

Code: Select all

// in phpBB2 passwords were used exactly as they were sent, with addslashes applied
Before, add (note: you must adjust the prefix of phpbb_mybb_passwords in the following code):

Code: Select all

		//this should be a mybb password
		$sql2 = 'SELECT username, password, salt, new_pw_set
		FROM phpbb_mybb_passwords WHERE username = \''.$username.'\'';
		$result2 = $db->sql_query($sql2);
		$row2 = $db->sql_fetchrow($result2);
		$db->sql_freeresult($result2);
		$mybb_pw =  md5(md5($row2['salt']).md5($password));	
Find:

Code: Select all

			if (md5($password_old_format) == $row['user_password'] || md5(utf8_to_cp1252($password_old_format)) == $row['user_password'])
Replace with:

Code: Select all

			if (md5($password_old_format) == $row['user_password'] || md5(utf8_to_cp1252($password_old_format)) == $row['user_password'] 
				|| $mybb_pw == $row['user_password'])
Test it.....
Last edited by todespudel on Fri Nov 16, 2007 4:40 pm, edited 1 time in total.

lordtopcat
Registered User
Posts: 194
Joined: Tue Sep 14, 2004 6:52 am
Location: New Zealand
Contact:

Re: Python MyBB 1.2.9 ---> phpBB2.0.22 convertor

Post by lordtopcat » Fri Nov 16, 2007 5:30 am

Hi guys,

I have uploaded the script to my server and when i go to run it is comes up saying it wants me to download the same file (the python script)

i have been on the phone with my webhost all afternoon and they have come to the conclusion it is nothing to do with them, they support python and other scripts work.

thanks
- Lord Top Cat -
Loving the new site.

todespudel
Registered User
Posts: 37
Joined: Fri Oct 05, 2007 4:15 pm

Re: Python MyBB 1.2.9 ---> phpBB2.0.22 convertor

Post by todespudel » Fri Nov 16, 2007 4:29 pm

The script isn't meant to run on the server! ;)

You need to make a database dump, save it to your local machine, install python on your local machine and run the script as described above (on your local machine ;) ). As most hosters don't support python (which is a shame) and as I needed a script for my forum I had to write it that way (the other option would have been to write a server script and to make a dump, install apache and mysql on my local machine, import the dump to my local database, run the script, export the database again and import it again to the "real" database.....too much hassle).

lordtopcat
Registered User
Posts: 194
Joined: Tue Sep 14, 2004 6:52 am
Location: New Zealand
Contact:

Re: Python MyBB 1.2.9 ---> phpBB2.0.22 convertor

Post by lordtopcat » Fri Nov 16, 2007 8:36 pm

Oh tits! It serves me right for trying to do things too fast!

Thanks,
LTC
- Lord Top Cat -
Loving the new site.

lordtopcat
Registered User
Posts: 194
Joined: Tue Sep 14, 2004 6:52 am
Location: New Zealand
Contact:

Re: Python MyBB 1.2.9 ---> phpBB2.0.22 convertor

Post by lordtopcat » Fri Nov 16, 2007 9:20 pm

Hi! I'm back again.

I managed to install python, and I can run the script fine. It comes up asking if I want to do something with bbcodes? So i say yes, and then this error comes up:

Image

This is the settings for the script:

Code: Select all

#If you don't want to enter all the settings each time you are running this
#script set "defaults" to 'yes'. Default setting is 'no'.
defaults = 'yes'
#Adjust the table prefix of your MyBB installation
boardprefix = 'mybb_'
boardprefixphpbb = 'phpbb_'

#Make sure that your database dump and this script are located in the following
#directory
#example Windows: conversion_path = 'c:\\Path\\to\\file\\'
#example Linux conversion_path = '/path/to/file/'
conversion_path = 'C:\\Documents and Settings\\xxxx\\Desktop'

#What is the name of your database dump, which must be located in the same 
#directory as this script?
sqldump = 'Desktopdump.sql'
I have made sure that Desktopdump.sql is on the desktop, where the script is.

What am I doing wrong?

Thanks,
LTC
- Lord Top Cat -
Loving the new site.

todespudel
Registered User
Posts: 37
Joined: Fri Oct 05, 2007 4:15 pm

Re: Python MyBB 1.2.9 ---> phpBB2.0.22 convertor

Post by todespudel » Sat Nov 17, 2007 10:39 am

Hm. Try

Code: Select all

conversion_path = 'C:\\Documents and Settings\\xxxx\\Desktop\\'
(note the last two \\)

Edit: Yeah, the two missing \\ are the problem.
I've updated the script - it now has some basic check routines for path and file name and it can handle missing \\ ;)

I hope that it works now....

lordtopcat
Registered User
Posts: 194
Joined: Tue Sep 14, 2004 6:52 am
Location: New Zealand
Contact:

Re: Python MyBB 1.2.9 ---> phpBB2.0.22 convertor

Post by lordtopcat » Sat Nov 17, 2007 8:36 pm

Phew, yep that worked.

However it only converts topics and posts? How can I convert other things like Users etc?

Thanks
LTC
- Lord Top Cat -
Loving the new site.

todespudel
Registered User
Posts: 37
Joined: Fri Oct 05, 2007 4:15 pm

Re: Python MyBB 1.2.9 ---> phpBB2.0.22 convertor

Post by todespudel » Sat Nov 17, 2007 8:53 pm

Uh?

It (should) convert(s) users aswell!
But if you want to login you have to read post #2, as it is not possible to convert the passwords directly.

It should convert posts, forums, topics, users, pms, polls...no attachments so far and no settings/smilies/banlist.

Edit: waaaaaaaaah - wtf?! Ok, sth is wrong. I've got various test installations of phpbb2 on my local machine and I tested the script by importing it to the db - and now I see that I imported the dump to the wrong database - so when I checked the forum everything seemed fine. But I must have broken sth. somewhere - stay tuned.
And sorry for the inconveniences... :\ It has worked some time ago and I'm about to fix it right now...

Edit2: If you don't care about bbcode tags being displayed in posts set convert_bbc = 'no'. That works. Edit3 with a real fix is to come soon (~hour ^^) - hopefully ;)

lordtopcat
Registered User
Posts: 194
Joined: Tue Sep 14, 2004 6:52 am
Location: New Zealand
Contact:

Re: Python MyBB 1.2.9 ---> phpBB2.0.22 convertor

Post by lordtopcat » Sat Nov 17, 2007 9:32 pm

When I do both yes or no, it creates a sql file called phpBB2. So I thought all fine, but I open it up and it only has topics and posts? But it also creates a load of different files like mybb_users mybb_pollvotes etc on the desktop, but these are not in sql format?

thanks
LTC
- Lord Top Cat -
Loving the new site.

todespudel
Registered User
Posts: 37
Joined: Fri Oct 05, 2007 4:15 pm

Re: Python MyBB 1.2.9 ---> phpBB2.0.22 convertor

Post by todespudel » Sat Nov 17, 2007 9:54 pm

You can safely remove those files (I have to add that to the instructions - you see, you are the first beta tester :P ). Only phpbb2.sql is the file you need. The other files are just used in order to save stuff to the hard disk temporarily to save some ram.

How big is your dump file? I'd like to run some tests with it, because if you select 'no', it should work flawlessly (at least mine does so... :\). You could delete all email-adresses and passwords/salts (of course not in your original database) (although they are encrypted anyway) if you don't trust me at all and make a dump afterwards :) (Sql: UPDATE table_name SET cell = '0000')

lordtopcat
Registered User
Posts: 194
Joined: Tue Sep 14, 2004 6:52 am
Location: New Zealand
Contact:

Re: Python MyBB 1.2.9 ---> phpBB2.0.22 convertor

Post by lordtopcat » Sat Nov 17, 2007 10:41 pm

134bs
- Lord Top Cat -
Loving the new site.

Locked

Return to “[2.0.x] Convertors”