Date registered is not converted

Started by Joris, June 02, 2007, 02:41:10 AM

Previous topic - Next topic

Joris

Hi, I am hoping someone can help me out with this one;
I am converting a YaBB 2.1 forum to SMF 1.1.2. I got the conversion to complete, but the member registration date is set to 1-1-1970. Is this not included in the conversion routine for some reason? Or did I do something wrong?
Thanks for any input.

Here's one of the .vars files from YaBB:
### User variables for ID: bbutcher ###

'password',"xxxxxxxx"
'realname',"bbutcher"
'email',"[email protected]"
'regdate',"03/16/07 at 15:57:18"
'webtitle',"C J Shawn & Co "
'weburl',"http://www.cjshawn.com"
'signature',"G. William "Bill" Butcher&&"When life hands you lemons, reach for the tequila & salt !""
'postcount',"0"
'position',""
'addgroups',""
'icq',""
'aim',""
'yim',""
'gender',"Male"
'usertext',""
'userpic',"http://www.cjshawn.com/images/bill.jpg"
'regtime',"1174057038"
'location',"Atlanta, GA"
'bday',"10/16/1942"
'timeselect',"4"
'timeoffset',"-5"
'timeformat',"MM D+ YYYY @ HH:mm:ss*"
'hidemail',""
'msn',""
'gtalk',""
'template',"Forum default"
'language',"English"
'lastonline',"1174061891"
'lastpost',""
'lastim',""
'im_ignorelist',""
'im_notify',"1"
'im_popup',""
'im_imspop',""
'cathide',""
'postlayout',""
'session',""
'sesquest',""
'sesanswer',"xxxxxxxxx"
'favorites',""
'dsttimeoffset',"1"
'pageindex',"1|1|1"

backyard

This is the same problem I'm having. I'm thinking this is what's causing my members to be ex-members.

Joris

#2
Here's fixed code with a workaround for this problem. Just replace function convertStep2() in yabb21_to_smf.php with this code.

Note that I am not this project's programmer, so ask him for the proper fixes!!


