News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

[Converter] XenForo 1.2 --> SMF 2.0.x

Started by margarett, October 06, 2013, 05:09:45 PM

Previous topic - Next topic

margarett

Following some requests here, I tried to create a converter from XF. The attached file results of some trial-and-error around XF's database schema and the necessary equivalent in SMF.
Unfortunately I struggled too much with the "official" converters so I eventually gave up and started from scratch. I know that I've probably tried to reinvent the wheel but this way I know what I am doing, every step of the way.
Also, I'm not very good at design and present forms to fill and blablabla. So, there is no beautiful layout and some file edits are needed. Nothing too much, but it has to be done.

What the converter will convert:

  • Members
  • Categories
  • Boards
  • Topics/Posts
  • PMs
  • post attachments
  • avatars
  • polls

How to use this converter:
1 - BACKUP
2 - Install SMF in a separate folder and in the same database as XF
3 - Download the attached "xf2smf.php" file to you computer and edit it with a decent editor (eg: Notepad++). The small edits that are needed are all localized in this part here:

3.1 - You need to define the folder where XF is installed. By folder, I mean the server path where XF's installation is located. SMF's path is automatically discovered (because you will put the file there :P ). If you don't know it, please upload the attached "whats_the_path.php" file to XF's folder and run it via browser. It will tell you the path you should add.
3.2 - You need to adjust my "$max_queries" variable. This defines how many registers the converter tries to move at once. A low number takes a LOT of time, a large number will hammer your server and may cause it to become unresponsive.
3.3 - As my image above states, I didn't find a way to change XF's table prefix, so it shouldn't be necessary to change anything else. But, in case your prefix isn't "xf_" please edit the corresponding line
4 - Save. Load the file "xf2smf.php" to SMF's folder and launch it through your browser. The whole "thing" is a step-by-step operation and each step deals with each of the converted parts.
4.1 - You will notice, in the first screen, that the paths for SMF and XF (the first one is self-discovered, the second was set by you) are shown. Please check them ;)

5 - When the conversion finishes, you should remove the file from your SMF folder. Go to your newly converted forum and recover your password. The converter does not (and probably will not) convert passwords so you need to follow the usual steps for password recovery. If you cannot email yourself a new password, use this trick from the wiki:
QuoteResetting an admin users password

Use phpMyAdmin (or similar) to locate (within the "_members" table) the member whose password is to be reset. In the database field entitled "passwd", enter a new password using plain text.
Then, clear out (erase) any existing content in the database field entitled "password_salt".
The next time the member logs in (using the new password), SMF will automatically re-encrypt his credentials.
6 - Go to your ACP --> Maintenance --> Recount all forum totals and statistics. This will (obviously) fill your boards and topics totals.

That's it, for now. Please do test and let me know the outcome. If the converter throws a "database error" somewhere, it will be stored in the table "smf_log_errors" (it will probably be the last one). It is handy if you check that table and also attach your "xf2smf.php" in use.
Finally, be advised that this was developed and tested with a local installation of XAMPP, so I cannot tell the impact in a live and especially shared server. It shouldn't kill it, don't worry :P

License: Simplified BSD (BSD-2)

Code (Changelog) Select

Version 1.02 // 22-03-2016
! Fixed issue with trying to insert empty polls
! Changed license to Simplified BSD

Version 1.01 // 18-03-2014
================================================================================
! Fixed issue with empty "poster_name" or "poster_email"

Version 1.00 // 13-11-2013
================================================================================
+ Added import for polls
+ Added option to automate the converter (moving between steps automatically)

Version 0.14 // 26-10-2013
================================================================================
! Fixed possible issue with password not stored as initially expected

Version 0.13 // 26-10-2013
================================================================================
+ Added a license
+ Added import for user avatars

Version 0.12 // 21-10-2013
================================================================================
+ Added import for Post Attachments

Version 0.11 // 07-10-2013
================================================================================
+ Added import for PMs

Version 0.10 // 06-10-2013
================================================================================
+ First release

Legend:
--------------------------------------------------------------------------------
! Minor change or bugfix.
+ Feature addition or improvement.
- Feature or option removal.
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

margarett

Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

AllanD

Thank you Margerett I will try this out today sometime and post back here for you.
Check out this great sites.
KnD Hosting

AllanD

Quick question and for some reason I can't remember how to define the root directory for the xenforo install.
Check out this great sites.
KnD Hosting

