Skip to content

Instantly share code, notes, and snippets.

@Omranic
Created April 3, 2012 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Omranic/2294431 to your computer and use it in GitHub Desktop.
Save Omranic/2294431 to your computer and use it in GitHub Desktop.
Simple old code for migrating Vivvo3 to vB3 DB - Run inside vB3
<?php
// ###################### Start Importing Vivvo User #######################
if ($_REQUEST['do'] == 'vivvousers')
{
if (empty($vbulletin->GPC['perpage']))
{
$vbulletin->GPC['perpage'] = 1000;
}
echo '<p>Importing Vivvo Users</p>';
$users = $db->query_read("
SELECT *
FROM news_users
WHERE userid >= " . $vbulletin->GPC['startat'] . "
ORDER BY userid
LIMIT " . $vbulletin->GPC['perpage']
);
$finishat = $vbulletin->GPC['startat'];
while ($user = $db->fetch_array($users))
{
switch ($user['user_type'])
{
case 0:
case 3:
$user['usergroupid'] = 7;
break;
case 4:
$user['usergroupid'] = 2;
break;
case 1:
$user['usergroupid'] = 5;
break;
case 2:
$user['usergroupid'] = 6;
break;
}
$newuser =& datamanager_init('User', $vbulletin, ERRTYPE_ARRAY);
$newuser->set('username', $user['username']);
$newuser->set('email', $user['email_address']);
$newuser->set('password', $user['password']);
$newuser->set('usergroupid', $user['usergroupid']);
$newuser->set('lastvisit', strtotime($user['last_login']));
$newuser->set('lastactivity', strtotime($user['last_login']));
$newuser->set('joindate', strtotime($user['created']));
if (!$newuser->errors)
{
$newuserid = $newuser->save();
echo construct_phrase($vbphrase['processing_x'], $newuserid) . "<br />\n";
}
else
{
print_r($newuser->errors);
echo "<br />\n";
}
vbflush();
$finishat = ($user['userid'] > $finishat ? $user['userid'] : $finishat);
}
$finishat++; // move past the last processed user
if ($checkmore = $db->query_first("SELECT userid FROM news_users WHERE userid >= $finishat LIMIT 1"))
{
print_cp_redirect("misc.php?" . $vbulletin->session->vars['sessionurl'] . "do=vivvousers&startat=$finishat&pp=" . $vbulletin->GPC['perpage']);
echo "<p><a href=\"misc.php?" . $vbulletin->session->vars['sessionurl'] . "do=vivvousers&amp;startat=$finishat&amp;pp=" . $vbulletin->GPC['perpage'] . "\">" . $vbphrase['click_here_to_continue_processing'] . "</a></p>";
}
else
{
define('CP_REDIRECT', 'misc.php');
print_stop_message('updated_usernames_successfully');
}
}
// ###################### Start Importing Vivvo Categories #######################
if ($_REQUEST['do'] == 'vivvocats')
{
if (empty($vbulletin->GPC['perpage']))
{
$vbulletin->GPC['perpage'] = 1000;
}
echo '<p>Importing Vivvo Categories</p>';
$forums = $db->query_read("
SELECT *
FROM news_categories
WHERE id >= " . $vbulletin->GPC['startat'] . "
ORDER BY id
LIMIT " . $vbulletin->GPC['perpage']
);
$finishat = $vbulletin->GPC['startat'];
while ($forum = $db->fetch_array($forums))
{
$newforum =& datamanager_init('Forum', $vbulletin, ERRTYPE_ARRAY);
$newforum->set('forumid', $forum['id']);
$newforum->set('title', $forum['category_name']);
$newforum->set('parentid', 1);
$newforum->set('displayorder', $forum['order_num']);
$options = array(
'active' => 1,
'allowposting' => 1,
'cancontainthreads' => 1,
'indexposts' => 1,
'allowhtml' => 0,
'allowbbcode' => 1,
'allowimages' => 1,
'allowsmilies' => 1,
'allowicons' => 1,
'allowratings' => 1,
'countposts' => 1,
'showonforumjump' => 1,
'canhavepassword' => 1,
);
foreach ($options AS $key => $val)
{
$newforum->set_bitfield('options', $key, $val);
}
$newforum->set('daysprune', -1);
$newforum->set('newpostemail', '');
$newforum->set('newthreademail', '');
$newforum->set('description', '');
$newforum->set('description_clean', '');
if (!$newforum->errors)
{
$newforumid = $newforum->save();
echo construct_phrase($vbphrase['processing_x'], $newforumid) . "<br />\n";
}
else
{
print_r($newforum->errors);
echo "<br />\n";
}
vbflush();
$finishat = ($forum['id'] > $finishat ? $forum['id'] : $finishat);
}
$finishat++; // move past the last processed user
if ($checkmore = $db->query_first("SELECT id FROM news_categories WHERE id >= $finishat LIMIT 1"))
{
print_cp_redirect("misc.php?" . $vbulletin->session->vars['sessionurl'] . "do=vivvocats&startat=$finishat&pp=" . $vbulletin->GPC['perpage']);
echo "<p><a href=\"misc.php?" . $vbulletin->session->vars['sessionurl'] . "do=vivvocats&amp;startat=$finishat&amp;pp=" . $vbulletin->GPC['perpage'] . "\">" . $vbphrase['click_here_to_continue_processing'] . "</a></p>";
}
else
{
define('CP_REDIRECT', 'misc.php');
print_stop_message('updated_usernames_successfully');
}
}
// ###################### Start Importing Vivvo Articles #######################
if ($_REQUEST['do'] == 'vivvoarts')
{
if (empty($vbulletin->GPC['perpage']))
{
$vbulletin->GPC['perpage'] = 500;
}
echo '<p>Importing Vivvo Articles</p>';
$articles = $db->query_read("
SELECT *
FROM news_articles
WHERE id >= " . $vbulletin->GPC['startat'] . "
ORDER BY id
LIMIT " . $vbulletin->GPC['perpage']
);
require_once(DIR . '/includes/functions_newpost.php');
require_once(DIR . '/includes/functions_wysiwyg.php');
$finishat = $vbulletin->GPC['startat'];
while ($article = $db->fetch_array($articles))
{
$views = $article['times_read'];
$dateline = strtotime($article['created']);
$newthread['title'] = html_entity_decode(convert_wysiwyg_html_to_bbcode($article['title']), ENT_QUOTES, "utf-8");
$newthread['message'] = html_entity_decode(convert_wysiwyg_html_to_bbcode($article['body']), ENT_QUOTES, "utf-8");
//$title = convert_wysiwyg_html_to_bbcode($article['title']);
//$newthread['title'] = html_entity_decode($title, ENT_QUOTES, "utf-8");
//$newthread['title'] = convert_wysiwyg_html_to_bbcode($article['title']);
//$newthread['message'] = convert_wysiwyg_html_to_bbcode($article['body']);
//$message = convert_wysiwyg_html_to_bbcode($article['body']);
//$newthread['message'] = html_entity_decode($message, ENT_QUOTES, "utf-8");
//$newthread['message'] = html_entity_decode(convert_wysiwyg_html_to_bbcode($article['body']), ENT_QUOTES, "utf-8");
build_new_post('thread', array('forumid' => $article['category_id']), array(), array(), $newthread, $errors);
if (!$errors)
{
echo "Added Thread \"" . $newthread['threadid'] . "\". __." . $article['id'] . "<br />\n";
$db->query_write("
UPDATE " . TABLE_PREFIX . "thread
SET dateline = '$dateline', views = '$views', lastpost = '$dateline'
WHERE threadid = '" . $newthread['threadid'] . "'
");
echo "\t-- Updated views";
$db->query_write("
UPDATE " . TABLE_PREFIX . "post
SET dateline = '$dateline'
WHERE threadid = '" . $newthread['threadid'] . "'
");
echo " & dateline!<br /><br />\n";
}
else
{
print_r($errors);
echo "<br />\n";
}
vbflush();
$finishat = ($article['id'] > $finishat ? $article['id'] : $finishat);
}
$finishat++; // move past the last processed user
if ($checkmore = $db->query_first("SELECT id FROM news_articles WHERE id >= $finishat LIMIT 1"))
{
print_cp_redirect("misc.php?" . $vbulletin->session->vars['sessionurl'] . "do=vivvoarts&startat=$finishat&pp=" . $vbulletin->GPC['perpage']);
echo "<p><a href=\"misc.php?" . $vbulletin->session->vars['sessionurl'] . "do=vivvoarts&amp;startat=$finishat&amp;pp=" . $vbulletin->GPC['perpage'] . "\">" . $vbphrase['click_here_to_continue_processing'] . "</a></p>";
}
else
{
define('CP_REDIRECT', 'misc.php');
print_stop_message('updated_usernames_successfully');
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment