Hallo,
ist es möglich Themen und Beiträge eines vBulletin 3.0.7 Forums in die aktuelle PHPbb Version zu importieren ?
Da ich mir überlege, ob ich von vBulletin nun die "Lebenslang-Lizenz" kaufe oder zu PHPbb wechsle. Jedoch würde das mit einem komplett neuen Board nichts werden ...
[erledigt] vB 3.0.7 Posts nach PHPbb 2.0.18 importieren?
Forumsregeln
phpBB 2.0 hat das Ende seiner Lebenszeit überschritten
phpBB 2.0 wird nicht mehr aktiv unterstützt. Insbesondere werden - auch bei Sicherheitslücken - keine Patches mehr bereitgestellt. Der Einsatz von phpBB 2.0 erfolgt daher auf eigene Gefahr. Wir empfehlen einen Umstieg auf phpBB 3.1, welches aktiv weiterentwickelt wird und für welches regelmäßig Updates zur Verfügung gestellt werden.
Eine Neuinstallation von phpBB 2.0 wird auf phpBB.de nicht mehr unterstützt.
Siehe auch Entwicklungs-Ende von phpBB 2.0 - Auswirkungen auf phpBB.de
phpBB 2.0 hat das Ende seiner Lebenszeit überschritten
phpBB 2.0 wird nicht mehr aktiv unterstützt. Insbesondere werden - auch bei Sicherheitslücken - keine Patches mehr bereitgestellt. Der Einsatz von phpBB 2.0 erfolgt daher auf eigene Gefahr. Wir empfehlen einen Umstieg auf phpBB 3.1, welches aktiv weiterentwickelt wird und für welches regelmäßig Updates zur Verfügung gestellt werden.
Eine Neuinstallation von phpBB 2.0 wird auf phpBB.de nicht mehr unterstützt.
Siehe auch Entwicklungs-Ende von phpBB 2.0 - Auswirkungen auf phpBB.de
[erledigt] vB 3.0.7 Posts nach PHPbb 2.0.18 importieren?
Zuletzt geändert von Miroerr am 13.12.2005 23:24, insgesamt 1-mal geändert.
Habe den Konverter geladen, entpackt und hochgeladen.
Wenn ich ihn nun aufrufe (.../phpBB2/convert.php), erscheint diese Meldung:
Was hat das zu bedeuten ?
Manchmal erscheint auch:
Wer kann mir sagen, was ich falsch mache ?
Wenn ich ihn nun aufrufe (.../phpBB2/convert.php), erscheint diese Meldung:
Code: Alles auswählen
Check the path defines.
"); } if ( !@file_exists(PHPBB_PATH . 'extension.inc') ) { die("ERROR: Unable to find phpBB includes.
Check the path defines.
"); } // Unlimited execution time, but not in safe mode $ini_val = ( phpversion() >= '4.0.0' ) ? 'ini_get' : 'get_cfg_var'; if ( @$ini_val('safe_mode') || FORCE_SAFE_MODE ) { define('SAFE_MODE', 1); } else { @set_time_limit(0); define('SAFE_MODE', 0); } // // This will load all vBulletin needed data // No vBulletin functions are used, accept for the database class // // Load config file require(VBULLETIN_PATH . 'admin/config.php'); // Force persistent connections $usepconnect = 1; // Init DB class, force MySQL require(VBULLETIN_PATH . 'admin/db_mysql.php'); $DB_site = new DB_Sql_vb(); $DB_site->database = $dbname; $DB_site->server = $servername; $DB_site->user = $dbusername; $DB_site->password = $dbpassword; // Use our own error reporting $DB_site->reporterror = 0; $DB_site->connect(); // Load vBulletin options $sql = "SELECT template AS options FROM template WHERE title='options'"; $options_query = $DB_site->query($sql); if ( !$options_query ) { die("Unable to fetch vBulletin options"); } $row = $DB_site->fetch_array($options_query); eval($row['options']); $DB_site->free_result($options_query); unset($row); if ( !$templateversion ) { $templateversion = '2.0.0'; } define('VBULLETIN_VERSION', $templateversion); // // End vBulletin global settings // // // Include phpBB config and global files and needed functions // $phpbb_root_path = PHPBB_PATH; include(PHPBB_PATH . 'extension.inc'); include(PHPBB_PATH . 'common.' . $phpEx); include(PHPBB_PATH . 'includes/functions_post.' . $phpEx); include(PHPBB_PATH . 'includes/bbcode.' . $phpEx); include(PHPBB_PATH . 'includes/functions_search.' . $phpEx); include(PHPBB_PATH . 'includes/functions_admin.' . $phpEx); // Output no caching headers to keep browsers from caching steps header ("Cache-Control: no-store, no-cache, must-revalidate"); header ("Cache-Control: pre-check=0, post-check=0, max-age=0", false); header ("Pragma: no-cache"); header ("Expires: " . gmdate("D, d M Y H:i:s", time()) . " GMT"); header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Step descriptions and sequence $steps = array("start" => "Welcome Screen", "settings" => "Settings", "forums" => "Forums, Catogories and Permissions", "users" => "Users", "mods" => "Moderators, Admins and Usergroups", "topics" => "Topics", "posts" => "Posts", "pm" => "Private Messages", "polls" => "Polls", "wordlist" => "Search Wordlist", "end" => "Finalisation and Thank You Screen"); // // Start of functions block // // // Dies with a nicely formatted error message // function die_nice($message, $line = '', $sql = '') { global $db, $DB_site; $phpbb_error = $db->sql_error(); if ( !empty($phpbb_error['message']) ) { $error = $phpbb_error['code'] . " :: " . $phpbb_error['message']; } else { $error = $DB_site->errno . " :: " . $DB_site->errdesc; } print "
Manchmal erscheint auch:
Code: Alles auswählen
ERROR: Unable to find vBulletin configuration file.
Check the path defines.
Jop, das ist klar. Hab mittlerweile entdeckt, dass ich die Pfade manuell in der convert.php eingeben muss
.
Hier ein paar Beispiele und meine Lösungsvorschlläge
:
$DB_site->database = $dbname;
$DB_site->server = $servername;
$DB_site->user = $dbusername;
$DB_site->password = $dbpassword;
=>
$DB_site->database = $datenbankname; z.B. Testdatenbank
$DB_site->server = $servername; z.B. Testserver
$DB_site->user = $datenbankusername; z.B. Testuser
$DB_site->password = $datenbankpasswort; z.B. Testpasswort
^natürlich werden hier die echten Daten eingetragen, jedoch hab ich keine Lust diese hier preiszugeben
).
include(PHPBB_PATH . 'includes/functions_admin.' . $phpEx);
=>
include(PHPBB_PATH . 'www.meinedomain.de/phpBB2/includes/functions_admin.' . $phpEx);
require(VBULLETIN_PATH . 'admin/db_mysql.php');
=>
require(VBULLETIN_PATH . 'www.meinedomain.de/vb/includes/db_mysql.php');
Stimmt das so ?
Und wo in der convert.php muss ich alles etwas ändern? Diese sieht standardmäßig so aus:
[quote]<?php
/***************************************************************************
* convert.php
* -------------------
* begin : Saturday, Feb 23, 2002
* copyright : (C) 2002 Matthijs van de Water
* Portions of code (C) 2001 the phpBB Group
* email : converter@matthijs.net
* support@phpbb.com
*
* $Id: convert.php,v 1.33 2003/01/18 17:27:13 mvdwater Exp $
*
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
/***************************************************************************
*
* If you are unsure if this piece of software reached you unmodified,
* please download the latest version from http://matthijs.beryllium.net/
*
***************************************************************************/
/***************************************************************************
*
* VBULLETIN 2.0/2.2 TO PHPBB 2.0 CONVERSION TOOL
*
***************************************************************************
*
* FILE DESCRIPTION
*
* This script will convert from an existing vBulletin 2.0 / 2.2 installation
* to a new phpBB 2.0 installation.
*
*
* INSTALLATION GUIDELINES
*
* Backup your files and database before attempting to run this conversion!
* No change is made to your original vBulletin database, but one can never
* be too carefull. The author and/or the phpBB Group are not responsible
* for any data-loss as a result of using this software.
*
* Do a clean install of the latest version of phpBB 2.0.
*
* Make sure smilie and avatar dirs are writable and executable
* for the webserver, as it needs to create directories and images.
*
* Please verify the configuration defines below and update them to
* your situation.
*
* Place the convert.php file in the vBulletin root dir.
*
* Open the script in your browser and follow the onscreen instructions.
* Be sure to take your time for the conversion, as the process may take
* up to an hour, depending on the size of your board and the speed of
* your server.
*
***************************************************************************/
//
// Conversion Tool Configuration Settings
//
// Global path defines, change this if your installation is different.
// On Windows systems, use either \\ or / as directory delimiters.
// Be sure to keep the tailing slash on all paths!
define('VBULLETIN_PATH', 'http://miroerr.mi.funpic.de/forum/');
define('PHPBB_PATH', 'http://miroerr.mi.funpic.de/phpBB2/');
define('PHPBB_URI', 'http://miroerr.mi.funpic.de/phpBB2/');
// Do this many items in one go.
// Should be good for most servers, no need to change this unless your
// server can't handle the load.
define('BATCH_SIZE', 1000);
// If safe mode is on, process this many batches before breaking
// and reloading to stop script timeouts in lengthy steps.
// Only change this if you have timout problems. Can't be lower than 1
// and must be integer.
define('SAFE_MODE_BATCHES', 2);
// Enable this if you have timeout problems
define('FORCE_SAFE_MODE', 0);
//
// End Configuration Settings
//
//
// THERE IS NO NEED TO CHANGE ANYTHING BELOW THIS LINE
//
// This must be defined to be able to use the phpBB includes
// And to access the page if the board is disabled
define('IN_PHPBB', true);
define('IN_ADMIN', true);
// Define script version and filename
define('SCRIPT_VERSION', '1.33');
define('SCRIPT_FILENAME', $PHP_SELF);
// Some defines for vBulletin
// These guys may not like using defines, but I do
define('VB_THREAD_CLOSED', 0);
define('VB_THREAD_OPEN', 1);
define('VB_THREAD_MOVED', 10);
define('VB_INBOX', 0);
define('VB_SENTBOX', -1);
define('VB_UG_UNREGISTERED', 1);
define('VB_UG_REGISTERED', 2);
define('VB_UG_AWAITING_EMAIL_CONF', 3);
define('VB_UG_AWAITING_COPPA_CONF', 4);
define('VB_UG_SUPER_MODS', 5);
define('VB_UG_ADMIN', 6);
define('VB_UG_MODERATORS', 7);
// Record starttime
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$script_starttime = $mtime;
// Check if paths defined above are correct
if ( !@file_exists(VBULLETIN_PATH . 'http://miroerr.mi.funpic.de/forum/includes/config.php') )
{
die("ERROR: Unable to find vBulletin configuration file.<br />Check the path defines.<br />");
}
if ( !@file_exists(PHPBB_PATH . 'http://miroerr.mi.funpic.de/phpBB2/extension.inc') )
{
die("ERROR: Unable to find phpBB includes.<br />Check the path defines.<br />");
}
// Unlimited execution time, but not in safe mode
$ini_val = ( phpversion() >= '4.0.0' ) ? 'ini_get' : 'get_cfg_var';
if ( @$ini_val('safe_mode') || FORCE_SAFE_MODE )
{
define('SAFE_MODE', 1);
}
else
{
@set_time_limit(0);
define('SAFE_MODE', 0);
}
//
// This will load all vBulletin needed data
// No vBulletin functions are used, accept for the database class
//
// Load config file
require(VBULLETIN_PATH . 'http://miroerr.mi.funpic.de/forum/includes/config.php');
// Force persistent connections
$usepconnect = 1;
// Init DB class, force MySQL
require(VBULLETIN_PATH . 'http://miroerr.mi.funpic.de/forum/includes/db_mysql.php');
$DB_site = new DB_Sql_vb();
$DB_site->database = $dbname;
$DB_site->server = $servername;
$DB_site->user = $dbusername;
$DB_site->password = $dbpassword;
// Use our own error reporting
$DB_site->reporterror = 0;
$DB_site->connect();
// Load vBulletin options
$sql = "SELECT template AS options FROM template WHERE title='options'";
$options_query = $DB_site->query($sql);
if ( !$options_query )
{
die("Unable to fetch vBulletin options");
}
$row = $DB_site->fetch_array($options_query);
eval($row['options']);
$DB_site->free_result($options_query);
unset($row);
if ( !$templateversion )
{
$templateversion = '2.0.0';
}
define('VBULLETIN_VERSION', $templateversion);
//
// End vBulletin global settings
//
//
// Include phpBB config and global files and needed functions
//
$phpbb_root_path = PHPBB_PATH;
include(PHPBB_PATH . 'http://miroerr.mi.funpic.de/phpBB2/extension.inc');
include(PHPBB_PATH . 'http://miroerr.mi.funpic.de/phpBB2/common.' . $phpEx);
include(PHPBB_PATH . 'http://miroerr.mi.funpic.de/phpBB2/incl ... tions_post.' . $phpEx);
include(PHPBB_PATH . 'http://miroerr.mi.funpic.de/phpBB2/includes/bbcode.' . $phpEx);
include(PHPBB_PATH . 'http://miroerr.mi.funpic.de/phpBB2/incl ... ons_search.' . $phpEx);
include(PHPBB_PATH . 'http://miroerr.mi.funpic.de/phpBB2/incl ... ions_admin.' . $phpEx);
// Output no caching headers to keep browsers from caching steps
header ("Cache-Control: no-store, no-cache, must-revalidate");
header ("Cache-Control: pre-check=0, post-check=0, max-age=0", false);
header ("Pragma: no-cache");
header ("Expires: " . gmdate("D, d M Y H:i:s", time()) . " GMT");
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// Step descriptions and sequence
$steps = array("start" => "Welcome Screen",
"settings" => "Settings",
"forums" => "Forums, Catogories and Permissions",
"users" => "Users",
"mods" => "Moderators, Admins and Usergroups",
"topics" => "Topics",
"posts" => "Posts",
"pm" => "Private Messages",
"polls" => "Polls",
"wordlist" => "Search Wordlist",
"end" => "Finalisation and Thank You Screen");
//
// Start of functions block
//
//
// Dies with a nicely formatted error message
//
function die_nice($message, $line = '', $sql = '')
{
global $db, $DB_site;
$phpbb_error = $db->sql_error();
if ( !empty($phpbb_error['message']) )
{
$error = $phpbb_error['code'] . " :: " . $phpbb_error['message'];
}
else
{
$error = $DB_site->errno . " :: " . $DB_site->errdesc;
}
print "<br /><br /><span class="error">ERROR</span>: $message<br /><br />\n";
print "After you have located and fixed the error, reload this page to continue the conversion process.<br />\n";
print "<pre>Debug information:<br />\n";
if ( !empty($line) )
{
print "Line: " . $line . "<br />\n";
}
if ( !empty($sql) )
{
print "SQL: " . $sql . "<br />\n";
}
print "MySQL Error: " . $error . "<br />\n";
print "</pre>\n";
common_footer();
exit;
}
//
// Converts vB only bbcode tags to corresponding phpBB bbcode
//
function convert_vb_code ($bbcode, $quote_template = -1)
{
// Remove [font] tags
$search = array("|\[font=[^\]]*\]|si", "|\[/font\]|si");
$replace = array("", "");
$bbcode = preg_replace($search, $replace, $bbcode);
// Convert [php] tag to [code]
// If you have the [php] MOD installed, you should comment this out
$search = array("[php]", "[/php]", "[PHP]", "[/PHP]");
$replace = array("[code]", "[/code]", "[code]", "[/code]");
$bbcode = str_replace($search, $replace, $bbcode);
// Convert [size] tags
// This needs PHP > 4 since it uses the eval option
$search = "/\[size=([0-9]+)\]/ie";
$replace = "'[size='.( (\\1 == 1) ? 9 : 6*\\1 ).']'";
$bbcode = preg_replace($search, $replace, $bbcode);
// Convert "" syntax
$search = "/\{1}([^"']*)['"]{1}\](.*)\[\/url\]/siU";
$replace = "[url=\\1]\\2";
$bbcode = preg_replace($search, $replace, $bbcode);
// Convert [quote] structure (use specified template)
if ($quote_template != -1)
{
if ( preg_match("/(\[quote\].*\[\/quote\])/si", $bbcode, $match) )
{
$quote_text = $match[1];
$search = $quote_template;
$replace = array("[quote="\\1"]\n", "[/quote][/quote][/quote]");
$quote_text = preg_replace($search, $replace, $quote_text);
$bbcode = preg_replace("/(\[quote\].*\[\/quote\])/si", $quote_text, $bbcode);
}
}
return $bbcode;
}
//
// Locks tables - modified from upgrade.php
//
function lock_tables($state, $tables= '')
{
global $DB_site;
if ( $state == 1 )
{
if ( is_array($tables) )
{
$tables = join(' WRITE, ', $tables);
}
$sql = "LOCK TABLES $tables WRITE";
$result = $DB_site->query($sql);
if ( !$result )
{
die_nice("Unable to do LOCK TABLES $tables WRITE", __LINE__, $sql);
}
}
else
{
$sql = "UNLOCK TABLES";
$result = $DB_site->query($sql);
if ( !$result )
{
die_nice("Unable to unlock tables", __LINE__, $sql);
}
}
}
//
// Print common page header - modified from upgrade.php
//
function common_header()
{
global $step, $steps;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>vBulletin 2.0/2.2 Conversion Tool for phpBB 2.0</title>
<meta name="description" content="vBulletin 2.0/2.2 to phpBB 2.0 Conversion Tool">
<meta name="keywords" content="phpbb2 phpbb 2.0 vbulletin vb phpbb2vb convert_vb2 2.2.2 2.2.1 2.2.0 2.2.x 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.x 2.x conversion tool import convert merge">
<meta name="author" content="Matthijs van de Water">
<meta name="version" content="<?php print SCRIPT_VERSION; ?>">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css">
<!--
/* Specifiy background images for selected styles
This can't be done within the external style sheet as NS4 sees image paths relative to
the page which called the style sheet (i.e. this page in the root phpBB directory)
whereas all other browsers see image paths relative to the style sheet. Stupid NS again!
*/
TH { background-image: url(<?php print PHPBB_URI; ?>templates/subSilver/images/cellpic3.gif) }
TD.cat { background-image: url(<?php print PHPBB_URI; ?>templates/subSilver/images/cellpic1.gif) }
TD.rowpic { background-image: url(<?php print PHPBB_URI; ?>templates/subSilver/images/cellpic2.jpg); background-repeat: repeat-y }
td.icqback { background-image: url(<?php print PHPBB_URI; ?>templates/subSilver/images/icon_icq_add.gif); background-repeat: no-repeat }
TD.catHead,TD.catSides,TD.catLeft,TD.catRight,TD.catBottom { background-image: url(<?php print PHPBB_URI; ?>templates/subSilver/images/cellpic1.gif) }
font,th,td,p,body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11pt }
a:link,a:active,a:visited { font-family: Verdana, Arial, Helvetica, sans-serif; color : #006699; font-size:11pt }
a:hover { font-family: Verdana, Arial, Helvetica, sans-serif; text-decoration: underline; color : #DD6900; font-size:11pt }
hr { height: 0px; border: solid #D1D7DC 0px; border-top-width: 1px;}
.maintitle,h1,h2 { font-weight: bold; font-size: 22px; font-family: "Trebuchet MS",Verdana, Arial, Helvetica, sans-serif; text-decoration: none; line-height : 120%; color : #000000;}
.copyright { font-size: 10px; font-family: Verdana, Arial, Helvetica, sans-serif; color: #444444; letter-spacing: -1px;}
a.copyright { font-size: 10px; font-family: Verdana, Arial, Helvetica, sans-serif; color: #444444; text-decoration: none;}
a.copyright:hover { font-size: 10px; font-family: Verdana, Arial, Helvetica, sans-serif; color: #000000; text-decoration: underline;}
a.copyright:visited { font-size: 10px; font-family: Verdana, Arial, Helvetica, sans-serif; color: #444444; }
.ok { color:green; }
.error { color:red; font-weight: bold; }
/* Import the fancy styles for IE only (NS4.x doesn't use the @import function) */
@import url("<?php print PHPBB_URI; ?>templates/subSilver/formIE.css");
-->
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#006699" vlink="#5584AA">
<table width="100%" border="0" cellspacing="0" cellpadding="10" align="center">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="<?php print PHPBB_URI; ?>templates/subSilver/images/logo_phpBB.gif" border="0" alt="phpBB 2.0" vspace="1" /></td>
<td align="center" width="100%" valign="middle"><span class="maintitle">Converting to phpBB 2.0</span><br />vBulletin 2.0/2.2 Conversion Tool by Matthijs van de Water</span></td>
</tr>
</table></td>
</tr>
</table>
<br clear="all" />
<?php
if ( $step != "all" && $step != "start" && $step != "end" )
{
print "<b>Converting " . $steps[$step] . "</b><br />\n";
}
return;
}
// Print common page footer - modified from upgrade.php
function common_footer()
{
global $db, $query_count, $script_starttime;
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
?>
<br clear="all" />
<br />
<div align="center"><span class="copyright">
Conversion Tool © 2002 <a href="http://www.matthijs.net/phpbb/" target="_mvdw" class="copyright">Matthijs van de Water</a><br />
phpBB 2.0 and portions of code © 2001 <a href="http://www.phpbb.com/" target="_phpbb" class="copyright">phpBB Group</a><br />
vBulletin © 2000-2003 <a href="http://www.jelsoft.com/" target="_vb" class="copyright">Jelsoft Enterprises Limited</a><br />
</span></div>
<br />
<div align="center"><span class="copyright">Step execution time <?php printf("%.3f", $endtime - $script_starttime); ?> seconds :: <?php print $db->num_queries; ?> queries in phpBB database :: <?php print $query_count; ?> queries in vBulletin database :: Debug Mode</span></div>
</body>
</html>
<?php
return;
}
//
// Print next step HTML
//
function next_step($step, $continue)
{
global $steps;
if ( $continue )
{
print "<hr /><a href="$PHP_SELF?step=$step&startat=$continue">Resume step: <b>$step</b></a><br /><br />\n";
print "<script language="javascript">document.location = '$PHP_SELF?step=$step&startat=$continue';</script>\n";
}
else if ( $step != 'all' && $step != 'start' && $step != 'end' )
{
// Get next step from steps array
@reset($steps);
$next = false;
while ( list($key, $value) = each($steps) )
{
if ( $key == $step )
{
$next = key($steps);
break;
}
}
if ( $next )
{
print "<hr /><a href="$PHP_SELF?step=$next">Next step: <b>$next</b></a><br /><br />\n";
}
}
return;
}
//
// End functions
//
// Display welcome screen if the user hasn't specified a specific starting point.
$step = ( isset($HTTP_GET_VARS['step']) ) ? $HTTP_GET_VARS['step'] : 'start';
// Get resume point if one was given
$start_id = ( isset($HTTP_GET_VARS['startat']) ) ? $HTTP_GET_VARS['startat'] : 0;
// Next resume point initialisation
$resume_id = false;
// Output common header
common_header();
//
// The big switch, determine step to be taken
//
switch ( $step )
{
//
// STEP START - SHOW STARTUP SCREEN
//
case 'start':
print "<b>Welcome to the vBulletin 2.0 / 2.2 to phpBB 2.0 Conversion Tool.</b><br /><br />\n";
print "This script will guide you through the conversion process. Depending on the size of your board and the speed of your server the process can last over an hour, so be patient.<br />\n";
print "Don't interrupt the loading of pages, follow the instructions on screen.<br />\n";
print "<br /><b>Be sure to backup your database(s) before continuing!</b><br />\n";
if ( $board_config['version'] < '.0.4' )
{
print "<span class="error">Warning</span> :: Your phpBB version is incompatible with this version of the converter. You should install <a target="_phpbb" href="http://www.phpbb.com/downloads.php">the latest version of phpBB</a> available.<br />";
}
if ( substr($dbms, 0, 5) != 'mysql' )
{
print "<span class="error">Warning</span> :: You have selected a DBMS that is not MySQL. The script may not work as expected and might give errors. You should select either MySQL 3.x or 4.x as your DBMS during the phpBB installation.<br />";
}
if ( SAFE_MODE == 1 )
{
print "<span class="error">Warning</span> :: PHP Safe Mode is on. This can cause the script to timeout. You should disable safe mode if you can.<br />";
}
if ( !@is_writable(PHPBB_PATH . $board_config['smilies_path'] . '/') )
{
print "<span class="error">Warning</span> :: Smilies dir is not writable. You should change the permissions if you can.</span><br />";
}
if ( !@is_writable(PHPBB_PATH . $board_config['avatar_gallery_path'] . '/') )
{
print "<span class="error">Warning</span> :: Avatar Gallery dir is not writable. You should change the permissions if you can.</span><br />";
}
if ( !@is_writable(PHPBB_PATH . $board_config['avatar_path'] . '/') )
{
print "<span class="error">Warning</span> :: Avatar dir is not writable. You should change the permissions if you can.</span><br />";
}
print "<br /><br /><br /><br />\n";
print "<hr /><a href="$PHP_SELF?step=settings">Start Conversion</a><br /><br />\n";
if ($step != 'all')
{
break;
}
//
// STEP ALL - DO ALL STEPS IN ONE GO IF NOT IN SAFE MODE
//
case 'all':
if ( SAFE_MODE )
{
print "<span class="error">Error</span> :: Cannot do all steps in one go when in safe mode.<br />\n";
break;
}
//
// STEP SETTINGS - CONVERT BOARD SETTINGS
//
case 'settings':
print "* Converting configuration settings :: ";
flush();
//
// General Config Table
//
// Private message quota
$pm_sentbox = intval($pmquota);
$pm_savebox = intval($pmquota / 2);
$pm_inbox = intval($pmquota / 2);
// Patch floodcheck time
$floodchecktime = ( $enablefloodcheck ) ? intval($floodchecktime) : 0;
// Patch dateformat
$dateformat .= " $timeformat";
// Patch timezone offset if needed
if ( substr($timeoffset, 0, 1) == '+' )
{
$timeoffset = substr($timeoffset, 1);
}
// Get max online users and date/time
$sql = "SELECT template AS maxloggedin
FROM template
WHERE title = 'maxloggedin'
AND templatesetid = -1";
$template_query = $DB_site->query($sql);
if ( !$template_query )
{
die_nice("Unable to query maxloggedin information", __LINE__, $sql);
}
$row = $DB_site->fetch_array($template_query);
$max_logged_in = $row['maxloggedin'];
$max = explode(" ", $max_logged_in);
$max_users = intval($max[0]);
$max_users_timestamp = intval($max[1]);
// Activation type
$activation = ($verifyemail) ? USER_ACTIVATION_SELF : USER_ACTIVATION_NONE;
$activation = ($moderatenewmembers) ? USER_ACTIVATION_ADMIN : $activation;
// Inversed config options
$priv_msg_disable = ( $enablepms ) ? 0 : 1;
$board_disable = ( $bbactive ) ? 0 : 1;
$queries = array();
// Generate update configuration table queries
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . $board_disable . "' WHERE config_name = 'board_disable'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . addslashes($bbtitle) . "' WHERE config_name = 'sitename'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = 'vBulletin 2.x Converted Board' WHERE config_name = 'site_desc'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . addslashes($cookiepath) . "' WHERE config_name = 'cookie_path'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . addslashes($cookiedomain) . "' WHERE config_name = 'cookie_domain'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . intval($cookietimeout) . "' WHERE config_name = 'session_length'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . intval($allowhtml) . "' WHERE config_name = 'allow_html'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . intval($allowbbcode) . "' WHERE config_name = 'allow_bbcode'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . intval($allowsmilies) . "' WHERE config_name = 'allow_smilies'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . intval($allowsignatures) . "' WHERE config_name = 'allow_sig'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . intval($avatarallowupload) . "' WHERE config_name = 'allow_avatar_local'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . intval($avatarallowwebsite) . "' WHERE config_name = 'allow_avatar_remote'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . intval($avatarallowupload) . "' WHERE config_name = 'allow_avatar_upload'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . intval($maxposts) . "' WHERE config_name = 'posts_per_page'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . intval($maxthreads) . "' WHERE config_name = 'topics_per_page'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . intval($hotnumberposts) . "' WHERE config_name = 'hot_threshold'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . intval($maxpolloptions) . "' WHERE config_name = 'max_poll_options'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . $pm_inbox . "' WHERE config_name = 'max_inbox_privmsgs'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . $pm_sentbox . "' WHERE config_name = 'max_sentbox_privmsgs'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . $pm_savebox . "' WHERE config_name = 'max_savebox_privmsgs'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . addslashes($webmasteremail) . "' WHERE config_name = 'board_email'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . $activation . "' WHERE config_name = 'require_activation'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . intval($floodchecktime) . "' WHERE config_name = 'flood_interval'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . intval($secureemail) . "' WHERE config_name = 'board_email_form'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . intval($avatarmaxsize) . "' WHERE config_name = 'avatar_filesize'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . intval($avatarmaxdimension) . "' WHERE config_name = 'avatar_max_width'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . intval($avatarmaxdimension) . "' WHERE config_name = 'avatar_max_height'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . $dateformat . "' WHERE config_name = 'default_dateformat'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . $timeoffset . "' WHERE config_name = 'board_timezone'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . $priv_msg_disable . "' WHERE config_name = 'privmsg_disable'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . intval($gzipoutput) . "' WHERE config_name = 'gzip_compress'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . $faxnumber . "' WHERE config_name = 'coppa_fax'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . $address . "' WHERE config_name = 'coppa_mail'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . $max_users . "' WHERE config_name = 'record_online_users'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . $max_users_timestamp . "' WHERE config_name = 'record_online_date'";
@reset($queries);
while ( list($i, $sql) = each($queries) )
{
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to update config table ($i)", __LINE__, $sql);
}
}
unset($queries);
print " <span class="ok"><b>OK</b></span><br />\n";
// Update board_config (this is only usefull when using the step=all option)
$board_config['allow_html'] = $allowhtml;
$board_config['allow_bbcode'] = $allowbbcode;
$board_config['allow_smilies'] = $allowsmilies;
$board_config['allow_sig'] = $allowsignatures;
$board_config['allow_avatar_local'] = $avatarallowupload;
$board_config['allow_avatar_remote'] = $avatarallowwebsite;
$board_config['allow_avatar_upload'] = $avatarallowupload;
//
// Ranks
//
print "* Converting ranks :: ";
$sql = "DELETE FROM " . RANKS_TABLE;
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Delete ranks from table failed", __LINE__, $sql);
}
$sql = "SELECT * FROM usertitle";
$ranks_query = $DB_site->query($sql);
if ( !$result )
{
die_nice("Unable to query ranks", __LINE__, $sql);
}
while ( $rank = $DB_site->fetch_array($ranks_query) )
{
$title = addslashes($rank['title']);
$min = intval($rank['minposts']);
$sql = "INSERT INTO " . RANKS_TABLE . " (rank_title, rank_min) VALUES ('$title', '$min')";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to insert rank '$title'", __LINE__, $sql);
}
}
print " <span class="ok"><b>OK</b></span><br />\n";
//
// Censor Words
//
print "* Converting censored words :: ";
flush();
$sql = "DELETE FROM " . WORDS_TABLE;
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to delete existing entries from words table", __LINE__, $sql);
}
$words = explode(" ",$censorwords);
$sql = "INSERT IGNORE INTO " . WORDS_TABLE . " (word, replacement) VALUES ";
$count = 0;
$censor_char = ( $censorchar ) ? $censorchar : '*';
while ( list($i, $word) = each($words) )
{
$word = strtolower(trim($word));
if ( ereg("^\{.*\}$", $word) )
{
$word = substr($word, 1, -1);
$replacement = str_repeat($censor_char, strlen($word));
}
else
{
$replacement = str_repeat($censor_char, strlen($word));
$word = "*$word*";
}
if ( strlen($replacement) > 1 )
{
$sql .= "('" . str_replace("\'", "''", $word) . "', '" . $replacement . "'),";
$count++;
}
}
if ( $count )
{
// Remove tailing ','
$sql = substr($sql, 0, -1);
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to insert censored words", __LINE__, $sql);
}
}
print " <span class="ok"><b>OK</b></span><br />\n";
//
// Illegal Usernames
//
print "* Converting disallowed usernames :: ";
flush();
$sql = "DELETE FROM ". DISALLOW_TABLE;
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to empty disallowed usernames", __LINE__, $sql);
}
$usernames = explode(" ", $illegalusernames);
$sql = "INSERT IGNORE INTO " . DISALLOW_TABLE . " (disallow_username) VALUES ";
$count = 0;
while ( list($i, $username) = each($usernames) )
{
$username = strtolower(trim($username));
if ( strlen($username) > 1 )
{
$sql .= "('" . addslashes($username) . "'),";
$count++;
}
}
if ( $count )
{
$sql = substr($sql, 0, -1);
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to insert disallowed usernames", __LINE__, $sql);
}
}
print " <span class="ok"><b>OK</b></span><br />\n";
// Ban-list cleanup
$sql = "DELETE FROM " . BANLIST_TABLE;
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to empty banlist table", __LINE__, $sql);
}
//
// IP addresses
//
print "* Converting banned IPs :: ";
flush();
$ip_list_temp = explode(" ", $banip);
$sql = "INSERT IGNORE INTO " . BANLIST_TABLE . " (ban_ip) VALUES ";
for($i = 0; $i < count($ip_list_temp); $i++)
{
$dots = substr_count($ip_list_temp[$i], ".");
while ($dots < 3)
{
$ip_list_temp[$i] .= ".255";
$dots++;
}
$ip = encode_ip($ip_list_temp[$i]);
$sql .= "('$ip'),";
}
if ( count($ip_list_temp) )
{
$sql = substr($sql, 0, -1);
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to insert banned IPs", __LINE__, $sql);
}
}
print " <span class="ok"><b>OK</b></span><br />\n";
//
// Email addresses
//
print "* Converting banned email addresses :: ";
flush();
$ban_mail_temp = explode(" ", $banemail);
$sql = "INSERT IGNORE INTO " . BANLIST_TABLE . " (ban_email) VALUES ";
while ( list($i,$email) = each($ban_mail_temp) )
{
$email = strtolower(trim($email));
if ( substr($email, 0, 1) == "@" )
{
$email = '*' . $email;
}
$sql .= "('$email'),";
}
if ( count($ban_mail_temp) )
{
$sql = substr($sql, 0, -1);
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to insert banned email addresses", __LINE__, $sql);
}
}
print " <span class="ok"><b>OK</b></span><br />\n";
//
// Convert smilies and generate smilie packs
//
// Check if smilie dir is writable
if ( is_writable(PHPBB_PATH . $board_config['smilies_path'] . '/') )
{
print "* Generating smilie pack from vBulletin smilies :: ";
$delimeter = '=+:';
//
// Export our current smiley config as a smiley pak...
//
$sql = "SELECT * FROM " . SMILIES_TABLE;
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Couldn't query current smilies", __LINE__, $sql);
}
$resultset = $db->sql_fetchrowset($result);
$smile_pak = "";
for($i = 0; $i < count($resultset); $i++ )
{
$smile_pak .= $resultset[$i]['smile_url'] . $delimeter;
$smile_pak .= $resultset[$i]['emoticon'] . $delimeter;
$smile_pak .= $resultset[$i]['code'] . "\n";
}
$fp = fopen (PHPBB_PATH . $board_config['smilies_path'] . '/phpbb2_original_smilies.pak', 'wb');
$written = fwrite($fp, $smile_pak);
fclose($fp);
if ( $written != strlen($smile_pak) )
{
@unlink(PHPBB_PATH . $board_config['smilies_path'] . '/phpbb2_original_smilies.pak');
print "<br /> <b>Warning</b>: error writing smilie pack, skipping smilie conversion.<br />";
}
else
{
// Old smilie pack written
// Build smilie pack from vB smilies and save it, copy smilies to new location
// Store only non-existing smilies in the database
$vb_smile_pak = "";
$no_copy = false;
$sql = "SELECT * FROM smilie";
$smilie_query = $DB_site->query($sql);
if ( !$smilie_query )
{
die_nice("Unable to query smilie info", __LINE__, $sql);
}
while ( $smilie = $DB_site->fetch_array($smilie_query) )
{
$filename = basename($smilie['smiliepath']);
$new_file = "vb_" . $filename;
$copy_from = VBULLETIN_PATH . $smilie['smiliepath'];
$copy_to = PHPBB_PATH . $board_config['smilies_path'] . '/' . $new_file;
if ( !$no_copy )
{
if ( !@copy($copy_from, $copy_to) )
{
print "<br /> <b>Warning</b>: error copying smilies, copy them by hand.<br />";
$no_copy = true;
}
}
$vb_smile_pak .= $new_file . $delimeter;
$vb_smile_pak .= $smilie['title'] . $delimeter;
$vb_smile_pak .= $smilie['smilietext'] . "\n";
// Check if smilie exists
$sql = "SELECT smilies_id FROM " . SMILIES_TABLE . " WHERE code = '" . addslashes($smilie['smilietext']) . "'";
$exists = $db->sql_query($sql);
if ( !$exists )
{
die_nice("Unable to query existing smilie", __LINE__, $sql);
}
if ( !$db->sql_numrows($exists) )
{
// Smilie does not yet exist, insert
$smilie_code = addslashes($smilie['smilietext']);
$emoticon = addslashes($smilie['title']);
$sql = "INSERT INTO " . SMILIES_TABLE . " (code, smile_url, emoticon)
VALUES ('$smilie_code', '$new_file', '$emoticon')";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to insert smilie (" . $smilie['smilietext'] . ")", __LINE__, $sql);
}
}
}
$fp = fopen(PHPBB_PATH . $board_config['smilies_path'] . '/vb_converted_smilies.pak', 'wb');
$written = fwrite($fp, $vb_smile_pak);
fclose($fp);
if ( $written != strlen($vb_smile_pak) )
{
@unlink(PHPBB_PATH . $board_config['smilies_path'] . '/vb_converted_smilies.pak');
print "<br /> <b>Warning</b>: error writing vB smilie pack.<br />";
}
}
print " <span class="ok"><b>OK</b></span><br />\n";
}
else
{
// Some day I may put some code here to download the smilie pack
// for now, we just forget about the smilies
// User should make sure dir has correct permissions
print "* <span class="error">Skipping smilies, smilie dir not writable</span><br />";
}
//
// Convert Avatar Gallery
//
$failed = false;
if ( is_writable(PHPBB_PATH . $board_config['avatar_gallery_path'] . '/') )
{
print "* Generating Avatar Gallery from vBulletin Avatars :: ";
flush();
$sql = "SELECT avatarpath FROM avatar";
$avatar_query = $DB_site->query($sql);
if ( !$avatar_query )
{
die_nice("Unable to query avatar data", __LINE__, $sql);
}
while ( $avatar = $DB_site->fetch_array($avatar_query) )
{
// Strip beginning 'images/avatars/'.
// Ignore avatars outside images/avatars dir for the moment,
// people with normal installations shouldn't have any problems.
if ( substr($avatar['avatarpath'], 0, 15) == 'images/avatars/' )
{
$path = substr($avatar['avatarpath'], 15);
$dirname = dirname($path);
if ($dirname == ".")
{
$dirname = "default";
}
$filename = basename($path);
if ( !@file_exists(PHPBB_PATH . $board_config['avatar_gallery_path'] . '/' . $dirname . '/') )
{
// Create dir
if ( !@mkdir(PHPBB_PATH . $board_config['avatar_gallery_path'] . '/' . $dirname, 0777) )
{
// Dir creation failed... skip gallery conversion
$failed = true;
break;
}
}
@copy(VBULLETIN_PATH . $avatar['avatarpath'], PHPBB_PATH . $board_config['avatar_gallery_path'] . '/' . $dirname . '/' . $filename);
}
}
if ( $failed == true )
{
print "<span class="error">FAILED</span><br />\nYou should copy the avatars by hand. Note that the avatars in the vBulletin root dir should be copied to a dir called 'default'.";
}
else
{
print " <span class="ok"><b>OK</b></span><br />\n";
}
}
else
{
// Avatar Gallery not writable
print "* <span class="error">Skipping Gallery Avatars, avatar dir not writable</span><br />";
}
//
// Topic watch list
//
print "* Converting topic watch list :: ";
flush();
$sql = "DELETE FROM " . TOPICS_WATCH_TABLE;
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to delete existing entries from topic watchlist", __LINE__, $sql);
}
$sql = "SELECT * FROM subscribethread";
$subscribe_query = $DB_site->query($sql);
if ( !$subscribe_query )
{
die_nice("Unable to query watch list info", __LINE__, $sql);
}
while ( $subscribe = $DB_site->fetch_array($subscribe_query) )
{
$topic_id = intval($subscribe['topic_id']);
$user_id = intval($subscribe['user_id']);
$sql = "INSERT INTO " . TOPICS_WATCH_TABLE . " (topic_id, user_id)
VALUES ('$topic_id', '$user_id')";
}
print " <span class="ok"><b>OK</b></span><br />\n";
if ($step != 'all')
{
break;
}
//
// STEP FORUMS - CONVERT FORUMS
//
case 'forums':
print "* Deleting existing forums and categories :: ";
flush();
$sql = "DELETE FROM " . FORUMS_TABLE;
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to delete old forums", __LINE__, $sql);
}
$sql = "DELETE FROM " . CATEGORIES_TABLE;
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to delete old categories", __LINE__, $sql);
}
$sql = "DELETE FROM " . GROUPS_TABLE . " WHERE group_id <> 1";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to delete old groups", __LINE__, $sql);
}
$sql = "DELETE FROM " . AUTH_ACCESS_TABLE . " WHERE group_id <> 1";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to delete access rights", __LINE__, $sql);
}
print " <span class="ok"><b>OK</b></span><br />\n";
print "* Converting categories :: ";
flush();
$sql = "SELECT forumid, title, displayorder, parentid, parentlist
FROM forum
WHERE cancontainthreads = 0
ORDER BY parentid,displayorder";
$category_query = $DB_site->query($sql);
if ( !$category_query )
{
die_nice("Unable to query category information", __LINE__, $sql);
}
$categories = array();
$display_order = 0;
while ( $category = $DB_site->fetch_array($category_query) )
{
$categories[ $category['forumid'] ] = $category;
$display_order++;
$title = addslashes($category['title']);
$sql = "INSERT INTO " . CATEGORIES_TABLE . " (cat_title, cat_order)
VALUES ('$title', '$display_order')";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to insert category (" . $category['title'] . ")", __LINE__, $sql);
}
$categories[ $category['forumid'] ]['cat_id'] = $db->sql_nextid();
}
print " <span class="ok"><b>OK</b></span><br />\n";
print "* Converting forums and permissions :: ";
flush();
//
// Get standard usergroup permissions
//
$sql = "SELECT * FROM usergroup WHERE usergroupid IN (1,2) ORDER BY usergroupid";
$permission_query = $DB_site->query($sql);
if ( !$permission_query )
{
die_nice("Unable to query default usergroup permissions", __LINE__, $sql);
}
$auth_standard = array();
while ( $perm = $DB_site->fetch_array($permission_query) )
{
if ( $perm['usergroupid'] == 1 )
{
$auth_standard['view'] = ( $perm['canview'] ) ? AUTH_ALL : AUTH_REG;
$auth_standard['read'] = $auth_standard['view'];
$auth_standard['post'] = ( $perm['canpostnew'] ) ? AUTH_ALL : AUTH_REG;
$auth_standard['reply'] = ( $perm['canreplyothers'] ) ? AUTH_ALL : AUTH_REG;
$auth_standard['edit'] = ( $perm['caneditpost'] ) ? AUTH_ALL : AUTH_REG;
$auth_standard['delete'] = ( $perm['candeletepost'] ) ? AUTH_ALL : AUTH_REG;
$auth_standard['vote'] = ( $perm['canvote'] ) ? AUTH_ALL : AUTH_REG;
$auth_standard['pollcreate'] = ( $perm['canpostpoll'] ) ? AUTH_ALL : AUTH_REG;
$auth_standard['attachments'] = ( $perm['canpostattachment'] ) ? AUTH_ALL : AUTH_REG;
}
else
{
$auth_standard['view'] = ( $perm['canview'] ) ? $auth_standard['view'] : AUTH_MOD;
$auth_standard['read'] = $auth_standard['view'];
$auth_standard['post'] = ( $perm['canpostnew'] ) ? $auth_standard['post'] : AUTH_MOD;
$auth_standard['reply'] = ( $perm['canreplyothers'] ) ? $auth_standard['reply'] : AUTH_MOD;
$auth_standard['edit'] = ( $perm['caneditpost'] ) ? $auth_standard['edit'] : AUTH_MOD;
$auth_standard['delete'] = ( $perm['candeletepost'] ) ? $auth_standard['delete'] : AUTH_MOD;
$auth_standard['vote'] = ( $perm['canvote'] ) ? $auth_standard['vote'] : AUTH_MOD;
$auth_standard['pollcreate'] = ( $perm['canpostpoll'] ) ? $auth_standard['pollcreate'] : AUTH_MOD;
$auth_standard['attachments'] = ( $perm['canpostattachment'] ) ? $auth_standard['attachments'] : AUTH_MOD;
}
}
// Sticky and announce only for MODs
$auth_standard['sticky'] = AUTH_MOD;
$auth_standard['announce'] = AUTH_MOD;
$sql = "SELECT * FROM forum WHERE cancontainthreads<>0 ORDER BY parentid,displayorder";
$forums_query = $DB_site->query($sql);
if ( !$forums_query )
{
die_nice("Unable to query forum information", __LINE__, $sql);
}
while ( $forum = $DB_site->fetch_array($forums_query) )
{
$forum_status = ( $forum['allowposting'] ) ? FORUM_UNLOCKED : FORUM_LOCKED;
// This should always give the correct category
$cat_id = $categories[ $forum['parentid'] ]['cat_id'];
if (!$cat_id)
{
$parents = explode(',', $forum['parentlist']);
for ($i = 0; $i < count($parents); $i++)
{
if ( $categories[ $parents[$i] ]['cat_id'] )
{
$cat_id = $categories[ $parents[$i] ]['cat_id'];
break;
}
}
if ( !$cat_id )
{
// This should never happen...
$cat_id = 1;
}
}
//
// Get custom forum permissions
// Yeah.. it's pretty messy
//
$forum_id = intval($forum['forumid']);
$sql = "SELECT *
FROM forumpermission
WHERE forumid = '$forum_id'
AND usergroupid IN (1,2)
ORDER BY usergroupid";
$permission_query = $DB_site->query($sql);
if ( !$permission_query )
{
die_nice("Unable to query forum permissions for forum " . $forum['forumid'], __LINE__, $sql);
}
$auth = array();
while ( $perm = $DB_site->fetch_array($permission_query) )
{
if ( $perm['usergroupid'] == 1 )
{
$auth['view'] = ( $perm['canview'] ) ? AUTH_ALL : AUTH_REG;
$auth['read'] = $auth['view'];
$auth['post'] = ( $perm['canpostnew'] ) ? AUTH_ALL : AUTH_REG;
$auth['reply'] = ( $perm['canreplyothers'] ) ? AUTH_ALL : AUTH_REG;
$auth['edit'] = ( $perm['caneditpost'] ) ? AUTH_ALL : AUTH_REG;
$auth['delete'] = ( $perm['candeletepost'] ) ? AUTH_ALL : AUTH_REG;
$auth['vote'] = ( $perm['canvote'] ) ? AUTH_ALL : AUTH_REG;
$auth['pollcreate'] = ( $perm['canpostpoll'] ) ? AUTH_ALL : AUTH_REG;
$auth['attachments'] = ( $perm['canpostattachment'] ) ? AUTH_ALL : AUTH_REG;
}
else if ( isset($auth['view']) )
{
$auth['view'] = ( $perm['canview'] ) ? $auth['view'] : AUTH_MOD;
$auth['read'] = $auth['view'];
$auth['post'] = ( $perm['canpostnew'] ) ? $auth['post'] : AUTH_MOD;
$auth['reply'] = ( $perm['canreplyothers'] ) ? $auth['reply'] : AUTH_MOD;
$auth['edit'] = ( $perm['caneditpost'] ) ? $auth['edit'] : AUTH_MOD;
$auth['delete'] = ( $perm['candeletepost'] ) ? $auth['delete'] : AUTH_MOD;
$auth['vote'] = ( $perm['canvote'] ) ? $auth['vote'] : AUTH_MOD;
$auth['pollcreate'] = ( $perm['canpostpoll'] ) ? $auth['pollcreate'] : AUTH_MOD;
$auth['attachments'] = ( $perm['canpostattachment'] ) ? $auth['attachments'] : AUTH_MOD;
}
else
{
$auth['view'] = ( $perm['canview'] ) ? $auth_standard['view'] : AUTH_MOD;
$auth['read'] = $auth['view'];
$auth['post'] = ( $perm['canpostnew'] ) ? $auth_standard['post'] : AUTH_MOD;
$auth['reply'] = ( $perm['canreplyothers'] ) ? $auth_standard['reply'] : AUTH_MOD;
$auth['edit'] = ( $perm['caneditpost'] ) ? $auth_standard['edit'] : AUTH_MOD;
$auth['delete'] = ( $perm['candeletepost'] ) ? $auth_standard['delete'] : AUTH_MOD;
$auth['vote'] = ( $perm['canvote'] ) ? $auth_standard['vote'] : AUTH_MOD;
$auth['pollcreate'] = ( $perm['canpostpoll'] ) ? $auth_standard['pollcreate'] : AUTH_MOD;
$auth['attachments'] = ( $perm['canpostattachment'] ) ? $auth_standard['attachments'] : AUTH_MOD;
}
}
if ( !isset($auth['view']) )
{
// Use standard permissions
$auth['view'] = $auth_standard['view'];
$auth['read'] = $auth_standard['read'];
$auth['post'] = $auth_standard['post'];
$auth['reply'] = $auth_standard['reply'];
$auth['edit'] = $auth_standard['edit'];
$auth['delete']= $auth_standard['delete'];
$auth['vote'] = $auth_standard['vote'];
$auth['pollcreate'] = $auth_standard['pollcreate'];
$auth['attachments'] = $auth_standard['attachments'];
}
// Sticky and announce only for MODs
$auth['sticky'] = AUTH_MOD;
$auth['announce'] = AUTH_MOD;
// Will let forum sync at the end handle this
$last_post_id = 0;
$forum_title = addslashes($forum['title']);
$forum_description = addslashes($forum['description']);
$forum_order = intval($forum['displayorder']);
$forum_posts = intval($forum['replycount']);
$forum_topics = intval($forum['threadcount']);
$sql = "INSERT INTO " . FORUMS_TABLE . " (forum_id, cat_id, forum_name, forum_desc, forum_status, forum_order, forum_posts, forum_topics, forum_last_post_id, prune_next, prune_enable, auth_view, auth_read, auth_post, auth_reply, auth_edit, auth_delete, auth_sticky, auth_announce, auth_vote, auth_pollcreate, auth_attachments)
VALUES ('$forum_id', '$cat_id', '$forum_title', '$forum_description', '$forum_status', '$forum_order', '$forum_posts', '$forum_topics', '$last_post_id', '0', '0', '" . $auth['view'] . "', '" . $auth['read'] . "', '" . $auth['post'] . "', '" . $auth['reply'] . "', '" . $auth['edit'] . "', '" . $auth['delete'] . "', '" . $auth['sticky'] . "', '" . $auth['announce'] . "', '" . $auth['vote'] . "', '" . $auth['pollcreate'] . "', '" . $auth['attachments'] . "')";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to insert forum (". $forum['title'] . ")", __LINE__, $sql);
}
}
print " <span class="ok"><b>OK</b></span><br />\n";
if ( $step != 'all' )
{
break;
}
//
// STEP USERS - CONVERT USERS
//
case 'users':
if ( !$start_id )
{
print "* Deleting existing users :: ";
flush();
$sql = "DELETE FROM " . USERS_TABLE . " WHERE user_id <> -1";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Delete users from users table failed", __LINE__, $sql);
}
$sql = "DELETE FROM " . USER_GROUP_TABLE . " WHERE user_id <> -1";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Delete users from usergroup table failed", __LINE__, $sql);
}
print " <span class="ok"><b>OK</b></span><br />\n";
}
$sql = "SELECT MAX(userid) AS max_id FROM user";
$max_query = $DB_site->query($sql);
if ( !$max_query )
{
die_nice("Unable to get maximum userid", __LINE__, $sql);
}
$row = $DB_site->fetch_array($max_query);
$max_id = $row['max_id'];
$sql = "SELECT MAX(group_id) AS total
FROM " . GROUPS_TABLE;
if ( !($result = $db->sql_query($sql)) )
{
die_nice('Could not obtain next group_id information', __LINE__, $sql);
}
if ( !($row = $db->sql_fetchrow($result)) )
{
die_nice('Could not obtain next group_id information', __LINE__, $sql);
}
$group_id = $row['total'] + 1;
// Default settings for users
$style = $board_config['default_style'];
$lang = $board_config['default_lang'];
$date_format = $board_config['default_dateformat'];
$allow_html = $board_config['allow_html'];
$allow_bbcode = $board_config['allow_bbcode'];
$allow_smile = $board_config['allow_smilies'];
$allow_sig = $board_config['allow_sig'];
// Global config will overwrite this setting, so it is safe to set it to 1
// Changed this in version 1.31 because of avatar-problems people seemed to have
$allow_avatar = 1;
$allow_pm = ( $board_config['privmsg_disable'] ) ? 0 : 1;
//
// Check for custom userfields Location, Interests and Occupation
//
$sql = "SELECT profilefieldid, title FROM profilefield WHERE title IN ('location', 'interests', 'occupation')";
$pf_query = $DB_site->query($sql);
if ( !$pf_query )
{
die_nice("Unable to fetch custom profile fields", __LINE__, $sql);
}
$profilefield_sql = "%s AS location, %s AS interests, %s AS occupation ";
$location = "''";
$interests = "''";
$occupation = "''";
while ( $row = $DB_site->fetch_array($pf_query) )
{
switch ( $row['title'] )
{
case 'location':
$location = 'uf.field' . $row['profilefieldid'];
break;
case 'interests':
$interests = 'uf.field' . $row['profilefieldid'];
break;
case 'occupation':
$occupation = 'uf.field' . $row['profilefieldid'];
break;
}
}
// Build custom profilefield sql
$profilefield_sql = sprintf($profilefield_sql, $location, $interests, $occupation);
$banned_users = array();
$batchsize = intval(BATCH_SIZE); // Process this many posts per loop
$batchcount = 0;
if ( SAFE_MODE )
{
$resume_batches = intval(SAFE_MODE_BATCHES);
}
else
{
$resume_batches = 0;
}
//
// Loop through the users in batches
//
for($counter = $start_id; $counter <= $max_id; $counter += $batchsize)
{
$batchstart = $counter + 1;
$batchend = $counter + $batchsize;
$batchcount++;
print " * Converting Users ( $batchstart to $batchend ) :: ";
flush();
$sql = "SELECT u.*, $profilefield_sql
FROM user u LEFT JOIN userfield uf ON u.userid=uf.userid
WHERE u.userid
BETWEEN $batchstart
AND $batchend
ORDER BY u.userid ASC";
$users_query = $DB_site->query($sql);
if ( !$users_query )
{
die_nice("Unable to query batch ( $batchstart - $batchend )", __LINE__, $sql);
}
$per_pct = ceil( $DB_site->num_rows($users_query) / 40 );
$inc = 0;
while ( $user = $DB_site->fetch_array($users_query) )
{
// Rank
$user_rank = $user['usertitle'];
// Convert user level
switch ( $user['usergroupid'] )
{
case VB_UG_UNREGISTERED:
$user_level = ANONYMOUS;
$active = 0;
// This treats all users in this category as banned
// Not the best solution, but vB doesn't allow us a better one
$banned_users[] = $user['userid'];
break;
case VB_UG_REGISTERED:
$user_level = USER;
$active = 1;
break;
case VB_UG_AWAITING_EMAIL_CONF:
$user_level = USER;
$active = 0;
break;
case VB_UG_AWAITING_COPPA_CONF:
$user_level = USER;
$active = 0;
break;
case VB_UG_SUPER_MODS:
$user_level = MOD;
$active = 1;
$groups['super_mods'][] = $user['userid'];
break;
case VB_UG_ADMIN:
$user_level = ADMIN;
$active = 1;
$groups['admins'][] = $user['userid'];
break;
case VB_UG_MODERATORS:
$user_level = MOD;
$active = 1;
break;
default:
// Unknown custom usergroup
$user_level = USER;
$active = 1;
$groups[ $user['usergroupid'] ][] = $user['userid'];
break;
}
//
// Do custom rank
//
$sql = "SELECT rank_id, rank_special
FROM " . RANKS_TABLE . "
WHERE rank_title = '" . addslashes($user_rank) . "'";
$rank_query = $db->sql_query($sql);
if ( !$rank_query )
{
die_nice("Unable to query rankid for rank $user_rank", __LINE__, $sql);
}
$rank_data = $db->sql_fetchrow($rank_query);
if ( !$rank_data )
{
// Non-existing rank
$sql = "INSERT INTO " . RANKS_TABLE . " (rank_title, rank_special)
VALUES ('" . addslashes($user_rank) . "', 1)";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to insert new rank ($user_rank)", __LINE__, $sql);
}
$rank_id = $db->sql_nextid();
}
else if ( $rank_data['rank_special'] == 0 )
{
$rank_id = 'NULL';
}
else
{
$rank_id = $rank_data['rank_id'];
}
//
// Do avatar (check if gallery avatar or normal avatar)
//
$avatar_id = intval($user['avatarid']);
if ( $avatar_id == 0 )
{
//
// Normal avatar
//
$user_id = intval($user['userid']);
$sql = "SELECT avatardata FROM customavatar WHERE userid = '$user_id'";
$avatar_query = $DB_site->query($sql);
if ( !$avatar_query )
{
die_nice("Unable to query avatar data for user $user_id", __LINE__, $sql);
}
$row = $DB_site->fetch_array($avatar_query);
$avatar_data = $row['avatardata'];
if ( strlen($avatar_data) > 0 )
{
// Portion of code taken from profile.php
// Build avatar image from vB database string
$avatar_filename = $user_id . ".gif";
if( file_exists( PHPBB_PATH . $board_config['avatar_path'] . "/$avatar_filename" ) )
{
@unlink(PHPBB_PATH . $board_config['avatar_path'] . "/$avatar_filename");
}
$fptr = @fopen(PHPBB_PATH . $board_config['avatar_path'] . "/$avatar_filename", "wb");
$bytes_written = @fwrite($fptr, $avatar_data, strlen($avatar_data));
@fclose($fptr);
$avatar = $avatar_filename;
$avatar_type = USER_AVATAR_UPLOAD;
}
else
{
//
// No avatar
//
$avatar = '';
$avatar_type = USER_AVATAR_NONE;
}
}
else
{
//
// Gallery avatar
//
$sql = "SELECT avatarpath FROM avatar WHERE avatarid = $avatar_id";
$avatar_query = $DB_site->query($sql);
if ( !$avatar_query )
{
die_nice("Unable to query gallery avatar data (" . $user['avatarid'] . ")", __LINE__, $sql);
}
$row = $DB_site->fetch_array($avatar_query);
// Only support avatars in the appropriate avatars dir
// This should be ok for standard installs
// People with different setups should change this
if ( substr($row['avatar_path'], 0, 15) == 'images/avatars/' )
{
$path = substr($row['avatar_path'], 15);
$dirname = dirname($path);
if ($dirname == ".")
{
// Name of gallery category for vB root avatars
$dirname = "default";
}
$filename = basename($path);
$avatar = $dirname . "/" . $filename;
$avatar_type = USER_AVATAR_GALLERY;
}
else
{
$avatar = '';
$avatar_type = USER_AVATAR_NONE;
}
}
//
// Do signature
//
$sig_uid = ( $allow_bbcode ) ? make_bbcode_uid() : "";
$signature = addslashes(convert_vb_code($user['signature']));
$signature = prepare_message($signature, $allow_html, $allow_bbcode, $allow_smilies, $sig_uid);
//
// Do some checks on the data
//
$user['yahoo'] = ( strlen($user['yahoo']) < 3 ) ? '' : $user['yahoo'];
$user['aim'] = ( strlen($user['aim']) < 3 ) ? '' : $user['aim'];
$website = trim($user['homepage']);
if ( substr(strtolower($website), 0, 7) != "http://" )
{
$website = "http://" . $website;
}
if ( strtolower($website) == 'http://' )
{
$website = '';
}
$website = addslashes($website);
$icq = ( ereg("^[0-9]+$", $user['icq']) ) ? $user['icq'] : '';
$show_online = ( $user['invisible'] ) ? 0 : 1;
// Check if passwords needs to be encrypted.
// vBulletin < 2.2.0 doesn't encrypt passwords.
if ( VBULLETIN_VERSION < '2.2.0' )
{
$user['password'] = md5($user['password']);
}
$password = addslashes($user['password']);
$user_id = intval($user['userid']);
$username = addslashes($user['username']);
$last_visit = intval($user['lastvisit']);
$join_date = intval($user['joindate']);
$posts = intval($user['posts']);
$timezone_offset = addslashes($user['timezoneoffset']);
$date_format = addslashes($date_format);
$view_email = intval($user['showemail']);
$notify = intval($user['emailnotification']);
$notify_pm = intval($user['emailonpm']);
$pm_popup = intval($user['pmpopup']);
$avatar = addslashes($avatar);
$email = addslashes($user['email']);
$location = addslashes($user['location']);
$aim = addslashes($user['aim']);
$yim = addslashes($user['yahoo']);
$occupation = addslashes($user['occupation']);
$interests = addslashes($user['interests']);
// Change this if a MSN-messenger hack is installed on your vB
$msnm = '';
//
// User insert
//
$sql = "INSERT INTO " . USERS_TABLE . " (user_id, user_active, username, user_password, user_lastvisit, user_regdate, user_level, user_posts, user_timezone, user_style, user_lang, user_dateformat, user_viewemail, user_attachsig, user_allowhtml, user_allowbbcode, user_allowsmile, user_allowavatar, user_allow_pm, user_allow_viewonline, user_notify, user_notify_pm, user_popup_pm, user_rank, user_avatar, user_avatar_type, user_email, user_icq, user_website, user_from, user_sig, user_sig_bbcode_uid, user_aim, user_yim, user_msnm, user_occ, user_interests)
VALUES ('$user_id', '$active', '$username', '$password', '$last_visit', '$join_date', '$user_level', '$posts', '$timezone_offset', '$style', '$lang', '$date_format', '$view_email', '$allow_sig', '$allow_html', '$allow_bbcode', '$allow_smile', '$allow_avatar', '$allow_pm', '$show_online', '$notify', '$notify_pm', '$pm_popup', '$rank_id', '$avatar', '$avatar_type', '$email', '$icq', '$website', '$location', '$signature', '$sig_uid', '$aim', '$yim', '$msnm', '$occupation', '$interests')";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to insert user $user_id", __LINE__, $sql);
}
//
// Group creation
//
$sql = "INSERT INTO " . GROUPS_TABLE . " (group_id, group_name, group_description, group_single_user)
VALUES ('$group_id', '$username', 'Personal User', '1')";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to create group for user $user_id", __LINE__, $sql);
}
//
// User -> Group creation
//
$sql = "INSERT INTO " . USER_GROUP_TABLE . " (group_id, user_id, user_pending)
VALUES ('$group_id', '$user_id', '0')";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to create user-group link for user $user_id", __LINE__, $sql);
}
$group_id++;
$inc++;
if ( $inc == $per_pct )
{
print ".";
flush();
$inc = 0;
}
}
$DB_site->free_result($users_query);
print " <span class="ok"><b>OK</b></span><br />\n";
// Output resume HTML if batchcount equals resume_batches
if ( $batchcount == $resume_batches )
{
$resume_id = $batchend;
break;
}
}
if ( $step != 'all' )
{
break;
}
//
// STEP MODS - CONVERT MODERATORS, ADMINS AND USERGROUPS
//
case 'mods':
$banned_users = array();
$groups = array();
$groups['admins'] = array();
$groups['super_mods'] = array();
// Fetch info to populate usergroups
$sql = "SELECT userid, usergroupid FROM user
WHERE usergroupid NOT IN ('" . VB_UG_REGISTERED . "', '" . VB_UG_AWAITING_EMAIL_CONF . "', '" . VB_UG_AWAITING_COPPA_CONF . "', '" . VB_UG_MODERATORS . "')";
$user_query = $DB_site->query($sql);
if ( !$user_query )
{
die_nice("Unable to query usergroup information", __LINE__, $sql);
}
while ( $user = $DB_site->fetch_array($user_query) )
{
$usergroup_id = intval($user['usergroupid']);
$user_id = intval($user['userid']);
switch ( $usergroup_id )
{
case 0:
// Invalid entry
break;
case VB_UG_UNREGISTERED:
// This treats all users in this category as banned
// Not the best solution, but vB doesn't allow us a better one
$banned_users[] = $user_id;
break;
case VB_UG_SUPER_MODS:
$groups['super_mods'][] = $user_id;
break;
case VB_UG_ADMIN:
$groups['admins'][] = $user_id;
break;
default:
// Unknown custom usergroup
$groups[$usergroup_id][] = $user_id;
break;
}
}
$DB_site->free_result($user_query);
$sql = "SELECT MAX(group_id) AS total
FROM " . GROUPS_TABLE;
if ( !($result = $db->sql_query($sql)) )
{
die_nice('Could not obtain next group_id information', __LINE__, $sql);
}
if ( !($row = $db->sql_fetchrow($result)) )
{
die_nice('Could not obtain next group_id information', __LINE__, $sql);
}
$group_id = $row['total'] + 1;
//
// Handle super-mods and admins, create groups for them
//
if( count($groups['super_mods']) && count($groups['admins']) )
{
print " * Creating new group for admins and super moderators :: ";
flush();
$primary_admin = intval($groups['admins'][0]);
$group_type = GRO

Hier ein paar Beispiele und meine Lösungsvorschlläge

$DB_site->database = $dbname;
$DB_site->server = $servername;
$DB_site->user = $dbusername;
$DB_site->password = $dbpassword;
=>
$DB_site->database = $datenbankname; z.B. Testdatenbank
$DB_site->server = $servername; z.B. Testserver
$DB_site->user = $datenbankusername; z.B. Testuser
$DB_site->password = $datenbankpasswort; z.B. Testpasswort
^natürlich werden hier die echten Daten eingetragen, jedoch hab ich keine Lust diese hier preiszugeben

include(PHPBB_PATH . 'includes/functions_admin.' . $phpEx);
=>
include(PHPBB_PATH . 'www.meinedomain.de/phpBB2/includes/functions_admin.' . $phpEx);
require(VBULLETIN_PATH . 'admin/db_mysql.php');
=>
require(VBULLETIN_PATH . 'www.meinedomain.de/vb/includes/db_mysql.php');
Stimmt das so ?
Und wo in der convert.php muss ich alles etwas ändern? Diese sieht standardmäßig so aus:
[quote]<?php
/***************************************************************************
* convert.php
* -------------------
* begin : Saturday, Feb 23, 2002
* copyright : (C) 2002 Matthijs van de Water
* Portions of code (C) 2001 the phpBB Group
* email : converter@matthijs.net
* support@phpbb.com
*
* $Id: convert.php,v 1.33 2003/01/18 17:27:13 mvdwater Exp $
*
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
/***************************************************************************
*
* If you are unsure if this piece of software reached you unmodified,
* please download the latest version from http://matthijs.beryllium.net/
*
***************************************************************************/
/***************************************************************************
*
* VBULLETIN 2.0/2.2 TO PHPBB 2.0 CONVERSION TOOL
*
***************************************************************************
*
* FILE DESCRIPTION
*
* This script will convert from an existing vBulletin 2.0 / 2.2 installation
* to a new phpBB 2.0 installation.
*
*
* INSTALLATION GUIDELINES
*
* Backup your files and database before attempting to run this conversion!
* No change is made to your original vBulletin database, but one can never
* be too carefull. The author and/or the phpBB Group are not responsible
* for any data-loss as a result of using this software.
*
* Do a clean install of the latest version of phpBB 2.0.
*
* Make sure smilie and avatar dirs are writable and executable
* for the webserver, as it needs to create directories and images.
*
* Please verify the configuration defines below and update them to
* your situation.
*
* Place the convert.php file in the vBulletin root dir.
*
* Open the script in your browser and follow the onscreen instructions.
* Be sure to take your time for the conversion, as the process may take
* up to an hour, depending on the size of your board and the speed of
* your server.
*
***************************************************************************/
//
// Conversion Tool Configuration Settings
//
// Global path defines, change this if your installation is different.
// On Windows systems, use either \\ or / as directory delimiters.
// Be sure to keep the tailing slash on all paths!
define('VBULLETIN_PATH', 'http://miroerr.mi.funpic.de/forum/');
define('PHPBB_PATH', 'http://miroerr.mi.funpic.de/phpBB2/');
define('PHPBB_URI', 'http://miroerr.mi.funpic.de/phpBB2/');
// Do this many items in one go.
// Should be good for most servers, no need to change this unless your
// server can't handle the load.
define('BATCH_SIZE', 1000);
// If safe mode is on, process this many batches before breaking
// and reloading to stop script timeouts in lengthy steps.
// Only change this if you have timout problems. Can't be lower than 1
// and must be integer.
define('SAFE_MODE_BATCHES', 2);
// Enable this if you have timeout problems
define('FORCE_SAFE_MODE', 0);
//
// End Configuration Settings
//
//
// THERE IS NO NEED TO CHANGE ANYTHING BELOW THIS LINE
//
// This must be defined to be able to use the phpBB includes
// And to access the page if the board is disabled
define('IN_PHPBB', true);
define('IN_ADMIN', true);
// Define script version and filename
define('SCRIPT_VERSION', '1.33');
define('SCRIPT_FILENAME', $PHP_SELF);
// Some defines for vBulletin
// These guys may not like using defines, but I do
define('VB_THREAD_CLOSED', 0);
define('VB_THREAD_OPEN', 1);
define('VB_THREAD_MOVED', 10);
define('VB_INBOX', 0);
define('VB_SENTBOX', -1);
define('VB_UG_UNREGISTERED', 1);
define('VB_UG_REGISTERED', 2);
define('VB_UG_AWAITING_EMAIL_CONF', 3);
define('VB_UG_AWAITING_COPPA_CONF', 4);
define('VB_UG_SUPER_MODS', 5);
define('VB_UG_ADMIN', 6);
define('VB_UG_MODERATORS', 7);
// Record starttime
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$script_starttime = $mtime;
// Check if paths defined above are correct
if ( !@file_exists(VBULLETIN_PATH . 'http://miroerr.mi.funpic.de/forum/includes/config.php') )
{
die("ERROR: Unable to find vBulletin configuration file.<br />Check the path defines.<br />");
}
if ( !@file_exists(PHPBB_PATH . 'http://miroerr.mi.funpic.de/phpBB2/extension.inc') )
{
die("ERROR: Unable to find phpBB includes.<br />Check the path defines.<br />");
}
// Unlimited execution time, but not in safe mode
$ini_val = ( phpversion() >= '4.0.0' ) ? 'ini_get' : 'get_cfg_var';
if ( @$ini_val('safe_mode') || FORCE_SAFE_MODE )
{
define('SAFE_MODE', 1);
}
else
{
@set_time_limit(0);
define('SAFE_MODE', 0);
}
//
// This will load all vBulletin needed data
// No vBulletin functions are used, accept for the database class
//
// Load config file
require(VBULLETIN_PATH . 'http://miroerr.mi.funpic.de/forum/includes/config.php');
// Force persistent connections
$usepconnect = 1;
// Init DB class, force MySQL
require(VBULLETIN_PATH . 'http://miroerr.mi.funpic.de/forum/includes/db_mysql.php');
$DB_site = new DB_Sql_vb();
$DB_site->database = $dbname;
$DB_site->server = $servername;
$DB_site->user = $dbusername;
$DB_site->password = $dbpassword;
// Use our own error reporting
$DB_site->reporterror = 0;
$DB_site->connect();
// Load vBulletin options
$sql = "SELECT template AS options FROM template WHERE title='options'";
$options_query = $DB_site->query($sql);
if ( !$options_query )
{
die("Unable to fetch vBulletin options");
}
$row = $DB_site->fetch_array($options_query);
eval($row['options']);
$DB_site->free_result($options_query);
unset($row);
if ( !$templateversion )
{
$templateversion = '2.0.0';
}
define('VBULLETIN_VERSION', $templateversion);
//
// End vBulletin global settings
//
//
// Include phpBB config and global files and needed functions
//
$phpbb_root_path = PHPBB_PATH;
include(PHPBB_PATH . 'http://miroerr.mi.funpic.de/phpBB2/extension.inc');
include(PHPBB_PATH . 'http://miroerr.mi.funpic.de/phpBB2/common.' . $phpEx);
include(PHPBB_PATH . 'http://miroerr.mi.funpic.de/phpBB2/incl ... tions_post.' . $phpEx);
include(PHPBB_PATH . 'http://miroerr.mi.funpic.de/phpBB2/includes/bbcode.' . $phpEx);
include(PHPBB_PATH . 'http://miroerr.mi.funpic.de/phpBB2/incl ... ons_search.' . $phpEx);
include(PHPBB_PATH . 'http://miroerr.mi.funpic.de/phpBB2/incl ... ions_admin.' . $phpEx);
// Output no caching headers to keep browsers from caching steps
header ("Cache-Control: no-store, no-cache, must-revalidate");
header ("Cache-Control: pre-check=0, post-check=0, max-age=0", false);
header ("Pragma: no-cache");
header ("Expires: " . gmdate("D, d M Y H:i:s", time()) . " GMT");
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// Step descriptions and sequence
$steps = array("start" => "Welcome Screen",
"settings" => "Settings",
"forums" => "Forums, Catogories and Permissions",
"users" => "Users",
"mods" => "Moderators, Admins and Usergroups",
"topics" => "Topics",
"posts" => "Posts",
"pm" => "Private Messages",
"polls" => "Polls",
"wordlist" => "Search Wordlist",
"end" => "Finalisation and Thank You Screen");
//
// Start of functions block
//
//
// Dies with a nicely formatted error message
//
function die_nice($message, $line = '', $sql = '')
{
global $db, $DB_site;
$phpbb_error = $db->sql_error();
if ( !empty($phpbb_error['message']) )
{
$error = $phpbb_error['code'] . " :: " . $phpbb_error['message'];
}
else
{
$error = $DB_site->errno . " :: " . $DB_site->errdesc;
}
print "<br /><br /><span class="error">ERROR</span>: $message<br /><br />\n";
print "After you have located and fixed the error, reload this page to continue the conversion process.<br />\n";
print "<pre>Debug information:<br />\n";
if ( !empty($line) )
{
print "Line: " . $line . "<br />\n";
}
if ( !empty($sql) )
{
print "SQL: " . $sql . "<br />\n";
}
print "MySQL Error: " . $error . "<br />\n";
print "</pre>\n";
common_footer();
exit;
}
//
// Converts vB only bbcode tags to corresponding phpBB bbcode
//
function convert_vb_code ($bbcode, $quote_template = -1)
{
// Remove [font] tags
$search = array("|\[font=[^\]]*\]|si", "|\[/font\]|si");
$replace = array("", "");
$bbcode = preg_replace($search, $replace, $bbcode);
// Convert [php] tag to [code]
// If you have the [php] MOD installed, you should comment this out
$search = array("[php]", "[/php]", "[PHP]", "[/PHP]");
$replace = array("[code]", "[/code]", "[code]", "[/code]");
$bbcode = str_replace($search, $replace, $bbcode);
// Convert [size] tags
// This needs PHP > 4 since it uses the eval option
$search = "/\[size=([0-9]+)\]/ie";
$replace = "'[size='.( (\\1 == 1) ? 9 : 6*\\1 ).']'";
$bbcode = preg_replace($search, $replace, $bbcode);
// Convert "" syntax
$search = "/\{1}([^"']*)['"]{1}\](.*)\[\/url\]/siU";
$replace = "[url=\\1]\\2";
$bbcode = preg_replace($search, $replace, $bbcode);
// Convert [quote] structure (use specified template)
if ($quote_template != -1)
{
if ( preg_match("/(\[quote\].*\[\/quote\])/si", $bbcode, $match) )
{
$quote_text = $match[1];
$search = $quote_template;
$replace = array("[quote="\\1"]\n", "[/quote][/quote][/quote]");
$quote_text = preg_replace($search, $replace, $quote_text);
$bbcode = preg_replace("/(\[quote\].*\[\/quote\])/si", $quote_text, $bbcode);
}
}
return $bbcode;
}
//
// Locks tables - modified from upgrade.php
//
function lock_tables($state, $tables= '')
{
global $DB_site;
if ( $state == 1 )
{
if ( is_array($tables) )
{
$tables = join(' WRITE, ', $tables);
}
$sql = "LOCK TABLES $tables WRITE";
$result = $DB_site->query($sql);
if ( !$result )
{
die_nice("Unable to do LOCK TABLES $tables WRITE", __LINE__, $sql);
}
}
else
{
$sql = "UNLOCK TABLES";
$result = $DB_site->query($sql);
if ( !$result )
{
die_nice("Unable to unlock tables", __LINE__, $sql);
}
}
}
//
// Print common page header - modified from upgrade.php
//
function common_header()
{
global $step, $steps;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>vBulletin 2.0/2.2 Conversion Tool for phpBB 2.0</title>
<meta name="description" content="vBulletin 2.0/2.2 to phpBB 2.0 Conversion Tool">
<meta name="keywords" content="phpbb2 phpbb 2.0 vbulletin vb phpbb2vb convert_vb2 2.2.2 2.2.1 2.2.0 2.2.x 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.x 2.x conversion tool import convert merge">
<meta name="author" content="Matthijs van de Water">
<meta name="version" content="<?php print SCRIPT_VERSION; ?>">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css">
<!--
/* Specifiy background images for selected styles
This can't be done within the external style sheet as NS4 sees image paths relative to
the page which called the style sheet (i.e. this page in the root phpBB directory)
whereas all other browsers see image paths relative to the style sheet. Stupid NS again!
*/
TH { background-image: url(<?php print PHPBB_URI; ?>templates/subSilver/images/cellpic3.gif) }
TD.cat { background-image: url(<?php print PHPBB_URI; ?>templates/subSilver/images/cellpic1.gif) }
TD.rowpic { background-image: url(<?php print PHPBB_URI; ?>templates/subSilver/images/cellpic2.jpg); background-repeat: repeat-y }
td.icqback { background-image: url(<?php print PHPBB_URI; ?>templates/subSilver/images/icon_icq_add.gif); background-repeat: no-repeat }
TD.catHead,TD.catSides,TD.catLeft,TD.catRight,TD.catBottom { background-image: url(<?php print PHPBB_URI; ?>templates/subSilver/images/cellpic1.gif) }
font,th,td,p,body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11pt }
a:link,a:active,a:visited { font-family: Verdana, Arial, Helvetica, sans-serif; color : #006699; font-size:11pt }
a:hover { font-family: Verdana, Arial, Helvetica, sans-serif; text-decoration: underline; color : #DD6900; font-size:11pt }
hr { height: 0px; border: solid #D1D7DC 0px; border-top-width: 1px;}
.maintitle,h1,h2 { font-weight: bold; font-size: 22px; font-family: "Trebuchet MS",Verdana, Arial, Helvetica, sans-serif; text-decoration: none; line-height : 120%; color : #000000;}
.copyright { font-size: 10px; font-family: Verdana, Arial, Helvetica, sans-serif; color: #444444; letter-spacing: -1px;}
a.copyright { font-size: 10px; font-family: Verdana, Arial, Helvetica, sans-serif; color: #444444; text-decoration: none;}
a.copyright:hover { font-size: 10px; font-family: Verdana, Arial, Helvetica, sans-serif; color: #000000; text-decoration: underline;}
a.copyright:visited { font-size: 10px; font-family: Verdana, Arial, Helvetica, sans-serif; color: #444444; }
.ok { color:green; }
.error { color:red; font-weight: bold; }
/* Import the fancy styles for IE only (NS4.x doesn't use the @import function) */
@import url("<?php print PHPBB_URI; ?>templates/subSilver/formIE.css");
-->
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#006699" vlink="#5584AA">
<table width="100%" border="0" cellspacing="0" cellpadding="10" align="center">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="<?php print PHPBB_URI; ?>templates/subSilver/images/logo_phpBB.gif" border="0" alt="phpBB 2.0" vspace="1" /></td>
<td align="center" width="100%" valign="middle"><span class="maintitle">Converting to phpBB 2.0</span><br />vBulletin 2.0/2.2 Conversion Tool by Matthijs van de Water</span></td>
</tr>
</table></td>
</tr>
</table>
<br clear="all" />
<?php
if ( $step != "all" && $step != "start" && $step != "end" )
{
print "<b>Converting " . $steps[$step] . "</b><br />\n";
}
return;
}
// Print common page footer - modified from upgrade.php
function common_footer()
{
global $db, $query_count, $script_starttime;
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
?>
<br clear="all" />
<br />
<div align="center"><span class="copyright">
Conversion Tool © 2002 <a href="http://www.matthijs.net/phpbb/" target="_mvdw" class="copyright">Matthijs van de Water</a><br />
phpBB 2.0 and portions of code © 2001 <a href="http://www.phpbb.com/" target="_phpbb" class="copyright">phpBB Group</a><br />
vBulletin © 2000-2003 <a href="http://www.jelsoft.com/" target="_vb" class="copyright">Jelsoft Enterprises Limited</a><br />
</span></div>
<br />
<div align="center"><span class="copyright">Step execution time <?php printf("%.3f", $endtime - $script_starttime); ?> seconds :: <?php print $db->num_queries; ?> queries in phpBB database :: <?php print $query_count; ?> queries in vBulletin database :: Debug Mode</span></div>
</body>
</html>
<?php
return;
}
//
// Print next step HTML
//
function next_step($step, $continue)
{
global $steps;
if ( $continue )
{
print "<hr /><a href="$PHP_SELF?step=$step&startat=$continue">Resume step: <b>$step</b></a><br /><br />\n";
print "<script language="javascript">document.location = '$PHP_SELF?step=$step&startat=$continue';</script>\n";
}
else if ( $step != 'all' && $step != 'start' && $step != 'end' )
{
// Get next step from steps array
@reset($steps);
$next = false;
while ( list($key, $value) = each($steps) )
{
if ( $key == $step )
{
$next = key($steps);
break;
}
}
if ( $next )
{
print "<hr /><a href="$PHP_SELF?step=$next">Next step: <b>$next</b></a><br /><br />\n";
}
}
return;
}
//
// End functions
//
// Display welcome screen if the user hasn't specified a specific starting point.
$step = ( isset($HTTP_GET_VARS['step']) ) ? $HTTP_GET_VARS['step'] : 'start';
// Get resume point if one was given
$start_id = ( isset($HTTP_GET_VARS['startat']) ) ? $HTTP_GET_VARS['startat'] : 0;
// Next resume point initialisation
$resume_id = false;
// Output common header
common_header();
//
// The big switch, determine step to be taken
//
switch ( $step )
{
//
// STEP START - SHOW STARTUP SCREEN
//
case 'start':
print "<b>Welcome to the vBulletin 2.0 / 2.2 to phpBB 2.0 Conversion Tool.</b><br /><br />\n";
print "This script will guide you through the conversion process. Depending on the size of your board and the speed of your server the process can last over an hour, so be patient.<br />\n";
print "Don't interrupt the loading of pages, follow the instructions on screen.<br />\n";
print "<br /><b>Be sure to backup your database(s) before continuing!</b><br />\n";
if ( $board_config['version'] < '.0.4' )
{
print "<span class="error">Warning</span> :: Your phpBB version is incompatible with this version of the converter. You should install <a target="_phpbb" href="http://www.phpbb.com/downloads.php">the latest version of phpBB</a> available.<br />";
}
if ( substr($dbms, 0, 5) != 'mysql' )
{
print "<span class="error">Warning</span> :: You have selected a DBMS that is not MySQL. The script may not work as expected and might give errors. You should select either MySQL 3.x or 4.x as your DBMS during the phpBB installation.<br />";
}
if ( SAFE_MODE == 1 )
{
print "<span class="error">Warning</span> :: PHP Safe Mode is on. This can cause the script to timeout. You should disable safe mode if you can.<br />";
}
if ( !@is_writable(PHPBB_PATH . $board_config['smilies_path'] . '/') )
{
print "<span class="error">Warning</span> :: Smilies dir is not writable. You should change the permissions if you can.</span><br />";
}
if ( !@is_writable(PHPBB_PATH . $board_config['avatar_gallery_path'] . '/') )
{
print "<span class="error">Warning</span> :: Avatar Gallery dir is not writable. You should change the permissions if you can.</span><br />";
}
if ( !@is_writable(PHPBB_PATH . $board_config['avatar_path'] . '/') )
{
print "<span class="error">Warning</span> :: Avatar dir is not writable. You should change the permissions if you can.</span><br />";
}
print "<br /><br /><br /><br />\n";
print "<hr /><a href="$PHP_SELF?step=settings">Start Conversion</a><br /><br />\n";
if ($step != 'all')
{
break;
}
//
// STEP ALL - DO ALL STEPS IN ONE GO IF NOT IN SAFE MODE
//
case 'all':
if ( SAFE_MODE )
{
print "<span class="error">Error</span> :: Cannot do all steps in one go when in safe mode.<br />\n";
break;
}
//
// STEP SETTINGS - CONVERT BOARD SETTINGS
//
case 'settings':
print "* Converting configuration settings :: ";
flush();
//
// General Config Table
//
// Private message quota
$pm_sentbox = intval($pmquota);
$pm_savebox = intval($pmquota / 2);
$pm_inbox = intval($pmquota / 2);
// Patch floodcheck time
$floodchecktime = ( $enablefloodcheck ) ? intval($floodchecktime) : 0;
// Patch dateformat
$dateformat .= " $timeformat";
// Patch timezone offset if needed
if ( substr($timeoffset, 0, 1) == '+' )
{
$timeoffset = substr($timeoffset, 1);
}
// Get max online users and date/time
$sql = "SELECT template AS maxloggedin
FROM template
WHERE title = 'maxloggedin'
AND templatesetid = -1";
$template_query = $DB_site->query($sql);
if ( !$template_query )
{
die_nice("Unable to query maxloggedin information", __LINE__, $sql);
}
$row = $DB_site->fetch_array($template_query);
$max_logged_in = $row['maxloggedin'];
$max = explode(" ", $max_logged_in);
$max_users = intval($max[0]);
$max_users_timestamp = intval($max[1]);
// Activation type
$activation = ($verifyemail) ? USER_ACTIVATION_SELF : USER_ACTIVATION_NONE;
$activation = ($moderatenewmembers) ? USER_ACTIVATION_ADMIN : $activation;
// Inversed config options
$priv_msg_disable = ( $enablepms ) ? 0 : 1;
$board_disable = ( $bbactive ) ? 0 : 1;
$queries = array();
// Generate update configuration table queries
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . $board_disable . "' WHERE config_name = 'board_disable'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . addslashes($bbtitle) . "' WHERE config_name = 'sitename'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = 'vBulletin 2.x Converted Board' WHERE config_name = 'site_desc'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . addslashes($cookiepath) . "' WHERE config_name = 'cookie_path'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . addslashes($cookiedomain) . "' WHERE config_name = 'cookie_domain'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . intval($cookietimeout) . "' WHERE config_name = 'session_length'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . intval($allowhtml) . "' WHERE config_name = 'allow_html'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . intval($allowbbcode) . "' WHERE config_name = 'allow_bbcode'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . intval($allowsmilies) . "' WHERE config_name = 'allow_smilies'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . intval($allowsignatures) . "' WHERE config_name = 'allow_sig'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . intval($avatarallowupload) . "' WHERE config_name = 'allow_avatar_local'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . intval($avatarallowwebsite) . "' WHERE config_name = 'allow_avatar_remote'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . intval($avatarallowupload) . "' WHERE config_name = 'allow_avatar_upload'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . intval($maxposts) . "' WHERE config_name = 'posts_per_page'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . intval($maxthreads) . "' WHERE config_name = 'topics_per_page'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . intval($hotnumberposts) . "' WHERE config_name = 'hot_threshold'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . intval($maxpolloptions) . "' WHERE config_name = 'max_poll_options'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . $pm_inbox . "' WHERE config_name = 'max_inbox_privmsgs'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . $pm_sentbox . "' WHERE config_name = 'max_sentbox_privmsgs'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . $pm_savebox . "' WHERE config_name = 'max_savebox_privmsgs'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . addslashes($webmasteremail) . "' WHERE config_name = 'board_email'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . $activation . "' WHERE config_name = 'require_activation'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . intval($floodchecktime) . "' WHERE config_name = 'flood_interval'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . intval($secureemail) . "' WHERE config_name = 'board_email_form'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . intval($avatarmaxsize) . "' WHERE config_name = 'avatar_filesize'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . intval($avatarmaxdimension) . "' WHERE config_name = 'avatar_max_width'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . intval($avatarmaxdimension) . "' WHERE config_name = 'avatar_max_height'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . $dateformat . "' WHERE config_name = 'default_dateformat'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . $timeoffset . "' WHERE config_name = 'board_timezone'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . $priv_msg_disable . "' WHERE config_name = 'privmsg_disable'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . intval($gzipoutput) . "' WHERE config_name = 'gzip_compress'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . $faxnumber . "' WHERE config_name = 'coppa_fax'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . $address . "' WHERE config_name = 'coppa_mail'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . $max_users . "' WHERE config_name = 'record_online_users'";
$queries[] = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . $max_users_timestamp . "' WHERE config_name = 'record_online_date'";
@reset($queries);
while ( list($i, $sql) = each($queries) )
{
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to update config table ($i)", __LINE__, $sql);
}
}
unset($queries);
print " <span class="ok"><b>OK</b></span><br />\n";
// Update board_config (this is only usefull when using the step=all option)
$board_config['allow_html'] = $allowhtml;
$board_config['allow_bbcode'] = $allowbbcode;
$board_config['allow_smilies'] = $allowsmilies;
$board_config['allow_sig'] = $allowsignatures;
$board_config['allow_avatar_local'] = $avatarallowupload;
$board_config['allow_avatar_remote'] = $avatarallowwebsite;
$board_config['allow_avatar_upload'] = $avatarallowupload;
//
// Ranks
//
print "* Converting ranks :: ";
$sql = "DELETE FROM " . RANKS_TABLE;
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Delete ranks from table failed", __LINE__, $sql);
}
$sql = "SELECT * FROM usertitle";
$ranks_query = $DB_site->query($sql);
if ( !$result )
{
die_nice("Unable to query ranks", __LINE__, $sql);
}
while ( $rank = $DB_site->fetch_array($ranks_query) )
{
$title = addslashes($rank['title']);
$min = intval($rank['minposts']);
$sql = "INSERT INTO " . RANKS_TABLE . " (rank_title, rank_min) VALUES ('$title', '$min')";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to insert rank '$title'", __LINE__, $sql);
}
}
print " <span class="ok"><b>OK</b></span><br />\n";
//
// Censor Words
//
print "* Converting censored words :: ";
flush();
$sql = "DELETE FROM " . WORDS_TABLE;
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to delete existing entries from words table", __LINE__, $sql);
}
$words = explode(" ",$censorwords);
$sql = "INSERT IGNORE INTO " . WORDS_TABLE . " (word, replacement) VALUES ";
$count = 0;
$censor_char = ( $censorchar ) ? $censorchar : '*';
while ( list($i, $word) = each($words) )
{
$word = strtolower(trim($word));
if ( ereg("^\{.*\}$", $word) )
{
$word = substr($word, 1, -1);
$replacement = str_repeat($censor_char, strlen($word));
}
else
{
$replacement = str_repeat($censor_char, strlen($word));
$word = "*$word*";
}
if ( strlen($replacement) > 1 )
{
$sql .= "('" . str_replace("\'", "''", $word) . "', '" . $replacement . "'),";
$count++;
}
}
if ( $count )
{
// Remove tailing ','
$sql = substr($sql, 0, -1);
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to insert censored words", __LINE__, $sql);
}
}
print " <span class="ok"><b>OK</b></span><br />\n";
//
// Illegal Usernames
//
print "* Converting disallowed usernames :: ";
flush();
$sql = "DELETE FROM ". DISALLOW_TABLE;
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to empty disallowed usernames", __LINE__, $sql);
}
$usernames = explode(" ", $illegalusernames);
$sql = "INSERT IGNORE INTO " . DISALLOW_TABLE . " (disallow_username) VALUES ";
$count = 0;
while ( list($i, $username) = each($usernames) )
{
$username = strtolower(trim($username));
if ( strlen($username) > 1 )
{
$sql .= "('" . addslashes($username) . "'),";
$count++;
}
}
if ( $count )
{
$sql = substr($sql, 0, -1);
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to insert disallowed usernames", __LINE__, $sql);
}
}
print " <span class="ok"><b>OK</b></span><br />\n";
// Ban-list cleanup
$sql = "DELETE FROM " . BANLIST_TABLE;
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to empty banlist table", __LINE__, $sql);
}
//
// IP addresses
//
print "* Converting banned IPs :: ";
flush();
$ip_list_temp = explode(" ", $banip);
$sql = "INSERT IGNORE INTO " . BANLIST_TABLE . " (ban_ip) VALUES ";
for($i = 0; $i < count($ip_list_temp); $i++)
{
$dots = substr_count($ip_list_temp[$i], ".");
while ($dots < 3)
{
$ip_list_temp[$i] .= ".255";
$dots++;
}
$ip = encode_ip($ip_list_temp[$i]);
$sql .= "('$ip'),";
}
if ( count($ip_list_temp) )
{
$sql = substr($sql, 0, -1);
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to insert banned IPs", __LINE__, $sql);
}
}
print " <span class="ok"><b>OK</b></span><br />\n";
//
// Email addresses
//
print "* Converting banned email addresses :: ";
flush();
$ban_mail_temp = explode(" ", $banemail);
$sql = "INSERT IGNORE INTO " . BANLIST_TABLE . " (ban_email) VALUES ";
while ( list($i,$email) = each($ban_mail_temp) )
{
$email = strtolower(trim($email));
if ( substr($email, 0, 1) == "@" )
{
$email = '*' . $email;
}
$sql .= "('$email'),";
}
if ( count($ban_mail_temp) )
{
$sql = substr($sql, 0, -1);
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to insert banned email addresses", __LINE__, $sql);
}
}
print " <span class="ok"><b>OK</b></span><br />\n";
//
// Convert smilies and generate smilie packs
//
// Check if smilie dir is writable
if ( is_writable(PHPBB_PATH . $board_config['smilies_path'] . '/') )
{
print "* Generating smilie pack from vBulletin smilies :: ";
$delimeter = '=+:';
//
// Export our current smiley config as a smiley pak...
//
$sql = "SELECT * FROM " . SMILIES_TABLE;
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Couldn't query current smilies", __LINE__, $sql);
}
$resultset = $db->sql_fetchrowset($result);
$smile_pak = "";
for($i = 0; $i < count($resultset); $i++ )
{
$smile_pak .= $resultset[$i]['smile_url'] . $delimeter;
$smile_pak .= $resultset[$i]['emoticon'] . $delimeter;
$smile_pak .= $resultset[$i]['code'] . "\n";
}
$fp = fopen (PHPBB_PATH . $board_config['smilies_path'] . '/phpbb2_original_smilies.pak', 'wb');
$written = fwrite($fp, $smile_pak);
fclose($fp);
if ( $written != strlen($smile_pak) )
{
@unlink(PHPBB_PATH . $board_config['smilies_path'] . '/phpbb2_original_smilies.pak');
print "<br /> <b>Warning</b>: error writing smilie pack, skipping smilie conversion.<br />";
}
else
{
// Old smilie pack written
// Build smilie pack from vB smilies and save it, copy smilies to new location
// Store only non-existing smilies in the database
$vb_smile_pak = "";
$no_copy = false;
$sql = "SELECT * FROM smilie";
$smilie_query = $DB_site->query($sql);
if ( !$smilie_query )
{
die_nice("Unable to query smilie info", __LINE__, $sql);
}
while ( $smilie = $DB_site->fetch_array($smilie_query) )
{
$filename = basename($smilie['smiliepath']);
$new_file = "vb_" . $filename;
$copy_from = VBULLETIN_PATH . $smilie['smiliepath'];
$copy_to = PHPBB_PATH . $board_config['smilies_path'] . '/' . $new_file;
if ( !$no_copy )
{
if ( !@copy($copy_from, $copy_to) )
{
print "<br /> <b>Warning</b>: error copying smilies, copy them by hand.<br />";
$no_copy = true;
}
}
$vb_smile_pak .= $new_file . $delimeter;
$vb_smile_pak .= $smilie['title'] . $delimeter;
$vb_smile_pak .= $smilie['smilietext'] . "\n";
// Check if smilie exists
$sql = "SELECT smilies_id FROM " . SMILIES_TABLE . " WHERE code = '" . addslashes($smilie['smilietext']) . "'";
$exists = $db->sql_query($sql);
if ( !$exists )
{
die_nice("Unable to query existing smilie", __LINE__, $sql);
}
if ( !$db->sql_numrows($exists) )
{
// Smilie does not yet exist, insert
$smilie_code = addslashes($smilie['smilietext']);
$emoticon = addslashes($smilie['title']);
$sql = "INSERT INTO " . SMILIES_TABLE . " (code, smile_url, emoticon)
VALUES ('$smilie_code', '$new_file', '$emoticon')";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to insert smilie (" . $smilie['smilietext'] . ")", __LINE__, $sql);
}
}
}
$fp = fopen(PHPBB_PATH . $board_config['smilies_path'] . '/vb_converted_smilies.pak', 'wb');
$written = fwrite($fp, $vb_smile_pak);
fclose($fp);
if ( $written != strlen($vb_smile_pak) )
{
@unlink(PHPBB_PATH . $board_config['smilies_path'] . '/vb_converted_smilies.pak');
print "<br /> <b>Warning</b>: error writing vB smilie pack.<br />";
}
}
print " <span class="ok"><b>OK</b></span><br />\n";
}
else
{
// Some day I may put some code here to download the smilie pack
// for now, we just forget about the smilies
// User should make sure dir has correct permissions
print "* <span class="error">Skipping smilies, smilie dir not writable</span><br />";
}
//
// Convert Avatar Gallery
//
$failed = false;
if ( is_writable(PHPBB_PATH . $board_config['avatar_gallery_path'] . '/') )
{
print "* Generating Avatar Gallery from vBulletin Avatars :: ";
flush();
$sql = "SELECT avatarpath FROM avatar";
$avatar_query = $DB_site->query($sql);
if ( !$avatar_query )
{
die_nice("Unable to query avatar data", __LINE__, $sql);
}
while ( $avatar = $DB_site->fetch_array($avatar_query) )
{
// Strip beginning 'images/avatars/'.
// Ignore avatars outside images/avatars dir for the moment,
// people with normal installations shouldn't have any problems.
if ( substr($avatar['avatarpath'], 0, 15) == 'images/avatars/' )
{
$path = substr($avatar['avatarpath'], 15);
$dirname = dirname($path);
if ($dirname == ".")
{
$dirname = "default";
}
$filename = basename($path);
if ( !@file_exists(PHPBB_PATH . $board_config['avatar_gallery_path'] . '/' . $dirname . '/') )
{
// Create dir
if ( !@mkdir(PHPBB_PATH . $board_config['avatar_gallery_path'] . '/' . $dirname, 0777) )
{
// Dir creation failed... skip gallery conversion
$failed = true;
break;
}
}
@copy(VBULLETIN_PATH . $avatar['avatarpath'], PHPBB_PATH . $board_config['avatar_gallery_path'] . '/' . $dirname . '/' . $filename);
}
}
if ( $failed == true )
{
print "<span class="error">FAILED</span><br />\nYou should copy the avatars by hand. Note that the avatars in the vBulletin root dir should be copied to a dir called 'default'.";
}
else
{
print " <span class="ok"><b>OK</b></span><br />\n";
}
}
else
{
// Avatar Gallery not writable
print "* <span class="error">Skipping Gallery Avatars, avatar dir not writable</span><br />";
}
//
// Topic watch list
//
print "* Converting topic watch list :: ";
flush();
$sql = "DELETE FROM " . TOPICS_WATCH_TABLE;
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to delete existing entries from topic watchlist", __LINE__, $sql);
}
$sql = "SELECT * FROM subscribethread";
$subscribe_query = $DB_site->query($sql);
if ( !$subscribe_query )
{
die_nice("Unable to query watch list info", __LINE__, $sql);
}
while ( $subscribe = $DB_site->fetch_array($subscribe_query) )
{
$topic_id = intval($subscribe['topic_id']);
$user_id = intval($subscribe['user_id']);
$sql = "INSERT INTO " . TOPICS_WATCH_TABLE . " (topic_id, user_id)
VALUES ('$topic_id', '$user_id')";
}
print " <span class="ok"><b>OK</b></span><br />\n";
if ($step != 'all')
{
break;
}
//
// STEP FORUMS - CONVERT FORUMS
//
case 'forums':
print "* Deleting existing forums and categories :: ";
flush();
$sql = "DELETE FROM " . FORUMS_TABLE;
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to delete old forums", __LINE__, $sql);
}
$sql = "DELETE FROM " . CATEGORIES_TABLE;
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to delete old categories", __LINE__, $sql);
}
$sql = "DELETE FROM " . GROUPS_TABLE . " WHERE group_id <> 1";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to delete old groups", __LINE__, $sql);
}
$sql = "DELETE FROM " . AUTH_ACCESS_TABLE . " WHERE group_id <> 1";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to delete access rights", __LINE__, $sql);
}
print " <span class="ok"><b>OK</b></span><br />\n";
print "* Converting categories :: ";
flush();
$sql = "SELECT forumid, title, displayorder, parentid, parentlist
FROM forum
WHERE cancontainthreads = 0
ORDER BY parentid,displayorder";
$category_query = $DB_site->query($sql);
if ( !$category_query )
{
die_nice("Unable to query category information", __LINE__, $sql);
}
$categories = array();
$display_order = 0;
while ( $category = $DB_site->fetch_array($category_query) )
{
$categories[ $category['forumid'] ] = $category;
$display_order++;
$title = addslashes($category['title']);
$sql = "INSERT INTO " . CATEGORIES_TABLE . " (cat_title, cat_order)
VALUES ('$title', '$display_order')";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to insert category (" . $category['title'] . ")", __LINE__, $sql);
}
$categories[ $category['forumid'] ]['cat_id'] = $db->sql_nextid();
}
print " <span class="ok"><b>OK</b></span><br />\n";
print "* Converting forums and permissions :: ";
flush();
//
// Get standard usergroup permissions
//
$sql = "SELECT * FROM usergroup WHERE usergroupid IN (1,2) ORDER BY usergroupid";
$permission_query = $DB_site->query($sql);
if ( !$permission_query )
{
die_nice("Unable to query default usergroup permissions", __LINE__, $sql);
}
$auth_standard = array();
while ( $perm = $DB_site->fetch_array($permission_query) )
{
if ( $perm['usergroupid'] == 1 )
{
$auth_standard['view'] = ( $perm['canview'] ) ? AUTH_ALL : AUTH_REG;
$auth_standard['read'] = $auth_standard['view'];
$auth_standard['post'] = ( $perm['canpostnew'] ) ? AUTH_ALL : AUTH_REG;
$auth_standard['reply'] = ( $perm['canreplyothers'] ) ? AUTH_ALL : AUTH_REG;
$auth_standard['edit'] = ( $perm['caneditpost'] ) ? AUTH_ALL : AUTH_REG;
$auth_standard['delete'] = ( $perm['candeletepost'] ) ? AUTH_ALL : AUTH_REG;
$auth_standard['vote'] = ( $perm['canvote'] ) ? AUTH_ALL : AUTH_REG;
$auth_standard['pollcreate'] = ( $perm['canpostpoll'] ) ? AUTH_ALL : AUTH_REG;
$auth_standard['attachments'] = ( $perm['canpostattachment'] ) ? AUTH_ALL : AUTH_REG;
}
else
{
$auth_standard['view'] = ( $perm['canview'] ) ? $auth_standard['view'] : AUTH_MOD;
$auth_standard['read'] = $auth_standard['view'];
$auth_standard['post'] = ( $perm['canpostnew'] ) ? $auth_standard['post'] : AUTH_MOD;
$auth_standard['reply'] = ( $perm['canreplyothers'] ) ? $auth_standard['reply'] : AUTH_MOD;
$auth_standard['edit'] = ( $perm['caneditpost'] ) ? $auth_standard['edit'] : AUTH_MOD;
$auth_standard['delete'] = ( $perm['candeletepost'] ) ? $auth_standard['delete'] : AUTH_MOD;
$auth_standard['vote'] = ( $perm['canvote'] ) ? $auth_standard['vote'] : AUTH_MOD;
$auth_standard['pollcreate'] = ( $perm['canpostpoll'] ) ? $auth_standard['pollcreate'] : AUTH_MOD;
$auth_standard['attachments'] = ( $perm['canpostattachment'] ) ? $auth_standard['attachments'] : AUTH_MOD;
}
}
// Sticky and announce only for MODs
$auth_standard['sticky'] = AUTH_MOD;
$auth_standard['announce'] = AUTH_MOD;
$sql = "SELECT * FROM forum WHERE cancontainthreads<>0 ORDER BY parentid,displayorder";
$forums_query = $DB_site->query($sql);
if ( !$forums_query )
{
die_nice("Unable to query forum information", __LINE__, $sql);
}
while ( $forum = $DB_site->fetch_array($forums_query) )
{
$forum_status = ( $forum['allowposting'] ) ? FORUM_UNLOCKED : FORUM_LOCKED;
// This should always give the correct category
$cat_id = $categories[ $forum['parentid'] ]['cat_id'];
if (!$cat_id)
{
$parents = explode(',', $forum['parentlist']);
for ($i = 0; $i < count($parents); $i++)
{
if ( $categories[ $parents[$i] ]['cat_id'] )
{
$cat_id = $categories[ $parents[$i] ]['cat_id'];
break;
}
}
if ( !$cat_id )
{
// This should never happen...
$cat_id = 1;
}
}
//
// Get custom forum permissions
// Yeah.. it's pretty messy
//
$forum_id = intval($forum['forumid']);
$sql = "SELECT *
FROM forumpermission
WHERE forumid = '$forum_id'
AND usergroupid IN (1,2)
ORDER BY usergroupid";
$permission_query = $DB_site->query($sql);
if ( !$permission_query )
{
die_nice("Unable to query forum permissions for forum " . $forum['forumid'], __LINE__, $sql);
}
$auth = array();
while ( $perm = $DB_site->fetch_array($permission_query) )
{
if ( $perm['usergroupid'] == 1 )
{
$auth['view'] = ( $perm['canview'] ) ? AUTH_ALL : AUTH_REG;
$auth['read'] = $auth['view'];
$auth['post'] = ( $perm['canpostnew'] ) ? AUTH_ALL : AUTH_REG;
$auth['reply'] = ( $perm['canreplyothers'] ) ? AUTH_ALL : AUTH_REG;
$auth['edit'] = ( $perm['caneditpost'] ) ? AUTH_ALL : AUTH_REG;
$auth['delete'] = ( $perm['candeletepost'] ) ? AUTH_ALL : AUTH_REG;
$auth['vote'] = ( $perm['canvote'] ) ? AUTH_ALL : AUTH_REG;
$auth['pollcreate'] = ( $perm['canpostpoll'] ) ? AUTH_ALL : AUTH_REG;
$auth['attachments'] = ( $perm['canpostattachment'] ) ? AUTH_ALL : AUTH_REG;
}
else if ( isset($auth['view']) )
{
$auth['view'] = ( $perm['canview'] ) ? $auth['view'] : AUTH_MOD;
$auth['read'] = $auth['view'];
$auth['post'] = ( $perm['canpostnew'] ) ? $auth['post'] : AUTH_MOD;
$auth['reply'] = ( $perm['canreplyothers'] ) ? $auth['reply'] : AUTH_MOD;
$auth['edit'] = ( $perm['caneditpost'] ) ? $auth['edit'] : AUTH_MOD;
$auth['delete'] = ( $perm['candeletepost'] ) ? $auth['delete'] : AUTH_MOD;
$auth['vote'] = ( $perm['canvote'] ) ? $auth['vote'] : AUTH_MOD;
$auth['pollcreate'] = ( $perm['canpostpoll'] ) ? $auth['pollcreate'] : AUTH_MOD;
$auth['attachments'] = ( $perm['canpostattachment'] ) ? $auth['attachments'] : AUTH_MOD;
}
else
{
$auth['view'] = ( $perm['canview'] ) ? $auth_standard['view'] : AUTH_MOD;
$auth['read'] = $auth['view'];
$auth['post'] = ( $perm['canpostnew'] ) ? $auth_standard['post'] : AUTH_MOD;
$auth['reply'] = ( $perm['canreplyothers'] ) ? $auth_standard['reply'] : AUTH_MOD;
$auth['edit'] = ( $perm['caneditpost'] ) ? $auth_standard['edit'] : AUTH_MOD;
$auth['delete'] = ( $perm['candeletepost'] ) ? $auth_standard['delete'] : AUTH_MOD;
$auth['vote'] = ( $perm['canvote'] ) ? $auth_standard['vote'] : AUTH_MOD;
$auth['pollcreate'] = ( $perm['canpostpoll'] ) ? $auth_standard['pollcreate'] : AUTH_MOD;
$auth['attachments'] = ( $perm['canpostattachment'] ) ? $auth_standard['attachments'] : AUTH_MOD;
}
}
if ( !isset($auth['view']) )
{
// Use standard permissions
$auth['view'] = $auth_standard['view'];
$auth['read'] = $auth_standard['read'];
$auth['post'] = $auth_standard['post'];
$auth['reply'] = $auth_standard['reply'];
$auth['edit'] = $auth_standard['edit'];
$auth['delete']= $auth_standard['delete'];
$auth['vote'] = $auth_standard['vote'];
$auth['pollcreate'] = $auth_standard['pollcreate'];
$auth['attachments'] = $auth_standard['attachments'];
}
// Sticky and announce only for MODs
$auth['sticky'] = AUTH_MOD;
$auth['announce'] = AUTH_MOD;
// Will let forum sync at the end handle this
$last_post_id = 0;
$forum_title = addslashes($forum['title']);
$forum_description = addslashes($forum['description']);
$forum_order = intval($forum['displayorder']);
$forum_posts = intval($forum['replycount']);
$forum_topics = intval($forum['threadcount']);
$sql = "INSERT INTO " . FORUMS_TABLE . " (forum_id, cat_id, forum_name, forum_desc, forum_status, forum_order, forum_posts, forum_topics, forum_last_post_id, prune_next, prune_enable, auth_view, auth_read, auth_post, auth_reply, auth_edit, auth_delete, auth_sticky, auth_announce, auth_vote, auth_pollcreate, auth_attachments)
VALUES ('$forum_id', '$cat_id', '$forum_title', '$forum_description', '$forum_status', '$forum_order', '$forum_posts', '$forum_topics', '$last_post_id', '0', '0', '" . $auth['view'] . "', '" . $auth['read'] . "', '" . $auth['post'] . "', '" . $auth['reply'] . "', '" . $auth['edit'] . "', '" . $auth['delete'] . "', '" . $auth['sticky'] . "', '" . $auth['announce'] . "', '" . $auth['vote'] . "', '" . $auth['pollcreate'] . "', '" . $auth['attachments'] . "')";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to insert forum (". $forum['title'] . ")", __LINE__, $sql);
}
}
print " <span class="ok"><b>OK</b></span><br />\n";
if ( $step != 'all' )
{
break;
}
//
// STEP USERS - CONVERT USERS
//
case 'users':
if ( !$start_id )
{
print "* Deleting existing users :: ";
flush();
$sql = "DELETE FROM " . USERS_TABLE . " WHERE user_id <> -1";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Delete users from users table failed", __LINE__, $sql);
}
$sql = "DELETE FROM " . USER_GROUP_TABLE . " WHERE user_id <> -1";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Delete users from usergroup table failed", __LINE__, $sql);
}
print " <span class="ok"><b>OK</b></span><br />\n";
}
$sql = "SELECT MAX(userid) AS max_id FROM user";
$max_query = $DB_site->query($sql);
if ( !$max_query )
{
die_nice("Unable to get maximum userid", __LINE__, $sql);
}
$row = $DB_site->fetch_array($max_query);
$max_id = $row['max_id'];
$sql = "SELECT MAX(group_id) AS total
FROM " . GROUPS_TABLE;
if ( !($result = $db->sql_query($sql)) )
{
die_nice('Could not obtain next group_id information', __LINE__, $sql);
}
if ( !($row = $db->sql_fetchrow($result)) )
{
die_nice('Could not obtain next group_id information', __LINE__, $sql);
}
$group_id = $row['total'] + 1;
// Default settings for users
$style = $board_config['default_style'];
$lang = $board_config['default_lang'];
$date_format = $board_config['default_dateformat'];
$allow_html = $board_config['allow_html'];
$allow_bbcode = $board_config['allow_bbcode'];
$allow_smile = $board_config['allow_smilies'];
$allow_sig = $board_config['allow_sig'];
// Global config will overwrite this setting, so it is safe to set it to 1
// Changed this in version 1.31 because of avatar-problems people seemed to have
$allow_avatar = 1;
$allow_pm = ( $board_config['privmsg_disable'] ) ? 0 : 1;
//
// Check for custom userfields Location, Interests and Occupation
//
$sql = "SELECT profilefieldid, title FROM profilefield WHERE title IN ('location', 'interests', 'occupation')";
$pf_query = $DB_site->query($sql);
if ( !$pf_query )
{
die_nice("Unable to fetch custom profile fields", __LINE__, $sql);
}
$profilefield_sql = "%s AS location, %s AS interests, %s AS occupation ";
$location = "''";
$interests = "''";
$occupation = "''";
while ( $row = $DB_site->fetch_array($pf_query) )
{
switch ( $row['title'] )
{
case 'location':
$location = 'uf.field' . $row['profilefieldid'];
break;
case 'interests':
$interests = 'uf.field' . $row['profilefieldid'];
break;
case 'occupation':
$occupation = 'uf.field' . $row['profilefieldid'];
break;
}
}
// Build custom profilefield sql
$profilefield_sql = sprintf($profilefield_sql, $location, $interests, $occupation);
$banned_users = array();
$batchsize = intval(BATCH_SIZE); // Process this many posts per loop
$batchcount = 0;
if ( SAFE_MODE )
{
$resume_batches = intval(SAFE_MODE_BATCHES);
}
else
{
$resume_batches = 0;
}
//
// Loop through the users in batches
//
for($counter = $start_id; $counter <= $max_id; $counter += $batchsize)
{
$batchstart = $counter + 1;
$batchend = $counter + $batchsize;
$batchcount++;
print " * Converting Users ( $batchstart to $batchend ) :: ";
flush();
$sql = "SELECT u.*, $profilefield_sql
FROM user u LEFT JOIN userfield uf ON u.userid=uf.userid
WHERE u.userid
BETWEEN $batchstart
AND $batchend
ORDER BY u.userid ASC";
$users_query = $DB_site->query($sql);
if ( !$users_query )
{
die_nice("Unable to query batch ( $batchstart - $batchend )", __LINE__, $sql);
}
$per_pct = ceil( $DB_site->num_rows($users_query) / 40 );
$inc = 0;
while ( $user = $DB_site->fetch_array($users_query) )
{
// Rank
$user_rank = $user['usertitle'];
// Convert user level
switch ( $user['usergroupid'] )
{
case VB_UG_UNREGISTERED:
$user_level = ANONYMOUS;
$active = 0;
// This treats all users in this category as banned
// Not the best solution, but vB doesn't allow us a better one
$banned_users[] = $user['userid'];
break;
case VB_UG_REGISTERED:
$user_level = USER;
$active = 1;
break;
case VB_UG_AWAITING_EMAIL_CONF:
$user_level = USER;
$active = 0;
break;
case VB_UG_AWAITING_COPPA_CONF:
$user_level = USER;
$active = 0;
break;
case VB_UG_SUPER_MODS:
$user_level = MOD;
$active = 1;
$groups['super_mods'][] = $user['userid'];
break;
case VB_UG_ADMIN:
$user_level = ADMIN;
$active = 1;
$groups['admins'][] = $user['userid'];
break;
case VB_UG_MODERATORS:
$user_level = MOD;
$active = 1;
break;
default:
// Unknown custom usergroup
$user_level = USER;
$active = 1;
$groups[ $user['usergroupid'] ][] = $user['userid'];
break;
}
//
// Do custom rank
//
$sql = "SELECT rank_id, rank_special
FROM " . RANKS_TABLE . "
WHERE rank_title = '" . addslashes($user_rank) . "'";
$rank_query = $db->sql_query($sql);
if ( !$rank_query )
{
die_nice("Unable to query rankid for rank $user_rank", __LINE__, $sql);
}
$rank_data = $db->sql_fetchrow($rank_query);
if ( !$rank_data )
{
// Non-existing rank
$sql = "INSERT INTO " . RANKS_TABLE . " (rank_title, rank_special)
VALUES ('" . addslashes($user_rank) . "', 1)";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to insert new rank ($user_rank)", __LINE__, $sql);
}
$rank_id = $db->sql_nextid();
}
else if ( $rank_data['rank_special'] == 0 )
{
$rank_id = 'NULL';
}
else
{
$rank_id = $rank_data['rank_id'];
}
//
// Do avatar (check if gallery avatar or normal avatar)
//
$avatar_id = intval($user['avatarid']);
if ( $avatar_id == 0 )
{
//
// Normal avatar
//
$user_id = intval($user['userid']);
$sql = "SELECT avatardata FROM customavatar WHERE userid = '$user_id'";
$avatar_query = $DB_site->query($sql);
if ( !$avatar_query )
{
die_nice("Unable to query avatar data for user $user_id", __LINE__, $sql);
}
$row = $DB_site->fetch_array($avatar_query);
$avatar_data = $row['avatardata'];
if ( strlen($avatar_data) > 0 )
{
// Portion of code taken from profile.php
// Build avatar image from vB database string
$avatar_filename = $user_id . ".gif";
if( file_exists( PHPBB_PATH . $board_config['avatar_path'] . "/$avatar_filename" ) )
{
@unlink(PHPBB_PATH . $board_config['avatar_path'] . "/$avatar_filename");
}
$fptr = @fopen(PHPBB_PATH . $board_config['avatar_path'] . "/$avatar_filename", "wb");
$bytes_written = @fwrite($fptr, $avatar_data, strlen($avatar_data));
@fclose($fptr);
$avatar = $avatar_filename;
$avatar_type = USER_AVATAR_UPLOAD;
}
else
{
//
// No avatar
//
$avatar = '';
$avatar_type = USER_AVATAR_NONE;
}
}
else
{
//
// Gallery avatar
//
$sql = "SELECT avatarpath FROM avatar WHERE avatarid = $avatar_id";
$avatar_query = $DB_site->query($sql);
if ( !$avatar_query )
{
die_nice("Unable to query gallery avatar data (" . $user['avatarid'] . ")", __LINE__, $sql);
}
$row = $DB_site->fetch_array($avatar_query);
// Only support avatars in the appropriate avatars dir
// This should be ok for standard installs
// People with different setups should change this
if ( substr($row['avatar_path'], 0, 15) == 'images/avatars/' )
{
$path = substr($row['avatar_path'], 15);
$dirname = dirname($path);
if ($dirname == ".")
{
// Name of gallery category for vB root avatars
$dirname = "default";
}
$filename = basename($path);
$avatar = $dirname . "/" . $filename;
$avatar_type = USER_AVATAR_GALLERY;
}
else
{
$avatar = '';
$avatar_type = USER_AVATAR_NONE;
}
}
//
// Do signature
//
$sig_uid = ( $allow_bbcode ) ? make_bbcode_uid() : "";
$signature = addslashes(convert_vb_code($user['signature']));
$signature = prepare_message($signature, $allow_html, $allow_bbcode, $allow_smilies, $sig_uid);
//
// Do some checks on the data
//
$user['yahoo'] = ( strlen($user['yahoo']) < 3 ) ? '' : $user['yahoo'];
$user['aim'] = ( strlen($user['aim']) < 3 ) ? '' : $user['aim'];
$website = trim($user['homepage']);
if ( substr(strtolower($website), 0, 7) != "http://" )
{
$website = "http://" . $website;
}
if ( strtolower($website) == 'http://' )
{
$website = '';
}
$website = addslashes($website);
$icq = ( ereg("^[0-9]+$", $user['icq']) ) ? $user['icq'] : '';
$show_online = ( $user['invisible'] ) ? 0 : 1;
// Check if passwords needs to be encrypted.
// vBulletin < 2.2.0 doesn't encrypt passwords.
if ( VBULLETIN_VERSION < '2.2.0' )
{
$user['password'] = md5($user['password']);
}
$password = addslashes($user['password']);
$user_id = intval($user['userid']);
$username = addslashes($user['username']);
$last_visit = intval($user['lastvisit']);
$join_date = intval($user['joindate']);
$posts = intval($user['posts']);
$timezone_offset = addslashes($user['timezoneoffset']);
$date_format = addslashes($date_format);
$view_email = intval($user['showemail']);
$notify = intval($user['emailnotification']);
$notify_pm = intval($user['emailonpm']);
$pm_popup = intval($user['pmpopup']);
$avatar = addslashes($avatar);
$email = addslashes($user['email']);
$location = addslashes($user['location']);
$aim = addslashes($user['aim']);
$yim = addslashes($user['yahoo']);
$occupation = addslashes($user['occupation']);
$interests = addslashes($user['interests']);
// Change this if a MSN-messenger hack is installed on your vB
$msnm = '';
//
// User insert
//
$sql = "INSERT INTO " . USERS_TABLE . " (user_id, user_active, username, user_password, user_lastvisit, user_regdate, user_level, user_posts, user_timezone, user_style, user_lang, user_dateformat, user_viewemail, user_attachsig, user_allowhtml, user_allowbbcode, user_allowsmile, user_allowavatar, user_allow_pm, user_allow_viewonline, user_notify, user_notify_pm, user_popup_pm, user_rank, user_avatar, user_avatar_type, user_email, user_icq, user_website, user_from, user_sig, user_sig_bbcode_uid, user_aim, user_yim, user_msnm, user_occ, user_interests)
VALUES ('$user_id', '$active', '$username', '$password', '$last_visit', '$join_date', '$user_level', '$posts', '$timezone_offset', '$style', '$lang', '$date_format', '$view_email', '$allow_sig', '$allow_html', '$allow_bbcode', '$allow_smile', '$allow_avatar', '$allow_pm', '$show_online', '$notify', '$notify_pm', '$pm_popup', '$rank_id', '$avatar', '$avatar_type', '$email', '$icq', '$website', '$location', '$signature', '$sig_uid', '$aim', '$yim', '$msnm', '$occupation', '$interests')";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to insert user $user_id", __LINE__, $sql);
}
//
// Group creation
//
$sql = "INSERT INTO " . GROUPS_TABLE . " (group_id, group_name, group_description, group_single_user)
VALUES ('$group_id', '$username', 'Personal User', '1')";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to create group for user $user_id", __LINE__, $sql);
}
//
// User -> Group creation
//
$sql = "INSERT INTO " . USER_GROUP_TABLE . " (group_id, user_id, user_pending)
VALUES ('$group_id', '$user_id', '0')";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to create user-group link for user $user_id", __LINE__, $sql);
}
$group_id++;
$inc++;
if ( $inc == $per_pct )
{
print ".";
flush();
$inc = 0;
}
}
$DB_site->free_result($users_query);
print " <span class="ok"><b>OK</b></span><br />\n";
// Output resume HTML if batchcount equals resume_batches
if ( $batchcount == $resume_batches )
{
$resume_id = $batchend;
break;
}
}
if ( $step != 'all' )
{
break;
}
//
// STEP MODS - CONVERT MODERATORS, ADMINS AND USERGROUPS
//
case 'mods':
$banned_users = array();
$groups = array();
$groups['admins'] = array();
$groups['super_mods'] = array();
// Fetch info to populate usergroups
$sql = "SELECT userid, usergroupid FROM user
WHERE usergroupid NOT IN ('" . VB_UG_REGISTERED . "', '" . VB_UG_AWAITING_EMAIL_CONF . "', '" . VB_UG_AWAITING_COPPA_CONF . "', '" . VB_UG_MODERATORS . "')";
$user_query = $DB_site->query($sql);
if ( !$user_query )
{
die_nice("Unable to query usergroup information", __LINE__, $sql);
}
while ( $user = $DB_site->fetch_array($user_query) )
{
$usergroup_id = intval($user['usergroupid']);
$user_id = intval($user['userid']);
switch ( $usergroup_id )
{
case 0:
// Invalid entry
break;
case VB_UG_UNREGISTERED:
// This treats all users in this category as banned
// Not the best solution, but vB doesn't allow us a better one
$banned_users[] = $user_id;
break;
case VB_UG_SUPER_MODS:
$groups['super_mods'][] = $user_id;
break;
case VB_UG_ADMIN:
$groups['admins'][] = $user_id;
break;
default:
// Unknown custom usergroup
$groups[$usergroup_id][] = $user_id;
break;
}
}
$DB_site->free_result($user_query);
$sql = "SELECT MAX(group_id) AS total
FROM " . GROUPS_TABLE;
if ( !($result = $db->sql_query($sql)) )
{
die_nice('Could not obtain next group_id information', __LINE__, $sql);
}
if ( !($row = $db->sql_fetchrow($result)) )
{
die_nice('Could not obtain next group_id information', __LINE__, $sql);
}
$group_id = $row['total'] + 1;
//
// Handle super-mods and admins, create groups for them
//
if( count($groups['super_mods']) && count($groups['admins']) )
{
print " * Creating new group for admins and super moderators :: ";
flush();
$primary_admin = intval($groups['admins'][0]);
$group_type = GRO
Zuletzt geändert von Miroerr am 22.11.2005 22:20, insgesamt 2-mal geändert.
Zweiter Teil ...
$sql = "INSERT INTO " . GROUPS_TABLE . " (group_id, group_type, group_name, group_description, group_moderator, group_single_user)
VALUES ('$group_id', '$group_type', 'Super Moderators', 'This group contains the converted Super Moderators', '$primary_admin', '0')";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Couldn't create group for Super Moderators", __LINE__, $sql);
}
$mods_group_id = $group_id;
$group_id++;
$sql = "INSERT INTO " . GROUPS_TABLE . " (group_id, group_type, group_name, group_description, group_moderator, group_single_user)
VALUES ('$group_id', '$group_type', 'Administrators', 'This group contains the converted Administrators', '$primary_admin', '0')";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Couldn't create group for Administrators", __LINE__, $sql);
}
$admins_group_id = $group_id;
$group_id++;
print " <span class=\"ok\"><b>OK</b></span><br />\n";
print " * Updating auth_access for super moderator group :: ";
flush();
$sql = "SELECT forum_id FROM " . FORUMS_TABLE;
$forum_result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Couldn't obtain forum_id list", __LINE__, $sql);
}
while( $row = $db->sql_fetchrow($forum_result) )
{
$forum_id = intval($row['forum_id']);
$sql = "INSERT INTO " . AUTH_ACCESS_TABLE . " (group_id, forum_id, auth_mod)
VALUES ('$mods_group_id', '$forum_id', '1')";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to set group auth access for super mods.", __LINE__, $sql);
}
}
print " <span class=\"ok\"><b>OK</b></span><br />\n";
print " * Populating admin and super moderator groups :: ";
flush();
for($i = 0; $i < count($groups['super_mods']); $i++)
{
$user_id = intval($groups['super_mods'][$i]);
$sql = "INSERT INTO " . USER_GROUP_TABLE . " (group_id, user_id, user_pending)
VALUES ('$mods_group_id', '$user_id', '0')";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to add user_id $user_id to group_id $mods_group_id (super mods)", __LINE__, $sql);
}
}
for($i = 0; $i < count($groups['admins']); $i++)
{
$user_id = intval($groups['admins'][$i]);
$sql = "INSERT INTO " . USER_GROUP_TABLE . " (group_id, user_id, user_pending)
VALUES ('$admins_group_id', '', '0')";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to add user_id $user_id to group_id $admins_group_id (admins)", __LINE__, $sql);
}
}
print " <span class=\"ok\"><b>OK</b></span><br />\n";
flush();
}
//
// Create groups from custom vB usergroups
//
print " * Converting custom vB usergroups and permissions :: ";
flush();
$new_group_id = $group_id;
while ( list($group_id, $group_members) = each($groups) )
{
if ( $group_id == "admins" || $group_id == "super_mods" || intval($group_id) == 0 )
{
// These are already done or invalid, skip them
continue;
}
$group_id = intval($group_id);
// Get data
$sql = "SELECT * FROM usergroup WHERE usergroupid = '$group_id'";
$group_query = $DB_site->query($sql);
if ( !$group_query )
{
die_nice("Unable to get usergroup data for $group_id", __LINE__, $sql);
}
$group_data = $DB_site->fetch_array($group_query);
if ( $group_data['ismoderator'] )
{
$group_data['sticky'] = 1;
$group_data['announce'] = 1;
}
else
{
$group_data['sticky'] = 0;
$group_data['announce'] = 0;
}
// Create group
$group_type = ( $group_data['showgroup'] ) ? GROUP_CLOSED : GROUP_HIDDEN;
$title = addslashes($group_data['title']);
$group_moderator = intval($group_members[0]);
$sql = "INSERT INTO " . GROUPS_TABLE . " (group_id, group_type, group_name, group_description, group_moderator, group_single_user)
VALUES ('$new_group_id', '$group_type', '$title', 'Converted Group $title', '$group_moderator', '0')";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Couldn't create group " . $group_data['title'], __LINE__, $sql);
}
// Populate group
for($i = 0; $i < count($group_members); $i++)
{
$user_id = intval($group_members[$i]);
$sql = "INSERT INTO " . USER_GROUP_TABLE . " (group_id, user_id, user_pending)
VALUES ('$new_group_id', '$user_id', '0')";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to add user_id $user_id to group_id $new_group_id", __LINE__, $sql);
}
}
// Do permissions
$sql = "SELECT forum_id FROM " . FORUMS_TABLE;
$forums = $db->sql_query($sql);
if ( !$forums )
{
die_nice("Unable to fetch forumids for usergroup permissions", __LINE__, $sql);
}
while ( $row = $db->sql_fetchrow($forums) )
{
// Check if forum has custom permissions
$forum_id = intval($row['forum_id']);
$sql = "SELECT * FROM forumpermission WHERE usergroupid = '$group_id' AND forumid = '$forum_id'";
$permissions_query = $DB_site->query($sql);
if ( !$result )
{
die_nice("Unable to fetch forumpermissions for custom usergroup", __LINE__, $sql);
}
$permissions = $DB_site->fetch_array($permissions_query);
if ( !$permissions )
{
// No custom permissions, use usergroup standard permissions
$permissions = $group_data;
}
$sql = "INSERT INTO " . AUTH_ACCESS_TABLE . " (group_id, forum_id, auth_view, auth_read, auth_post, auth_reply, auth_edit, auth_delete, auth_sticky, auth_announce, auth_vote, auth_pollcreate, auth_attachments, auth_mod)
VALUES ('$new_group_id', '$forum_id', '" . $permissions['canview'] . "', '" . $permissions['canview'] . "', '" . $permissions['canpostnew'] . "', '" . $permissions['canreplyothers'] . "', '" . $permissions['caneditpost'] . "', '" . $permissions['candeletepost'] . "', '" . $group_data['sticky'] . "', '" . $group_data['announce'] . "', '" . $permissions['canvote'] . "', '" . $permissions['canpostpoll'] . "', '" . $permissions['canpostattachment'] . "', '" . $group_data['ismoderator'] . "')";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to insert forumpermissions for usergroup", __LINE__, $sql);
}
}
$new_group_id++;
}
print " <span class=\"ok\"><b>OK</b></span><br />\n";
//
// Moderators convert
//
print " * Converting moderators :: ";
flush();
$user_mods = array();
$sql = "SELECT userid, forumid FROM moderator";
$moderators_query = $DB_site->query($sql);
if ( !$moderators_query )
{
die_nice("Unable to get moderators", __LINE__, $sql);
}
while ( $moderators = $DB_site->fetch_array($moderators_query) )
{
$user_id = intval($moderators['userid']);
$forum_id = intval($moderators['forumid']);
$sql = "SELECT g.group_id
FROM " . USER_GROUP_TABLE . " ug LEFT JOIN " . GROUPS_TABLE . " g ON ug.group_id = g.group_id
WHERE ug.user_id = '$user_id' AND g.group_single_user = '1'";
$group_query = $db->sql_query($sql);
if ( !$group_query )
{
die_nice("Unable to get group_id for user", __LINE__, $sql);
}
$row = $db->sql_fetchrow($group_query);
$group_id = intval($row['group_id']);
if ( $group_id == 0 )
{
print "<span class=\"error\">Warning</span>: skipping corrupted moderator ($user_id)<br />";
flush();
}
else
{
$user_mods[] = $user_id;
$sql = "INSERT INTO " . AUTH_ACCESS_TABLE . " (group_id, forum_id, auth_mod)
VALUES ('$group_id', '$forum_id', '1')";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to insert moderator ($user_id)", __LINE__, $sql);
}
}
}
//
// Update user_level for users that are moderator
//
if ( count($user_mods) )
{
$sql = "UPDATE " . USERS_TABLE . "
SET user_level = " . MOD . "
WHERE user_id IN (" . implode(", ", $user_mods) . ") AND user_level <> " . ADMIN;
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Couldn't update user levels to moderator", __LINE__, $sql);
}
}
print " <span class=\"ok\"><b>OK</b></span><br />\n";
//
// Banned users convert
//
print " * Converting banned users :: ";
flush();
$sql = "INSERT IGNORE INTO " . BANLIST_TABLE . " (ban_userid) VALUES ";
$count = 0;
while ( list($i, $user_id) = each($banned_users) )
{
$user_id = intval($user_id);
if ( $user_id )
{
$sql .= "('$user_id'),";
$count++;
}
}
if ( $count != 0 )
{
$sql = substr($sql, 0, -1);
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to insert banned users", __LINE__, $sql);
}
}
print " <span class=\"ok\"><b>OK</b></span><br />\n";
flush();
if ( $step != 'all' )
{
break;
}
//
// STEP TOPICS - CONVERT TOPICS
//
case 'topics':
print "* Deleting existing topics :: ";
flush();
if ( !$start_id )
{
$sql = "DELETE FROM " . TOPICS_TABLE;
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to delete existing topics", __LINE__, $sql);
}
print " <span class=\"ok\"><b>OK</b></span><br />\n";
}
$sql = "SELECT MAX(threadid) AS max_id FROM thread";
$max_query = $DB_site->query($sql);
if ( !$max_query )
{
die_nice("Unable to get maximum threadid", __LINE__, $sql);
}
$row = $DB_site->fetch_array($max_query);
$max_id = $row['max_id'];
$batchsize = intval(BATCH_SIZE); // Process this many posts per loop
$batchcount = 0;
if ( SAFE_MODE )
{
$resume_batches = intval(SAFE_MODE_BATCHES);
}
else
{
$resume_batches = 0;
}
for($counter = $start_id; $counter <= $max_id; $counter += $batchsize)
{
$batchstart = $counter + 1;
$batchend = $counter + $batchsize;
$batchcount++;
print "* Converting topics ( $batchstart to $batchend ) :: ";
flush();
$sql = "SELECT * FROM thread
WHERE ( threadid
BETWEEN $batchstart
AND $batchend )
AND visible = 1
ORDER BY threadid ASC";
$thread_query = $DB_site->query($sql);
if ( !$result )
{
die_nice("Unable to get topics batch ( $batchstart to $batchend )", __LINE__, $sql);
}
$per_pct = ceil( $DB_site->num_rows($thread_query) / 40 );
$inc = 0;
while ( $thread = $DB_site->fetch_array($thread_query) )
{
$topic_id = intval($thread['threadid']);
$forum_id = intval($thread['forumid']);
$title = addslashes($thread['title']);
$replies = intval($thread['replycount']);
$time = intval($thread['dateline']);
$views = intval($thread['views']);
$type = ( $thread['sticky'] ) ? POST_STICKY : POST_NORMAL;
// Handle the ugly vB hack for moved topics
switch ( $thread['open'] )
{
case VB_THREAD_CLOSED:
$status = TOPIC_LOCKED;
$vote = ( $thread['pollid'] ) ? 1 : 0;
$moved = 0;
break;
case VB_THREAD_MOVED:
$status = TOPIC_MOVED;
$moved = intval($thread['pollid']);
break;
case VB_THREAD_OPEN:
default:
$status = TOPIC_UNLOCKED;
$vote = ( $thread['pollid'] ) ? 1 : 0;
$moved = 0;
break;
}
$poster = ( intval($thread['postuserid']) ) ? intval($thread['postuserid']) : ANONYMOUS;
// Get correct topic_id even if topic is moved
// post_topic_id is only used to fetch the first and last post_id
$post_topic_id = ( $status == TOPIC_MOVED ) ? $moved : $topic_id;
$sql = "SELECT MIN(postid) AS firstpostid, MAX(postid) AS lastpostid
FROM post
WHERE threadid = $post_topic_id
GROUP BY threadid";
$post_query = $DB_site->query($sql);
if ( !$result )
{
die_nice("Unable to get first and last postid for topic: $post_topic_id", __LINE__, $sql);
}
$row = $DB_site->fetch_array($post_query);
$first_post_id = intval($row['firstpostid']);
$last_post_id = intval($row['lastpostid']);
$sql = "INSERT INTO " . TOPICS_TABLE . " (topic_id, forum_id, topic_title, topic_poster, topic_time, topic_views, topic_replies, topic_status, topic_vote, topic_type, topic_first_post_id, topic_last_post_id, topic_moved_id)
VALUES ('$topic_id', '$forum_id', '$title', '$poster', '$time', '$views', '$replies', '$status', '$vote', '$type', '$first_post_id', '$last_post_id', '$moved')";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to insert topic ($topic_id)", __LINE__, $sql);
}
$inc++;
if ( $inc == $per_pct )
{
print ".";
flush();
$inc = 0;
}
}
print " <span class=\"ok\"><b>OK</b></span><br />\n";
$DB_site->free_result($thread_query);
// Output resume HTML if batchcount equals resume_batches
if ( $batchcount == $resume_batches )
{
$resume_id = $batchend;
break;
}
}
if ( $step != 'all' )
{
break;
}
//
// STEP POSTS - CONVERT POSTS
//
case 'posts':
if ( !$start_id )
{
print "* Deleting existing posts :: ";
flush();
$sql = "DELETE FROM " . POSTS_TABLE;
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to delete existing posts", __LINE__, $sql);
}
$sql = "DELETE FROM " . POSTS_TEXT_TABLE;
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to delete existing posts", __LINE__, $sql);
}
print " <span class=\"ok\"><b>OK</b></span><br />\n";
}
// Fetch max post_id
$sql = "SELECT MAX(postid) AS max_id FROM post";
$max_query = $DB_site->query($sql);
if ( !$max_query )
{
die_nice("Unable to get maximum postid", __LINE__, $sql);
}
$row = $DB_site->fetch_array($max_query);
$max_id = $row['max_id'];
$allow_html = $board_config['allow_html'];
$allow_bbcode = $board_config['allow_bbcode'];
// Get the quote template and modify it for later use
$sql = "SELECT template AS quotereply
FROM template
WHERE title='quotereply'
AND ( templatesetid = -1 OR templatesetid = '$templatesetid' )
ORDER BY templatesetid DESC LIMIT 1";
$template_query = $DB_site->query($sql);
if ( !$template_query )
{
die_nice("Unable to fetch quotereply template", __LINE__, $sql);
}
$row = $DB_site->fetch_array($template_query);
$quote_template = $row['quotereply'];
$quote_template = str_replace("\n","\r\n", $quote_template);
$quote_template = preg_quote($quote_template);
$quote_template = str_replace("\\\$originalposter","(.*)", $quote_template);
$quote_template = explode("\\\$pagetext", $quote_template);
for ($i = 0; $i < count($quote_template); $i++)
{
$quote_template[$i] = "|" . trim($quote_template[$i]) . "|isU";
}
$batchsize = intval(BATCH_SIZE); // Process this many posts per loop
$batchcount = 0;
if ( SAFE_MODE )
{
$resume_batches = intval(SAFE_MODE_BATCHES);
}
else
{
$resume_batches = 0;
}
for($counter = $start_id; $counter <= $max_id; $counter += $batchsize)
{
$batchstart = $counter + 1;
$batchend = $counter + $batchsize;
$batchcount++;
print "* Converting posts ($batchstart to $batchend) :: ";
flush();
$sql = "SELECT p.*, t.forumid
FROM post p LEFT JOIN thread t ON p.threadid = t.threadid
WHERE p.postid
BETWEEN $batchstart
AND $batchend
ORDER BY p.postid ASC";
$posts_query = $DB_site->query($sql);
if ( !$posts_query )
{
die_nice("Unable to select batch of posts", __LINE__, $sql);
}
$per_pct = ceil( $DB_site->num_rows($posts_query) / 40 );
$inc = 0;
while ( $post = $DB_site->fetch_array($posts_query) )
{
$post_id = intval($post['postid']);
$topic_id = intval($post['threadid']);
$forum_id = intval($post['forumid']);
$poster_id = ( intval($post['userid']) ) ? intval($post['userid']) : ANONYMOUS;
$post_time = intval($post['dateline']);
$ip = encode_ip($post['ipaddress']);
$username = ( $poster_id == ANONYMOUS ) ? addslashes($post['username']) : '';
$enable_smilies = intval($post['allowsmilie']);
$enable_sig = intval($post['showsignature']);
$post_edit_time = intval($post['editdate']);
$post_edit_count = ( $post['editdate'] ) ? 1 : 0;
//
// Do general postinfo
//
$sql = "INSERT INTO " . POSTS_TABLE . " (post_id, topic_id, forum_id, poster_id, post_time, poster_ip, post_username, enable_bbcode, enable_html, enable_smilies, enable_sig, post_edit_time, post_edit_count)
VALUES ('$post_id', '$topic_id', '$forum_id', '$poster_id', '$post_time', '$ip', '$username', '$allow_bbcode', '$allow_html', '$enable_smilies', '$enable_sig', '$post_edit_time', '$post_edit_count')";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to insert general postinfo for postid $post_id", __LINE__, $sql);
}
//
// Do posttext
//
$bbcode_uid = make_bbcode_uid();
$post_subject = addslashes($post['title']);
// Convert vB bbcode to phpBB bbcode
$post_text = addslashes(convert_vb_code($post['pagetext'], $quote_template));
$post_text = prepare_message($post_text, $allow_html, $allow_bbcode, $enable_smilies, $bbcode_uid);
$sql = "INSERT INTO " . POSTS_TEXT_TABLE . " (post_id, bbcode_uid, post_subject, post_text)
VALUES ('$post_id', '$bbcode_uid', '$post_subject', '$post_text')";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to insert post text for post $post_id", __LINE__, $sql);
}
$inc++;
if ( $inc == $per_pct )
{
print ".";
flush();
$inc = 0;
}
}
print " <span class=\"ok\"><b>OK</b></span><br />\n";
$DB_site->free_result($posts_query);
// Output resume HTML if batchcount equals resume_batches
if ( $batchcount == $resume_batches )
{
$resume_id = $batchend;
break;
}
}
// Only do this if all batches are complete
if ( !$resume_id )
{
//
// Do announcements
//
print "* Converting announcements :: ";
$sql = "SELECT * FROM announcement";
$announce_query = $DB_site->query($sql);
if ( !$announce_query )
{
die_nice("Unable to fetch announcements", __LINE__, $sql);
}
while ( $announcement = $DB_site->fetch_array($announce_query) )
{
// Get forum(s) where this announcement should be in
$forum_id = intval($announcement['forumid']);
$forum_ids = array();
if ( $forum_id == -1 )
{
$sql = "SELECT forum_id FROM " . FORUMS_TABLE;
$forum_query = $db->sql_query($sql);
if ( !$forum_query )
{
die_nice("Unable to query forum ids", __LINE__, $sql);
}
while ( $forum = $db->sql_fetchrow($forum_query) )
{
$forum_ids[] = intval($forum['forum_id']);
}
}
else
{
$forum_ids[] = $forum_id;
}
@reset($forum_ids);
$title = addslashes($announcement['title']);
$type = POST_ANNOUNCE;
$status = TOPIC_LOCKED;
$bbcode_uid = make_bbcode_uid();
$post_text = addslashes(convert_vb_code($announcement['pagetext']));
$post_text = prepare_message($post_text, 1, 1, 1, $bbcode_uid);
$poster_id = intval($announcement['userid']);
$time_stamp = intval($announcement['startdate']);
// Loop all forums in forum_ids
while ( list($i, $forum_id) = each($forum_ids) )
{
// Make topic
$sql = "INSERT INTO " . TOPICS_TABLE . " (forum_id, topic_title, topic_poster, topic_time, topic_status, topic_vote, topic_type, topic_first_post_id, topic_last_post_id, topic_moved_id)
VALUES ('$forum_id', '$title', '$poster_id', '$time_stamp', '$status', '0', '$type', '0', '0', '0')";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to insert announcement topic (" . $announcement['announcementid'] . ")", __LINE__, $sql);
}
$topic_id = $db->sql_nextid();
// Make postinfo
$sql = "INSERT INTO " . POSTS_TABLE . " (topic_id, forum_id, poster_id, post_time, post_username, enable_bbcode, enable_html, enable_smilies, enable_sig)
VALUES ('$topic_id', '$forum_id', '$poster_id', '$time_stamp', '', '1', '1', '1', '0')";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to insert general postinfo for announcement " . $announcement['announcementid'], __LINE__, $sql);
}
$post_id = $db->sql_nextid();
// Make posttext
$sql = "INSERT INTO " . POSTS_TEXT_TABLE . " (post_id, bbcode_uid, post_subject, post_text)
VALUES ('$post_id', '$bbcode_uid', '$title', '$post_text')";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to insert post text for announcement " . $announcement['announcementid'], __LINE__, $sql);
}
// Update first_post_id and last_post_id
$sql = "UPDATE " . TOPICS_TABLE . "
SET topic_first_post_id = $post_id, topic_last_post_id = $post_id
WHERE topic_id = $topic_id";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to update first and last postid for announcement " . $announcement['announcementid'], __LINE__, $sql);
}
}
}
print " <span class=\"ok\"><b>OK</b></span><br />\n";
$DB_site->free_result($announce_query);
}
if ( $step != 'all' )
{
break;
}
//
// STEP POLLS - CONVERT POLLS
//
case 'polls':
if ( !$start_id )
{
print "* Deleting existing polls :: ";
flush();
$sql = "DELETE FROM " . VOTE_DESC_TABLE;
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to delete existing poll descriptions", __LINE__, $sql);
}
$sql = "DELETE FROM " . VOTE_RESULTS_TABLE;
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to delete existing poll results", __LINE__, $sql);
}
$sql = "DELETE FROM " . VOTE_USERS_TABLE;
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to delete existing poll users", __LINE__, $sql);
}
print " <span class=\"ok\"><b>OK</b></span><br />\n";
}
$sql = "SELECT MAX(pollid) AS max_id FROM poll";
$max_query = $DB_site->query($sql);
if ( !$result )
{
die_nice("Unable to get maximum pollid", __LINE__, $sql);
}
$row = $DB_site->fetch_array($max_query);
$max_id = $row['max_id'];
$batchsize = intval(BATCH_SIZE); // Process this many posts per loop
$batchcount = 0;
if ( SAFE_MODE )
{
$resume_batches = intval(SAFE_MODE_BATCHES);
}
else
{
$resume_batches = 0;
}
for($counter = $start_id; $counter <= $max_id; $counter += $batchsize)
{
$batchstart = $counter + 1;
$batchend = $counter + $batchsize;
$batchcount++;
print "* Converting polls ($batchstart to $batchend) :: ";
flush();
$sql = "SELECT p.*, t.threadid
FROM poll p LEFT JOIN thread t ON t.pollid = p.pollid
WHERE t.open <> " . VB_THREAD_MOVED . "
AND ( p.pollid
BETWEEN $batchstart
AND $batchend )
ORDER BY p.pollid";
$polls_query = $DB_site->query($sql);
if ( !$polls_query )
{
die_nice("Unable to select batch of polls", __LINE__, $sql);
}
$per_pct = ceil( $DB_site->num_rows($polls_query) / 40 );
$inc = 0;
while ( $poll = $DB_site->fetch_array($polls_query) )
{
// Convert from days to seconds
$vote_length = intval($poll['timeout'] * 86400);
$vote_id = intval($poll['pollid']);
$topic_id = intval($poll['threadid']);
$vote_text = addslashes($poll['question']);
$vote_start = intval($poll['dateline']);
// Description
$sql = "INSERT INTO " . VOTE_DESC_TABLE . " (vote_id, topic_id, vote_text, vote_start, vote_length)
VALUES ('$vote_id', '$topic_id', '$vote_text', '$vote_start', '$vote_length')";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to insert poll desc ($vote_id)", __LINE__, $sql);
}
// Options
$options = explode("|||", $poll['options']);
$votes = explode("|||", $poll['votes']);
$sql = "INSERT INTO " . VOTE_RESULTS_TABLE . " (vote_id, vote_option_id, vote_option_text, vote_result) VALUES ";
for ($i = 0; $i < count($options); $i++)
{
$option_id = $i + 1;
$option_text = addslashes(trim($options[$i]));
$option_results = intval($votes[$i]);
$sql .= "('$vote_id', '$option_id', '$option_text', '$option_results'),";
}
$sql = substr($sql, 0, -1);
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to insert poll options ($vote_id)", __LINE__, $sql);
}
// Voters
$sql = "SELECT userid FROM pollvote WHERE pollid = '$vote_id'";
$user_query = $DB_site->query($sql);
if ( !$user_query )
{
die_nice("Unable to fetch poll voters ($vote_id)", __LINE__, $sql);
}
if ( $DB_site->num_rows($user_query) )
{
$sql = "INSERT INTO " . VOTE_USERS_TABLE . " (vote_id, vote_user_id) VALUES ";
while ( $voters = $DB_site->fetch_array($user_query) )
{
$user_id = intval($voters['userid']);
$sql .= "('$vote_id', '$user_id'),";
}
$sql = substr($sql, 0, -1);
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to insert poll voters ($vote_id)", __LINE__, $sql);
}
}
$inc++;
if ( $inc == $per_pct )
{
print ".";
flush();
$inc = 0;
}
}
print " <span class=\"ok\"><b>OK</b></span><br />\n";
$DB_site->free_result($polls_query);
// Output resume HTML if batchcount equals resume_batches
if ( $batchcount == $resume_batches )
{
$resume_id = $batchend;
break;
}
}
if ( $step != 'all' )
{
break;
}
//
// STEP PM - CONVERT PRIVATE MESSAGES
//
case 'pm':
if ( !$start_id )
{
print "* Deleting existing private messages :: ";
flush();
$sql = "DELETE FROM " . PRIVMSGS_TABLE;
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to delete existing private messages", __LINE__, $sql);
}
$sql = "DELETE FROM " . PRIVMSGS_TEXT_TABLE;
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to delete existing private messages text", __LINE__, $sql);
}
print " <span class=\"ok\"><b>OK</b></span><br />\n";
}
// Get max privmsgs_id
$sql = "SELECT MAX(privatemessageid) AS max_id FROM privatemessage";
$max_query = $DB_site->query($sql);
if ( !$max_query )
{
die_nice("Unable to fetch maximum private message id", __LINE__, $sql);
}
$row = $DB_site->fetch_array($max_query);
$max_id = $row['max_id'];
$allow_html = $board_config['allow_html'];
$allow_bbcode = $board_config['allow_bbcode'];
$batchsize = intval(BATCH_SIZE); // Process this many posts per loop
$batchcount = 0;
if ( SAFE_MODE )
{
$resume_batches = intval(SAFE_MODE_BATCHES);
}
else
{
$resume_batches = 0;
}
for($counter = $start_id; $counter <= $max_id; $counter += $batchsize)
{
$batchstart = $counter + 1;
$batchend = $counter + $batchsize;
$batchcount++;
print "* Converting private messages ($batchstart to $batchend) :: ";
flush();
$sql = "SELECT *
FROM privatemessage
WHERE privatemessageid
BETWEEN $batchstart
AND $batchend";
$pm_query = $DB_site->query($sql);
if ( !$pm_query )
{
die_nice("Unable to select batch of private messages", __LINE__, $sql);
}
$per_pct = ceil( $DB_site->num_rows($pm_query) / 40 );
$inc = 0;
while ( $pm = $DB_site->fetch_array($pm_query) )
{
// Determine message type
// If message is in INBOX, it can be either READ or UNREAD
// If message is in SENTBOX, it is saved accordingly
// No SAVEBOX exists in vB
switch ( $pm['folderid'] )
{
case VB_INBOX:
$pm_type = ( $pm['messageread'] ) ? PRIVMSGS_READ_MAIL : PRIVMSGS_UNREAD_MAIL;
break;
case VB_SENTBOX:
default:
$pm_type = PRIVMSGS_SENT_MAIL;
break;
}
$pm_bbcode_uid = make_bbcode_uid();
$pm_text = addslashes(convert_vb_code($pm['message']));
$pm_text = prepare_message($pm_text, $allow_html, $allow_bbcode, $allow_bbcode, $pm_bbcode_uid);
$pm_title = addslashes($pm['title']);
$from = intval($pm['fromuserid']);
$to = intval($pm['touserid']);
$time_stamp = intval($pm['dateline']);
$show_signature = intval($pm['showsignature']);
// This will reset the private message ID's
// Since there are no links to this ID, it seems wise to restart the numbering
// General info
$sql = "INSERT INTO " . PRIVMSGS_TABLE . " (privmsgs_type, privmsgs_subject, privmsgs_from_userid, privmsgs_to_userid, privmsgs_date, privmsgs_enable_bbcode, privmsgs_enable_html, privmsgs_enable_smilies, privmsgs_attach_sig)
VALUES ('$pm_type', '$pm_title', '$from', '$to', '$time_stamp', '$allow_bbcode', '$allow_html', '$allow_bbcode', '$show_signature')";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to insert private message (" . $pm['privatemessageid'] . ")", __LINE__, $sql);
}
$pm_id = $db->sql_nextid();
// Actual message
$sql = "INSERT INTO " . PRIVMSGS_TEXT_TABLE . " (privmsgs_text_id, privmsgs_bbcode_uid, privmsgs_text)
VALUES ('$pm_id', '$pm_bbcode_uid', '$pm_text')";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to insert private message text (" . $pm['privatemessageid'] . ")", __LINE__, $sql);
}
$inc++;
if ( $inc == $per_pct )
{
print ".";
flush();
$inc = 0;
}
}
print " <span class=\"ok\"><b>OK</b></span><br />\n";
$DB_site->free_result($pm_query);
// Output resume HTML if batchcount equals resume_batches
if ( $batchcount == $resume_batches )
{
$resume_id = $batchend;
break;
}
}
if ( $step != 'all' )
{
break;
}
//
// STEP WORDLIST - GENERATE SEARCH WORDLIST
//
case 'wordlist':
if ( !$start_id )
{
print "* Deleting existing wordlist :: ";
flush();
$sql = "DELETE FROM " . SEARCH_WORD_TABLE;
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to delete existing search words", __LINE__, $sql);
}
$sql = "DELETE FROM " . SEARCH_MATCH_TABLE;
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Unable to delete existing search word matches", __LINE__, $sql);
}
print " <span class=\"ok\"><b>OK</b></span><br />\n";
flush();
}
//
// Generate search word list (modified from upgrade.php)
//
//
// Fetch a batch of posts_text entries
//
$sql = "SELECT COUNT(*) as total, MAX(post_id) as max_post_id
FROM " . POSTS_TEXT_TABLE;
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Couldn't get post count totals", __LINE__, $sql);
}
$max_post_id = $db->sql_fetchrow($result);
$totalposts = $max_post_id['total'];
$max_post_id = $max_post_id['max_post_id'];
$per_percent = round(( $totalposts / 500 ) * 10);
$batchsize = 150; // Process this many posts per loop
$batchcount = 0;
$total_percent = 0;
if ( SAFE_MODE )
{
$resume_batches = intval(5 * SAFE_MODE_BATCHES);
}
else
{
$resume_batches = 0;
}
for($postcounter = $start_id; $postcounter <= $max_post_id; $postcounter += $batchsize)
{
$batchstart = $postcounter + 1;
$batchend = $postcounter + $batchsize;
$batchcount++;
print " * Fulltext Indexing ( $batchstart to $batchend ) :: ";
flush();
$sql = "SELECT *
FROM " . POSTS_TEXT_TABLE ."
WHERE post_id
BETWEEN $batchstart
AND $batchend";
$posts_result = $db->sql_query($sql);
if ( !$posts_result )
{
die_nice("Couldn't obtain post_text", __LINE__, $sql);
}
$per_pct = ceil( $db->sql_numrows($posts_result) / 40 );
$inc = 0;
if ( $row = $db->sql_fetchrow($posts_result) )
{
do
{
add_search_words('post', $row['post_id'], $row['post_text'], $row['post_subject']);
$inc++;
if ( $inc == $per_pct )
{
print ".";
flush();
$inc = 0;
}
}
while( $row = $db->sql_fetchrow($posts_result) );
}
$db->sql_freeresult($posts_result);
// Remove common words after the first 2 batches and after every 4th batch after that.
if ( $batchcount % 4 == 3 )
{
remove_common('global', 0.4);
}
print " <span class=\"ok\"><b>OK</b></span><br />\n";
// Output resume HTML if batchcount equals resume_batches
if ( $batchcount == $resume_batches )
{
$resume_id = $batchend;
break;
}
}
if ( $step != 'all' )
{
break;
}
//
// STEP END - FINALIZE INSTALL AND SHOW SUCCESS MESSAGE
//
case 'end':
//
// Do some things that didn't fit into any other category
// or have to be done last
//
echo "* Finalizing installation :: ";
flush();
// Find board startdate
$sql = "SELECT MIN(user_regdate) AS oldest_time
FROM " . USERS_TABLE . "
WHERE user_regdate > 0";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Couldn't obtain oldest user registration time", __LINE__, $sql);
}
$row = $db->sql_fetchrow($result);
$sql = "UPDATE " . CONFIG_TABLE . "
SET config_value = " . $row['oldest_time'] . "
WHERE config_name = 'board_startdate'";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Couldn't update board_startdate", __LINE__, $sql);
}
//
// Sync all forums
//
sync('all forums', 0);
//
// Change session table to HEAP if MySQL version matches
//
$sql = "SELECT VERSION() AS mysql_version";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Couldn't obtain MySQL Version", __LINE__, $sql);
}
$row = $db->sql_fetchrow($result);
$version = $row['mysql_version'];
if ( preg_match("/^(3\.23)|(4\.)/", $version) )
{
$sql = "ALTER TABLE " . SESSIONS_TABLE . " TYPE=HEAP";
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Couldn't alter sessions table to HEAP", __LINE__, $sql);
}
}
// Optimize tables
$sql = 'OPTIMIZE TABLE ' . AUTH_ACCESS_TABLE . ', ' . BANLIST_TABLE . ', ' . CATEGORIES_TABLE . ', ' . CONFIG_TABLE . ', ' . DISALLOW_TABLE . ', ' . FORUMS_TABLE . ', ' . GROUPS_TABLE . ', ' . POSTS_TABLE . ', ' . POSTS_TEXT_TABLE . ', ' . PRIVMSGS_TABLE . ', ' . PRIVMSGS_TEXT_TABLE . ', ' . PRIVMSGS_IGNORE_TABLE . ', ' . PRUNE_TABLE . ', ' . RANKS_TABLE . ', ' . SEARCH_TABLE . ', ' . SEARCH_WORD_TABLE . ', ' . SEARCH_MATCH_TABLE . ', ' . SESSIONS_TABLE . ', ' . SMILIES_TABLE . ', ' . THEMES_TABLE . ', ' . THEMES_NAME_TABLE . ', ' . TOPICS_TABLE . ', ' . TOPICS_WATCH_TABLE . ', ' . USER_GROUP_TABLE . ', ' . USERS_TABLE . ', ' . WORDS_TABLE . ', ' . VOTE_DESC_TABLE . ', ' . VOTE_RESULTS_TABLE . ', ' . VOTE_USERS_TABLE;
$result = $db->sql_query($sql);
if ( !$result )
{
die_nice("Couldn't optimize tables. This is not a critical error, you can safely ignore it.", __LINE__, $sql);
}
echo " <span class=\"ok\"><b>OK</b></span><br />\n";
//
// Display DONE HTML message
//
print "<br clear=\"all\" /><br />\n";
print "<b>Conversion successfull.</b><br />\n";
print "<a target=\"_blank\" href=\"" . PHPBB_URI . "\">Your board</a> is now converted. Please check all settings in <a target=\"_blank\" href=\"" . PHPBB_URI . "admin/\">the control panel</a>. You can login with any old admin user / password combination of you vBulletin installation. The standard phpBB admin account is deleted. Be sure to <b>remove or disable this conversion script</b>, as it can destroy the entire new phpBB installation!<br /><br />\n";
print "Thank you for using this Conversion Tool by <a target=\"_blank\" href=\"http://www.matthijs.net/phpbb/\">Matthijs van de Water</a>. If you are happy with the results, drop me <a href=\"mailto:converter@matthijs.net\">an email</a> to thank me. Since I put quite some time in this little project, I always like to hear from the end-users. If you have to much money, you can always buy something from <a target=\"_amazon\" href=\"http://www.amazon.com/exec/obidos/wishl ... A0TUX\">my Amazon Wish List</a> or donate something via PayPal<br />\n";
print "<br />\n<hr />\n";
break;
} // switch
// Print next step HTML if needed
next_step($step, $resume_id);
// Output common footer
common_footer();
?>