margarett

Ty for trying.

Edit the converter and edit the line:

$xf_dir = '';

If you are unsure of what the full path is, upload the attached file to XF's folder and run it through your browser. It will tell you the folder.
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

AllanD

ok got that sorted out here is the error I'm receiving

in the acp

http://xxxxx.com/forum/xf2smf.phpApply Filter: Only show the errors with the same messageDatabase Error: Table 'xxxx_smf.xf_user' doesn't existApply Filter: Only show the errors from this file File: /home/xxx/public_html/forum/xf2smf.php
Line: 71

and this is the error in the

Table 'xxxx_smf.xf_user' doesn't exist
File: /home/xxxxx/public_html/forum/xf2smf.php
Line: 71

If you need to know the xxxx i will pm you.
Check out this great sites.
KnD Hosting

margarett

Did you install both XF and SMF in the same DB (different prefixes)?
Is the prefix for XF's tables "xf_"?

That line is just a test to see if it finds both sets of tables (and I just tested both "members" tables).
So, the script cannot find the table "xf_user" in the database "xxxx_smf".
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

AllanD

oh they have to go into the sames Db, not on the same server?  Never done that so not sure how lol
also will that mess up the current live xenforo forum.
Check out this great sites.
KnD Hosting

margarett

It won't mess up, as long as you don't mix the table prefixes ;)

Using the default values in both forums, XF is "xf_" and SMF is "smf_". So it should be safe ;)
Just backup your XF DB for the sake of conscience, but it will be fine.
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

AllanD

Once I got this the set worked like a charm, no errors converting.
Check out this great sites.
KnD Hosting

margarett

Very nice to "hear" that, thanks a lot. ;D

Can you check if everything is in place, no missing boards, topics, PMs, etc? The conversion from "Conversations" from our "PM" was a bit tricky, I admit...

Post attachments are in the making ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

AllanD

Everything is in order, Pm's, topics and boards all is great. Thank you so much for this.
Check out this great sites.
KnD Hosting

margarett

New update. The converter is now taking care of Post Attachments.
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

AllanD

Very nice, was looking for a like button :P
Check out this great sites.
KnD Hosting

margarett

New update: user avatars are now converted :)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

matt1206

I'm getting the following error on the members section when trying to convert:

This is the first step of the conversion. We are trying to convert Members


First, let's trash the actual contents of SMF members table....
Members cleared from SMF table. Next step, how many members are in XF "users" table? 20 users were found in XF.
Now retrieving members 1 to 10...

Notice: Undefined index: hash in /home/sffcouk/public_html/smf/xf2smf.php on line 210

Notice: Undefined index: hash in /home/sffcouk/public_html/smf/xf2smf.php on line 210

Notice: Undefined index: hash in /home/sffcouk/public_html/smf/xf2smf.php on line 210
An Error Has Occurred!

The database value you're trying to insert does not exist: passwd


Converting from XF1.2.2

Thanks,
Matt

margarett

Hu? :o Let's hope that the database schema wasn't changed (I used 1.2.0). Can you please edit the file, find:
foreach ($members as $key => $value)
{
$temp_passwd = unserialize($value['passwd']);

Add after:
echo '<pre>';
print_r ($temp_passwd);
echo '</pre>';


And repeat?
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

matt1206

#17
Sure:

First, let's trash the actual contents of SMF members table....
Members cleared from SMF table. Next step, how many members are in XF "users" table? 20 users were found in XF.
Now retrieving members 1 to 10...
Array
(
    [hash] =>
)
Array
(
    [hash] =>
)
Array
(
)

Notice: Undefined index: hash in /home/sffcouk/public_html/smf/xf2smf.php on line 213
Array
(
   
)
Array
(
)

Notice: Undefined index: hash in /home/sffcouk/public_html/smf/xf2smf.php on line 213
Array
(
    [hash] =>
)
Array
(
    [hash] =>
)
Array
(
)

Notice: Undefined index: hash in /home/sffcouk/public_html/smf/xf2smf.php on line 213
Array
(
    [hash] =>
)
Array
(
    [hash] =>
)
An Error Has Occurred!

The database value you're trying to insert does not exist: passwd

margarett

Sorry, edited your post to remove the hash. Just in case ;)
Anyway, it was OK, there is no reason for the undefinedindex, unless it's some PHP version difference...
Can you please attach your current xf2smf.php here?
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

matt1206


Advertisement: