Fixed SMF Importer Beta Improvements

Chris D

XenForo developer
Staff member
Some improvements have been made to the SMF Importer.
  • Avatars and attachments now import correctly in the event that there is only one configured attachments directory.
  • A member's date of birth is only imported if it is valid.
  •   has been cleaned up from post content.
Currently these issues are fixed in XenForo 1.4.4 but if you would like to beta test the updated importer it is attached below.

The updated file can overwrite the exiting file at the following path:

library/XenForo/Importer/SMF.php

 

Attachments

It very much depends on a few factors but with regards to the SMF importer it's not particularly relevant:

Currently these issues are fixed in XenForo 1.4.4 but if you would like to receive the fixed file sooner, please create a ticket in the Customer Area.
 
Some fixes:

SMF.php

Missing gender and custom title:
Replace:
PHP:
            'user_state' => ($user['is_activated'] == 1) ? 'valid' : 'moderated'

With:
PHP:
            'user_state' => ($user['is_activated'] == 1) ? 'valid' : 'moderated',
            'gender' => ($user['gender'] == 1) ? 'male' : (($user['gender'] == 2) ? 'female' : ''),
            'custom_title' => $user['personal_text'],

In my case, birthdate was yyyy/mm/dd.
Replace:
PHP:
        if ($user['birthdate'])
        {
            $parts = explode('-', $user['birthdate']);
            if (count($parts) == 3)
            {
                // Default birth year.
                if (trim($parts[2]) != '0001')
                {
                    $import['dob_day'] = trim($parts[0]);
                    $import['dob_month'] = trim($parts[1]);
                    $import['dob_year'] = trim($parts[2]);
                }
            }
        }

with:
PHP:
        if ($user['birthdate'] && $user['birthdate'] != '0001-01-01')
        {
            $parts = explode('-', $user['birthdate']);
            if (count($parts) == 3)
            {
                $import['dob_year'] = trim($parts[0]);
                $import['dob_month'] = trim($parts[1]);
                $import['dob_day'] = trim($parts[2]);
            }
        }

Abstract.php

In my case, since i'm not sure only   is there i wanted to play sure (today's fix version already handles nbsp in SMF.php)

After:
PHP:
     $string = utf8_unhtml($string, $entities);
     $string = preg_replace('/[\xF0-\xF7].../', '', $string);
     $string = preg_replace('/[\xF8-\xFB]..../', '', $string);
Add:
PHP:
     $string = html_entity_decode($string, ENT_QUOTES, 'UTF-8');
 
Last edited:
Top Bottom