$memberpath = \\"/path/to/members\\";
$dbhost = \\"localhost\\";
$dbname = \\"database\\"; //change this to correct value
$dbuser = \\"login\\"; //change this to correct value
$dbpass = \\"pass\\"; //change this to correct value
// open directory, load member filenames into array
$handle = opendir($memberpath);
$a = 0;
while ($file = readdir($handle))
{
if((preg_match(\\\'||\\\', $file)))
{
$members[$a] = $file;
echo \\"
file $a: $file\\";
$a++;
}
}
closedir($handle);
// count remaining elements of array
$i = count($members) - 1;
// insert data into XMB mysql database
$db = mysql_connect(\\"$dbhost\\", \\"$dbuser\\", \\"$dbpass\\") or
die(\\"Error: could not connect to the database. Using username $dbuser and password $dbpass.
Please go back and try again.\\");
@mysql_select_db(\\"$dbname\\", $db) or die (\\"
Error: Could not open database.\\");
// for each member, gather data for import
echo \\"
Processing $i members .\\";
while ( $i >= 0 ) {
$linetodecode = file($members[$i]);
$member = explode( \\"|\\", $linetodecode[0]);
$user_username = addslashes(trim($member[0]));
$user_password = addslashes(trim($member[1]));
$user_regdate = trim($member[13]);
$user_postnum = trim($member[4]);
$user_email = trim($member[5]);
$user_site = addslashes(trim($member[8]));
if (!strcmp($user_website,\\\'http://\\\')) {$user_website = \\"\\";}
$user_aim = trim($member[9]);
if($member[3] == \\"ad\\") {
$user_status = \\"Administrator\\";
}
elseif($member[3] == \\"mo\\") {
$user_status = \\"Moderator\\";
}
elseif($member[3] == \\"me\\") {
$user_status = \\"Member\\";
}
$user_from = addslashes(trim($member[11]));
$user_bio = addslashes(trim($member[12]));
$user_sig = addslashes(trim($member[15]));
$user_regip = addslashes(trim($member[7]));
$user_showemail = trim($member[6]);
$user_icq = trim($member[10]);
$user_timeoffset = \\"0\\";
$user_location = addslashes(trim($member[11]));
$user_theme = \\"default\\";
$user_langfile = \\"english\\";
$user_tpp = \\"15\\";
$user_ppp = \\"25\\";
$user_newsletter = \\"no\\";
echo \\".\\";
$user_uid = $i+1;
$sql = \\"replace into xmb_members
(uid, username, password, regdate, postnum, email, site, aim, status, location, bio, sig, showemail, timeoffset, icq, avatar, yahoo, customstatus, theme, bday, langfile, tpp, ppp, newsletter, regip)
values
(\\\'$user_uid\\\', \\\'$user_username\\\', \\\'$user_password\\\', \\\'$user_regdate\\\', \\\'$user_postnum\\\', \\\'$user_email\\\', \\\'$user_site\\\', \\\'$user_aim\\\', \\\'$user_status\\\', \\\'$user_location\\\', \\\'$user_bio\\\', \\\'$user_sig\\\', \\\'$user_showemail\\\', \\\'$user_timeoffset\\\', \\\'$user_icq\\\', \\\'$user_avatar\\\', \\\'$user_yahoo\\\', \\\'$user_customstatus\\\', \\\'$user_theme\\\', \\\'$user_bday\\\', \\\'$user_langfile\\\', \\\'$user_tpp\\\', \\\'$user_ppp\\\', \\\'$user_newsletter\\\', \\\'$user_regip\\\' )\\";
echo \\"
\\";
echo $sql;
$result = mysql_query($sql, $db) or die(\\"
Could not query the database! Check syntax!
Failed inserting $username ($members[$i])
\\" );
$i--;
}
echo \\"
Done Processing!\\";
exit;
?>