Information on how to build an import script for users
If you are planning on importing users from a 3rd party script there are certain fields that are required. Below we list all the required fields to create a successful import of users from a 3rd party script.
There are 5 tables that require a record for each user. The main table is:
user
This creates the unique ID for each user. The remaining 4 tables uses the unique ID created by the "user" table:
user_activity user_field user_space user_count
First, we need to successfully create a unique ID and to do this we require the following fields for the
user
table:
user_group_id (Holds the users group ID, which by default is 2) full_name (Full Name or Display Name of the user) email (Email of the user) joined (Unix time stamp of when the user joined)
Another field we require is:
user_name
This field holds the vanity URL. It must be unique as this what we use to visit a users profile. Only alphanumeric characters can be used and the underscore:
A-Z0-9_
If you are unable to get a user name you can use a users full name/display name and remove any unwanted characters or use their unique ID#, which can be updated after inserting the user into the "user" table.
The final field we require for this table is the password. It is split up into 2 fields:
password password_salt
The field:
password
holds a 32 character salted MD5 hashed version of their password. In order to get this value we use the following PHP code:
md5(md5($PASSWORD) . md5($SALT))
The variable:
$PASSWORDholds the users password. The variable:
$SALTholds a random set of characters. The PHP function we use is:
function getSalt($iTotal = 3) { $sSalt = ''; for ($i = 0; $i < $iTotal; $i++) { $sSalt .= chr(rand(33, 91)); } return $sSalt; }
For the field:
password_salt
we input the value for the salt we created earlier and used in the MD5 hash.
Once you have inserted the information to the database it should return a unique ID#. This number will be used to insert information for the remaining tables:
user_activity user_field user_space user_count
With the ID# we now have, insert that ID# into the field:
user_id
for each remaining table.

Just in case it's useful to anyone who is manually importing their user database: You can manually calculate the Birthday_Search value from the Birthday field using the following SQL statement:
UPDATE `phpfox_user` SET `birthday_search` = DATEDIFF( STR_TO_DATE(`birthday`,'%d%m%Y'),FROM_UNIXTIME(0))*24*3600;
You can manually calculate the number of friends using the following SQL statement (don't forget that phpFox requires two rows for each friendship, so you don't have to perform a reverse search as you may do with other CMSs).
UPDATE phpfox_user_field SET total_friend = (SELECT count(*) FROM phpfox_friend WHERE phpfox_friend.friend_user_id = phpfox_user_field.user_id GROUP BY phpfox_friend.friend_user_id);