function convertStep2()
{
global $to_prefix, $yabb;

echo 'Converting members...';

if ($_GET['substep'] == 0 && !empty($_SESSION['purge']))
{
convert_query("
TRUNCATE {$to_prefix}members");
}
if ($_GET['substep'] == 0 || (isset($_SESSION['cstep']) && $_SESSION['cstep'] < 2))
{
// Get rid of the primary key... we have to resort anyway.
$knownKeys = array(
'PRIMARY' => 'DROP PRIMARY KEY',
);
$alterColumns = array(
'ID_MEMBER' => 'CHANGE COLUMN ID_MEMBER ID_MEMBER mediumint(8) unsigned NOT NULL default 0',
);
alterTable('members', $knownKeys, '', $alterColumns);

// Set the session to prevent falling back to step 0 and getting an error
$_SESSION['cstep']++;
}

pastTime(0);

$request = convert_query("
SELECT ID_GROUP, groupName
FROM {$to_prefix}membergroups
WHERE ID_GROUP != 3");
$groups = array('Administrator' => 1, 'Global Moderator' => 2, 'Moderator' => 0);
while ($row = mysql_fetch_assoc($request))
$groups[$row['groupName']] = $row['ID_GROUP'];
mysql_free_result($request);

$file_n = 0;
$dir = dir($yabb['memberdir']);
$block = array();
$text_columns = array(
'memberName' => 80,
'lngfile' => 255,
'realName' => 255,
'buddy_list' => 255,
'pm_ignore_list' => 255,
'messageLabels' => 65534,
'passwd' => 64,
'emailAddress' => 255,
'personalText' => 255,
'websiteTitle' => 255,
'websiteUrl' => 255,
'location' => 255,
'ICQ' => 255,
'AIM' => 16,
'YIM' => 32,
'MSN' => 255,
'timeFormat' => 80,
'signature' => 255,
'avatar' => 255,
'usertitle' => 255,
'memberIP' => 255,
'memberIP2' => 255,
'secretQuestion' => 255,
'secretAnswer' => 64,
'validation_code' => 10,
'additionalGroups' => 255,
'smileySet' => 48,
'passwordSalt' => 5,
);
while ($entry = $dir->read())
{
if ($_GET['substep'] < 0)
break;
if ($file_n++ < $_GET['substep'])
continue;
if (strrchr($entry, '.') != '.vars' && strrchr($entry, '.') != '.dat')
continue;

$name = substr($entry, 0, strrpos($entry, '.'));

$userData = file($yabb['memberdir'] . '/' . $entry);
if (count($userData) < 3)
continue;

$data = array();
foreach ($userData as $i => $v)
{
$userData[$i] = trim($userData[$i]);

if (strrchr($entry, '.') == '.vars' && preg_match('~^\'([^\']+)\',"([^"]+)"~', $userData[$i], $match) != 0)
$data[$match[1]] = $match[2];

}

// Is it an invalid user?
if (empty($data))
continue;

if (strrchr($entry, '.') != '.vars')
{
$userData = array_pad($userData, 31, '');
$data = array(
'password' => $userData[0],
'realname' => $userData[1],
'email' => $userData[2],
'webtitle' => $userData[3],
'weburl' => $userData[4],
'signature' => $userData[5],
'postcount' => $userData[6],
'position' => $userData[7],
'icq' => $userData[8],
'aim' => $userData[9],
'yim' => $userData[10],
'gender' => $userData[11],
'usertext' => $userData[12],
'userpic' => $userData[13],
'regdate' => $userData[14],
'location' => $userData[15],
'bday' => $userData[16],
'hidemail' => $userData[19],
'msn' => $userData[20],
'lastonline' => $userData[23],
'im_ignorelist' => $userData[26],
'im_notify' => $userData[27],
// !!! 'cathide' => $userData[30],
// !!! 'postlayout' => $userData[31],
);
}

$row = array(
'memberName' => substr(htmlspecialchars($name), 0, 80),
'passwd' => strlen($data['password']) == 22 ? bin2hex(base64_decode($data['password'])) : md5($data['password']),
'realName' => htmlspecialchars($data['realname']),
'emailAddress' => htmlspecialchars($data['email']),
'websiteTitle' => isset($data['website']) ? htmlspecialchars($data['webtitle']) : '',
'websiteUrl' => isset($data['weburl']) ? htmlspecialchars($data['weburl']) : '',
'signature' => isset($data['signature']) ? str_replace(array('&amp;&amp;', '&amp;lt;', '&amp;gt;'), array('<br />', '&lt;'. '&gt;'), strtr($data['signature'], array('\'' => '&#039;'))) : '',
'posts' => (int) $data['postcount'],
'ID_GROUP' => isset($data['position']) && isset($groups[$data['position']]) ? $groups[$data['position']] : 0,
'ICQ' => isset($data['icq']) ? htmlspecialchars($data['icq']) : '',
'AIM' => isset($data['aim']) ? substr(htmlspecialchars($data['aim']), 0, 16) : '',
'YIM' => isset($data['yim']) ? substr(htmlspecialchars($data['yim']), 0, 32) : '',
'MSN' => isset($data['msn']) ? htmlspecialchars($data['msn']) : '',
'gender' => isset($data['gender']) ? ($data['gender'] == 'Male' ? 1 : ($data['gender'] == 'Female' ? 2 : 0)) : '',
'personalText' => isset($data['usertext']) ? htmlspecialchars($data['usertext']) : '',
'avatar' => $data['userpic'],
'dateRegistered' => $data['regtime'],   // <JT> old code: parse_time($data['regdate'])
'location' => isset($data['location']) ? htmlspecialchars($data['location']) : '',
'birthdate' => isset($data['bday']) ? ($data['bday'] == '' || strtotime($data['bday']) == 0 ? '0001-01-01' : strftime('%Y-%m-%d', strtotime($data['bday']))) : '',
'hideEmail' => isset($data['hidemail']) && $data['hidemail'] == 'checked' ? '1' : '0',
'lastLogin' => isset($data['lastonline']) ? $data['lastonline'] : '',
'pm_email_notify' => empty($data['im_notify']) || trim($data['im_notify']) == '' ? '0' : '1',
'karmaGood' => 0,
'karmaBad' => 0
);


// Make sure these columns have a value and don't exceed max width.
foreach ($text_columns as $text_column => $max_size)
$row[$text_column] = isset($row[$text_column]) ? substr($row[$text_column], 0, $max_size) : '';

if ($row['birthdate'] == '0001-01-01' && parse_time($data['bday'], false) != 0)
$row['birthdate'] = strftime('%Y-%m-%d', parse_time($data['bday'], false));

if (file_exists($yabb['memberdir'] . '/' . substr($entry, 0, -4) . '.karma'))
{
$karma = (int) implode('', file($yabb['memberdir'] . '/' . substr($entry, 0, -4) . '.karma'));
$row['karmaGood'] = $karma > 0 ? $karma : 0;
$row['karmaBad'] = $karma < 0 ? -$karma : 0;
}

$block[] = addslashes_recursive($row);

if (count($block) > 100)
{
doBlock('members', $block);
pastTime($file_n);
}
}
$dir->close();

doBlock('members', $block);

pastTime(-1);

// Part 2: Now we get to resort the members table!
if ($_GET['substep'] >= -1)
{
convert_query("
ALTER TABLE {$to_prefix}members
ORDER BY ID_MEMBER, dateRegistered");
pastTime(-2);
}
if ($_GET['substep'] >= -2)
{
$knownKeys = array(
'PRIMARY' => 'ADD PRIMARY KEY (ID_MEMBER)',
);
$alterColumns = array(
'ID_MEMBER' => 'CHANGE COLUMN ID_MEMBER ID_MEMBER mediumint(8) unsigned NOT NULL auto_increment',
);
alterTable('members', $knownKeys, '', $alterColumns, true);

pastTime(-3);
}
if ($_GET['substep'] >= -3)
{
convert_query("
ALTER TABLE {$to_prefix}members
ORDER BY ID_MEMBER");
}
}


Advertisement: