Hey yall, I have subscriberinfo, which is the table that has all my sites users, from day one. this is up to 246. Around member 150 or so, i changed over the reg process to phpbb3, as well as login and sessions. When the user regs, it inputs the id, username, email, password into both tables, but Unfort, the first 150 users are not in the phpbb3 phpbb_users table. I have this code to transfer accounts which are not in phpbb_users into its table from subscriberinfo, but upon executing the php(its migrate.php, so is the correct way hxxp://www.mysite.com/migrate.php?)
CODE
<?php
define('IN_PHPBB', true);
$phpbb_root_path = './forum/'; //Path to forum
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
// Retrieve default group ID
$sql = 'SELECT group_id
FROM ' . GROUPS_TABLE . "
WHERE group_name = '" . $db->sql_escape('REGISTERED') . "'
AND group_type = " . GROUP_SPECIAL;
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!sizeof($row))
{
trigger_error('NO_GROUP');
}
$group_id = (int) $row['group_id'];
// Get the old users
$sql = 'SELECT user_id, email, password, username
FROM subscriberinfo
ORDER BY user_id DESC';
$result = $db->sql_query($sql);
$row = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
// Create new accounts for them
foreach($row as $existing)
{
//Data validation
$error = validate_data($row[$i], array(
'username' => array(
array('string', false, $config['min_name_chars'], $config['max_name_chars']),
array('username', '')),
'password' => array(
array('string', false, $config['min_pass_chars'], $config['max_pass_chars']),
array('password')),
'email' => array(
array('string', false, 6, 60),
array('email')),
));
if (!sizeof($error))
{
$data = array(
'username' => utf8_normalize_nfc($existing['username']),
'user_password' => phpbb_hash($existing['password']),
'user_email' => strtolower($existing['email']),
'group_id' => $group_id,
'user_type' => USER_NORMAL,
);
$user_id = user_add($data);
if ($user_id === false)
{
echo 'User: ' . $existing['username'] . ' failed to transfer<br />';
}
else
{
echo 'User: ' . $existing['username'] . ' (' . $user_id . ') added to phpBB successfully<br />';
}
}
}
?>
I had to manually delete the username_clean index key from the table so accounts with no username present could still be transferred, and a username be chosen via account panel on site.
This post has been edited by King8654: 16 Aug, 2008 - 09:45 AM