Browse Source

! Adding other branch with install.php and upgrade.php changes

Spuds 12 years ago
parent
commit
2f00d55551

+ 154 - 0
other/Settings.php

@@ -0,0 +1,154 @@
+<?php
+
+/**
+ * The settings file contains all of the basic settings that need to be present when a database/cache is not available.
+ * 
+ * Simple Machines Forum (SMF)
+ *
+ * @package SMF
+ * @author Simple Machines http://www.simplemachines.org
+ * @copyright 2011 Simple Machines
+ * @license http://www.simplemachines.org/about/smf/license.php BSD
+ *
+ * @version 2.1 Alpha 1
+ */
+
+########## Maintenance ##########
+/**
+ * The maintenance "mode"
+ * Set to 1 to enable Maintenance Mode, 2 to make the forum untouchable. (you'll have to make it 0 again manually!)
+ * 0 is default and disables maintenance mode.
+ * @var int 0, 1, 2
+ * @global int $maintenance
+ */
+$maintenance = 0;
+/**
+ * Title for the Maintenance Mode message.
+ * @var string
+ * @global int $mtitle
+ */
+$mtitle = 'Maintenance Mode';
+/**
+ * Description of why the forum is in maintenance mode.
+ * @var string
+ * @global string $mmessage
+ */
+$mmessage = 'Okay faithful users...we\'re attempting to restore an older backup of the database...news will be posted once we\'re back!';
+
+########## Forum Info ##########
+/**
+ * The name of your forum.
+ * @var string
+ */
+$mbname = 'My Community';
+/**
+ * The default language file set for the forum.
+ * @var string
+ */
+$language = 'english';
+/**
+ * URL to your forum's folder. (without the trailing /!)
+ * @var string
+ */
+$boardurl = 'http://127.0.0.1/smf';
+/**
+ * Email address to send emails from. (like [email protected].)
+ * @var string
+ */
+$webmaster_email = '[email protected]';
+/**
+ * Name of the cookie to set for authentication.
+ * @var string
+ */
+$cookiename = 'SMFCookie11';
+
+########## Database Info ##########
+/**
+ * The database type
+ * Default options: mysql, sqlite, postgresql
+ * @var string
+ */
+$db_type = 'mysql';
+/**
+ * The server to connect to (or a Unix socket)
+ * @var string
+ */
+$db_server = 'localhost';
+/**
+ * The database name
+ * @var string
+ */
+$db_name = 'smf';
+/**
+ * Database username
+ * @var string
+ */
+$db_user = 'root';
+/**
+ * Database password
+ * @var string
+ */
+$db_passwd = '';
+/**
+ * Database user for when connecting with SSI
+ * @var string
+ */
+$ssi_db_user = '';
+/**
+ * Database password for when connecting with SSI
+ * @var string
+ */
+$ssi_db_passwd = '';
+/**
+ * A prefix to put in front of your table names.
+ * This helps to prevent conflicts
+ * @var string
+ */
+$db_prefix = 'smf_';
+/**
+ * Use a persistent database connection
+ * @var int|bool
+ */
+$db_persist = 0;
+/**
+ * 
+ * @var int|bool
+ */
+$db_error_send = 1;
+
+########## Directories/Files ##########
+# Note: These directories do not have to be changed unless you move things.
+/**
+ * The absolute path to the forum's folder. (not just '.'!)
+ * @var string
+ */
+$boarddir = dirname(__FILE__);
+/**
+ * Path to the Sources directory.
+ * @var string
+ */
+$sourcedir = dirname(__FILE__) . '/Sources';
+/**
+ * Path to the cache directory.
+ * @var string
+ */
+$cachedir = dirname(__FILE__) . '/cache';
+
+########## Error-Catching ##########
+# Note: You shouldn't touch these settings.
+$db_last_error = 0;
+
+if (file_exists(dirname(__FILE__) . '/install.php'))
+{
+	header('Location: http' . (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 's' : '') . '://' . (empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST']) . (strtr(dirname($_SERVER['PHP_SELF']), '\\', '/') == '/' ? '' : strtr(dirname($_SERVER['PHP_SELF']), '\\', '/')) . '/install.php'); exit;
+}
+
+# Make sure the paths are correct... at least try to fix them.
+if (!file_exists($boarddir) && file_exists(dirname(__FILE__) . '/agreement.txt'))
+	$boarddir = dirname(__FILE__);
+if (!file_exists($sourcedir) && file_exists($boarddir . '/Sources'))
+	$sourcedir = $boarddir . '/Sources';
+if (!file_exists($cachedir) && file_exists($boarddir . '/cache'))
+	$cachedir = $boarddir . '/cache';
+
+?>

+ 2583 - 0
other/install.php

@@ -0,0 +1,2583 @@
+<?php
+
+/**
+ * Simple Machines Forum (SMF)
+ *
+ * @package SMF
+ * @author Simple Machines http://www.simplemachines.org
+ * @copyright 2011 Simple Machines
+ * @license http://www.simplemachines.org/about/smf/license.php BSD
+ *
+ * @version 2.1 Alpha 1
+ */
+
+$GLOBALS['current_smf_version'] = '2.1 Alpha 1';
+$GLOBALS['db_script_version'] = '2-1';
+
+$GLOBALS['required_php_version'] = '5.0.0';
+
+// Don't have PHP support, do you?
+// ><html dir="ltr"><head><title>Error!</title></head><body>Sorry, this installer requires PHP!<div style="display: none;">
+
+// Database info.
+$databases = array(
+	'mysql' => array(
+		'name' => 'MySQL',
+		'version' => '4.0.18',
+		'version_check' => 'return min(mysql_get_server_info(), mysql_get_client_info());',
+		'supported' => function_exists('mysql_connect'),
+		'default_user' => 'mysql.default_user',
+		'default_password' => 'mysql.default_password',
+		'default_host' => 'mysql.default_host',
+		'default_port' => 'mysql.default_port',
+		'utf8_support' => true,
+		'utf8_version' => '4.1.0',
+		'utf8_version_check' => 'return mysql_get_server_info();',
+		'utf8_default' => false,
+		'utf8_required' => false,
+		'alter_support' => true,
+		'validate_prefix' => create_function('&$value', '
+			$value = preg_replace(\'~[^A-Za-z0-9_\$]~\', \'\', $value);
+			return true;
+		'),
+	),
+	'postgresql' => array(
+		'name' => 'PostgreSQL',
+		'version' => '8.0',
+		'function_check' => 'pg_connect',
+		'version_check' => '$request = pg_query(\'SELECT version()\'); list ($version) = pg_fetch_row($request); list($pgl, $version) = explode(" ", $version); return $version;',
+		'supported' => function_exists('pg_connect'),
+		'always_has_db' => true,
+		'utf8_default' => true,
+		'utf8_required' => true,
+		'utf8_support' => true,
+		'utf8_version' => '8.0',
+		'utf8_version_check' => '$request = pg_query(\'SELECT version()\'); list ($version) = pg_fetch_row($request); list($pgl, $version) = explode(" ", $version); return $version;',
+		'validate_prefix' => create_function('&$value', '
+			$value = preg_replace(\'~[^A-Za-z0-9_\$]~\', \'\', $value);
+
+			// Is it reserved?
+			if ($value == \'pg_\')
+				return $txt[\'error_db_prefix_reserved\'];
+
+			// Is the prefix numeric?
+			if (preg_match(\'~^\d~\', $value))
+				return $txt[\'error_db_prefix_numeric\'];
+
+			return true;
+		'),
+	),
+	'sqlite' => array(
+		'name' => 'SQLite',
+		'version' => '1',
+		'function_check' => 'sqlite_open',
+		'version_check' => 'return 1;',
+		'supported' => function_exists('sqlite_open'),
+		'always_has_db' => true,
+		'utf8_default' => true,
+		'utf8_required' => true,
+		'validate_prefix' => create_function('&$value', '
+			global $incontext, $txt;
+
+			$value = preg_replace(\'~[^A-Za-z0-9_\$]~\', \'\', $value);
+
+			// Is it reserved?
+			if ($value == \'sqlite_\')
+				return $txt[\'error_db_prefix_reserved\'];
+
+			// Is the prefix numeric?
+			if (preg_match(\'~^\d~\', $value))
+				return $txt[\'error_db_prefix_numeric\'];
+
+			return true;
+		'),
+	),
+);
+
+// Initialize everything and load the language files.
+initialize_inputs();
+load_lang_file();
+
+// This is what we are.
+$installurl = $_SERVER['PHP_SELF'];
+// This is where SMF is.
+$smfsite = 'http://www.simplemachines.org/smf';
+
+// All the steps in detail.
+// Number,Name,Function,Progress Weight.
+$incontext['steps'] = array(
+	0 => array(1, $txt['install_step_welcome'], 'Welcome', 0),
+	1 => array(2, $txt['install_step_writable'], 'CheckFilesWritable', 10),
+	2 => array(3, $txt['install_step_databaseset'], 'DatabaseSettings', 15),
+	3 => array(4, $txt['install_step_forum'], 'ForumSettings', 40),
+	4 => array(5, $txt['install_step_databasechange'], 'DatabasePopulation', 15),
+	5 => array(6, $txt['install_step_admin'], 'AdminAccount', 20),
+	6 => array(7, $txt['install_step_delete'], 'DeleteInstall', 0),
+);
+
+// Default title...
+$incontext['page_title'] = $txt['smf_installer'];
+
+// What step are we on?
+$incontext['current_step'] = isset($_GET['step']) ? (int) $_GET['step'] : 0;
+
+// Loop through all the steps doing each one as required.
+$incontext['overall_percent'] = 0;
+foreach ($incontext['steps'] as $num => $step)
+{
+	if ($num >= $incontext['current_step'])
+	{
+		// The current weight of this step in terms of overall progress.
+		$incontext['step_weight'] = $step[3];
+		// Make sure we reset the skip button.
+		$incontext['skip'] = false;
+
+		// Call the step and if it returns false that means pause!
+		if (function_exists($step[2]) && $step[2]() === false)
+			break;
+		elseif (function_exists($step[2]))
+			$incontext['current_step']++;
+
+		// No warnings pass on.
+		$incontext['warning'] = '';
+	}
+	$incontext['overall_percent'] += $step[3];
+}
+
+// Actually do the template stuff.
+installExit();
+
+function initialize_inputs()
+{
+	global $databases, $incontext;
+
+	// Just so people using older versions of PHP aren't left in the cold.
+	if (!isset($_SERVER['PHP_SELF']))
+		$_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php';
+
+	// Turn off magic quotes runtime and enable error reporting.
+	if (function_exists('set_magic_quotes_runtime'))
+		@set_magic_quotes_runtime(0);
+	error_reporting(E_ALL);
+
+	// Fun.  Low PHP version...
+	if (!isset($_GET))
+	{
+		$GLOBALS['_GET']['step'] = 0;
+		return;
+	}
+
+	if (!isset($_GET['obgz']))
+	{
+		ob_start();
+
+		if (ini_get('session.save_handler') == 'user')
+			@ini_set('session.save_handler', 'files');
+		if (function_exists('session_start'))
+			@session_start();
+	}
+	else
+	{
+		ob_start('ob_gzhandler');
+
+		if (ini_get('session.save_handler') == 'user')
+			@ini_set('session.save_handler', 'files');
+		session_start();
+
+		if (!headers_sent())
+			echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+	<head>
+		<title>', htmlspecialchars($_GET['pass_string']), '</title>
+	</head>
+	<body style="background-color: #d4d4d4; margin-top: 16%; text-align: center; font-size: 16pt;">
+		<strong>', htmlspecialchars($_GET['pass_string']), '</strong>
+	</body>
+</html>';
+		exit;
+	}
+
+	// Are we calling the backup css file?
+	if (isset($_GET['infile_css']))
+	{
+		header('Content-Type: text/css');
+		template_css();
+		exit;
+	}
+
+	// Anybody home?
+	if (!isset($_GET['xml']))
+	{
+		$incontext['remote_files_available'] = false;
+		$test = @fsockopen('www.simplemachines.org', 80, $errno, $errstr, 1);
+		if ($test)
+			$incontext['remote_files_available'] = true;
+		@fclose($test);
+	}
+
+	// Add slashes, as long as they aren't already being added.
+	if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0)
+		foreach ($_POST as $k => $v)
+			$_POST[$k] = addslashes($v);
+
+	// This is really quite simple; if ?delete is on the URL, delete the installer...
+	if (isset($_GET['delete']))
+	{
+		if (isset($_SESSION['installer_temp_ftp']))
+		{
+			$ftp = new ftp_connection($_SESSION['installer_temp_ftp']['server'], $_SESSION['installer_temp_ftp']['port'], $_SESSION['installer_temp_ftp']['username'], $_SESSION['installer_temp_ftp']['password']);
+			$ftp->chdir($_SESSION['installer_temp_ftp']['path']);
+
+			$ftp->unlink('install.php');
+			$ftp->unlink('webinstall.php');
+
+			foreach ($databases as $key => $dummy)
+				$ftp->unlink('install_' . $GLOBALS['db_script_version'] . '_' . $key . '.sql');
+
+			$ftp->close();
+
+			unset($_SESSION['installer_temp_ftp']);
+		}
+		else
+		{
+			@unlink(__FILE__);
+			@unlink(dirname(__FILE__) . '/webinstall.php');
+
+			foreach ($databases as $key => $dummy)
+				@unlink(dirname(__FILE__) . '/install_' . $GLOBALS['db_script_version'] . '_' . $key . '.sql');
+		}
+
+		// Now just redirect to a blank.gif...
+		header('Location: http://' . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT']) . dirname($_SERVER['PHP_SELF']) . '/Themes/default/images/blank.gif');
+		exit;
+	}
+
+	// PHP 5 might cry if we don't do this now.
+	if (function_exists('date_default_timezone_set'))
+	{
+		$server_offset = @mktime(0, 0, 0, 1, 1, 1970);
+		date_default_timezone_set('Etc/GMT' . ($server_offset > 0 ? '+' : '') . ($server_offset / 3600));
+	}
+
+	// Force an integer step, defaulting to 0.
+	$_GET['step'] = (int) @$_GET['step'];
+}
+
+// Load the list of language files, and the current language file.
+function load_lang_file()
+{
+	global $txt, $incontext;
+
+	$incontext['detected_languages'] = array();
+
+	// Make sure the languages directory actually exists.
+	if (file_exists(dirname(__FILE__) . '/Themes/default/languages'))
+	{
+		// Find all the "Install" language files in the directory.
+		$dir = dir(dirname(__FILE__) . '/Themes/default/languages');
+		while ($entry = $dir->read())
+		{
+			if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php')
+				$incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12));
+		}
+		$dir->close();
+	}
+
+	// Didn't find any, show an error message!
+	if (empty($incontext['detected_languages']))
+	{
+		// Let's not cache this message, eh?
+		header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
+		header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
+		header('Cache-Control: no-cache');
+
+		echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+	<head>
+		<title>SMF Installer: Error!</title>
+	</head>
+	<body style="font-family: sans-serif;"><div style="width: 600px;">
+		<h1 style="font-size: 14pt;">A critical error has occurred.</h1>
+
+		<p>This installer was unable to find the installer\'s language file or files.  They should be found under:</p>
+
+		<div style="margin: 1ex; font-family: monospace; font-weight: bold;">', dirname($_SERVER['PHP_SELF']) != '/' ? dirname($_SERVER['PHP_SELF']) : '', '/Themes/default/languages</div>
+
+		<p>In some cases, FTP clients do not properly upload files with this many folders.  Please double check to make sure you <span style="font-weight: 600;">have uploaded all the files in the distribution</span>.</p>
+		<p>If that doesn\'t help, please make sure this install.php file is in the same place as the Themes folder.</p>
+
+		<p>If you continue to get this error message, feel free to <a href="http://support.simplemachines.org/">look to us for support</a>.</p>
+	</div></body>
+</html>';
+		die;
+	}
+
+	// Override the language file?
+	if (isset($_GET['lang_file']))
+		$_SESSION['installer_temp_lang'] = $_GET['lang_file'];
+	elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file']))
+		$_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file'];
+
+	// Make sure it exists, if it doesn't reset it.
+	if (!isset($_SESSION['installer_temp_lang']) || preg_match('~[^\\w_\\-.]~', $_SESSION['installer_temp_lang']) === 1 || !file_exists(dirname(__FILE__) . '/Themes/default/languages/' . $_SESSION['installer_temp_lang']))
+	{
+		// Use the first one...
+		list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
+
+		// If we have english and some other language, use the other language.  We Americans hate english :P.
+		if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1)
+			list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
+	}
+
+	// And now include the actual language file itself.
+	require_once(dirname(__FILE__) . '/Themes/default/languages/' . $_SESSION['installer_temp_lang']);
+}
+
+// This handy function loads some settings and the like.
+function load_database()
+{
+	global $db_prefix, $db_connection, $db_character_set, $sourcedir, $language;
+	global $smcFunc, $mbname, $scripturl, $boardurl, $modSettings, $db_type, $db_name, $db_user;
+
+	if (empty($sourcedir))
+		$sourcedir = dirname(__FILE__) . '/Sources';
+
+	// Need this to check whether we need the database password.
+	require(dirname(__FILE__) . '/Settings.php');
+	if (!defined('SMF'))
+		define('SMF', 1);
+	if (empty($smcFunc))
+		$smcFunc = array();
+
+	$modSettings['disableQueryCheck'] = true;
+
+	// Connect the database.
+	if (!$db_connection)
+	{
+		require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
+		if (version_compare(PHP_VERSION, '5', '<'))
+			require_once($sourcedir . '/Subs-Compat.php');
+
+		if (!$db_connection)
+			$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('persist' => $db_persist));
+	}
+}
+
+// This is called upon exiting the installer, for template etc.
+function installExit($fallThrough = false)
+{
+	global $incontext, $installurl, $txt;
+
+	// Send character set.
+	header('Content-Type: text/html; charset=' . (isset($txt['lang_character_set']) ? $txt['lang_character_set'] : 'ISO-8859-1'));
+
+	// We usually dump our templates out.
+	if (!$fallThrough)
+	{
+		// The top install bit.
+		template_install_above();
+
+		// Call the template.
+		if (isset($incontext['sub_template']))
+		{
+			$incontext['form_url'] = $installurl . '?step=' . $incontext['current_step'];
+
+			call_user_func('template_' . $incontext['sub_template']);
+		}
+		// @todo REMOVE THIS!!
+		else
+		{
+			if (function_exists('doStep' . $_GET['step']))
+				call_user_func('doStep' . $_GET['step']);
+		}
+		// Show the footer.
+		template_install_below();
+	}
+
+	// Bang - gone!
+	die();
+}
+
+function Welcome()
+{
+	global $incontext, $txt, $databases, $installurl;
+
+	$incontext['page_title'] = $txt['install_welcome'];
+	$incontext['sub_template'] = 'welcome_message';
+
+	// Done the submission?
+	if (isset($_POST['contbutt']))
+		return true;
+
+	// Check the PHP version.
+	if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>')))
+	{
+		$incontext['warning'] = $txt['error_php_too_low'];
+	}
+
+	// See if we think they have already installed it?
+	if (is_readable(dirname(__FILE__) . '/Settings.php'))
+	{
+		$probably_installed = 0;
+		foreach (file(dirname(__FILE__) . '/Settings.php') as $line)
+		{
+			if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line))
+				$probably_installed++;
+			if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line))
+				$probably_installed++;
+		}
+
+		if ($probably_installed == 2)
+			$incontext['warning'] = $txt['error_already_installed'];
+	}
+
+	// Is some database support even compiled in?
+	$incontext['supported_databases'] = array();
+	foreach ($databases as $key => $db)
+	{
+		if ($db['supported'])
+		{
+			if (!file_exists(dirname(__FILE__) . '/install_' . $GLOBALS['db_script_version'] . '_' . $key . '.sql'))
+			{
+				$databases[$key]['supported'] = false;
+				$notFoundSQLFile = true;
+				$txt['error_db_script_missing'] = sprintf($txt['error_db_script_missing'], 'install_' . $GLOBALS['db_script_version'] . '_' . $key . '.sql');
+			}
+			else
+			{
+				$db_type = $key;
+				$incontext['supported_databases'][] = $db;
+			}
+		}
+	}
+
+	if (empty($incontext['supported_databases']))
+		$error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing';
+	// How about session support?  Some crazy sysadmin remove it?
+	elseif (!function_exists('session_start'))
+		$error = 'error_session_missing';
+	// Make sure they uploaded all the files.
+	elseif (!file_exists(dirname(__FILE__) . '/index.php'))
+		$error = 'error_missing_files';
+	// Very simple check on the session.save_path for Windows.
+	// @todo Move this down later if they don't use database-driven sessions?
+	elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\')
+		$error = 'error_session_save_path';
+
+	// Since each of the three messages would look the same, anyway...
+	if (isset($error))
+		$incontext['error'] = $txt[$error];
+
+	// Mod_security blocks everything that smells funny. Let SMF handle security.
+	if (!fixModSecurity() && !isset($_GET['overmodsecurity']))
+		$incontext['error'] = $txt['error_mod_security'] . '<br /><br /><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again'];
+
+	return false;
+}
+
+function CheckFilesWritable()
+{
+	global $txt, $incontext;
+
+	$incontext['page_title'] = $txt['ftp_checking_writable'];
+	$incontext['sub_template'] = 'chmod_files';
+
+	$writable_files = array(
+		'attachments',
+		'avatars',
+		'cache',
+		'Packages',
+		'Packages/installed.list',
+		'Smileys',
+		'Themes',
+		'agreement.txt',
+		'Settings.php',
+		'Settings_bak.php'
+	);
+	$extra_files = array(
+		'Themes/classic/index.template.php',
+		'Themes/classic/style.css'
+	);
+	foreach ($incontext['detected_languages'] as $lang => $temp)
+		$extra_files[] = 'Themes/default/languages/' . $lang;
+
+	// With mod_security installed, we could attempt to fix it with .htaccess.
+	if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules()))
+		$writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.';
+
+	$failed_files = array();
+
+	// On linux, it's easy - just use is_writable!
+	if (substr(__FILE__, 1, 2) != ':\\')
+	{
+		foreach ($writable_files as $file)
+		{
+			if (!is_writable(dirname(__FILE__) . '/' . $file))
+			{
+				@chmod(dirname(__FILE__) . '/' . $file, 0755);
+
+				// Well, 755 hopefully worked... if not, try 777.
+				if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777))
+					$failed_files[] = $file;
+			}
+		}
+		foreach ($extra_files as $file)
+			@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
+	}
+	// Windows is trickier.  Let's try opening for r+...
+	else
+	{
+		foreach ($writable_files as $file)
+		{
+			// Folders can't be opened for write... but the index.php in them can ;)
+			if (is_dir(dirname(__FILE__) . '/' . $file))
+				$file .= '/index.php';
+
+			// Funny enough, chmod actually does do something on windows - it removes the read only attribute.
+			@chmod(dirname(__FILE__) . '/' . $file, 0777);
+			$fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+');
+
+			// Hmm, okay, try just for write in that case...
+			if (!is_resource($fp))
+				$fp = @fopen(dirname(__FILE__) . '/' . $file, 'w');
+
+			if (!is_resource($fp))
+				$failed_files[] = $file;
+
+			@fclose($fp);
+		}
+		foreach ($extra_files as $file)
+			@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
+	}
+
+	$failure = count($failed_files) >= 1;
+
+	if (!isset($_SERVER))
+		return !$failure;
+
+	// Put the list into context.
+	$incontext['failed_files'] = $failed_files;
+
+	// It's not going to be possible to use FTP on windows to solve the problem...
+	if ($failure && substr(__FILE__, 1, 2) == ':\\')
+	{
+		$incontext['error'] = $txt['error_windows_chmod'] . '
+					<ul style="margin: 2.5ex; font-family: monospace;">
+						<li>' . implode('</li>
+						<li>', $failed_files) . '</li>
+					</ul>';
+
+		return false;
+	}
+	// We're going to have to use... FTP!
+	elseif ($failure)
+	{
+		// Load any session data we might have...
+		if (!isset($_POST['ftp_username']) && isset($_SESSION['installer_temp_ftp']))
+		{
+			$_POST['ftp_server'] = $_SESSION['installer_temp_ftp']['server'];
+			$_POST['ftp_port'] = $_SESSION['installer_temp_ftp']['port'];
+			$_POST['ftp_username'] = $_SESSION['installer_temp_ftp']['username'];
+			$_POST['ftp_password'] = $_SESSION['installer_temp_ftp']['password'];
+			$_POST['ftp_path'] = $_SESSION['installer_temp_ftp']['path'];
+		}
+
+		$incontext['ftp_errors'] = array();
+
+		if (isset($_POST['ftp_username']))
+		{
+			$ftp = new ftp_connection($_POST['ftp_server'], $_POST['ftp_port'], $_POST['ftp_username'], $_POST['ftp_password']);
+
+			if ($ftp->error === false)
+			{
+				// Try it without /home/abc just in case they messed up.
+				if (!$ftp->chdir($_POST['ftp_path']))
+				{
+					$incontext['ftp_errors'][] = $ftp->last_message;
+					$ftp->chdir(preg_replace('~^/home[2]?/[^/]+?~', '', $_POST['ftp_path']));
+				}
+			}
+		}
+
+		if (!isset($ftp) || $ftp->error !== false)
+		{
+			if (!isset($ftp))
+				$ftp = new ftp_connection(null);
+			// Save the error so we can mess with listing...
+			elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message))
+				$incontext['ftp_errors'][] = $ftp->last_message;
+
+			list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__));
+
+			if (empty($_POST['ftp_path']) && $found_path)
+				$_POST['ftp_path'] = $detect_path;
+
+			if (!isset($_POST['ftp_username']))
+				$_POST['ftp_username'] = $username;
+
+			// Set the username etc, into context.
+			$incontext['ftp'] = array(
+				'server' => isset($_POST['ftp_server']) ? $_POST['ftp_server'] : 'localhost',
+				'port' => isset($_POST['ftp_port']) ? $_POST['ftp_port'] : '21',
+				'username' => isset($_POST['ftp_username']) ? $_POST['ftp_username'] : '',
+				'path' => isset($_POST['ftp_path']) ? $_POST['ftp_path'] : '/',
+				'path_msg' => !empty($found_path) ? $txt['ftp_path_found_info'] : $txt['ftp_path_info'],
+			);
+
+			return false;
+		}
+		else
+		{
+			$_SESSION['installer_temp_ftp'] = array(
+				'server' => $_POST['ftp_server'],
+				'port' => $_POST['ftp_port'],
+				'username' => $_POST['ftp_username'],
+				'password' => $_POST['ftp_password'],
+				'path' => $_POST['ftp_path']
+			);
+
+			$failed_files_updated = array();
+
+			foreach ($failed_files as $file)
+			{
+				if (!is_writable(dirname(__FILE__) . '/' . $file))
+					$ftp->chmod($file, 0755);
+				if (!is_writable(dirname(__FILE__) . '/' . $file))
+					$ftp->chmod($file, 0777);
+				if (!is_writable(dirname(__FILE__) . '/' . $file))
+				{
+					$failed_files_updated[] = $file;
+					$incontext['ftp_errors'][] = rtrim($ftp->last_message) . ' -> ' . $file . "\n";
+				}
+			}
+
+			$ftp->close();
+
+			// Are there any errors left?
+			if (count($failed_files_updated) >= 1)
+			{
+				// Guess there are...
+				$incontext['failed_files'] = $failed_files_updated;
+
+				// Set the username etc, into context.
+				$incontext['ftp'] = $_SESSION['installer_temp_ftp'] += array(
+					'path_msg' => $txt['ftp_path_info'],
+				);
+
+				return false;
+			}
+		}
+	}
+
+	return true;
+}
+
+function DatabaseSettings()
+{
+	global $txt, $databases, $incontext, $smcFunc, $sourcedir;
+
+	$incontext['sub_template'] = 'database_settings';
+	$incontext['page_title'] = $txt['db_settings'];
+	$incontext['continue'] = 1;
+
+	// Set up the defaults.
+	$incontext['db']['server'] = 'localhost';
+	$incontext['db']['user'] = '';
+	$incontext['db']['name'] = '';
+	$incontext['db']['pass'] = '';
+	$incontext['db']['type'] = '';
+	$incontext['supported_databases'] = array();
+
+	$foundOne = false;
+	foreach ($databases as $key => $db)
+	{
+		// Override with the defaults for this DB if appropriate.
+		if ($db['supported'])
+		{
+			$incontext['supported_databases'][$key] = $db;
+
+			if (!$foundOne)
+			{
+				if (isset($db['default_host']))
+					$incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost';
+				if (isset($db['default_user']))
+				{
+					$incontext['db']['user'] = ini_get($db['default_user']);
+					$incontext['db']['name'] = ini_get($db['default_user']);
+				}
+				if (isset($db['default_password']))
+					$incontext['db']['pass'] = ini_get($db['default_password']);
+				if (isset($db['default_port']))
+					$db_port = ini_get($db['default_port']);
+
+				$incontext['db']['type'] = $key;
+				$foundOne = true;
+			}
+		}
+	}
+
+	// Override for repost.
+	if (isset($_POST['db_user']))
+	{
+		$incontext['db']['user'] = $_POST['db_user'];
+		$incontext['db']['name'] = $_POST['db_type'] == 'sqlite' && isset($_POST['db_filename']) ? $_POST['db_filename'] : $_POST['db_name'];
+		$incontext['db']['server'] = $_POST['db_server'];
+		$incontext['db']['prefix'] = $_POST['db_prefix'];
+	}
+	else
+		$incontext['db']['prefix'] = 'smf_';
+
+	// Should we use a non standard port?
+	if (!empty($db_port))
+		$incontext['db']['server'] .= ':' . $db_port;
+
+	// Are we submitting?
+	if (isset($_POST['db_type']))
+	{
+		if (isset($_POST['db_filename']))
+		{
+			// You better enter enter a database name for SQLite.
+			if (trim($_POST['db_filename']) == '')
+			{
+				$incontext['error'] = $txt['error_db_filename'];
+				return false;
+			}
+			// Duplicate name in the same dir?  Can't do that with SQLite.  Weird things happen.
+			if (file_exists($_POST['db_filename'] . (substr($_POST['db_filename'], -3) != '.db' ? '.db' : '')))
+			{
+				$incontext['error'] = $txt['error_db_filename_exists'];
+				return false;
+			}
+		}
+
+		// What type are they trying?
+		$db_type = preg_replace('~[^A-Za-z0-9]~', '', $_POST['db_type']);
+		$db_prefix = $_POST['db_prefix'];
+		// Validate the prefix.
+		$valid_prefix = $databases[$db_type]['validate_prefix']($db_prefix);
+
+		if ($valid_prefix !== true)
+		{
+			$incontext['error'] = $valid_prefix;
+			return false;
+		}
+
+		// Take care of these variables...
+		$vars = array(
+			'db_type' => $db_type,
+			'db_name' => $_POST['db_type'] == 'sqlite' && isset($_POST['db_filename']) ? $_POST['db_filename'] : $_POST['db_name'],
+			'db_user' => $_POST['db_user'],
+			'db_passwd' => isset($_POST['db_passwd']) ? $_POST['db_passwd'] : '',
+			'db_server' => $_POST['db_server'],
+			'db_prefix' => $db_prefix,
+			// The cookiename is special; we want it to be the same if it ever needs to be reinstalled with the same info.
+			'cookiename' => 'SMFCookie' . abs(crc32($_POST['db_name'] . preg_replace('~[^A-Za-z0-9_$]~', '', $_POST['db_prefix'])) % 1000),
+		);
+
+		// God I hope it saved!
+		if (!updateSettingsFile($vars) && substr(__FILE__, 1, 2) == ':\\')
+		{
+			$incontext['error'] = $txt['error_windows_chmod'];
+			return false;
+		}
+
+		// Make sure it works.
+		require(dirname(__FILE__) . '/Settings.php');
+
+		if (empty($sourcedir))
+			$sourcedir = dirname(__FILE__) . '/Sources';
+
+		// Better find the database file!
+		if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php'))
+		{
+			$incontext['error'] = sprintf($txt['error_db_file'], 'Subs-Db-' . $db_type . '.php');
+			return false;
+		}
+
+		// Now include it for database functions!
+		define('SMF', 1);
+		$modSettings['disableQueryCheck'] = true;
+		if (empty($smcFunc))
+			$smcFunc = array();
+
+			require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
+
+		// What - running PHP4? The shame!
+		if (version_compare(PHP_VERSION, '5', '<'))
+			require_once($sourcedir . '/Subs-Compat.php');
+
+		// Attempt a connection.
+		$needsDB = !empty($databases[$db_type]['always_has_db']);
+		$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true, 'dont_select_db' => !$needsDB));
+
+		// No dice?  Let's try adding the prefix they specified, just in case they misread the instructions ;)
+		if ($db_connection == null)
+		{
+			$db_error = @$smcFunc['db_error']();
+
+			$db_connection = smf_db_initiate($db_server, $db_name, $_POST['db_prefix'] . $db_user, $db_passwd, $db_prefix, array('non_fatal' => true, 'dont_select_db' => !$needsDB));
+			if ($db_connection != null)
+			{
+				$db_user = $_POST['db_prefix'] . $db_user;
+				updateSettingsFile(array('db_user' => $db_user));
+			}
+		}
+
+		// Still no connection?  Big fat error message :P.
+		if (!$db_connection)
+		{
+			$incontext['error'] = $txt['error_db_connect'] . '<div style="margin: 2.5ex; font-family: monospace;"><strong>' . $db_error . '</strong></div>';
+			return false;
+		}
+
+		// Do they meet the install requirements?
+		// @todo Old client, new server?
+		if (version_compare($databases[$db_type]['version'], preg_replace('~^\D*|\-.+?$~', '', eval($databases[$db_type]['version_check']))) > 0)
+		{
+			$incontext['error'] = $txt['error_db_too_low'];
+			return false;
+		}
+
+		// Let's try that database on for size... assuming we haven't already lost the opportunity.
+		if ($db_name != '' && !$needsDB)
+		{
+			$smcFunc['db_query']('', "
+				CREATE DATABASE IF NOT EXISTS `$db_name`",
+				array(
+					'security_override' => true,
+					'db_error_skip' => true,
+				),
+				$db_connection
+			);
+
+			// Okay, let's try the prefix if it didn't work...
+			if (!$smcFunc['db_select_db']($db_name, $db_connection) && $db_name != '')
+			{
+				$smcFunc['db_query']('', "
+					CREATE DATABASE IF NOT EXISTS `$_POST[db_prefix]$db_name`",
+					array(
+						'security_override' => true,
+						'db_error_skip' => true,
+					),
+					$db_connection
+				);
+
+				if ($smcFunc['db_select_db']($_POST['db_prefix'] . $db_name, $db_connection))
+				{
+					$db_name = $_POST['db_prefix'] . $db_name;
+					updateSettingsFile(array('db_name' => $db_name));
+				}
+			}
+
+			// Okay, now let's try to connect...
+			if (!$smcFunc['db_select_db']($db_name, $db_connection))
+			{
+				$incontext['error'] = sprintf($txt['error_db_database'], $db_name);
+				return false;
+			}
+		}
+
+		return true;
+	}
+
+	return false;
+}
+
+// Let's start with basic forum type settings.
+function ForumSettings()
+{
+	global $txt, $incontext, $databases, $smcFunc, $db_connection, $db_type;
+
+	$incontext['sub_template'] = 'forum_settings';
+	$incontext['page_title'] = $txt['install_settings'];
+
+	// Let's see if we got the database type correct.
+	if (isset($_POST['db_type'], $databases[$_POST['db_type']]))
+		$db_type = $_POST['db_type'];
+
+	// Else we'd better be able to get the connection.
+	else
+		load_database();
+
+	$db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type;
+
+	// What host and port are we on?
+	$host = empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST'];
+
+	// Now, to put what we've learned together... and add a path.
+	$incontext['detected_url'] = 'http' . (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 's' : '') . '://' . $host . substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/'));
+
+	// Check if the database sessions will even work.
+	$incontext['test_dbsession'] = ini_get('session.auto_start') != 1;
+	$incontext['utf8_should_work'] = stripos(PHP_OS, 'win') !== false;
+	$incontext['utf8_default'] = $databases[$db_type]['utf8_default'];
+	$incontext['utf8_required'] = $databases[$db_type]['utf8_required'];
+
+	$incontext['continue'] = 1;
+
+	// Submitting?
+	if (isset($_POST['boardurl']))
+	{
+		if (substr($_POST['boardurl'], -10) == '/index.php')
+			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
+		elseif (substr($_POST['boardurl'], -1) == '/')
+			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
+		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://')
+			$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
+
+		// Save these variables.
+		$vars = array(
+			'boardurl' => $_POST['boardurl'],
+			'boarddir' => addslashes(dirname(__FILE__)),
+			'sourcedir' => addslashes(dirname(__FILE__)) . '/Sources',
+			'cachedir' => addslashes(dirname(__FILE__)) . '/cache',
+			'mbname' => strtr($_POST['mbname'], array('\"' => '"')),
+			'language' => substr($_SESSION['installer_temp_lang'], 8, -4),
+		);
+
+		// Must save!
+		if (!updateSettingsFile($vars) && substr(__FILE__, 1, 2) == ':\\')
+		{
+			$incontext['error'] = $txt['error_windows_chmod'];
+			return false;
+		}
+
+		// Make sure it works.
+		require(dirname(__FILE__) . '/Settings.php');
+
+		// UTF-8 requires a setting to override the language charset.
+		if (isset($_POST['utf8']) && !empty($databases[$db_type]['utf8_support']))
+		{
+			if (version_compare($databases[$db_type]['utf8_version'], preg_replace('~\-.+?$~', '', eval($databases[$db_type]['utf8_version_check'])), '>'))
+			{
+				$incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']);
+				return false;
+			}
+			else
+				// Set the character set here.
+				updateSettingsFile(array('db_character_set' => 'utf8'));
+		}
+
+		// Good, skip on.
+		return true;
+	}
+
+	return false;
+}
+
+// Step one: Do the SQL thang.
+function DatabasePopulation()
+{
+	global $db_character_set, $txt, $db_connection, $smcFunc, $databases, $modSettings, $db_type, $sourcedir, $db_prefix, $incontext, $db_name, $boardurl;
+
+	$incontext['sub_template'] = 'populate_database';
+	$incontext['page_title'] = $txt['db_populate'];
+	$incontext['continue'] = 1;
+
+	// Already done?
+	if (isset($_POST['pop_done']))
+		return true;
+
+	// Reload settings.
+	require(dirname(__FILE__) . '/Settings.php');
+	load_database();
+
+	// Before running any of the queries, let's make sure another version isn't already installed.
+	$result = $smcFunc['db_query']('', '
+		SELECT variable, value
+		FROM {db_prefix}settings',
+		array(
+			'db_error_skip' => true,
+		)
+	);
+	$modSettings = array();
+	if ($result !== false)
+	{
+		while ($row = $smcFunc['db_fetch_assoc']($result))
+			$modSettings[$row['variable']] = $row['value'];
+		$smcFunc['db_free_result']($result);
+
+		// Do they match?  If so, this is just a refresh so charge on!
+		if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] != $GLOBALS['current_smf_version'])
+		{
+			$incontext['error'] = $txt['error_versions_do_not_match'];
+			return false;
+		}
+	}
+	$modSettings['disableQueryCheck'] = true;
+
+	// If doing UTF8, select it. PostgreSQL requires passing it as a string...
+	if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support']))
+		$smcFunc['db_query']('', '
+			SET NAMES {'. ($db_type == 'postgresql' ? 'string' : 'raw') . ':utf8}',
+			array(
+				'db_error_skip' => true,
+				'utf8' => 'utf8',
+			)
+		);
+
+	$replaces = array(
+		'{$db_prefix}' => $db_prefix,
+		'{$boarddir}' => $smcFunc['db_escape_string'](dirname(__FILE__)),
+		'{$boardurl}' => $boardurl,
+		'{$enableCompressedOutput}' => isset($_POST['compress']) ? '1' : '0',
+		'{$databaseSession_enable}' => isset($_POST['dbsession']) ? '1' : '0',
+		'{$smf_version}' => $GLOBALS['current_smf_version'],
+		'{$current_time}' => time(),
+		'{$sched_task_offset}' => 82800 + mt_rand(0, 86399),
+	);
+
+	foreach ($txt as $key => $value)
+	{
+		if (substr($key, 0, 8) == 'default_')
+			$replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value);
+	}
+	$replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n'));
+
+	// If the UTF-8 setting was enabled, add it to the table definitions.
+	// @todo Very MySQL specific still
+	if ($db_type == 'mysql' && isset($_POST['utf8']) && !empty($databases[$db_type]['utf8_support']))
+		$replaces[') ENGINE=MyISAM;'] = ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;';
+
+	// Read in the SQL.  Turn this on and that off... internationalize... etc.
+	$sql_lines = explode("\n", strtr(implode(' ', file(dirname(__FILE__) . '/install_' . $GLOBALS['db_script_version'] . '_' . $db_type . '.sql')), $replaces));
+
+	// Execute the SQL.
+	$current_statement = '';
+	$exists = array();
+	$incontext['failures'] = array();
+	$incontext['sql_results'] = array(
+		'tables' => 0,
+		'inserts' => 0,
+		'table_dups' => 0,
+		'insert_dups' => 0,
+	);
+	foreach ($sql_lines as $count => $line)
+	{
+		// No comments allowed!
+		if (substr(trim($line), 0, 1) != '#')
+			$current_statement .= "\n" . rtrim($line);
+
+		// Is this the end of the query string?
+		if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines)))
+			continue;
+
+		// Does this table already exist?  If so, don't insert more data into it!
+		if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists))
+		{
+			$incontext['sql_results']['insert_dups']++;
+			$current_statement = '';
+			continue;
+		}
+
+		if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false)
+		{
+			// Error 1050: Table already exists!
+			// @todo Needs to be made better!
+			if (($db_type != 'mysql' || mysql_errno($db_connection) === 1050) && preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1)
+			{
+				$exists[] = $match[1];
+				$incontext['sql_results']['table_dups']++;
+			}
+			// Don't error on duplicate indexes (or duplicate operators in PostgreSQL.)
+			elseif (!preg_match('~^\s*CREATE( UNIQUE)? INDEX ([^\n\r]+?)~', $current_statement, $match) && !($db_type == 'postgresql' && preg_match('~^\s*CREATE OPERATOR (^\n\r]+?)~', $current_statement, $match)))
+			{
+				$incontext['failures'][$count] = $smcFunc['db_error']();
+			}
+		}
+		else
+		{
+			if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1)
+				$incontext['sql_results']['tables']++;
+			else
+			{
+				preg_match_all('~\)[,;]~', $current_statement, $matches);
+				if (!empty($matches[0]))
+					$incontext['sql_results']['inserts'] += count($matches[0]);
+				else
+					$incontext['sql_results']['inserts']++;
+			}
+		}
+
+		$current_statement = '';
+	}
+
+	// Sort out the context for the SQL.
+	foreach ($incontext['sql_results'] as $key => $number)
+	{
+		if ($number == 0)
+			unset($incontext['sql_results'][$key]);
+		else
+			$incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number);
+	}
+
+	// Make sure UTF will be used globally.
+	if (isset($_POST['utf8']) && !empty($databases[$db_type]['utf8_support']))
+		$smcFunc['db_insert']('replace',
+			$db_prefix . 'settings',
+			array(
+				'variable' => 'string-255', 'value' => 'string-65534',
+			),
+			array(
+				'global_character_set', 'UTF-8',
+			),
+			array('variable')
+		);
+
+	// Maybe we can auto-detect better cookie settings?
+	preg_match('~^http[s]?://([^\.]+?)([^/]*?)(/.*)?$~', $boardurl, $matches);
+	if (!empty($matches))
+	{
+		// Default = both off.
+		$localCookies = false;
+		$globalCookies = false;
+
+		// Okay... let's see.  Using a subdomain other than www.? (not a perfect check.)
+		if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www'))))
+			$globalCookies = true;
+		// If there's a / in the middle of the path, or it starts with ~... we want local.
+		if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false))
+			$localCookies = true;
+
+		if ($globalCookies)
+			$rows[] = array('globalCookies', '1');
+		if ($localCookies)
+			$rows[] = array('localCookies', '1');
+
+		if (!empty($rows))
+		{
+			$smcFunc['db_insert']('replace',
+				$db_prefix . 'settings',
+				array('variable' => 'string-255', 'value' => 'string-65534'),
+				$rows,
+				array('variable')
+			);
+		}
+	}
+
+	// Are we allowing stat collection?
+	if (isset($_POST['stats']) && strpos($_POST['boardurl'], 'http://localhost') !== 0)
+	{
+		// Attempt to register the site etc.
+		$fp = @fsockopen("www.simplemachines.org", 80, $errno, $errstr);
+		if ($fp)
+		{
+			$out = "GET /smf/stats/register_stats.php?site=" . base64_encode($_POST['boardurl']) . " HTTP/1.1\r\n";
+			$out .= "Host: www.simplemachines.org\r\n";
+			$out .= "Connection: Close\r\n\r\n";
+			fwrite($fp, $out);
+
+			$return_data = '';
+			while (!feof($fp))
+				$return_data .= fgets($fp, 128);
+
+			fclose($fp);
+
+			// Get the unique site ID.
+			preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID);
+
+			if (!empty($ID[1]))
+				$smcFunc['db_insert']('',
+					$db_prefix . 'settings',
+					array(
+						'variable' => 'string-255', 'value' => 'string-65534',
+					),
+					array(
+						'allow_sm_stats', $ID[1],
+					),
+					array('variable')
+				);
+		}
+	}
+
+	// As of PHP 5.1, setting a timezone is required.
+	if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set'))
+	{
+		$server_offset = mktime(0, 0, 0, 1, 1, 1970);
+		$timezone_id = 'Etc/GMT' . ($server_offset > 0 ? '+' : '') . ($server_offset / 3600);
+		if (date_default_timezone_set($timezone_id))
+			$smcFunc['db_insert']('',
+				$db_prefix . 'settings',
+				array(
+					'variable' => 'string-255', 'value' => 'string-65534',
+				),
+				array(
+					'default_timezone', $timezone_id,
+				),
+				array('variable')
+			);
+	}
+
+	// Let's optimize those new tables.
+	db_extend();
+	$tables = $smcFunc['db_list_tables']($db_name, $db_prefix . '%');
+	foreach ($tables as $table)
+	{
+		$smcFunc['db_optimize_table']($table) != -1 or $db_messed = true;
+
+		// Optimizing one sqlite table, optimizes them all
+		if($db_type == 'sqlite')
+			break;
+
+		if (!empty($db_messed))
+		{
+			$incontext['failures'][-1] = $smcFunc['db_error']();
+			break;
+		}
+	}
+
+	// Check for the ALTER privilege.
+	if (!empty($databases[$db_type]['alter_support']) && $smcFunc['db_query']('', "ALTER TABLE {$db_prefix}boards ORDER BY id_board", array('security_override' => true, 'db_error_skip' => true)) === false)
+	{
+		$incontext['error'] = $txt['error_db_alter_priv'];
+		return false;
+	}
+
+	if (!empty($exists))
+	{
+		$incontext['page_title'] = $txt['user_refresh_install'];
+		$incontext['was_refresh'] = true;
+	}
+
+	return false;
+}
+
+// Ask for the administrator login information.
+function AdminAccount()
+{
+	global $txt, $db_type, $db_connection, $databases, $smcFunc, $incontext, $db_prefix, $db_passwd, $sourcedir;
+
+	$incontext['sub_template'] = 'admin_account';
+	$incontext['page_title'] = $txt['user_settings'];
+	$incontext['continue'] = 1;
+
+	// Skipping?
+	if (!empty($_POST['skip']))
+		return true;
+
+	// Need this to check whether we need the database password.
+	require(dirname(__FILE__) . '/Settings.php');
+	load_database();
+
+	// Define the sha1 function, if it doesn't exist.
+	if (!function_exists('sha1') || version_compare(PHP_VERSION, '5', '<'))
+		require_once($sourcedir . '/Subs-Compat.php');
+
+	if (!isset($_POST['username']))
+		$_POST['username'] = '';
+	if (!isset($_POST['email']))
+		$_POST['email'] = '';
+
+	$incontext['username'] = htmlspecialchars(stripslashes($_POST['username']));
+	$incontext['email'] = htmlspecialchars(stripslashes($_POST['email']));
+
+	$incontext['require_db_confirm'] = empty($db_type) || $db_type != 'sqlite';
+
+	// Only allow skipping if we think they already have an account setup.
+	$request = $smcFunc['db_query']('', '
+		SELECT id_member
+		FROM {db_prefix}members
+		WHERE id_group = {int:admin_group} OR FIND_IN_SET({int:admin_group}, additional_groups) != 0
+		LIMIT 1',
+		array(
+			'db_error_skip' => true,
+			'admin_group' => 1,
+		)
+	);
+	if ($smcFunc['db_num_rows']($request) != 0)
+		$incontext['skip'] = 1;
+	$smcFunc['db_free_result']($request);
+
+	// Trying to create an account?
+	if (isset($_POST['password1']) && !empty($_POST['contbutt']))
+	{
+		// Wrong password?
+		if ($incontext['require_db_confirm'] && $_POST['password3'] != $db_passwd)
+		{
+			$incontext['error'] = $txt['error_db_connect'];
+			return false;
+		}
+		// Not matching passwords?
+		if ($_POST['password1'] != $_POST['password2'])
+		{
+			$incontext['error'] = $txt['error_user_settings_again_match'];
+			return false;
+		}
+		// No password?
+		if (strlen($_POST['password1']) < 4)
+		{
+			$incontext['error'] = $txt['error_user_settings_no_password'];
+			return false;
+		}
+		if (!file_exists($sourcedir . '/Subs.php'))
+		{
+			$incontext['error'] = $txt['error_subs_missing'];
+			return false;
+		}
+
+		// Update the main contact email?
+		if (!empty($_POST['email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]'))
+			updateSettingsFile(array('webmaster_email' => $_POST['email']));
+
+		// Work out whether we're going to have dodgy characters and remove them.
+		$invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0;
+		$_POST['username'] = preg_replace('~[<>&"\'=\\\]~', '', $_POST['username']);
+
+		$result = $smcFunc['db_query']('', '
+			SELECT id_member, password_salt
+			FROM {db_prefix}members
+			WHERE member_name = {string:username} OR email_address = {string:email}
+			LIMIT 1',
+			array(
+				'username' => stripslashes($_POST['username']),
+				'email' => stripslashes($_POST['email']),
+				'db_error_skip' => true,
+			)
+		);
+		if ($smcFunc['db_num_rows']($result) != 0)
+		{
+			list ($incontext['member_id'], $incontext['member_salt']) = $smcFunc['db_fetch_row']($result);
+			$smcFunc['db_free_result']($result);
+
+			$incontext['account_existed'] = $txt['error_user_settings_taken'];
+		}
+		elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25)
+		{
+			// Try the previous step again.
+			$incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long'];
+			return false;
+		}
+		elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false)
+		{
+			// Try the previous step again.
+			$incontext['error'] = $txt['error_invalid_characters_username'];
+			return false;
+		}
+		elseif (empty($_POST['email']) || preg_match('~^[0-9A-Za-z=_+\-/][0-9A-Za-z=_\'+\-/\.]*@[\w\-]+(\.[\w\-]+)*(\.[\w]{2,6})$~', stripslashes($_POST['email'])) === 0 || strlen(stripslashes($_POST['email'])) > 255)
+		{
+			// One step back, this time fill out a proper email address.
+			$incontext['error'] = sprintf($txt['error_valid_email_needed'], $_POST['username']);
+			return false;
+		}
+		elseif ($_POST['username'] != '')
+		{
+			$incontext['member_salt'] = substr(md5(mt_rand()), 0, 4);
+
+			// Format the username properly.
+			$_POST['username'] = preg_replace('~[\t\n\r\x0B\0\xA0]+~', ' ', $_POST['username']);
+			$ip = isset($_SERVER['REMOTE_ADDR']) ? substr($_SERVER['REMOTE_ADDR'], 0, 255) : '';
+
+			$request = $smcFunc['db_insert']('',
+				$db_prefix . 'members',
+				array(
+					'member_name' => 'string-25', 'real_name' => 'string-25', 'passwd' => 'string', 'email_address' => 'string',
+					'id_group' => 'int', 'posts' => 'int', 'date_registered' => 'int', 'hide_email' => 'int',
+					'password_salt' => 'string', 'lngfile' => 'string', 'personal_text' => 'string', 'avatar' => 'string',
+					'member_ip' => 'string', 'member_ip2' => 'string', 'buddy_list' => 'string', 'pm_ignore_list' => 'string',
+					'message_labels' => 'string', 'website_title' => 'string', 'website_url' => 'string', 'location' => 'string',
+					'aim' => 'string', 'icq' => 'string', 'msn' => 'string', 'signature' => 'string', 'usertitle' => 'string', 'secret_question' => 'string',
+					'additional_groups' => 'string', 'ignore_boards' => 'string', 'openid_uri' => 'string',
+				),
+				array(
+					stripslashes($_POST['username']), stripslashes($_POST['username']), sha1(strtolower(stripslashes($_POST['username'])) . stripslashes($_POST['password1'])), stripslashes($_POST['email']),
+					1, 0, time(), 0,
+					$incontext['member_salt'], '', '', '',
+					$ip, $ip, '', '',
+					'', '', '', '',
+					'', '', '', '', '', '',
+					'', '', '',
+				),
+				array('id_member')
+			);
+
+			// Awww, crud!
+			if ($request === false)
+			{
+				$incontext['error'] = $txt['error_user_settings_query'] . '<br />
+				<div style="margin: 2ex;">' . nl2br(htmlspecialchars($smcFunc['db_error']($db_connection))) . '</div>';
+				return false;
+			}
+
+			$incontext['member_id'] = $smcFunc['db_insert_id']("{$db_prefix}members", 'id_member');
+		}
+
+		// If we're here we're good.
+		return true;
+	}
+
+	return false;
+}
+
+// Final step, clean up and a complete message!
+function DeleteInstall()
+{
+	global $txt, $db_prefix, $db_connection, $HTTP_SESSION_VARS, $cookiename, $incontext;
+	global $smcFunc, $db_character_set, $mbname, $context, $scripturl, $boardurl;
+	global $current_smf_version, $databases, $sourcedir, $forum_version, $modSettings, $user_info, $language, $db_type;
+
+	$incontext['page_title'] = $txt['congratulations'];
+	$incontext['sub_template'] = 'delete_install';
+	$incontext['continue'] = 0;
+
+	require(dirname(__FILE__) . '/Settings.php');
+	load_database();
+
+	chdir(dirname(__FILE__));
+
+	require_once($sourcedir . '/Errors.php');
+	require_once($sourcedir . '/Logging.php');
+	require_once($sourcedir . '/Subs.php');
+	require_once($sourcedir . '/Load.php');
+	require_once($sourcedir . '/Security.php');
+	require_once($sourcedir . '/Subs-Auth.php');
+
+	// Bring a warning over.
+	if (!empty($incontext['account_existed']))
+		$incontext['warning'] = $incontext['account_existed'];
+
+	if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support']))
+		$smcFunc['db_query']('', '
+			SET NAMES {raw:db_character_set}',
+			array(
+				'db_character_set' => $db_character_set,
+				'db_error_skip' => true,
+			)
+		);
+
+	// As track stats is by default enabled let's add some activity.
+	$smcFunc['db_insert']('ignore',
+		'{db_prefix}log_activity',
+		array('date' => 'date', 'topics' => 'int', 'posts' => 'int', 'registers' => 'int'),
+		array(strftime('%Y-%m-%d', time()), 1, 1, (!empty($incontext['member_id']) ? 1 : 0)),
+		array('date')
+	);
+
+	// We're going to want our lovely $modSettings now.
+	$request = $smcFunc['db_query']('', '
+		SELECT variable, value
+		FROM {db_prefix}settings',
+		array(
+			'db_error_skip' => true,
+		)
+	);
+	// Only proceed if we can load the data.
+	if ($request)
+	{
+		while ($row = $smcFunc['db_fetch_row']($request))
+			$modSettings[$row[0]] = $row[1];
+		$smcFunc['db_free_result']($request);
+	}
+
+	// Automatically log them in ;)
+	if (isset($incontext['member_id']) && isset($incontext['member_salt']))
+		setLoginCookie(3153600 * 60, $incontext['member_id'], sha1(sha1(strtolower($_POST['username']) . $_POST['password1']) . $incontext['member_salt']));
+
+	$result = $smcFunc['db_query']('', '
+		SELECT value
+		FROM {db_prefix}settings
+		WHERE variable = {string:db_sessions}',
+		array(
+			'db_sessions' => 'databaseSession_enable',
+			'db_error_skip' => true,
+		)
+	);
+	if ($smcFunc['db_num_rows']($result) != 0)
+		list ($db_sessions) = $smcFunc['db_fetch_row']($result);
+	$smcFunc['db_free_result']($result);
+
+	if (empty($db_sessions))
+		$_SESSION['admin_time'] = time();
+	else
+	{
+		$_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211);
+
+		$smcFunc['db_insert']('replace',
+			'{db_prefix}sessions',
+			array(
+				'session_id' => 'string', 'last_update' => 'int', 'data' => 'string',
+			),
+			array(
+				session_id(), time(), 'USER_AGENT|s:' . strlen($_SERVER['HTTP_USER_AGENT']) . ':"' . $_SERVER['HTTP_USER_AGENT'] . '";admin_time|i:' . time() . ';',
+			),
+			array('session_id')
+		);
+	}
+
+	updateStats('member');
+	updateStats('message');
+	updateStats('topic');
+
+	// This function is needed to do the updateStats('subject') call.
+	$smcFunc['strtolower'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8' ? create_function('$string', '
+		return $string;') : 'strtolower';
+
+	$request = $smcFunc['db_query']('', '
+		SELECT id_msg
+		FROM {db_prefix}messages
+		WHERE id_msg = 1
+			AND modified_time = 0
+		LIMIT 1',
+		array(
+			'db_error_skip' => true,
+		)
+	);
+	if ($smcFunc['db_num_rows']($request) > 0)
+		updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject']));
+	$smcFunc['db_free_result']($request);
+
+	// Now is the perfect time to fetch the SM files.
+	require_once($sourcedir . '/ScheduledTasks.php');
+	// Sanity check that they loaded earlier!
+	if (isset($modSettings['recycle_board']))
+	{
+		$forum_version = $current_smf_version;  // The variable is usually defined in index.php so lets just use our variable to do it for us.
+		scheduled_fetchSMfiles(); // Now go get those files!
+
+		// We've just installed!
+		$user_info['ip'] = $_SERVER['REMOTE_ADDR'];
+		$user_info['id'] = isset($incontext['member_id']) ? $incontext['member_id'] : 0;
+		logAction('install', array('version' => $forum_version), 'admin');
+	}
+
+	// Check if we need some stupid MySQL fix.
+	$server_version = $smcFunc['db_server_info']();
+	if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51')))
+		updateSettings(array('db_mysql_group_by_fix' => '1'));
+
+	// Some final context for the template.
+	$incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\';
+	$incontext['probably_delete_install'] = isset($_SESSION['installer_temp_ftp']) || is_writable(dirname(__FILE__)) || is_writable(__FILE__);
+
+	return false;
+}
+
+// http://www.faqs.org/rfcs/rfc959.html
+class ftp_connection
+{
+	var $connection = 'no_connection', $error = false, $last_message, $pasv = array();
+
+	// Create a new FTP connection...
+	function ftp_connection($ftp_server, $ftp_port = 21, $ftp_user = 'anonymous', $ftp_pass = '[email protected]')
+	{
+		if ($ftp_server !== null)
+			$this->connect($ftp_server, $ftp_port, $ftp_user, $ftp_pass);
+	}
+
+	function connect($ftp_server, $ftp_port = 21, $ftp_user = 'anonymous', $ftp_pass = '[email protected]')
+	{
+		if (substr($ftp_server, 0, 6) == 'ftp://')
+			$ftp_server = substr($ftp_server, 6);
+		elseif (substr($ftp_server, 0, 7) == 'ftps://')
+			$ftp_server = 'ssl://' . substr($ftp_server, 7);
+		if (substr($ftp_server, 0, 7) == 'http://')
+			$ftp_server = substr($ftp_server, 7);
+		$ftp_server = strtr($ftp_server, array('/' => '', ':' => '', '@' => ''));
+
+		// Connect to the FTP server.
+		$this->connection = @fsockopen($ftp_server, $ftp_port, $err, $err, 5);
+		if (!$this->connection)
+		{
+			$this->error = 'bad_server';
+			return;
+		}
+
+		// Get the welcome message...
+		if (!$this->check_response(220))
+		{
+			$this->error = 'bad_response';
+			return;
+		}
+
+		// Send the username, it should ask for a password.
+		fwrite($this->connection, 'USER ' . $ftp_user . "\r\n");
+		if (!$this->check_response(331))
+		{
+			$this->error = 'bad_username';
+			return;
+		}
+
+		// Now send the password... and hope it goes okay.
+		fwrite($this->connection, 'PASS ' . $ftp_pass . "\r\n");
+		if (!$this->check_response(230))
+		{
+			$this->error = 'bad_password';
+			return;
+		}
+	}
+
+	function chdir($ftp_path)
+	{
+		if (!is_resource($this->connection))
+			return false;
+
+		// No slash on the end, please...
+		if (substr($ftp_path, -1) == '/')
+			$ftp_path = substr($ftp_path, 0, -1);
+
+		fwrite($this->connection, 'CWD ' . $ftp_path . "\r\n");
+		if (!$this->check_response(250))
+		{
+			$this->error = 'bad_path';
+			return false;
+		}
+
+		return true;
+	}
+
+	function chmod($ftp_file, $chmod)
+	{
+		if (!is_resource($this->connection))
+			return false;
+
+		// Convert the chmod value from octal (0777) to text ("777")
+		fwrite($this->connection, 'SITE CHMOD ' . decoct($chmod) . ' ' . $ftp_file . "\r\n");
+		if (!$this->check_response(200))
+		{
+			$this->error = 'bad_file';
+			return false;
+		}
+
+		return true;
+	}
+
+	function unlink($ftp_file)
+	{
+		// We are actually connected, right?
+		if (!is_resource($this->connection))
+			return false;
+
+		// Delete file X.
+		fwrite($this->connection, 'DELE ' . $ftp_file . "\r\n");
+		if (!$this->check_response(250))
+		{
+			fwrite($this->connection, 'RMD ' . $ftp_file . "\r\n");
+
+			// Still no love?
+			if (!$this->check_response(250))
+			{
+				$this->error = 'bad_file';
+				return false;
+			}
+		}
+
+		return true;
+	}
+
+	function check_response($desired)
+	{
+		// Wait for a response that isn't continued with -, but don't wait too long.
+		$time = time();
+		do
+			$this->last_message = fgets($this->connection, 1024);
+		while (substr($this->last_message, 3, 1) != ' ' && time() - $time < 5);
+
+		// Was the desired response returned?
+		return is_array($desired) ? in_array(substr($this->last_message, 0, 3), $desired) : substr($this->last_message, 0, 3) == $desired;
+	}
+
+	function passive()
+	{
+		// We can't create a passive data connection without a primary one first being there.
+		if (!is_resource($this->connection))
+			return false;
+
+		// Request a passive connection - this means, we'll talk to you, you don't talk to us.
+		@fwrite($this->connection, "PASV\r\n");
+		$time = time();
+		do
+			$response = fgets($this->connection, 1024);
+		while (substr($response, 3, 1) != ' ' && time() - $time < 5);
+
+		// If it's not 227, we weren't given an IP and port, which means it failed.
+		if (substr($response, 0, 4) != '227 ')
+		{
+			$this->error = 'bad_response';
+			return false;
+		}
+
+		// Snatch the IP and port information, or die horribly trying...
+		if (preg_match('~\((\d+),\s*(\d+),\s*(\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+))\)~', $response, $match) == 0)
+		{
+			$this->error = 'bad_response';
+			return false;
+		}
+
+		// This is pretty simple - store it for later use ;)
+		$this->pasv = array('ip' => $match[1] . '.' . $match[2] . '.' . $match[3] . '.' . $match[4], 'port' => $match[5] * 256 + $match[6]);
+
+		return true;
+	}
+
+	function create_file($ftp_file)
+	{
+		// First, we have to be connected... very important.
+		if (!is_resource($this->connection))
+			return false;
+
+		// I'd like one passive mode, please!
+		if (!$this->passive())
+			return false;
+
+		// Seems logical enough, so far...
+		fwrite($this->connection, 'STOR ' . $ftp_file . "\r\n");
+
+		// Okay, now we connect to the data port.  If it doesn't work out, it's probably "file already exists", etc.
+		$fp = @fsockopen($this->pasv['ip'], $this->pasv['port'], $err, $err, 5);
+		if (!$fp || !$this->check_response(150))
+		{
+			$this->error = 'bad_file';
+			@fclose($fp);
+			return false;
+		}
+
+		// This may look strange, but we're just closing it to indicate a zero-byte upload.
+		fclose($fp);
+		if (!$this->check_response(226))
+		{
+			$this->error = 'bad_response';
+			return false;
+		}
+
+		return true;
+	}
+
+	function list_dir($ftp_path = '', $search = false)
+	{
+		// Are we even connected...?
+		if (!is_resource($this->connection))
+			return false;
+
+		// Passive... non-agressive...
+		if (!$this->passive())
+			return false;
+
+		// Get the listing!
+		fwrite($this->connection, 'LIST -1' . ($search ? 'R' : '') . ($ftp_path == '' ? '' : ' ' . $ftp_path) . "\r\n");
+
+		// Connect, assuming we've got a connection.
+		$fp = @fsockopen($this->pasv['ip'], $this->pasv['port'], $err, $err, 5);
+		if (!$fp || !$this->check_response(array(150, 125)))
+		{
+			$this->error = 'bad_response';
+			@fclose($fp);
+			return false;
+		}
+
+		// Read in the file listing.
+		$data = '';
+		while (!feof($fp))
+			$data .= fread($fp, 4096);
+		fclose($fp);
+
+		// Everything go okay?
+		if (!$this->check_response(226))
+		{
+			$this->error = 'bad_response';
+			return false;
+		}
+
+		return $data;
+	}
+
+	function locate($file, $listing = null)
+	{
+		if ($listing === null)
+			$listing = $this->list_dir('', true);
+		$listing = explode("\n", $listing);
+
+		@fwrite($this->connection, "PWD\r\n");
+		$time = time();
+		do
+			$response = fgets($this->connection, 1024);
+		while (substr($response, 3, 1) != ' ' && time() - $time < 5);
+
+		// Check for 257!
+		if (preg_match('~^257 "(.+?)" ~', $response, $match) != 0)
+			$current_dir = strtr($match[1], array('""' => '"'));
+		else
+			$current_dir = '';
+
+		for ($i = 0, $n = count($listing); $i < $n; $i++)
+		{
+			if (trim($listing[$i]) == '' && isset($listing[$i + 1]))
+			{
+				$current_dir = substr(trim($listing[++$i]), 0, -1);
+				$i++;
+			}
+
+			// Okay, this file's name is:
+			$listing[$i] = $current_dir . '/' . trim(strlen($listing[$i]) > 30 ? strrchr($listing[$i], ' ') : $listing[$i]);
+
+			if (substr($file, 0, 1) == '*' && substr($listing[$i], -(strlen($file) - 1)) == substr($file, 1))
+				return $listing[$i];
+			if (substr($file, -1) == '*' && substr($listing[$i], 0, strlen($file) - 1) == substr($file, 0, -1))
+				return $listing[$i];
+			if (basename($listing[$i]) == $file || $listing[$i] == $file)
+				return $listing[$i];
+		}
+
+		return false;
+	}
+
+	function create_dir($ftp_dir)
+	{
+		// We must be connected to the server to do something.
+		if (!is_resource($this->connection))
+			return false;
+
+		// Make this new beautiful directory!
+		fwrite($this->connection, 'MKD ' . $ftp_dir . "\r\n");
+		if (!$this->check_response(257))
+		{
+			$this->error = 'bad_file';
+			return false;
+		}
+
+		return true;
+	}
+
+	function detect_path($filesystem_path, $lookup_file = null)
+	{
+		$username = '';
+
+		if (isset($_SERVER['DOCUMENT_ROOT']))
+		{
+			if (preg_match('~^/home[2]?/([^/]+?)/public_html~', $_SERVER['DOCUMENT_ROOT'], $match))
+			{
+				$username = $match[1];
+
+				$path = strtr($_SERVER['DOCUMENT_ROOT'], array('/home/' . $match[1] . '/' => '', '/home2/' . $match[1] . '/' => ''));
+
+				if (substr($path, -1) == '/')
+					$path = substr($path, 0, -1);
+
+				if (strlen(dirname($_SERVER['PHP_SELF'])) > 1)
+					$path .= dirname($_SERVER['PHP_SELF']);
+			}
+			elseif (substr($filesystem_path, 0, 9) == '/var/www/')
+				$path = substr($filesystem_path, 8);
+			else
+				$path = strtr(strtr($filesystem_path, array('\\' => '/')), array($_SERVER['DOCUMENT_ROOT'] => ''));
+		}
+		else
+			$path = '';
+
+		if (is_resource($this->connection) && $this->list_dir($path) == '')
+		{
+			$data = $this->list_dir('', true);
+
+			if ($lookup_file === null)
+				$lookup_file = $_SERVER['PHP_SELF'];
+
+			$found_path = dirname($this->locate('*' . basename(dirname($lookup_file)) . '/' . basename($lookup_file), $data));
+			if ($found_path == false)
+				$found_path = dirname($this->locate(basename($lookup_file)));
+			if ($found_path != false)
+				$path = $found_path;
+		}
+		elseif (is_resource($this->connection))
+			$found_path = true;
+
+		return array($username, $path, isset($found_path));
+	}
+
+	function close()
+	{
+		// Goodbye!
+		fwrite($this->connection, "QUIT\r\n");
+		fclose($this->connection);
+
+		return true;
+	}
+}
+
+function updateSettingsFile($vars)
+{
+	// Modify Settings.php.
+	$settingsArray = file(dirname(__FILE__) . '/Settings.php');
+
+	// @todo Do we just want to read the file in clean, and split it this way always?
+	if (count($settingsArray) == 1)
+		$settingsArray = preg_split('~[\r\n]~', $settingsArray[0]);
+
+	for ($i = 0, $n = count($settingsArray); $i < $n; $i++)
+	{
+		// Remove the redirect...
+		if (trim($settingsArray[$i]) == 'if (file_exists(dirname(__FILE__) . \'/install.php\'))' && trim($settingsArray[$i + 1]) == '{' && trim($settingsArray[$i + 3]) == '}')
+		{
+			// Get the four lines to nothing.
+			$settingsArray[$i] = '';
+			$settingsArray[++$i] = '';
+			$settingsArray[++$i] = '';
+			$settingsArray[++$i] = '';
+			continue;
+		}
+
+		if (trim($settingsArray[$i]) == '?' . '>')
+			$settingsArray[$i] = '';
+
+		// Don't trim or bother with it if it's not a variable.
+		if (substr($settingsArray[$i], 0, 1) != '$')
+			continue;
+
+		$settingsArray[$i] = rtrim($settingsArray[$i]) . "\n";
+
+		foreach ($vars as $var => $val)
+			if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
+			{
+				$comment = strstr($settingsArray[$i], '#');
+				$settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n");
+				unset($vars[$var]);
+			}
+	}
+
+	// Uh oh... the file wasn't empty... was it?
+	if (!empty($vars))
+	{
+		$settingsArray[$i++] = '';
+		foreach ($vars as $var => $val)
+			$settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n";
+	}
+
+	// Blank out the file - done to fix a oddity with some servers.
+	$fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w');
+	if (!$fp)
+		return false;
+	fclose($fp);
+
+	$fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+');
+
+	// Gotta have one of these ;)
+	if (trim($settingsArray[0]) != '<?php')
+		fwrite($fp, "<?php\n");
+
+	$lines = count($settingsArray);
+	for ($i = 0; $i < $lines - 1; $i++)
+	{
+		// Don't just write a bunch of blank lines.
+		if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '')
+			fwrite($fp, strtr($settingsArray[$i], "\r", ''));
+	}
+	fwrite($fp, $settingsArray[$i] . '?' . '>');
+	fclose($fp);
+
+	return true;
+}
+
+// Create an .htaccess file to prevent mod_security. SMF has filtering built-in.
+function fixModSecurity()
+{
+	$htaccess_addition = '
+<IfModule mod_security.c>
+	# Turn off mod_security filtering.  SMF is a big boy, it doesn\'t need its hands held.
+	SecFilterEngine Off
+
+	# The below probably isn\'t needed, but better safe than sorry.
+	SecFilterScanPOST Off
+</IfModule>';
+
+	if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules()))
+		return true;
+	elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess'))
+	{
+		$current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess'));
+
+		// Only change something if mod_security hasn't been addressed yet.
+		if (strpos($current_htaccess, '<IfModule mod_security.c>') === false)
+		{
+			if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'a'))
+			{
+				fwrite($ht_handle, $htaccess_addition);
+				fclose($ht_handle);
+				return true;
+			}
+			else
+				return false;
+		}
+		else
+			return true;
+	}
+	elseif (file_exists(dirname(__FILE__) . '/.htaccess'))
+		return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false;
+	elseif (is_writable(dirname(__FILE__)))
+	{
+		if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w'))
+		{
+			fwrite($ht_handle, $htaccess_addition);
+			fclose($ht_handle);
+			return true;
+		}
+		else
+			return false;
+	}
+	else
+		return false;
+}
+
+function template_install_above()
+{
+	global $incontext, $txt, $smfsite, $installurl;
+
+	echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"', !empty($txt['lang_rtl']) ? ' dir="rtl"' : '', '>
+	<head>
+		<meta http-equiv="Content-Type" content="text/html; charset=', isset($txt['lang_character_set']) ? $txt['lang_character_set'] : 'ISO-8859-1', '" />
+		<meta name="robots" content="noindex" />
+		<title>', $txt['smf_installer'], '</title>
+		<link rel="stylesheet" type="text/css" href="Themes/default/css/index.css?fin20" />
+		<link rel="stylesheet" type="text/css" href="Themes/default/css/install.css?fin20" />
+		<script type="text/javascript" src="Themes/default/scripts/script.js"></script>
+	</head>
+	<body>
+	<div id="header"><div class="frame">
+		<div id="top_section">
+			<h1 class="forumtitle">', $txt['smf_installer'], '</h1>
+			<img id="smflogo" src="Themes/default/images/smflogo.png" alt="Simple Machines Forum" title="Simple Machines Forum" />
+		</div>
+		<div id="upper_section" class="middletext flow_hidden">
+			<div class="user"></div>
+			<div class="news normaltext">';
+
+	// Have we got a language drop down - if so do it on the first step only.
+	if (!empty($incontext['detected_languages']) && count($incontext['detected_languages']) > 1 && $incontext['current_step'] == 0)
+	{
+		echo '
+				<div class="righttext">
+					<form action="', $installurl, '" method="get">
+						<label for="installer_language">', $txt['installer_language'], ':</label> <select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">';
+
+		foreach ($incontext['detected_languages'] as $lang => $name)
+			echo '
+							<option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected="selected"' : '', ' value="', $lang, '">', $name, '</option>';
+
+		echo '
+						</select>
+						<noscript><input type="submit" value="', $txt['installer_language_set'], '" class="button_submit" /></noscript>
+					</form>
+				</div>';
+	}
+
+	echo '
+			</div>
+		</div>
+	</div></div>
+	<div id="content_section"><div class="frame">
+		<div id="main_content_section">
+			<div id="main-steps">
+				<h2>', $txt['upgrade_progress'], '</h2>
+				<ul>';
+
+	foreach ($incontext['steps'] as $num => $step)
+		echo '
+					<li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>';
+
+	echo '
+				</ul>
+			</div>
+			<div style="font-size: 12pt; height: 25pt; border: 1px solid black; background: white; float: left; margin-left: 12%; width: 25%;">
+				<div id="overall_text" style="padding-top: 8pt; z-index: 2; color: black; margin-left: -4em; position: absolute; text-align: center; font-weight: bold;">', $incontext['overall_percent'], '%</div>
+				<div id="overall_progress" style="width: ', $incontext['overall_percent'], '%; height: 25pt; z-index: 1; background-color: lime;">&nbsp;</div>
+				<div class="overall_progress">', $txt['upgrade_overall_progress'], '</div>
+			</div>
+			<div id="main_screen" class="clear">
+				<h2>', $incontext['page_title'], '</h2>
+				<div class="panel">
+					<div style="max-height: 560px; overflow: auto;">';
+}
+
+function template_install_below()
+{
+	global $incontext, $txt;
+
+	if (!empty($incontext['continue']) || !empty($incontext['skip']))
+	{
+		echo '
+						<div class="righttext" style="margin: 1ex;">';
+
+		if (!empty($incontext['continue']))
+			echo '
+							<input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button_submit" />';
+		if (!empty($incontext['skip']))
+			echo '
+							<input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button_submit" />';
+		echo '
+						</div>';
+	}
+
+	// Show the closing form tag and other data only if not in the last step
+	if (count($incontext['steps']) - 1 !== (int) $incontext['current_step'])
+		echo '
+							</form>';
+
+	echo '
+					</div>
+				</div>
+			</div>
+		</div>
+	</div></div>
+	<div id="footer_section"><div class="frame" style="height: 40px;">
+		<div class="smalltext"><a href="http://www.simplemachines.org/" title="Simple Machines Forum" target="_blank" class="new_win">SMF &copy; 2011, Simple Machines</a></div>
+	</div></div>
+	</body>
+</html>';
+}
+
+// Welcome them to the wonderful world of SMF!
+function template_welcome_message()
+{
+	global $incontext, $installurl, $txt;
+
+	echo '
+	<script type="text/javascript" src="http://www.simplemachines.org/smf/current-version.js?version=' . $GLOBALS['current_smf_version'] . '"></script>
+	<form action="', $incontext['form_url'], '" method="post">
+		<p>', sprintf($txt['install_welcome_desc'], $GLOBALS['current_smf_version']), '</p>
+		<div id="version_warning" style="margin: 2ex; padding: 2ex; border: 2px dashed #a92174; color: black; background-color: #fbbbe2; display: none;">
+			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
+			<strong style="text-decoration: underline;">', $txt['error_warning_notice'], '</strong><br />
+			<div style="padding-left: 6ex;">
+				', sprintf($txt['error_script_outdated'], '<em id="smfVersion" style="white-space: nowrap;">??</em>', '<em id="yourVersion" style="white-space: nowrap;">' . $GLOBALS['current_smf_version'] . '</em>'), '
+			</div>
+		</div>';
+
+	// Show the warnings, or not.
+	if (template_warning_divs())
+		echo '
+		<h3>', $txt['install_all_lovely'], '</h3>';
+
+	echo '
+		<div style="height: 100px;"></div>';
+
+	// Say we want the continue button!
+	if (empty($incontext['error']))
+		$incontext['continue'] = 1;
+
+	// For the latest version stuff.
+	echo '
+		<script type="text/javascript"><!-- // --><![CDATA[
+			// Latest version?
+			function smfCurrentVersion()
+			{
+				var smfVer, yourVer;
+
+				if (!(\'smfVersion\' in window))
+					return;
+
+				window.smfVersion = window.smfVersion.replace(/SMF\s?/g, \'\');
+
+				smfVer = document.getElementById("smfVersion");
+				yourVer = document.getElementById("yourVersion");
+
+				setInnerHTML(smfVer, window.smfVersion);
+
+				var currentVersion = getInnerHTML(yourVer);
+				if (currentVersion < window.smfVersion)
+					document.getElementById(\'version_warning\').style.display = \'\';
+			}
+			addLoadEvent(smfCurrentVersion);
+		// ]]></script>';
+}
+
+// A shortcut for any warning stuff.
+function template_warning_divs()
+{
+	global $txt, $incontext;
+
+	// Errors are very serious..
+	if (!empty($incontext['error']))
+		echo '
+		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
+			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
+			<strong style="text-decoration: underline;">', $txt['upgrade_critical_error'], '</strong><br />
+			<div style="padding-left: 6ex;">
+				', $incontext['error'], '
+			</div>
+		</div>';
+	// A warning message?
+	elseif (!empty($incontext['warning']))
+		echo '
+		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
+			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
+			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br />
+			<div style="padding-left: 6ex;">
+				', $incontext['warning'], '
+			</div>
+		</div>';
+
+	return empty($incontext['error']) && empty($incontext['warning']);
+}
+
+function template_chmod_files()
+{
+	global $txt, $incontext;
+
+	echo '
+		<p>', $txt['ftp_setup_why_info'], '</p>
+		<ul style="margin: 2.5ex; font-family: monospace;">
+			<li>', implode('</li>
+			<li>', $incontext['failed_files']), '</li>
+		</ul>';
+
+	// This is serious!
+	if (!template_warning_divs())
+		return;
+
+	echo '
+		<hr />
+		<p>', $txt['ftp_setup_info'], '</p>';
+
+	if (!empty($incontext['ftp_errors']))
+		echo '
+		<div class="error_message">
+			<div style="color: red;">
+				', $txt['error_ftp_no_connect'], '<br />
+				<br />
+				<code>', implode('<br />', $incontext['ftp_errors']), '</code>
+			</div>
+		</div>
+		<br />';
+
+	echo '
+		<form action="', $incontext['form_url'], '" method="post">
+			<table width="520" cellspacing="0" cellpadding="0" border="0" align="center" style="margin: 1em 0;">
+				<tr>
+					<td width="26%" valign="top" class="textbox"><label for="ftp_server">', $txt['ftp_server'], ':</label></td>
+					<td>
+						<div style="float: ', empty($txt['lang_rtl']) ? 'right' : 'left', '; margin-', empty($txt['lang_rtl']) ? 'right' : 'left', ': 1px;"><label for="ftp_port" class="textbox"><strong>', $txt['ftp_port'], ':&nbsp;</strong></label> <input type="text" size="3" name="ftp_port" id="ftp_port" value="', $incontext['ftp']['port'], '" class="input_text" /></div>
+						<input type="text" size="30" name="ftp_server" id="ftp_server" value="', $incontext['ftp']['server'], '" style="width: 70%;" class="input_text" />
+						<div style="font-size: smaller; margin-bottom: 2ex;">', $txt['ftp_server_info'], '</div>
+					</td>
+				</tr><tr>
+					<td width="26%" valign="top" class="textbox"><label for="ftp_username">', $txt['ftp_username'], ':</label></td>
+					<td>
+						<input type="text" size="50" name="ftp_username" id="ftp_username" value="', $incontext['ftp']['username'], '" style="width: 99%;" class="input_text" />
+						<div style="font-size: smaller; margin-bottom: 2ex;">', $txt['ftp_username_info'], '</div>
+					</td>
+				</tr><tr>
+					<td width="26%" valign="top" class="textbox"><label for="ftp_password">', $txt['ftp_password'], ':</label></td>
+					<td>
+						<input type="password" size="50" name="ftp_password" id="ftp_password" style="width: 99%;" class="input_password" />
+						<div style="font-size: smaller; margin-bottom: 3ex;">', $txt['ftp_password_info'], '</div>
+					</td>
+				</tr><tr>
+					<td width="26%" valign="top" class="textbox"><label for="ftp_path">', $txt['ftp_path'], ':</label></td>
+					<td style="padding-bottom: 1ex;">
+						<input type="text" size="50" name="ftp_path" id="ftp_path" value="', $incontext['ftp']['path'], '" style="width: 99%;" class="input_text" />
+						<div style="font-size: smaller; margin-bottom: 2ex;">', $incontext['ftp']['path_msg'], '</div>
+					</td>
+				</tr>
+			</table>
+			<div style="margin: 1ex; margin-top: 1ex; text-align: ', empty($txt['lang_rtl']) ? 'right' : 'left', ';"><input type="submit" value="', $txt['ftp_connect'], '" onclick="return submitThisOnce(this);" class="button_submit" /></div>
+		</form>
+		<a href="', $incontext['form_url'], '">', $txt['error_message_click'], '</a> ', $txt['ftp_setup_again'];
+}
+
+// Get the database settings prepared.
+function template_database_settings()
+{
+	global $incontext, $installurl, $txt;
+
+	echo '
+	<form action="', $incontext['form_url'], '" method="post">
+		<p>', $txt['db_settings_info'], '</p>';
+
+	template_warning_divs();
+
+	echo '
+		<table width="100%" cellpadding="0" cellspacing="0" border="0" style="margin: 1em 0;">';
+
+	// More than one database type?
+	if (count($incontext['supported_databases']) > 1)
+	{
+		echo '
+			<tr>
+				<td width="20%" valign="top" class="textbox"><label for="db_type_input">', $txt['db_settings_type'], ':</label></td>
+				<td>
+					<select name="db_type" id="db_type_input" onchange="toggleDBInput();">';
+
+	foreach ($incontext['supported_databases'] as $key => $db)
+			echo '
+						<option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected="selected"' : '', '>', $db['name'], '</option>';
+
+	echo '
+					</select><div id="db_sqlite_warning" style="color: blue; display: none;" class="smalltext">', $txt['db_sqlite_warning'], '</div>
+					<div style="font-size: smaller; margin-bottom: 2ex;">', $txt['db_settings_type_info'], '</div>
+				</td>
+			</tr>';
+	}
+	else
+	{
+		echo '
+			<tr style="display: none;">
+				<td>
+					<input type="hidden" name="db_type" value="', $incontext['db']['type'], '" />
+				</td>
+			</tr>';
+	}
+
+	echo '
+			<tr id="db_server_contain">
+				<td width="20%" valign="top" class="textbox"><label for="db_server_input">', $txt['db_settings_server'], ':</label></td>
+				<td>
+					<input type="text" name="db_server" id="db_server_input" value="', $incontext['db']['server'], '" size="30" class="input_text" /><br />
+					<div style="font-size: smaller; margin-bottom: 2ex;">', $txt['db_settings_server_info'], '</div>
+				</td>
+			</tr><tr id="db_user_contain">
+				<td valign="top" class="textbox"><label for="db_user_input">', $txt['db_settings_username'], ':</label></td>
+				<td>
+					<input type="text" name="db_user" id="db_user_input" value="', $incontext['db']['user'], '" size="30" class="input_text" /><br />
+					<div style="font-size: smaller; margin-bottom: 2ex;">', $txt['db_settings_username_info'], '</div>
+				</td>
+			</tr><tr id="db_passwd_contain">
+				<td valign="top" class="textbox"><label for="db_passwd_input">', $txt['db_settings_password'], ':</label></td>
+				<td>
+					<input type="password" name="db_passwd" id="db_passwd_input" value="', $incontext['db']['pass'], '" size="30" class="input_password" /><br />
+					<div style="font-size: smaller; margin-bottom: 2ex;">', $txt['db_settings_password_info'], '</div>
+				</td>
+			</tr><tr id="db_name_contain">
+				<td valign="top" class="textbox"><label for="db_name_input">', $txt['db_settings_database'], ':</label></td>
+				<td>
+					<input type="text" name="db_name" id="db_name_input" value="', empty($incontext['db']['name']) ? 'smf' : $incontext['db']['name'], '" size="30" class="input_text" /><br />
+					<div style="font-size: smaller; margin-bottom: 2ex;">', $txt['db_settings_database_info'], '
+					<span id="db_name_info_warning">', $txt['db_settings_database_info_note'], '</span></div>
+				</td>
+			</tr><tr id="db_filename_contain" style="display: none;">
+				<td valign="top" class="textbox"><label for="db_filename_input">', $txt['db_settings_database_file'], ':</label></td>
+				<td>
+					<input type="text" name="db_filename" id="db_filename_input" value="', empty($incontext['db']['name']) ? dirname(__FILE__) . '/smf_' . substr(md5(microtime()), 0, 10) : stripslashes($incontext['db']['name']), '" size="30" class="input_text" /><br />
+					<div style="font-size: smaller; margin-bottom: 2ex;">', $txt['db_settings_database_file_info'], '</div>
+				</td>
+			</tr><tr>
+				<td valign="top" class="textbox"><label for="db_prefix_input">', $txt['db_settings_prefix'], ':</label></td>
+				<td>
+					<input type="text" name="db_prefix" id="db_prefix_input" value="', $incontext['db']['prefix'], '" size="30" class="input_text" /><br />
+					<div style="font-size: smaller; margin-bottom: 2ex;">', $txt['db_settings_prefix_info'], '</div>
+				</td>
+			</tr>
+		</table>';
+
+	// Allow the toggling of input boxes for SQLite etc.
+	echo '
+	<script type="text/javascript"><!-- // --><![CDATA[
+		function toggleDBInput()
+		{
+			// What state is it?';
+
+	if (!isset($incontext['supported_databases']['sqlite']))
+		echo '
+			var showAll = true;';
+	elseif (count($incontext['supported_databases']) < 2)
+		echo '
+			var showAll = false;';
+	// If we have more than one DB including SQLite, what should we be doing?
+	else
+		echo '
+			var showAll = document.getElementById(\'db_type_input\').value == \'sqlite\' ? false : true;';
+
+	echo '
+			document.getElementById(\'db_passwd_contain\').style.display = showAll ? \'\' : \'none\';
+			document.getElementById(\'db_server_contain\').style.display = showAll ? \'\' : \'none\';
+			document.getElementById(\'db_user_contain\').style.display = showAll ? \'\' : \'none\';
+			document.getElementById(\'db_name_contain\').style.display = showAll ? \'\' : \'none\';
+			document.getElementById(\'db_filename_contain\').style.display = !showAll ? \'\' : \'none\';
+			document.getElementById(\'db_sqlite_warning\').style.display = !showAll ? \'\' : \'none\';
+			if (document.getElementById(\'db_type_input\').value == \'postgresql\')
+				document.getElementById(\'db_name_info_warning\').style.display = \'none\';
+			else
+				document.getElementById(\'db_name_info_warning\').style.display = \'\';
+		}
+		toggleDBInput();
+	// ]]></script>';
+}
+
+// Stick in their forum settings.
+function template_forum_settings()
+{
+	global $incontext, $installurl, $txt;
+
+	echo '
+	<form action="', $incontext['form_url'], '" method="post">
+		<h3>', $txt['install_settings_info'], '</h3>';
+
+	template_warning_divs();
+
+	echo '
+		<table width="100%" cellpadding="0" cellspacing="0" border="0" style="margin: 1em 0;">
+			<tr>
+				<td width="20%" valign="top" class="textbox"><label for="mbname_input">', $txt['install_settings_name'], ':</label></td>
+				<td>
+					<input type="text" name="mbname" id="mbname_input" value="', $txt['install_settings_name_default'], '" size="65" class="input_text" />
+					<div style="font-size: smaller; margin-bottom: 2ex;">', $txt['install_settings_name_info'], '</div>
+				</td>
+			</tr><tr>
+				<td valign="top" class="textbox"><label for="boardurl_input">', $txt['install_settings_url'], ':</label></td>
+				<td>
+					<input type="text" name="boardurl" id="boardurl_input" value="', $incontext['detected_url'], '" size="65" class="input_text" /><br />
+					<div style="font-size: smaller; margin-bottom: 2ex;">', $txt['install_settings_url_info'], '</div>
+				</td>
+			</tr><tr>
+				<td valign="top" class="textbox">', $txt['install_settings_compress'], ':</td>
+				<td>
+					<input type="checkbox" name="compress" id="compress_check" checked="checked" class="input_check" /> <label for="compress_check">', $txt['install_settings_compress_title'], '</label><br />
+					<div style="font-size: smaller; margin-bottom: 2ex;">', $txt['install_settings_compress_info'], '</div>
+				</td>
+			</tr><tr>
+				<td valign="top" class="textbox">', $txt['install_settings_dbsession'], ':</td>
+				<td>
+					<input type="checkbox" name="dbsession" id="dbsession_check" checked="checked" class="input_check" /> <label for="dbsession_check">', $txt['install_settings_dbsession_title'], '</label><br />
+					<div style="font-size: smaller; margin-bottom: 2ex;">', $incontext['test_dbsession'] ? $txt['install_settings_dbsession_info1'] : $txt['install_settings_dbsession_info2'], '</div>
+				</td>
+			</tr>';
+
+	if ($incontext['utf8_should_work'])
+		echo '
+			<tr>
+				<td valign="top" class="textbox">', $txt['install_settings_utf8'], ':</td>
+				<td>
+					<input type="checkbox" name="utf8" id="utf8_check"', $incontext['utf8_default'] ? ' checked="checked"' : '', ' class="input_check"', $incontext['utf8_required'] ? ' disabled="disabled"' : '', ' /> <label for="utf8_check">', $txt['install_settings_utf8_title'], '</label><br />
+					<div style="font-size: smaller; margin-bottom: 2ex;">', $txt['install_settings_utf8_info'], '</div>
+				</td>
+			</tr>';
+
+	echo '
+			<tr>
+				<td valign="top" class="textbox">', $txt['install_settings_stats'], ':</td>
+				<td>
+					<input type="checkbox" name="stats" id="stats_check" class="input_check" /> <label for="stats_check">', $txt['install_settings_stats_title'], '</label><br />
+					<div style="font-size: smaller; margin-bottom: 2ex;">', $txt['install_settings_stats_info'], '</div>
+				</td>
+			</tr>
+		</table>';
+}
+
+// Show results of the database population.
+function template_populate_database()
+{
+	global $incontext, $installurl, $txt;
+
+	echo '
+	<form action="', $incontext['form_url'], '" method="post">
+		<p>', !empty($incontext['was_refresh']) ? $txt['user_refresh_install_desc'] : $txt['db_populate_info'], '</p>';
+
+	if (!empty($incontext['sql_results']))
+	{
+		echo '
+		<ul>
+			<li>', implode('</li><li>', $incontext['sql_results']), '</li>
+		</ul>';
+	}
+
+	if (!empty($incontext['failures']))
+	{
+		echo '
+				<div style="color: red;">', $txt['error_db_queries'], '</div>
+				<ul>';
+
+		foreach ($incontext['failures'] as $line => $fail)
+			echo '
+						<li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>';
+
+		echo '
+				</ul>';
+	}
+
+	echo '
+		<p>', $txt['db_populate_info2'], '</p>';
+
+	template_warning_divs();
+
+	echo '
+	<input type="hidden" name="pop_done" value="1" />';
+}
+
+// Create the admin account.
+function template_admin_account()
+{
+	global $incontext, $installurl, $txt;
+
+	echo '
+	<form action="', $incontext['form_url'], '" method="post">
+		<p>', $txt['user_settings_info'], '</p>';
+
+	template_warning_divs();
+
+	echo '
+		<table width="100%" cellspacing="0" cellpadding="0" border="0" style="margin: 2em 0;">
+			<tr>
+				<td width="18%" valign="top" class="textbox"><label for="username">', $txt['user_settings_username'], ':</label></td>
+				<td>
+					<input type="text" name="username" id="username" value="', $incontext['username'], '" size="40" class="input_text" />
+					<div style="font-size: smaller; margin-bottom: 2ex;">', $txt['user_settings_username_info'], '</div>
+				</td>
+			</tr><tr>
+				<td valign="top" class="textbox"><label for="password1">', $txt['user_settings_password'], ':</label></td>
+				<td>
+					<input type="password" name="password1" id="password1" size="40" class="input_password" />
+					<div style="font-size: smaller; margin-bottom: 2ex;">', $txt['user_settings_password_info'], '</div>
+				</td>
+			</tr><tr>
+				<td valign="top" class="textbox"><label for="password2">', $txt['user_settings_again'], ':</label></td>
+				<td>
+					<input type="password" name="password2" id="password2" size="40" class="input_password" />
+					<div style="font-size: smaller; margin-bottom: 2ex;">', $txt['user_settings_again_info'], '</div>
+				</td>
+			</tr><tr>
+				<td valign="top" class="textbox"><label for="email">', $txt['user_settings_email'], ':</label></td>
+				<td>
+					<input type="text" name="email" id="email" value="', $incontext['email'], '" size="40" class="input_text" />
+					<div style="font-size: smaller; margin-bottom: 2ex;">', $txt['user_settings_email_info'], '</div>
+				</td>
+			</tr>
+		</table>';
+
+	if ($incontext['require_db_confirm'])
+		echo '
+		<h2>', $txt['user_settings_database'], '</h2>
+		<p>', $txt['user_settings_database_info'], '</p>
+
+		<div style="margin-bottom: 2ex; padding-', empty($txt['lang_rtl']) ? 'left' : 'right', ': 50px;">
+			<input type="password" name="password3" size="30" class="input_password" />
+		</div>';
+}
+
+// Tell them it's done, and to delete.
+function template_delete_install()
+{
+	global $incontext, $installurl, $txt, $boardurl;
+
+	echo '
+		<p>', $txt['congratulations_help'], '</p>';
+
+	template_warning_divs();
+
+	// Install directory still writable?
+	if ($incontext['dir_still_writable'])
+		echo '
+		<em>', $txt['still_writable'], '</em><br />
+		<br />';
+
+	// Don't show the box if it's like 99% sure it won't work :P.
+	if ($incontext['probably_delete_install'])
+		echo '
+		<div style="margin: 1ex; font-weight: bold;">
+			<label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete();" class="input_check" /> ', $txt['delete_installer'], !isset($_SESSION['installer_temp_ftp']) ? ' ' . $txt['delete_installer_maybe'] : '', '</label>
+		</div>
+		<script type="text/javascript"><!-- // --><![CDATA[
+			function doTheDelete()
+			{
+				var theCheck = document.getElementById ? document.getElementById("delete_self") : document.all.delete_self;
+				var tempImage = new Image();
+
+				tempImage.src = "', $installurl, '?delete=1&ts_" + (new Date().getTime());
+				tempImage.width = 0;
+				theCheck.disabled = true;
+			}
+		// ]]></script>
+		<br />';
+
+	echo '
+		', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '<br />
+		<br />
+		', $txt['good_luck'];
+}
+
+?>

+ 2013 - 0
other/install_2-1_mysql.sql

@@ -0,0 +1,2013 @@
+#### ATTENTION: You do not need to run or use this file!  The install.php script does everything for you!
+#### Install script for MySQL 4.0.18+
+
+#
+# Table structure for table `admin_info_files`
+#
+
+CREATE TABLE {$db_prefix}admin_info_files (
+  id_file tinyint(4) unsigned NOT NULL auto_increment,
+  filename varchar(255) NOT NULL default '',
+  path varchar(255) NOT NULL default '',
+  parameters varchar(255) NOT NULL default '',
+  data text NOT NULL,
+  filetype varchar(255) NOT NULL default '',
+  PRIMARY KEY (id_file),
+  KEY filename (filename(30))
+) ENGINE=MyISAM;
+
+#
+# Dumping data for table `admin_info_files`
+#
+
+INSERT INTO {$db_prefix}admin_info_files
+	(id_file, filename, path, parameters, data, filetype)
+VALUES
+	(1, 'current-version.js', '/smf/', 'version=%3$s', '', 'text/javascript'),
+	(2, 'detailed-version.js', '/smf/', 'language=%1$s&version=%3$s', '', 'text/javascript'),
+	(3, 'latest-news.js', '/smf/', 'language=%1$s&format=%2$s', '', 'text/javascript'),
+	(4, 'latest-packages.js', '/smf/', 'language=%1$s&version=%3$s', '', 'text/javascript'),
+	(5, 'latest-smileys.js', '/smf/', 'language=%1$s&version=%3$s', '', 'text/javascript'),
+	(6, 'latest-support.js', '/smf/', 'language=%1$s&version=%3$s', '', 'text/javascript'),
+	(7, 'latest-themes.js', '/smf/', 'language=%1$s&version=%3$s', '', 'text/javascript');
+# --------------------------------------------------------
+
+#
+# Table structure for table `approval_queue`
+#
+
+CREATE TABLE {$db_prefix}approval_queue (
+  id_msg int(10) unsigned NOT NULL default '0',
+  id_attach int(10) unsigned NOT NULL default '0',
+  id_event smallint(5) unsigned NOT NULL default '0'
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `attachments`
+#
+
+CREATE TABLE {$db_prefix}attachments (
+  id_attach int(10) unsigned NOT NULL auto_increment,
+  id_thumb int(10) unsigned NOT NULL default '0',
+  id_msg int(10) unsigned NOT NULL default '0',
+  id_member mediumint(8) unsigned NOT NULL default '0',
+  id_folder tinyint(3) NOT NULL default '1',
+  attachment_type tinyint(3) unsigned NOT NULL default '0',
+  filename varchar(255) NOT NULL default '',
+  file_hash varchar(40) NOT NULL default '',
+  fileext varchar(8) NOT NULL default '',
+  size int(10) unsigned NOT NULL default '0',
+  downloads mediumint(8) unsigned NOT NULL default '0',
+  width mediumint(8) unsigned NOT NULL default '0',
+  height mediumint(8) unsigned NOT NULL default '0',
+  mime_type varchar(20) NOT NULL default '',
+  approved tinyint(3) NOT NULL default '1',
+  PRIMARY KEY (id_attach),
+  UNIQUE id_member (id_member, id_attach),
+  KEY id_msg (id_msg),
+  KEY attachment_type (attachment_type)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `ban_groups`
+#
+
+CREATE TABLE {$db_prefix}ban_groups (
+  id_ban_group mediumint(8) unsigned NOT NULL auto_increment,
+  name varchar(20) NOT NULL default '',
+  ban_time int(10) unsigned NOT NULL default '0',
+  expire_time int(10) unsigned,
+  cannot_access tinyint(3) unsigned NOT NULL default '0',
+  cannot_register tinyint(3) unsigned NOT NULL default '0',
+  cannot_post tinyint(3) unsigned NOT NULL default '0',
+  cannot_login tinyint(3) unsigned NOT NULL default '0',
+  reason varchar(255) NOT NULL default '',
+  notes text NOT NULL,
+  PRIMARY KEY (id_ban_group)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `ban_items`
+#
+
+CREATE TABLE {$db_prefix}ban_items (
+  id_ban mediumint(8) unsigned NOT NULL auto_increment,
+  id_ban_group smallint(5) unsigned NOT NULL default '0',
+  ip_low1 smallint(255) unsigned NOT NULL default '0',
+  ip_high1 smallint(255) unsigned NOT NULL default '0',
+  ip_low2 smallint(255) unsigned NOT NULL default '0',
+  ip_high2 smallint(255) unsigned NOT NULL default '0',
+  ip_low3 smallint(255) unsigned NOT NULL default '0',
+  ip_high3 smallint(255) unsigned NOT NULL default '0',
+  ip_low4 smallint(255) unsigned NOT NULL default '0',
+  ip_high4 smallint(255) unsigned NOT NULL default '0',
+  ip_low5 smallint(255) unsigned NOT NULL default '0',
+  ip_high5 smallint(255) unsigned NOT NULL default '0',
+  ip_low6 smallint(255) unsigned NOT NULL default '0',
+  ip_high6 smallint(255) unsigned NOT NULL default '0',
+  ip_low7 smallint(255) unsigned NOT NULL default '0',
+  ip_high7 smallint(255) unsigned NOT NULL default '0',
+  ip_low8 smallint(255) unsigned NOT NULL default '0',
+  ip_high8 smallint(255) unsigned NOT NULL default '0',
+  hostname varchar(255) NOT NULL default '',
+  email_address varchar(255) NOT NULL default '',
+  id_member mediumint(8) unsigned NOT NULL default '0',
+  hits mediumint(8) unsigned NOT NULL default '0',
+  PRIMARY KEY (id_ban),
+  KEY id_ban_group (id_ban_group)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `board_permissions`
+#
+
+CREATE TABLE {$db_prefix}board_permissions (
+  id_group smallint(5) NOT NULL default '0',
+  id_profile smallint(5) unsigned NOT NULL default '0',
+  permission varchar(30) NOT NULL default '',
+  add_deny tinyint(4) NOT NULL default '1',
+  PRIMARY KEY (id_group, id_profile, permission)
+) ENGINE=MyISAM;
+
+#
+# Dumping data for table `board_permissions`
+#
+
+INSERT INTO {$db_prefix}board_permissions
+	(id_group, id_profile, permission)
+VALUES (-1, 1, 'poll_view'),
+	(0, 1, 'remove_own'),
+	(0, 1, 'lock_own'),
+	(0, 1, 'mark_any_notify'),
+	(0, 1, 'mark_notify'),
+	(0, 1, 'modify_own'),
+	(0, 1, 'poll_add_own'),
+	(0, 1, 'poll_edit_own'),
+	(0, 1, 'poll_lock_own'),
+	(0, 1, 'poll_post'),
+	(0, 1, 'poll_view'),
+	(0, 1, 'poll_vote'),
+	(0, 1, 'post_attachment'),
+	(0, 1, 'post_new'),
+	(0, 1, 'post_reply_any'),
+	(0, 1, 'post_reply_own'),
+	(0, 1, 'post_unapproved_topics'),
+	(0, 1, 'post_unapproved_replies_any'),
+	(0, 1, 'post_unapproved_replies_own'),
+	(0, 1, 'post_unapproved_attachments'),
+	(0, 1, 'delete_own'),
+	(0, 1, 'report_any'),
+	(0, 1, 'send_topic'),
+	(0, 1, 'view_attachments'),
+	(2, 1, 'moderate_board'),
+	(2, 1, 'post_new'),
+	(2, 1, 'post_reply_own'),
+	(2, 1, 'post_reply_any'),
+	(2, 1, 'post_unapproved_topics'),
+	(2, 1, 'post_unapproved_replies_any'),
+	(2, 1, 'post_unapproved_replies_own'),
+	(2, 1, 'post_unapproved_attachments'),
+	(2, 1, 'poll_post'),
+	(2, 1, 'poll_add_any'),
+	(2, 1, 'poll_remove_any'),
+	(2, 1, 'poll_view'),
+	(2, 1, 'poll_vote'),
+	(2, 1, 'poll_lock_any'),
+	(2, 1, 'poll_edit_any'),
+	(2, 1, 'report_any'),
+	(2, 1, 'lock_own'),
+	(2, 1, 'send_topic'),
+	(2, 1, 'mark_any_notify'),
+	(2, 1, 'mark_notify'),
+	(2, 1, 'delete_own'),
+	(2, 1, 'modify_own'),
+	(2, 1, 'make_sticky'),
+	(2, 1, 'lock_any'),
+	(2, 1, 'remove_any'),
+	(2, 1, 'move_any'),
+	(2, 1, 'merge_any'),
+	(2, 1, 'split_any'),
+	(2, 1, 'delete_any'),
+	(2, 1, 'modify_any'),
+	(2, 1, 'approve_posts'),
+	(2, 1, 'post_attachment'),
+	(2, 1, 'view_attachments'),
+	(3, 1, 'moderate_board'),
+	(3, 1, 'post_new'),
+	(3, 1, 'post_reply_own'),
+	(3, 1, 'post_reply_any'),
+	(3, 1, 'post_unapproved_topics'),
+	(3, 1, 'post_unapproved_replies_any'),
+	(3, 1, 'post_unapproved_replies_own'),
+	(3, 1, 'post_unapproved_attachments'),
+	(3, 1, 'poll_post'),
+	(3, 1, 'poll_add_any'),
+	(3, 1, 'poll_remove_any'),
+	(3, 1, 'poll_view'),
+	(3, 1, 'poll_vote'),
+	(3, 1, 'poll_lock_any'),
+	(3, 1, 'poll_edit_any'),
+	(3, 1, 'report_any'),
+	(3, 1, 'lock_own'),
+	(3, 1, 'send_topic'),
+	(3, 1, 'mark_any_notify'),
+	(3, 1, 'mark_notify'),
+	(3, 1, 'delete_own'),
+	(3, 1, 'modify_own'),
+	(3, 1, 'make_sticky'),
+	(3, 1, 'lock_any'),
+	(3, 1, 'remove_any'),
+	(3, 1, 'move_any'),
+	(3, 1, 'merge_any'),
+	(3, 1, 'split_any'),
+	(3, 1, 'delete_any'),
+	(3, 1, 'modify_any'),
+	(3, 1, 'approve_posts'),
+	(3, 1, 'post_attachment'),
+	(3, 1, 'view_attachments'),
+	(-1, 2, 'poll_view'),
+	(0, 2, 'remove_own'),
+	(0, 2, 'lock_own'),
+	(0, 2, 'mark_any_notify'),
+	(0, 2, 'mark_notify'),
+	(0, 2, 'modify_own'),
+	(0, 2, 'poll_view'),
+	(0, 2, 'poll_vote'),
+	(0, 2, 'post_attachment'),
+	(0, 2, 'post_new'),
+	(0, 2, 'post_reply_any'),
+	(0, 2, 'post_reply_own'),
+	(0, 2, 'post_unapproved_topics'),
+	(0, 2, 'post_unapproved_replies_any'),
+	(0, 2, 'post_unapproved_replies_own'),
+	(0, 2, 'post_unapproved_attachments'),
+	(0, 2, 'delete_own'),
+	(0, 2, 'report_any'),
+	(0, 2, 'send_topic'),
+	(0, 2, 'view_attachments'),
+	(2, 2, 'moderate_board'),
+	(2, 2, 'post_new'),
+	(2, 2, 'post_reply_own'),
+	(2, 2, 'post_reply_any'),
+	(2, 2, 'post_unapproved_topics'),
+	(2, 2, 'post_unapproved_replies_any'),
+	(2, 2, 'post_unapproved_replies_own'),
+	(2, 2, 'post_unapproved_attachments'),
+	(2, 2, 'poll_post'),
+	(2, 2, 'poll_add_any'),
+	(2, 2, 'poll_remove_any'),
+	(2, 2, 'poll_view'),
+	(2, 2, 'poll_vote'),
+	(2, 2, 'poll_lock_any'),
+	(2, 2, 'poll_edit_any'),
+	(2, 2, 'report_any'),
+	(2, 2, 'lock_own'),
+	(2, 2, 'send_topic'),
+	(2, 2, 'mark_any_notify'),
+	(2, 2, 'mark_notify'),
+	(2, 2, 'delete_own'),
+	(2, 2, 'modify_own'),
+	(2, 2, 'make_sticky'),
+	(2, 2, 'lock_any'),
+	(2, 2, 'remove_any'),
+	(2, 2, 'move_any'),
+	(2, 2, 'merge_any'),
+	(2, 2, 'split_any'),
+	(2, 2, 'delete_any'),
+	(2, 2, 'modify_any'),
+	(2, 2, 'approve_posts'),
+	(2, 2, 'post_attachment'),
+	(2, 2, 'view_attachments'),
+	(3, 2, 'moderate_board'),
+	(3, 2, 'post_new'),
+	(3, 2, 'post_reply_own'),
+	(3, 2, 'post_reply_any'),
+	(3, 2, 'post_unapproved_topics'),
+	(3, 2, 'post_unapproved_replies_any'),
+	(3, 2, 'post_unapproved_replies_own'),
+	(3, 2, 'post_unapproved_attachments'),
+	(3, 2, 'poll_post'),
+	(3, 2, 'poll_add_any'),
+	(3, 2, 'poll_remove_any'),
+	(3, 2, 'poll_view'),
+	(3, 2, 'poll_vote'),
+	(3, 2, 'poll_lock_any'),
+	(3, 2, 'poll_edit_any'),
+	(3, 2, 'report_any'),
+	(3, 2, 'lock_own'),
+	(3, 2, 'send_topic'),
+	(3, 2, 'mark_any_notify'),
+	(3, 2, 'mark_notify'),
+	(3, 2, 'delete_own'),
+	(3, 2, 'modify_own'),
+	(3, 2, 'make_sticky'),
+	(3, 2, 'lock_any'),
+	(3, 2, 'remove_any'),
+	(3, 2, 'move_any'),
+	(3, 2, 'merge_any'),
+	(3, 2, 'split_any'),
+	(3, 2, 'delete_any'),
+	(3, 2, 'modify_any'),
+	(3, 2, 'approve_posts'),
+	(3, 2, 'post_attachment'),
+	(3, 2, 'view_attachments'),
+	(-1, 3, 'poll_view'),
+	(0, 3, 'remove_own'),
+	(0, 3, 'lock_own'),
+	(0, 3, 'mark_any_notify'),
+	(0, 3, 'mark_notify'),
+	(0, 3, 'modify_own'),
+	(0, 3, 'poll_view'),
+	(0, 3, 'poll_vote'),
+	(0, 3, 'post_attachment'),
+	(0, 3, 'post_reply_any'),
+	(0, 3, 'post_reply_own'),
+	(0, 3, 'post_unapproved_replies_any'),
+	(0, 3, 'post_unapproved_replies_own'),
+	(0, 3, 'post_unapproved_attachments'),
+	(0, 3, 'delete_own'),
+	(0, 3, 'report_any'),
+	(0, 3, 'send_topic'),
+	(0, 3, 'view_attachments'),
+	(2, 3, 'moderate_board'),
+	(2, 3, 'post_new'),
+	(2, 3, 'post_reply_own'),
+	(2, 3, 'post_reply_any'),
+	(2, 3, 'post_unapproved_topics'),
+	(2, 3, 'post_unapproved_replies_any'),
+	(2, 3, 'post_unapproved_replies_own'),
+	(2, 3, 'post_unapproved_attachments'),
+	(2, 3, 'poll_post'),
+	(2, 3, 'poll_add_any'),
+	(2, 3, 'poll_remove_any'),
+	(2, 3, 'poll_view'),
+	(2, 3, 'poll_vote'),
+	(2, 3, 'poll_lock_any'),
+	(2, 3, 'poll_edit_any'),
+	(2, 3, 'report_any'),
+	(2, 3, 'lock_own'),
+	(2, 3, 'send_topic'),
+	(2, 3, 'mark_any_notify'),
+	(2, 3, 'mark_notify'),
+	(2, 3, 'delete_own'),
+	(2, 3, 'modify_own'),
+	(2, 3, 'make_sticky'),
+	(2, 3, 'lock_any'),
+	(2, 3, 'remove_any'),
+	(2, 3, 'move_any'),
+	(2, 3, 'merge_any'),
+	(2, 3, 'split_any'),
+	(2, 3, 'delete_any'),
+	(2, 3, 'modify_any'),
+	(2, 3, 'approve_posts'),
+	(2, 3, 'post_attachment'),
+	(2, 3, 'view_attachments'),
+	(3, 3, 'moderate_board'),
+	(3, 3, 'post_new'),
+	(3, 3, 'post_reply_own'),
+	(3, 3, 'post_reply_any'),
+	(3, 3, 'post_unapproved_topics'),
+	(3, 3, 'post_unapproved_replies_any'),
+	(3, 3, 'post_unapproved_replies_own'),
+	(3, 3, 'post_unapproved_attachments'),
+	(3, 3, 'poll_post'),
+	(3, 3, 'poll_add_any'),
+	(3, 3, 'poll_remove_any'),
+	(3, 3, 'poll_view'),
+	(3, 3, 'poll_vote'),
+	(3, 3, 'poll_lock_any'),
+	(3, 3, 'poll_edit_any'),
+	(3, 3, 'report_any'),
+	(3, 3, 'lock_own'),
+	(3, 3, 'send_topic'),
+	(3, 3, 'mark_any_notify'),
+	(3, 3, 'mark_notify'),
+	(3, 3, 'delete_own'),
+	(3, 3, 'modify_own'),
+	(3, 3, 'make_sticky'),
+	(3, 3, 'lock_any'),
+	(3, 3, 'remove_any'),
+	(3, 3, 'move_any'),
+	(3, 3, 'merge_any'),
+	(3, 3, 'split_any'),
+	(3, 3, 'delete_any'),
+	(3, 3, 'modify_any'),
+	(3, 3, 'approve_posts'),
+	(3, 3, 'post_attachment'),
+	(3, 3, 'view_attachments'),
+	(-1, 4, 'poll_view'),
+	(0, 4, 'mark_any_notify'),
+	(0, 4, 'mark_notify'),
+	(0, 4, 'poll_view'),
+	(0, 4, 'poll_vote'),
+	(0, 4, 'report_any'),
+	(0, 4, 'send_topic'),
+	(0, 4, 'view_attachments'),
+	(2, 4, 'moderate_board'),
+	(2, 4, 'post_new'),
+	(2, 4, 'post_reply_own'),
+	(2, 4, 'post_reply_any'),
+	(2, 4, 'post_unapproved_topics'),
+	(2, 4, 'post_unapproved_replies_any'),
+	(2, 4, 'post_unapproved_replies_own'),
+	(2, 4, 'post_unapproved_attachments'),
+	(2, 4, 'poll_post'),
+	(2, 4, 'poll_add_any'),
+	(2, 4, 'poll_remove_any'),
+	(2, 4, 'poll_view'),
+	(2, 4, 'poll_vote'),
+	(2, 4, 'poll_lock_any'),
+	(2, 4, 'poll_edit_any'),
+	(2, 4, 'report_any'),
+	(2, 4, 'lock_own'),
+	(2, 4, 'send_topic'),
+	(2, 4, 'mark_any_notify'),
+	(2, 4, 'mark_notify'),
+	(2, 4, 'delete_own'),
+	(2, 4, 'modify_own'),
+	(2, 4, 'make_sticky'),
+	(2, 4, 'lock_any'),
+	(2, 4, 'remove_any'),
+	(2, 4, 'move_any'),
+	(2, 4, 'merge_any'),
+	(2, 4, 'split_any'),
+	(2, 4, 'delete_any'),
+	(2, 4, 'modify_any'),
+	(2, 4, 'approve_posts'),
+	(2, 4, 'post_attachment'),
+	(2, 4, 'view_attachments'),
+	(3, 4, 'moderate_board'),
+	(3, 4, 'post_new'),
+	(3, 4, 'post_reply_own'),
+	(3, 4, 'post_reply_any'),
+	(3, 4, 'post_unapproved_topics'),
+	(3, 4, 'post_unapproved_replies_any'),
+	(3, 4, 'post_unapproved_replies_own'),
+	(3, 4, 'post_unapproved_attachments'),
+	(3, 4, 'poll_post'),
+	(3, 4, 'poll_add_any'),
+	(3, 4, 'poll_remove_any'),
+	(3, 4, 'poll_view'),
+	(3, 4, 'poll_vote'),
+	(3, 4, 'poll_lock_any'),
+	(3, 4, 'poll_edit_any'),
+	(3, 4, 'report_any'),
+	(3, 4, 'lock_own'),
+	(3, 4, 'send_topic'),
+	(3, 4, 'mark_any_notify'),
+	(3, 4, 'mark_notify'),
+	(3, 4, 'delete_own'),
+	(3, 4, 'modify_own'),
+	(3, 4, 'make_sticky'),
+	(3, 4, 'lock_any'),
+	(3, 4, 'remove_any'),
+	(3, 4, 'move_any'),
+	(3, 4, 'merge_any'),
+	(3, 4, 'split_any'),
+	(3, 4, 'delete_any'),
+	(3, 4, 'modify_any'),
+	(3, 4, 'approve_posts'),
+	(3, 4, 'post_attachment'),
+	(3, 4, 'view_attachments');
+# --------------------------------------------------------
+
+#
+# Table structure for table `boards`
+#
+
+CREATE TABLE {$db_prefix}boards (
+  id_board smallint(5) unsigned NOT NULL auto_increment,
+  id_cat tinyint(4) unsigned NOT NULL default '0',
+  child_level tinyint(4) unsigned NOT NULL default '0',
+  id_parent smallint(5) unsigned NOT NULL default '0',
+  board_order smallint(5) NOT NULL default '0',
+  id_last_msg int(10) unsigned NOT NULL default '0',
+  id_msg_updated int(10) unsigned NOT NULL default '0',
+  member_groups varchar(255) NOT NULL default '-1,0',
+  id_profile smallint(5) unsigned NOT NULL default '1',
+  name varchar(255) NOT NULL default '',
+  description text NOT NULL,
+  num_topics mediumint(8) unsigned NOT NULL default '0',
+  num_posts mediumint(8) unsigned NOT NULL default '0',
+  count_posts tinyint(4) NOT NULL default '0',
+  id_theme tinyint(4) unsigned NOT NULL default '0',
+  override_theme tinyint(4) unsigned NOT NULL default '0',
+  unapproved_posts smallint(5) NOT NULL default '0',
+  unapproved_topics smallint(5) NOT NULL default '0',
+  redirect varchar(255) NOT NULL default '',
+  PRIMARY KEY (id_board),
+  UNIQUE categories (id_cat, id_board),
+  KEY id_parent (id_parent),
+  KEY id_msg_updated (id_msg_updated),
+  KEY member_groups (member_groups(48))
+) ENGINE=MyISAM;
+
+#
+# Dumping data for table `boards`
+#
+
+INSERT INTO {$db_prefix}boards
+	(id_board, id_cat, board_order, id_last_msg, id_msg_updated, name, description, num_topics, num_posts, member_groups)
+VALUES (1, 1, 1, 1, 1, '{$default_board_name}', '{$default_board_description}', 1, 1, '-1,0,2');
+# --------------------------------------------------------
+
+#
+# Table structure for table `calendar`
+#
+
+CREATE TABLE {$db_prefix}calendar (
+  id_event smallint(5) unsigned NOT NULL auto_increment,
+  start_date date NOT NULL default '0001-01-01',
+  end_date date NOT NULL default '0001-01-01',
+  id_board smallint(5) unsigned NOT NULL default '0',
+  id_topic mediumint(8) unsigned NOT NULL default '0',
+  title varchar(255) NOT NULL default '',
+  id_member mediumint(8) unsigned NOT NULL default '0',
+  PRIMARY KEY (id_event),
+  KEY start_date (start_date),
+  KEY end_date (end_date),
+  KEY topic (id_topic, id_member)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `calendar_holidays`
+#
+
+CREATE TABLE {$db_prefix}calendar_holidays (
+  id_holiday smallint(5) unsigned NOT NULL auto_increment,
+  event_date date NOT NULL default '0001-01-01',
+  title varchar(255) NOT NULL default '',
+  PRIMARY KEY (id_holiday),
+  KEY event_date (event_date)
+) ENGINE=MyISAM;
+
+#
+# Dumping data for table `calendar_holidays`
+#
+
+INSERT INTO {$db_prefix}calendar_holidays
+	(title, event_date)
+VALUES ('New Year\'s', '0004-01-01'),
+	('Christmas', '0004-12-25'),
+	('Valentine\'s Day', '0004-02-14'),
+	('St. Patrick\'s Day', '0004-03-17'),
+	('April Fools', '0004-04-01'),
+	('Earth Day', '0004-04-22'),
+	('United Nations Day', '0004-10-24'),
+	('Halloween', '0004-10-31'),
+	('Mother\'s Day', '2010-05-09'),
+	('Mother\'s Day', '2011-05-08'),
+	('Mother\'s Day', '2012-05-13'),
+	('Mother\'s Day', '2013-05-12'),
+	('Mother\'s Day', '2014-05-11'),
+	('Mother\'s Day', '2015-05-10'),
+	('Mother\'s Day', '2016-05-08'),
+	('Mother\'s Day', '2017-05-14'),
+	('Mother\'s Day', '2018-05-13'),
+	('Mother\'s Day', '2019-05-12'),
+	('Mother\'s Day', '2020-05-10'),
+	('Father\'s Day', '2008-06-15'),
+	('Father\'s Day', '2009-06-21'),
+	('Father\'s Day', '2010-06-20'),
+	('Father\'s Day', '2011-06-19'),
+	('Father\'s Day', '2012-06-17'),
+	('Father\'s Day', '2013-06-16'),
+	('Father\'s Day', '2014-06-15'),
+	('Father\'s Day', '2015-06-21'),
+	('Father\'s Day', '2016-06-19'),
+	('Father\'s Day', '2017-06-18'),
+	('Father\'s Day', '2018-06-17'),
+	('Father\'s Day', '2019-06-16'),
+	('Father\'s Day', '2020-06-21'),
+	('Summer Solstice', '2010-06-21'),
+	('Summer Solstice', '2011-06-21'),
+	('Summer Solstice', '2012-06-20'),
+	('Summer Solstice', '2013-06-21'),
+	('Summer Solstice', '2014-06-21'),
+	('Summer Solstice', '2015-06-21'),
+	('Summer Solstice', '2016-06-20'),
+	('Summer Solstice', '2017-06-20'),
+	('Summer Solstice', '2018-06-21'),
+	('Summer Solstice', '2019-06-21'),
+	('Summer Solstice', '2020-06-20'),
+	('Vernal Equinox', '2010-03-20'),
+	('Vernal Equinox', '2011-03-20'),
+	('Vernal Equinox', '2012-03-20'),
+	('Vernal Equinox', '2013-03-20'),
+	('Vernal Equinox', '2014-03-20'),
+	('Vernal Equinox', '2015-03-20'),
+	('Vernal Equinox', '2016-03-19'),
+	('Vernal Equinox', '2017-03-20'),
+	('Vernal Equinox', '2018-03-20'),
+	('Vernal Equinox', '2019-03-20'),
+	('Vernal Equinox', '2020-03-19'),
+	('Winter Solstice', '2010-12-21'),
+	('Winter Solstice', '2011-12-22'),
+	('Winter Solstice', '2012-12-21'),
+	('Winter Solstice', '2013-12-21'),
+	('Winter Solstice', '2014-12-21'),
+	('Winter Solstice', '2015-12-21'),
+	('Winter Solstice', '2016-12-21'),
+	('Winter Solstice', '2017-12-21'),
+	('Winter Solstice', '2018-12-21'),
+	('Winter Solstice', '2019-12-21'),
+	('Winter Solstice', '2020-12-21'),
+	('Autumnal Equinox', '2010-09-22'),
+	('Autumnal Equinox', '2011-09-23'),
+	('Autumnal Equinox', '2012-09-22'),
+	('Autumnal Equinox', '2013-09-22'),
+	('Autumnal Equinox', '2014-09-22'),
+	('Autumnal Equinox', '2015-09-23'),
+	('Autumnal Equinox', '2016-09-22'),
+	('Autumnal Equinox', '2017-09-22'),
+	('Autumnal Equinox', '2018-09-22'),
+	('Autumnal Equinox', '2019-09-23'),
+	('Autumnal Equinox', '2020-09-22');
+
+INSERT INTO {$db_prefix}calendar_holidays
+	(title, event_date)
+VALUES ('Independence Day', '0004-07-04'),
+	('Cinco de Mayo', '0004-05-05'),
+	('Flag Day', '0004-06-14'),
+	('Veterans Day', '0004-11-11'),
+	('Groundhog Day', '0004-02-02'),
+	('Thanksgiving', '2010-11-25'),
+	('Thanksgiving', '2011-11-24'),
+	('Thanksgiving', '2012-11-22'),
+	('Thanksgiving', '2013-11-21'),
+	('Thanksgiving', '2014-11-20'),
+	('Thanksgiving', '2015-11-26'),
+	('Thanksgiving', '2016-11-24'),
+	('Thanksgiving', '2017-11-23'),
+	('Thanksgiving', '2018-11-22'),
+	('Thanksgiving', '2019-11-21'),
+	('Thanksgiving', '2020-11-26'),
+	('Memorial Day', '2010-05-31'),
+	('Memorial Day', '2011-05-30'),
+	('Memorial Day', '2012-05-28'),
+	('Memorial Day', '2013-05-27'),
+	('Memorial Day', '2014-05-26'),
+	('Memorial Day', '2015-05-25'),
+	('Memorial Day', '2016-05-30'),
+	('Memorial Day', '2017-05-29'),
+	('Memorial Day', '2018-05-28'),
+	('Memorial Day', '2019-05-27'),
+	('Memorial Day', '2020-05-25'),
+	('Labor Day', '2010-09-06'),
+	('Labor Day', '2011-09-05'),
+	('Labor Day', '2012-09-03'),
+	('Labor Day', '2013-09-09'),
+	('Labor Day', '2014-09-08'),
+	('Labor Day', '2015-09-07'),
+	('Labor Day', '2016-09-05'),
+	('Labor Day', '2017-09-04'),
+	('Labor Day', '2018-09-03'),
+	('Labor Day', '2019-09-09'),
+	('Labor Day', '2020-09-07'),
+	('D-Day', '0004-06-06');
+# --------------------------------------------------------
+
+#
+# Table structure for table `categories`
+#
+
+CREATE TABLE {$db_prefix}categories (
+  id_cat tinyint(4) unsigned NOT NULL auto_increment,
+  cat_order tinyint(4) NOT NULL default '0',
+  name varchar(255) NOT NULL default '',
+  can_collapse tinyint(1) NOT NULL default '1',
+  PRIMARY KEY (id_cat)
+) ENGINE=MyISAM;
+
+#
+# Dumping data for table `categories`
+#
+
+INSERT INTO {$db_prefix}categories
+VALUES (1, 0, '{$default_category_name}', 1);
+# --------------------------------------------------------
+
+#
+# Table structure for table `collapsed_categories`
+#
+
+CREATE TABLE {$db_prefix}collapsed_categories (
+  id_cat tinyint(4) unsigned NOT NULL default '0',
+  id_member mediumint(8) unsigned NOT NULL default '0',
+  PRIMARY KEY (id_cat, id_member)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `custom_fields`
+#
+
+CREATE TABLE {$db_prefix}custom_fields (
+  id_field smallint(5) NOT NULL auto_increment,
+  col_name varchar(12) NOT NULL default '',
+  field_name varchar(40) NOT NULL default '',
+  field_desc varchar(255) NOT NULL default '',
+  field_type varchar(8) NOT NULL default 'text',
+  field_length smallint(5) NOT NULL default '255',
+  field_options text NOT NULL,
+  mask varchar(255) NOT NULL default '',
+  show_reg tinyint(3) NOT NULL default '0',
+  show_display tinyint(3) NOT NULL default '0',
+  show_profile varchar(20) NOT NULL default 'forumprofile',
+  private tinyint(3) NOT NULL default '0',
+  active tinyint(3) NOT NULL default '1',
+  bbc tinyint(3) NOT NULL default '0',
+  can_search tinyint(3) NOT NULL default '0',
+  default_value varchar(255) NOT NULL default '',
+  enclose text NOT NULL,
+  placement tinyint(3) NOT NULL default '0',
+  PRIMARY KEY (id_field),
+  UNIQUE col_name (col_name)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `group_moderators`
+#
+
+CREATE TABLE {$db_prefix}group_moderators (
+  id_group smallint(5) unsigned NOT NULL default '0',
+  id_member mediumint(8) unsigned NOT NULL default '0',
+  PRIMARY KEY (id_group, id_member)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `log_actions`
+#
+
+CREATE TABLE {$db_prefix}log_actions (
+  id_action int(10) unsigned NOT NULL auto_increment,
+  id_log tinyint(3) unsigned NOT NULL default '1',
+  log_time int(10) unsigned NOT NULL default '0',
+  id_member mediumint(8) unsigned NOT NULL default '0',
+  ip char(16) NOT NULL default '                ',
+  action varchar(30) NOT NULL default '',
+  id_board smallint(5) unsigned NOT NULL default '0',
+  id_topic mediumint(8) unsigned NOT NULL default '0',
+  id_msg int(10) unsigned NOT NULL default '0',
+  extra text NOT NULL,
+  PRIMARY KEY (id_action),
+  KEY id_log (id_log),
+  KEY log_time (log_time),
+  KEY id_member (id_member),
+  KEY id_board (id_board),
+  KEY id_msg (id_msg)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `log_activity`
+#
+
+CREATE TABLE {$db_prefix}log_activity (
+  date date NOT NULL default '0001-01-01',
+  hits mediumint(8) unsigned NOT NULL default '0',
+  topics smallint(5) unsigned NOT NULL default '0',
+  posts smallint(5) unsigned NOT NULL default '0',
+  registers smallint(5) unsigned NOT NULL default '0',
+  most_on smallint(5) unsigned NOT NULL default '0',
+  PRIMARY KEY (date),
+  KEY most_on (most_on)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `log_banned`
+#
+
+CREATE TABLE {$db_prefix}log_banned (
+  id_ban_log mediumint(8) unsigned NOT NULL auto_increment,
+  id_member mediumint(8) unsigned NOT NULL default '0',
+  ip char(16) NOT NULL default '                ',
+  email varchar(255) NOT NULL default '',
+  log_time int(10) unsigned NOT NULL default '0',
+  PRIMARY KEY (id_ban_log),
+  KEY log_time (log_time)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `log_boards`
+#
+
+CREATE TABLE {$db_prefix}log_boards (
+  id_member mediumint(8) unsigned NOT NULL default '0',
+  id_board smallint(5) unsigned NOT NULL default '0',
+  id_msg int(10) unsigned NOT NULL default '0',
+  PRIMARY KEY (id_member, id_board)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `log_comments`
+#
+
+CREATE TABLE {$db_prefix}log_comments (
+  id_comment mediumint(8) unsigned NOT NULL auto_increment,
+  id_member mediumint(8) unsigned NOT NULL default '0',
+  member_name varchar(80) NOT NULL default '',
+  comment_type varchar(8) NOT NULL default 'warning',
+  id_recipient mediumint(8) unsigned NOT NULL default '0',
+  recipient_name varchar(255) NOT NULL default '',
+  log_time int(10) NOT NULL default '0',
+  id_notice mediumint(8) unsigned NOT NULL default '0',
+  counter tinyint(3) NOT NULL default '0',
+  body text NOT NULL,
+  PRIMARY KEY (id_comment),
+  KEY id_recipient (id_recipient),
+  KEY log_time (log_time),
+  KEY comment_type (comment_type(8))
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `log_digest`
+#
+
+CREATE TABLE {$db_prefix}log_digest (
+  id_topic mediumint(8) unsigned NOT NULL,
+  id_msg int(10) unsigned NOT NULL,
+  note_type varchar(10) NOT NULL default 'post',
+  daily tinyint(3) unsigned NOT NULL default '0',
+  exclude mediumint(8) unsigned NOT NULL default '0'
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `log_errors`
+#
+
+CREATE TABLE {$db_prefix}log_errors (
+  id_error mediumint(8) unsigned NOT NULL auto_increment,
+  log_time int(10) unsigned NOT NULL default '0',
+  id_member mediumint(8) unsigned NOT NULL default '0',
+  ip char(16) NOT NULL default '                ',
+  url text NOT NULL,
+  message text NOT NULL,
+  session char(32) NOT NULL default '                                ',
+  error_type char(15) NOT NULL default 'general',
+  file varchar(255) NOT NULL default '',
+  line mediumint(8) unsigned NOT NULL default '0',
+  PRIMARY KEY (id_error),
+  KEY log_time (log_time),
+  KEY id_member (id_member),
+  KEY ip (ip(16))
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `log_floodcontrol`
+#
+
+CREATE TABLE {$db_prefix}log_floodcontrol (
+  ip char(16) NOT NULL default '                ',
+  log_time int(10) unsigned NOT NULL default '0',
+  log_type varchar(8) NOT NULL default 'post',
+  PRIMARY KEY (ip(16), log_type(8))
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `log_group_requests`
+#
+
+CREATE TABLE {$db_prefix}log_group_requests (
+  id_request mediumint(8) unsigned NOT NULL auto_increment,
+  id_member mediumint(8) unsigned NOT NULL default '0',
+  id_group smallint(5) unsigned NOT NULL default '0',
+  time_applied int(10) unsigned NOT NULL default '0',
+  reason text NOT NULL,
+  PRIMARY KEY (id_request),
+  UNIQUE id_member (id_member, id_group)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `log_karma`
+#
+
+CREATE TABLE {$db_prefix}log_karma (
+  id_target mediumint(8) unsigned NOT NULL default '0',
+  id_executor mediumint(8) unsigned NOT NULL default '0',
+  log_time int(10) unsigned NOT NULL default '0',
+  action tinyint(4) NOT NULL default '0',
+  PRIMARY KEY (id_target, id_executor),
+  KEY log_time (log_time)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `log_mark_read`
+#
+
+CREATE TABLE {$db_prefix}log_mark_read (
+  id_member mediumint(8) unsigned NOT NULL default '0',
+  id_board smallint(5) unsigned NOT NULL default '0',
+  id_msg int(10) unsigned NOT NULL default '0',
+  PRIMARY KEY (id_member, id_board)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `log_member_notices`
+#
+
+CREATE TABLE {$db_prefix}log_member_notices (
+  id_notice mediumint(8) unsigned NOT NULL auto_increment,
+  subject varchar(255) NOT NULL default '',
+  body text NOT NULL,
+  PRIMARY KEY (id_notice)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `log_notify`
+#
+
+CREATE TABLE {$db_prefix}log_notify (
+  id_member mediumint(8) unsigned NOT NULL default '0',
+  id_topic mediumint(8) unsigned NOT NULL default '0',
+  id_board smallint(5) unsigned NOT NULL default '0',
+  sent tinyint(1) unsigned NOT NULL default '0',
+  PRIMARY KEY (id_member, id_topic, id_board),
+  KEY id_topic (id_topic, id_member)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `log_online`
+#
+
+CREATE TABLE {$db_prefix}log_online (
+  session varchar(32) NOT NULL default '',
+  log_time int(10) NOT NULL default '0',
+  id_member mediumint(8) unsigned NOT NULL default '0',
+  id_spider smallint(5) unsigned NOT NULL default '0',
+  ip int(10) unsigned NOT NULL default '0',
+  url text NOT NULL,
+  PRIMARY KEY (session),
+  KEY log_time (log_time),
+  KEY id_member (id_member)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `log_packages`
+#
+
+CREATE TABLE {$db_prefix}log_packages (
+  id_install int(10) NOT NULL auto_increment,
+  filename varchar(255) NOT NULL default '',
+  package_id varchar(255) NOT NULL default '',
+  name varchar(255) NOT NULL default '',
+  version varchar(255) NOT NULL default '',
+  id_member_installed mediumint(8) NOT NULL default '0',
+  member_installed varchar(255) NOT NULL default '',
+  time_installed int(10) NOT NULL default '0',
+  id_member_removed mediumint(8) NOT NULL default '0',
+  member_removed varchar(255) NOT NULL default '',
+  time_removed int(10) NOT NULL default '0',
+  install_state tinyint(3) NOT NULL default '1',
+  failed_steps text NOT NULL,
+  themes_installed varchar(255) NOT NULL default '',
+  db_changes text NOT NULL,
+  PRIMARY KEY (id_install),
+  KEY filename (filename(15))
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `log_polls`
+#
+
+CREATE TABLE {$db_prefix}log_polls (
+  id_poll mediumint(8) unsigned NOT NULL default '0',
+  id_member mediumint(8) unsigned NOT NULL default '0',
+  id_choice tinyint(3) unsigned NOT NULL default '0',
+  KEY id_poll (id_poll, id_member, id_choice)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `log_reported`
+#
+
+CREATE TABLE {$db_prefix}log_reported (
+  id_report mediumint(8) unsigned NOT NULL auto_increment,
+  id_msg int(10) unsigned NOT NULL default '0',
+  id_topic mediumint(8) unsigned NOT NULL default '0',
+  id_board smallint(5) unsigned NOT NULL default '0',
+  id_member mediumint(8) unsigned NOT NULL default '0',
+  membername varchar(255) NOT NULL default '',
+  subject varchar(255) NOT NULL default '',
+  body text NOT NULL,
+  time_started int(10) NOT NULL default '0',
+  time_updated int(10) NOT NULL default '0',
+  num_reports mediumint(6) NOT NULL default '0',
+  closed tinyint(3) NOT NULL default '0',
+  ignore_all tinyint(3) NOT NULL default '0',
+  PRIMARY KEY (id_report),
+  KEY id_member (id_member),
+  KEY id_topic (id_topic),
+  KEY closed (closed),
+  KEY time_started (time_started),
+  KEY id_msg (id_msg)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `log_reported_comments`
+#
+
+CREATE TABLE {$db_prefix}log_reported_comments (
+  id_comment mediumint(8) unsigned NOT NULL auto_increment,
+  id_report mediumint(8) NOT NULL default '0',
+  id_member mediumint(8) NOT NULL,
+  membername varchar(255) NOT NULL default '',
+  email_address varchar(255) NOT NULL default '',
+  member_ip varchar(255) NOT NULL default '',
+  comment varchar(255) NOT NULL default '',
+  time_sent int(10) NOT NULL,
+  PRIMARY KEY (id_comment),
+  KEY id_report (id_report),
+  KEY id_member (id_member),
+  KEY time_sent (time_sent)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `log_scheduled_tasks`
+#
+
+CREATE TABLE {$db_prefix}log_scheduled_tasks (
+  id_log mediumint(8) NOT NULL auto_increment,
+  id_task smallint(5) NOT NULL default '0',
+  time_run int(10) NOT NULL default '0',
+  time_taken float NOT NULL default '0',
+  PRIMARY KEY (id_log)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `log_search_messages`
+#
+
+CREATE TABLE {$db_prefix}log_search_messages (
+  id_search tinyint(3) unsigned NOT NULL default '0',
+  id_msg int(10) unsigned NOT NULL default '0',
+  PRIMARY KEY (id_search, id_msg)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `log_search_results`
+#
+
+CREATE TABLE {$db_prefix}log_search_results (
+  id_search tinyint(3) unsigned NOT NULL default '0',
+  id_topic mediumint(8) unsigned NOT NULL default '0',
+  id_msg int(10) unsigned NOT NULL default '0',
+  relevance smallint(5) unsigned NOT NULL default '0',
+  num_matches smallint(5) unsigned NOT NULL default '0',
+  PRIMARY KEY (id_search, id_topic)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `log_search_subjects`
+#
+
+CREATE TABLE {$db_prefix}log_search_subjects (
+  word varchar(20) NOT NULL default '',
+  id_topic mediumint(8) unsigned NOT NULL default '0',
+  PRIMARY KEY (word, id_topic),
+  KEY id_topic (id_topic)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `log_search_topics`
+#
+
+CREATE TABLE {$db_prefix}log_search_topics (
+  id_search tinyint(3) unsigned NOT NULL default '0',
+  id_topic mediumint(8) unsigned NOT NULL default '0',
+  PRIMARY KEY (id_search, id_topic)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `log_spider_hits`
+#
+
+CREATE TABLE {$db_prefix}log_spider_hits (
+	id_hit int(10) unsigned NOT NULL auto_increment,
+  id_spider smallint(5) unsigned NOT NULL default '0',
+  log_time int(10) unsigned NOT NULL default '0',
+  url varchar(255) NOT NULL default '',
+  processed tinyint(3) NOT NULL default '0',
+  PRIMARY KEY (id_hit),
+  KEY id_spider(id_spider),
+  KEY log_time(log_time),
+  KEY processed (processed)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `log_spider_stats`
+#
+
+CREATE TABLE {$db_prefix}log_spider_stats (
+  id_spider smallint(5) unsigned NOT NULL default '0',
+  page_hits smallint(5) unsigned NOT NULL default '0',
+  last_seen int(10) unsigned NOT NULL default '0',
+  stat_date date NOT NULL default '0001-01-01',
+  PRIMARY KEY (stat_date, id_spider)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `log_subscribed`
+#
+
+CREATE TABLE {$db_prefix}log_subscribed (
+  id_sublog int(10) unsigned NOT NULL auto_increment,
+  id_subscribe mediumint(8) unsigned NOT NULL default '0',
+  id_member int(10) NOT NULL default '0',
+  old_id_group smallint(5) NOT NULL default '0',
+  start_time int(10) NOT NULL default '0',
+  end_time int(10) NOT NULL default '0',
+  status tinyint(3) NOT NULL default '0',
+  payments_pending tinyint(3) NOT NULL default '0',
+  pending_details text NOT NULL,
+  reminder_sent tinyint(3) NOT NULL default '0',
+  vendor_ref varchar(255) NOT NULL default '',
+  PRIMARY KEY (id_sublog),
+  UNIQUE KEY id_subscribe (id_subscribe, id_member),
+  KEY end_time (end_time),
+  KEY reminder_sent (reminder_sent),
+  KEY payments_pending (payments_pending),
+  KEY status (status),
+  KEY id_member (id_member)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `log_topics`
+#
+
+CREATE TABLE {$db_prefix}log_topics (
+  id_member mediumint(8) unsigned NOT NULL default '0',
+  id_topic mediumint(8) unsigned NOT NULL default '0',
+  id_msg int(10) unsigned NOT NULL default '0',
+  PRIMARY KEY (id_member, id_topic),
+  KEY id_topic (id_topic)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `mail_queue`
+#
+
+CREATE TABLE {$db_prefix}mail_queue (
+  id_mail int(10) unsigned NOT NULL auto_increment,
+  time_sent int(10) NOT NULL default '0',
+  recipient varchar(255) NOT NULL default '',
+  body text NOT NULL,
+  subject varchar(255) NOT NULL default '',
+  headers text NOT NULL,
+  send_html tinyint(3) NOT NULL default '0',
+  priority tinyint(3) NOT NULL default '1',
+  private tinyint(1) NOT NULL default '0',
+  PRIMARY KEY  (id_mail),
+  KEY time_sent (time_sent),
+  KEY mail_priority (priority, id_mail)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `membergroups`
+#
+
+CREATE TABLE {$db_prefix}membergroups (
+  id_group smallint(5) unsigned NOT NULL auto_increment,
+  group_name varchar(80) NOT NULL default '',
+  description text NOT NULL,
+  online_color varchar(20) NOT NULL default '',
+  min_posts mediumint(9) NOT NULL default '-1',
+  max_messages smallint(5) unsigned NOT NULL default '0',
+  stars varchar(255) NOT NULL default '',
+  group_type tinyint(3) NOT NULL default '0',
+  hidden tinyint(3) NOT NULL default '0',
+  id_parent smallint(5) NOT NULL default '-2',
+  PRIMARY KEY (id_group),
+  KEY min_posts (min_posts)
+) ENGINE=MyISAM;
+
+#
+# Dumping data for table `membergroups`
+#
+
+INSERT INTO {$db_prefix}membergroups
+	(id_group, group_name, description, online_color, min_posts, stars, group_type)
+VALUES (1, '{$default_administrator_group}', '', '#FF0000', -1, '5#staradmin.gif', 1),
+	(2, '{$default_global_moderator_group}', '', '#0000FF', -1, '5#stargmod.gif', 0),
+	(3, '{$default_moderator_group}', '', '', -1, '5#starmod.gif', 0),
+	(4, '{$default_newbie_group}', '', '', 0, '1#star.gif', 0),
+	(5, '{$default_junior_group}', '', '', 50, '2#star.gif', 0),
+	(6, '{$default_full_group}', '', '', 100, '3#star.gif', 0),
+	(7, '{$default_senior_group}', '', '', 250, '4#star.gif', 0),
+	(8, '{$default_hero_group}', '', '', 500, '5#star.gif', 0);
+# --------------------------------------------------------
+
+#
+# Table structure for table `members`
+#
+
+CREATE TABLE {$db_prefix}members (
+  id_member mediumint(8) unsigned NOT NULL auto_increment,
+  member_name varchar(80) NOT NULL default '',
+  date_registered int(10) unsigned NOT NULL default '0',
+  posts mediumint(8) unsigned NOT NULL default '0',
+  id_group smallint(5) unsigned NOT NULL default '0',
+  lngfile varchar(255) NOT NULL default '',
+  last_login int(10) unsigned NOT NULL default '0',
+  real_name varchar(255) NOT NULL default '',
+  instant_messages smallint(5) NOT NULL default 0,
+  unread_messages smallint(5) NOT NULL default 0,
+  new_pm tinyint(3) unsigned NOT NULL default '0',
+  buddy_list text NOT NULL,
+  pm_ignore_list varchar(255) NOT NULL default '',
+  pm_prefs mediumint(8) NOT NULL default '0',
+  mod_prefs varchar(20) NOT NULL default '',
+  message_labels text NOT NULL,
+  passwd varchar(64) NOT NULL default '',
+  openid_uri text NOT NULL,
+  email_address varchar(255) NOT NULL default '',
+  personal_text varchar(255) NOT NULL default '',
+  gender tinyint(4) unsigned NOT NULL default '0',
+  birthdate date NOT NULL default '0001-01-01',
+  website_title varchar(255) NOT NULL default '',
+  website_url varchar(255) NOT NULL default '',
+  location varchar(255) NOT NULL default '',
+  icq varchar(255) NOT NULL default '',
+  aim varchar(255) NOT NULL default '',
+  yim varchar(32) NOT NULL default '',
+  msn varchar(255) NOT NULL default '',
+  hide_email tinyint(4) NOT NULL default '0',
+  show_online tinyint(4) NOT NULL default '1',
+  time_format varchar(80) NOT NULL default '',
+  signature text NOT NULL,
+  time_offset float NOT NULL default '0',
+  avatar varchar(255) NOT NULL default '',
+  pm_email_notify tinyint(4) NOT NULL default '0',
+  karma_bad smallint(5) unsigned NOT NULL default '0',
+  karma_good smallint(5) unsigned NOT NULL default '0',
+  usertitle varchar(255) NOT NULL default '',
+  notify_announcements tinyint(4) NOT NULL default '1',
+  notify_regularity tinyint(4) NOT NULL default '1',
+  notify_send_body tinyint(4) NOT NULL default '0',
+  notify_types tinyint(4) NOT NULL default '2',
+  member_ip varchar(255) NOT NULL default '',
+  member_ip2 varchar(255) NOT NULL default '',
+  secret_question varchar(255) NOT NULL default '',
+  secret_answer varchar(64) NOT NULL default '',
+  id_theme tinyint(4) unsigned NOT NULL default '0',
+  is_activated tinyint(3) unsigned NOT NULL default '1',
+  validation_code varchar(10) NOT NULL default '',
+  id_msg_last_visit int(10) unsigned NOT NULL default '0',
+  additional_groups varchar(255) NOT NULL default '',
+  smiley_set varchar(48) NOT NULL default '',
+  id_post_group smallint(5) unsigned NOT NULL default '0',
+  total_time_logged_in int(10) unsigned NOT NULL default '0',
+  password_salt varchar(255) NOT NULL default '',
+  ignore_boards text NOT NULL,
+  warning tinyint(4) NOT NULL default '0',
+  passwd_flood varchar(12) NOT NULL default '',
+  pm_receive_from tinyint(4) unsigned NOT NULL default '1',
+  PRIMARY KEY (id_member),
+  KEY member_name (member_name),
+  KEY real_name (real_name),
+  KEY date_registered (date_registered),
+  KEY id_group (id_group),
+  KEY birthdate (birthdate),
+  KEY posts (posts),
+  KEY last_login (last_login),
+  KEY lngfile (lngfile(30)),
+  KEY id_post_group (id_post_group),
+  KEY warning (warning),
+  KEY total_time_logged_in (total_time_logged_in),
+  KEY id_theme (id_theme)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `member_logins`
+#
+
+CREATE TABLE {$db_prefix}member_logins (
+  id_login int(10) NOT NULL auto_increment,
+  id_member mediumint(8) NOT NULL default '0',
+  time int(10) NOT NULL default '0',
+  ip varchar(255) NOT NULL default '0',
+  ip2 varchar(255) NOT NULL default '0',
+  PRIMARY KEY (id_login),
+  KEY id_member (id_member),
+  KEY time (time)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `message_icons`
+#
+
+CREATE TABLE {$db_prefix}message_icons (
+  id_icon smallint(5) unsigned NOT NULL auto_increment,
+  title varchar(80) NOT NULL default '',
+  filename varchar(80) NOT NULL default '',
+  id_board smallint(5) unsigned NOT NULL default '0',
+  icon_order smallint(5) unsigned NOT NULL default '0',
+  PRIMARY KEY (id_icon),
+  KEY id_board (id_board)
+) ENGINE=MyISAM;
+
+#
+# Dumping data for table `message_icons`
+#
+
+# // @todo i18n
+INSERT INTO {$db_prefix}message_icons
+	(filename, title, icon_order)
+VALUES ('xx', 'Standard', '0'),
+	('thumbup', 'Thumb Up', '1'),
+	('thumbdown', 'Thumb Down', '2'),
+	('exclamation', 'Exclamation point', '3'),
+	('question', 'Question mark', '4'),
+	('lamp', 'Lamp', '5'),
+	('smiley', 'Smiley', '6'),
+	('angry', 'Angry', '7'),
+	('cheesy', 'Cheesy', '8'),
+	('grin', 'Grin', '9'),
+	('sad', 'Sad', '10'),
+	('wink', 'Wink', '11');
+# --------------------------------------------------------
+
+#
+# Table structure for table `messages`
+#
+
+CREATE TABLE {$db_prefix}messages (
+  id_msg int(10) unsigned NOT NULL auto_increment,
+  id_topic mediumint(8) unsigned NOT NULL default '0',
+  id_board smallint(5) unsigned NOT NULL default '0',
+  poster_time int(10) unsigned NOT NULL default '0',
+  id_member mediumint(8) unsigned NOT NULL default '0',
+  id_msg_modified int(10) unsigned NOT NULL default '0',
+  subject varchar(255) NOT NULL default '',
+  poster_name varchar(255) NOT NULL default '',
+  poster_email varchar(255) NOT NULL default '',
+  poster_ip varchar(255) NOT NULL default '',
+  smileys_enabled tinyint(4) NOT NULL default '1',
+  modified_time int(10) unsigned NOT NULL default '0',
+  modified_name varchar(255) NOT NULL default '',
+  body text NOT NULL,
+  icon varchar(16) NOT NULL default 'xx',
+  approved tinyint(3) NOT NULL default '1',
+  PRIMARY KEY (id_msg),
+  UNIQUE topic (id_topic, id_msg),
+  UNIQUE id_board (id_board, id_msg),
+  UNIQUE id_member (id_member, id_msg),
+  KEY approved (approved),
+  KEY ip_index (poster_ip(15), id_topic),
+  KEY participation (id_member, id_topic),
+  KEY show_posts (id_member, id_board),
+  KEY id_topic (id_topic),
+  KEY id_member_msg (id_member, approved, id_msg),
+  KEY current_topic (id_topic, id_msg, id_member, approved),
+  KEY related_ip (id_member, poster_ip, id_msg)
+) ENGINE=MyISAM;
+
+#
+# Dumping data for table `messages`
+#
+
+INSERT INTO {$db_prefix}messages
+	(id_msg, id_msg_modified, id_topic, id_board, poster_time, subject, poster_name, poster_email, poster_ip, modified_name, body, icon)
+VALUES (1, 1, 1, 1, UNIX_TIMESTAMP(), '{$default_topic_subject}', 'Simple Machines', '[email protected]', '127.0.0.1', '', '{$default_topic_message}', 'xx');
+# --------------------------------------------------------
+
+#
+# Table structure for table `moderators`
+#
+
+CREATE TABLE {$db_prefix}moderators (
+  id_board smallint(5) unsigned NOT NULL default '0',
+  id_member mediumint(8) unsigned NOT NULL default '0',
+  PRIMARY KEY (id_board, id_member)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `openid_assoc`
+#
+
+CREATE TABLE {$db_prefix}openid_assoc (
+  server_url text NOT NULL,
+  handle varchar(255) NOT NULL default '',
+  secret text NOT NULL,
+  issued int(10) NOT NULL default '0',
+  expires int(10) NOT NULL default '0',
+  assoc_type varchar(64) NOT NULL,
+  PRIMARY KEY (server_url(125), handle(125)),
+  KEY expires (expires)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `package_servers`
+#
+
+CREATE TABLE {$db_prefix}package_servers (
+  id_server smallint(5) unsigned NOT NULL auto_increment,
+  name varchar(255) NOT NULL default '',
+  url varchar(255) NOT NULL default '',
+  PRIMARY KEY (id_server)
+) ENGINE=MyISAM;
+
+#
+# Dumping data for table `package_servers`
+#
+
+INSERT INTO {$db_prefix}package_servers
+	(name, url)
+VALUES ('Simple Machines Third-party Mod Site', 'http://custom.simplemachines.org/packages/mods');
+# --------------------------------------------------------
+
+#
+# Table structure for table `permission_profiles`
+#
+
+CREATE TABLE {$db_prefix}permission_profiles (
+  id_profile smallint(5) NOT NULL auto_increment,
+  profile_name varchar(255) NOT NULL default '',
+  PRIMARY KEY (id_profile)
+) ENGINE=MyISAM;
+
+#
+# Dumping data for table `permission_profiles`
+#
+
+INSERT INTO {$db_prefix}permission_profiles
+	(id_profile, profile_name)
+VALUES (1, 'default'), (2, 'no_polls'), (3, 'reply_only'), (4, 'read_only');
+# --------------------------------------------------------
+
+#
+# Table structure for table `permissions`
+#
+
+CREATE TABLE {$db_prefix}permissions (
+  id_group smallint(5) NOT NULL default '0',
+  permission varchar(30) NOT NULL default '',
+  add_deny tinyint(4) NOT NULL default '1',
+  PRIMARY KEY (id_group, permission)
+) ENGINE=MyISAM;
+
+#
+# Dumping data for table `permissions`
+#
+
+INSERT INTO {$db_prefix}permissions
+	(id_group, permission)
+VALUES (-1, 'search_posts'),
+	(-1, 'calendar_view'),
+	(-1, 'view_stats'),
+	(-1, 'profile_view_any'),
+	(0, 'view_mlist'),
+	(0, 'search_posts'),
+	(0, 'profile_view_own'),
+	(0, 'profile_view_any'),
+	(0, 'pm_read'),
+	(0, 'pm_send'),
+	(0, 'calendar_view'),
+	(0, 'view_stats'),
+	(0, 'who_view'),
+	(0, 'profile_identity_own'),
+	(0, 'profile_extra_own'),
+	(0, 'profile_remove_own'),
+	(0, 'profile_server_avatar'),
+	(0, 'profile_upload_avatar'),
+	(0, 'profile_remote_avatar'),
+	(0, 'karma_edit'),
+	(2, 'view_mlist'),
+	(2, 'search_posts'),
+	(2, 'profile_view_own'),
+	(2, 'profile_view_any'),
+	(2, 'pm_read'),
+	(2, 'pm_send'),
+	(2, 'calendar_view'),
+	(2, 'view_stats'),
+	(2, 'who_view'),
+	(2, 'profile_identity_own'),
+	(2, 'profile_extra_own'),
+	(2, 'profile_remove_own'),
+	(2, 'profile_server_avatar'),
+	(2, 'profile_upload_avatar'),
+	(2, 'profile_remote_avatar'),
+	(2, 'profile_title_own'),
+	(2, 'calendar_post'),
+	(2, 'calendar_edit_any'),
+	(2, 'karma_edit'),
+	(2, 'access_mod_center');
+# --------------------------------------------------------
+
+#
+# Table structure for table `personal_messages`
+#
+
+CREATE TABLE {$db_prefix}personal_messages (
+  id_pm int(10) unsigned NOT NULL auto_increment,
+  id_pm_head int(10) unsigned NOT NULL default '0',
+  id_member_from mediumint(8) unsigned NOT NULL default '0',
+  deleted_by_sender tinyint(3) unsigned NOT NULL default '0',
+  from_name varchar(255) NOT NULL default '',
+  msgtime int(10) unsigned NOT NULL default '0',
+  subject varchar(255) NOT NULL default '',
+  body text NOT NULL,
+  PRIMARY KEY (id_pm),
+  KEY id_member (id_member_from, deleted_by_sender),
+  KEY msgtime (msgtime),
+  KEY id_pm_head (id_pm_head)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `pm_recipients`
+#
+
+CREATE TABLE {$db_prefix}pm_recipients (
+  id_pm int(10) unsigned NOT NULL default '0',
+  id_member mediumint(8) unsigned NOT NULL default '0',
+  labels varchar(60) NOT NULL default '-1',
+  bcc tinyint(3) unsigned NOT NULL default '0',
+  is_read tinyint(3) unsigned NOT NULL default '0',
+  is_new tinyint(3) unsigned NOT NULL default '0',
+  deleted tinyint(3) unsigned NOT NULL default '0',
+  PRIMARY KEY (id_pm, id_member),
+  UNIQUE id_member (id_member, deleted, id_pm)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `pm_rules`
+#
+
+CREATE TABLE {$db_prefix}pm_rules (
+  id_rule int(10) unsigned NOT NULL auto_increment,
+  id_member int(10) unsigned NOT NULL default '0',
+  rule_name varchar(60) NOT NULL,
+  criteria text NOT NULL,
+  actions text NOT NULL,
+  delete_pm tinyint(3) unsigned NOT NULL default '0',
+  is_or tinyint(3) unsigned NOT NULL default '0',
+  PRIMARY KEY (id_rule),
+  KEY id_member (id_member),
+  KEY delete_pm (delete_pm)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `polls`
+#
+
+CREATE TABLE {$db_prefix}polls (
+  id_poll mediumint(8) unsigned NOT NULL auto_increment,
+  question varchar(255) NOT NULL default '',
+  voting_locked tinyint(1) NOT NULL default '0',
+  max_votes tinyint(3) unsigned NOT NULL default '1',
+  expire_time int(10) unsigned NOT NULL default '0',
+  hide_results tinyint(3) unsigned NOT NULL default '0',
+  change_vote tinyint(3) unsigned NOT NULL default '0',
+  guest_vote tinyint(3) unsigned NOT NULL default '0',
+  num_guest_voters int(10) unsigned NOT NULL default '0',
+  reset_poll int(10) unsigned NOT NULL default '0',
+  id_member mediumint(8) NOT NULL default '0',
+  poster_name varchar(255) NOT NULL default '',
+  PRIMARY KEY (id_poll)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `poll_choices`
+#
+
+CREATE TABLE {$db_prefix}poll_choices (
+  id_poll mediumint(8) unsigned NOT NULL default '0',
+  id_choice tinyint(3) unsigned NOT NULL default '0',
+  label varchar(255) NOT NULL default '',
+  votes smallint(5) unsigned NOT NULL default '0',
+  PRIMARY KEY (id_poll, id_choice)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `scheduled_tasks`
+#
+
+CREATE TABLE {$db_prefix}scheduled_tasks (
+  id_task smallint(5) NOT NULL auto_increment,
+  next_time int(10) NOT NULL default '0',
+  time_offset int(10) NOT NULL default '0',
+  time_regularity smallint(5) NOT NULL default '0',
+  time_unit varchar(1) NOT NULL default 'h',
+  disabled tinyint(3) NOT NULL default '0',
+  task varchar(24) NOT NULL default '',
+  PRIMARY KEY (id_task),
+  KEY next_time (next_time),
+  KEY disabled (disabled),
+  UNIQUE task (task)
+) ENGINE=MyISAM;
+
+#
+# Dumping data for table `scheduled_tasks`
+#
+
+INSERT INTO {$db_prefix}scheduled_tasks
+	(id_task, next_time, time_offset, time_regularity, time_unit, disabled, task)
+VALUES
+	(1, 0, 0, 2, 'h', 0, 'approval_notification'),
+	(2, 0, 0, 7, 'd', 0, 'auto_optimize'),
+	(3, 0, 60, 1, 'd', 0, 'daily_maintenance'),
+	(5, 0, 0, 1, 'd', 0, 'daily_digest'),
+	(6, 0, 0, 1, 'w', 0, 'weekly_digest'),
+	(7, 0, {$sched_task_offset}, 1, 'd', 0, 'fetchSMfiles'),
+	(8, 0, 0, 1, 'd', 1, 'birthdayemails'),
+	(9, 0, 0, 1, 'w', 0, 'weekly_maintenance'),
+	(10, 0, 120, 1, 'd', 1, 'paid_subscriptions');
+
+# --------------------------------------------------------
+
+#
+# Table structure for table `settings`
+#
+
+CREATE TABLE {$db_prefix}settings (
+  variable varchar(255) NOT NULL default '',
+  value text NOT NULL,
+  PRIMARY KEY (variable(30))
+) ENGINE=MyISAM;
+
+#
+# Dumping data for table `settings`
+#
+
+INSERT INTO {$db_prefix}settings
+	(variable, value)
+VALUES ('smfVersion', '{$smf_version}'),
+	('news', '{$default_news}'),
+	('compactTopicPagesContiguous', '5'),
+	('compactTopicPagesEnable', '1'),
+	('enableStickyTopics', '1'),
+	('todayMod', '1'),
+	('karmaMode', '0'),
+	('karmaTimeRestrictAdmins', '1'),
+	('enablePreviousNext', '1'),
+	('pollMode', '1'),
+	('enableVBStyleLogin', '1'),
+	('enableCompressedOutput', '{$enableCompressedOutput}'),
+	('karmaWaitTime', '1'),
+	('karmaMinPosts', '0'),
+	('karmaLabel', '{$default_karmaLabel}'),
+	('karmaSmiteLabel', '{$default_karmaSmiteLabel}'),
+	('karmaApplaudLabel', '{$default_karmaApplaudLabel}'),
+	('attachmentSizeLimit', '128'),
+	('attachmentPostLimit', '192'),
+	('attachmentNumPerPostLimit', '4'),
+	('attachmentDirSizeLimit', '10240'),
+	('attachmentUploadDir', '{$boarddir}/attachments'),
+	('attachmentExtensions', 'doc,gif,jpg,mpg,pdf,png,txt,zip'),
+	('attachmentCheckExtensions', '0'),
+	('attachmentShowImages', '1'),
+	('attachmentEnable', '1'),
+	('attachmentEncryptFilenames', '1'),
+	('attachmentThumbnails', '1'),
+	('attachmentThumbWidth', '150'),
+	('attachmentThumbHeight', '150'),
+	('censorIgnoreCase', '1'),
+	('mostOnline', '1'),
+	('mostOnlineToday', '1'),
+	('mostDate', UNIX_TIMESTAMP()),
+	('allow_disableAnnounce', '1'),
+	('trackStats', '1'),
+	('userLanguage', '1'),
+	('titlesEnable', '1'),
+	('topicSummaryPosts', '15'),
+	('enableErrorLogging', '1'),
+	('max_image_width', '0'),
+	('max_image_height', '0'),
+	('onlineEnable', '0'),
+	('cal_enabled', '0'),
+	('cal_maxyear', '2020'),
+	('cal_minyear', '2008'),
+	('cal_daysaslink', '0'),
+	('cal_defaultboard', ''),
+	('cal_showholidays', '1'),
+	('cal_showbdays', '1'),
+	('cal_showevents', '1'),
+	('cal_showweeknum', '0'),
+	('cal_maxspan', '7'),
+	('smtp_host', ''),
+	('smtp_port', '25'),
+	('smtp_username', ''),
+	('smtp_password', ''),
+	('mail_type', '0'),
+	('timeLoadPageEnable', '0'),
+	('totalMembers', '0'),
+	('totalTopics', '1'),
+	('totalMessages', '1'),
+	('simpleSearch', '0'),
+	('censor_vulgar', ''),
+	('censor_proper', ''),
+	('enablePostHTML', '0'),
+	('theme_allow', '1'),
+	('theme_default', '1'),
+	('theme_guests', '1'),
+	('enableEmbeddedFlash', '0'),
+	('xmlnews_enable', '1'),
+	('xmlnews_maxlen', '255'),
+	('hotTopicPosts', '15'),
+	('hotTopicVeryPosts', '25'),
+	('registration_method', '0'),
+	('send_validation_onChange', '0'),
+	('send_welcomeEmail', '1'),
+	('allow_editDisplayName', '1'),
+	('allow_hideOnline', '1'),
+	('guest_hideContacts', '1'),
+	('spamWaitTime', '5'),
+	('pm_spam_settings', '10,5,20'),
+	('reserveWord', '0'),
+	('reserveCase', '1'),
+	('reserveUser', '1'),
+	('reserveName', '1'),
+	('reserveNames', '{$default_reserved_names}'),
+	('autoLinkUrls', '1'),
+	('banLastUpdated', '0'),
+	('smileys_dir', '{$boarddir}/Smileys'),
+	('smileys_url', '{$boardurl}/Smileys'),
+	('avatar_directory', '{$boarddir}/avatars'),
+	('avatar_url', '{$boardurl}/avatars'),
+	('avatar_max_height_external', '65'),
+	('avatar_max_width_external', '65'),
+	('avatar_action_too_large', 'option_html_resize'),
+	('avatar_max_height_upload', '65'),
+	('avatar_max_width_upload', '65'),
+	('avatar_resize_upload', '1'),
+	('avatar_download_png', '1'),
+	('failed_login_threshold', '3'),
+	('oldTopicDays', '120'),
+	('edit_wait_time', '90'),
+	('edit_disable_time', '0'),
+	('autoFixDatabase', '1'),
+	('allow_guestAccess', '1'),
+	('time_format', '{$default_time_format}'),
+	('number_format', '1234.00'),
+	('enableBBC', '1'),
+	('max_messageLength', '20000'),
+	('signature_settings', '1,300,0,0,0,0,0,0:'),
+	('autoOptMaxOnline', '0'),
+	('defaultMaxMessages', '15'),
+	('defaultMaxTopics', '20'),
+	('defaultMaxMembers', '30'),
+	('enableParticipation', '1'),
+	('recycle_enable', '0'),
+	('recycle_board', '0'),
+	('maxMsgID', '1'),
+	('enableAllMessages', '0'),
+	('fixLongWords', '0'),
+	('knownThemes', '1,2,3'),
+	('who_enabled', '1'),
+	('time_offset', '0'),
+	('cookieTime', '60'),
+	('lastActive', '15'),
+	('smiley_sets_known', 'default,aaron,akyhne'),
+	('smiley_sets_names', '{$default_smileyset_name}\n{$default_aaron_smileyset_name}\n{$default_akyhne_smileyset_name}'),
+	('smiley_sets_default', 'default'),
+	('cal_days_for_index', '7'),
+	('requireAgreement', '1'),
+	('unapprovedMembers', '0'),
+	('default_personal_text', ''),
+	('package_make_backups', '1'),
+	('databaseSession_enable', '{$databaseSession_enable}'),
+	('databaseSession_loose', '1'),
+	('databaseSession_lifetime', '2880'),
+	('search_cache_size', '50'),
+	('search_results_per_page', '30'),
+	('search_weight_frequency', '30'),
+	('search_weight_age', '25'),
+	('search_weight_length', '20'),
+	('search_weight_subject', '15'),
+	('search_weight_first_message', '10'),
+	('search_max_results', '1200'),
+	('search_floodcontrol_time', '5'),
+	('permission_enable_deny', '0'),
+	('permission_enable_postgroups', '0'),
+	('mail_next_send', '0'),
+	('mail_recent', '0000000000|0'),
+	('settings_updated', '0'),
+	('next_task_time', '1'),
+	('warning_settings', '1,20,0'),
+	('warning_watch', '10'),
+	('warning_moderate', '35'),
+	('warning_mute', '60'),
+	('admin_features', ''),
+	('last_mod_report_action', '0'),
+	('pruningOptions', '30,180,180,180,30,0'),
+	('cache_enable', '1'),
+	('reg_verification', '1'),
+	('visual_verification_type', '3'),
+	('enable_buddylist', '1'),
+	('birthday_email', 'happy_birthday'),
+	('dont_repeat_theme_core', '1'),
+	('dont_repeat_smileys_20', '1'),
+	('dont_repeat_buddylists', '1'),
+	('attachment_image_reencode', '1'),
+	('attachment_image_paranoid', '0'),
+	('attachment_thumb_png', '1'),
+	('avatar_reencode', '1'),
+	('avatar_paranoid', '0');
+# --------------------------------------------------------
+
+#
+# Table structure for table `sessions`
+#
+
+CREATE TABLE {$db_prefix}sessions (
+  session_id char(32) NOT NULL,
+  last_update int(10) unsigned NOT NULL,
+  data text NOT NULL,
+  PRIMARY KEY (session_id)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `smileys`
+#
+
+CREATE TABLE {$db_prefix}smileys (
+  id_smiley smallint(5) unsigned NOT NULL auto_increment,
+  code varchar(30) NOT NULL default '',
+  filename varchar(48) NOT NULL default '',
+  description varchar(80) NOT NULL default '',
+  smiley_row tinyint(4) unsigned NOT NULL default '0',
+  smiley_order smallint(5) unsigned NOT NULL default '0',
+  hidden tinyint(4) unsigned NOT NULL default '0',
+  PRIMARY KEY (id_smiley)
+) ENGINE=MyISAM;
+
+#
+# Dumping data for table `smileys`
+#
+
+INSERT INTO {$db_prefix}smileys
+	(code, filename, description, smiley_order, hidden)
+VALUES (':)', 'smiley.gif', '{$default_smiley_smiley}', 0, 0),
+	(';)', 'wink.gif', '{$default_wink_smiley}', 1, 0),
+	(':D', 'cheesy.gif', '{$default_cheesy_smiley}', 2, 0),
+	(';D', 'grin.gif', '{$default_grin_smiley}', 3, 0),
+	('>:(', 'angry.gif', '{$default_angry_smiley}', 4, 0),
+	(':(', 'sad.gif', '{$default_sad_smiley}', 5, 0),
+	(':o', 'shocked.gif', '{$default_shocked_smiley}', 6, 0),
+	('8)', 'cool.gif', '{$default_cool_smiley}', 7, 0),
+	('???', 'huh.gif', '{$default_huh_smiley}', 8, 0),
+	('::)', 'rolleyes.gif', '{$default_roll_eyes_smiley}', 9, 0),
+	(':P', 'tongue.gif', '{$default_tongue_smiley}', 10, 0),
+	(':-[', 'embarrassed.gif', '{$default_embarrassed_smiley}', 11, 0),
+	(':-X', 'lipsrsealed.gif', '{$default_lips_sealed_smiley}', 12, 0),
+	(':-\\', 'undecided.gif', '{$default_undecided_smiley}', 13, 0),
+	(':-*', 'kiss.gif', '{$default_kiss_smiley}', 14, 0),
+	(':\'(', 'cry.gif', '{$default_cry_smiley}', 15, 0),
+	('>:D', 'evil.gif', '{$default_evil_smiley}', 16, 1),
+	('^-^', 'azn.gif', '{$default_azn_smiley}', 17, 1),
+	('O0', 'afro.gif', '{$default_afro_smiley}', 18, 1),
+	(':))', 'laugh.gif', '{$default_laugh_smiley}', 19, 1),
+	('C:-)', 'police.gif', '{$default_police_smiley}', 20, 1),
+	('O:-)', 'angel.gif', '{$default_angel_smiley}', 21, 1);
+# --------------------------------------------------------
+
+#
+# Table structure for table `spiders`
+#
+
+CREATE TABLE {$db_prefix}spiders (
+  id_spider smallint(5) unsigned NOT NULL auto_increment,
+  spider_name varchar(255) NOT NULL default '',
+  user_agent varchar(255) NOT NULL default '',
+  ip_info varchar(255) NOT NULL default '',
+  PRIMARY KEY id_spider(id_spider)
+) ENGINE=MyISAM;
+
+#
+# Dumping data for table `spiders`
+#
+
+INSERT INTO {$db_prefix}spiders
+	(id_spider, spider_name, user_agent, ip_info)
+VALUES (1, 'Google', 'googlebot', ''),
+	(2, 'Yahoo!', 'slurp', ''),
+	(3, 'MSN', 'msnbot', ''),
+	(4, 'Google (Mobile)', 'Googlebot-Mobile', ''),
+	(5, 'Google (Image)', 'Googlebot-Image', ''),
+	(6, 'Google (AdSense)', 'Mediapartners-Google', ''),
+	(7, 'Google (Adwords)', 'AdsBot-Google', ''),
+	(8, 'Yahoo! (Mobile)', 'YahooSeeker/M1A1-R2D2', ''),
+	(9, 'Yahoo! (Image)', 'Yahoo-MMCrawler', ''),
+	(10, 'MSN (Mobile)', 'MSNBOT_Mobile', ''),
+	(11, 'MSN (Media)', 'msnbot-media', ''),
+	(12, 'Cuil', 'twiceler', ''),
+	(13, 'Ask', 'Teoma', ''),
+	(14, 'Baidu', 'Baiduspider', ''),
+	(15, 'Gigablast', 'Gigabot', ''),
+	(16, 'InternetArchive', 'ia_archiver-web.archive.org', ''),
+	(17, 'Alexa', 'ia_archiver', ''),
+	(18, 'Omgili', 'omgilibot', ''),
+	(19, 'EntireWeb', 'Speedy Spider', '');
+
+#
+# Table structure for table `subscriptions`
+#
+
+CREATE TABLE {$db_prefix}subscriptions(
+  id_subscribe mediumint(8) unsigned NOT NULL auto_increment,
+  name varchar(60) NOT NULL default '',
+  description varchar(255) NOT NULL default '',
+  cost text NOT NULL,
+  length varchar(6) NOT NULL default '',
+  id_group smallint(5) NOT NULL default '0',
+  add_groups varchar(40) NOT NULL default '',
+  active tinyint(3) NOT NULL default '1',
+  repeatable tinyint(3) NOT NULL default '0',
+  allow_partial tinyint(3) NOT NULL default '0',
+  reminder tinyint(3) NOT NULL default '0',
+  email_complete text NOT NULL,
+  PRIMARY KEY (id_subscribe),
+  KEY active (active)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table `themes`
+#
+
+CREATE TABLE {$db_prefix}themes (
+  id_member mediumint(8) NOT NULL default '0',
+  id_theme tinyint(4) unsigned NOT NULL default '1',
+  variable varchar(255) NOT NULL default '',
+  value text NOT NULL,
+  PRIMARY KEY (id_theme, id_member, variable(30)),
+  KEY id_member (id_member)
+) ENGINE=MyISAM;
+
+#
+# Dumping data for table `themes`
+#
+
+INSERT INTO {$db_prefix}themes
+	(id_theme, variable, value)
+VALUES (1, 'name', '{$default_theme_name}'),
+	(1, 'theme_url', '{$boardurl}/Themes/default'),
+	(1, 'images_url', '{$boardurl}/Themes/default/images'),
+	(1, 'theme_dir', '{$boarddir}/Themes/default'),
+	(1, 'show_bbc', '1'),
+	(1, 'show_latest_member', '1'),
+	(1, 'show_modify', '1'),
+	(1, 'show_user_images', '1'),
+	(1, 'show_blurb', '1'),
+	(1, 'show_gender', '0'),
+	(1, 'show_newsfader', '0'),
+	(1, 'number_recent_posts', '0'),
+	(1, 'show_member_bar', '1'),
+	(1, 'linktree_link', '1'),
+	(1, 'show_profile_buttons', '1'),
+	(1, 'show_mark_read', '1'),
+	(1, 'show_stats_index', '1'),
+	(1, 'linktree_inline', '0'),
+	(1, 'show_board_desc', '1'),
+	(1, 'newsfader_time', '5000'),
+	(1, 'allow_no_censored', '0'),
+	(1, 'additional_options_collapsable', '1'),
+	(1, 'use_image_buttons', '1'),
+	(1, 'enable_news', '1'),
+	(1, 'forum_width', '90%'),
+	(2, 'name', '{$default_core_theme_name}'),
+	(2, 'theme_url', '{$boardurl}/Themes/core'),
+	(2, 'images_url', '{$boardurl}/Themes/core/images'),
+	(2, 'theme_dir', '{$boarddir}/Themes/core');
+
+INSERT INTO {$db_prefix}themes (id_member, id_theme, variable, value) VALUES (-1, 1, 'display_quick_reply', '1');
+INSERT INTO {$db_prefix}themes (id_member, id_theme, variable, value) VALUES (-1, 1, 'posts_apply_ignore_list', '1');
+# --------------------------------------------------------
+
+#
+# Table structure for table `topics`
+#
+
+CREATE TABLE {$db_prefix}topics (
+  id_topic mediumint(8) unsigned NOT NULL auto_increment,
+  is_sticky tinyint(4) NOT NULL default '0',
+  id_board smallint(5) unsigned NOT NULL default '0',
+  id_first_msg int(10) unsigned NOT NULL default '0',
+  id_last_msg int(10) unsigned NOT NULL default '0',
+  id_member_started mediumint(8) unsigned NOT NULL default '0',
+  id_member_updated mediumint(8) unsigned NOT NULL default '0',
+  id_poll mediumint(8) unsigned NOT NULL default '0',
+  id_previous_board smallint(5) NOT NULL default '0',
+  id_previous_topic mediumint(8) NOT NULL default '0',
+  num_replies int(10) unsigned NOT NULL default '0',
+  num_views int(10) unsigned NOT NULL default '0',
+  locked tinyint(4) NOT NULL default '0',
+  unapproved_posts smallint(5) NOT NULL default '0',
+  approved tinyint(3) NOT NULL default '1',
+  PRIMARY KEY (id_topic),
+  UNIQUE last_message (id_last_msg, id_board),
+  UNIQUE first_message (id_first_msg, id_board),
+  UNIQUE poll (id_poll, id_topic),
+  KEY is_sticky (is_sticky),
+  KEY approved (approved),
+  KEY id_board (id_board),
+  KEY member_started (id_member_started, id_board),
+  KEY last_message_sticky (id_board, is_sticky, id_last_msg),
+  KEY board_news (id_board, id_first_msg)
+) ENGINE=MyISAM;
+
+#
+# Dumping data for table `topics`
+#
+
+INSERT INTO {$db_prefix}topics
+	(id_topic, id_board, id_first_msg, id_last_msg, id_member_started, id_member_updated)
+VALUES (1, 1, 1, 1, 0, 0);
+# --------------------------------------------------------

+ 2525 - 0
other/install_2-1_postgresql.sql

@@ -0,0 +1,2525 @@
+#### ATTENTION: You do not need to run or use this file!  The install.php script does everything for you!
+#### Install script for PostgreSQL 8.0.1
+
+#
+# Create PostgreSQL functions.
+# Some taken from http://www.xach.com/aolserver/mysql-functions.sql and http://pgfoundry.org/projects/mysqlcompat/.
+# IP Regex in inet_aton from http://www.mkyong.com/database/regular-expression-in-postgresql/.
+
+CREATE OR REPLACE FUNCTION FROM_UNIXTIME(integer) RETURNS timestamp AS
+  'SELECT timestamp ''epoch'' + $1 * interval ''1 second'' AS result'
+LANGUAGE 'sql';
+
+CREATE OR REPLACE FUNCTION IFNULL (text, text) RETURNS text AS
+  'SELECT COALESCE($1, $2) AS result'
+LANGUAGE 'sql';
+
+CREATE OR REPLACE FUNCTION IFNULL (int4, int4) RETURNS int4 AS
+  'SELECT COALESCE($1, $2) AS result'
+LANGUAGE 'sql';
+
+CREATE OR REPLACE FUNCTION IFNULL (int8, int8) RETURNS int8 AS
+  'SELECT COALESCE($1, $2) AS result'
+LANGUAGE 'sql';
+
+CREATE OR REPLACE FUNCTION IFNULL (character varying, character varying) RETURNS character varying AS
+  'SELECT COALESCE($1, $2) AS result'
+LANGUAGE 'sql';
+
+CREATE OR REPLACE FUNCTION IFNULL (character varying, boolean) RETURNS character varying AS
+  'SELECT COALESCE($1, CAST(CAST($2 AS int) AS varchar)) AS result'
+LANGUAGE 'sql';
+
+CREATE OR REPLACE FUNCTION IFNULL (int, boolean) RETURNS int AS
+  'SELECT COALESCE($1, CAST($2 AS int)) AS result'
+LANGUAGE 'sql';
+
+CREATE OR REPLACE FUNCTION INET_ATON(text) RETURNS bigint AS
+  'SELECT
+	CASE WHEN
+		$1 !~ ''^[0-9]?[0-9]?[0-9]?\.[0-9]?[0-9]?[0-9]?\.[0-9]?[0-9]?[0-9]?\.[0-9]?[0-9]?[0-9]?$'' THEN 0
+	ELSE
+		split_part($1, ''.'', 1)::int8 * (256 * 256 * 256) +
+		split_part($1, ''.'', 2)::int8 * (256 * 256) +
+		split_part($1, ''.'', 3)::int8 * 256 +
+		split_part($1, ''.'', 4)::int8
+	END AS result'
+LANGUAGE 'sql';
+
+CREATE OR REPLACE FUNCTION INET_NTOA(bigint) RETURNS text AS
+  'SELECT
+    (($1 >> 24) & 255::int8) || ''.'' ||
+    (($1 >> 16) & 255::int8) || ''.'' ||
+    (($1 >> 8) & 255::int8) || ''.'' ||
+    ($1 & 255::int8) AS result'
+LANGUAGE 'sql';
+
+CREATE OR REPLACE FUNCTION FIND_IN_SET(needle text, haystack text) RETURNS integer AS '
+	SELECT i AS result
+	FROM generate_series(1, array_upper(string_to_array($2,'',''), 1)) AS g(i)
+	WHERE  (string_to_array($2,'',''))[i] = $1
+		UNION ALL
+	SELECT 0
+	LIMIT 1'
+LANGUAGE 'sql';
+
+CREATE OR REPLACE FUNCTION FIND_IN_SET(needle integer, haystack text) RETURNS integer AS '
+	SELECT i AS result
+	FROM generate_series(1, array_upper(string_to_array($2,'',''), 1)) AS g(i)
+	WHERE  (string_to_array($2,'',''))[i] = CAST($1 AS text)
+		UNION ALL
+	SELECT 0
+	LIMIT 1'
+LANGUAGE 'sql';
+
+CREATE OR REPLACE FUNCTION LEFT (text, int4) RETURNS text AS
+  'SELECT SUBSTRING($1 FROM 0 FOR $2) AS result'
+LANGUAGE 'sql';
+
+CREATE OR REPLACE FUNCTION add_num_text (text, integer) RETURNS text AS
+  'SELECT CAST ((CAST($1 AS integer) + $2) AS text) AS result'
+LANGUAGE 'sql';
+
+CREATE OR REPLACE FUNCTION YEAR (timestamp) RETURNS integer AS
+  'SELECT CAST (EXTRACT(YEAR FROM $1) AS integer) AS result'
+LANGUAGE 'sql';
+
+CREATE OR REPLACE FUNCTION MONTH (timestamp) RETURNS integer AS
+  'SELECT CAST (EXTRACT(MONTH FROM $1) AS integer) AS result'
+LANGUAGE 'sql';
+
+CREATE OR REPLACE FUNCTION day(date) RETURNS integer AS
+  'SELECT EXTRACT(DAY FROM DATE($1))::integer AS result'
+LANGUAGE 'sql';
+
+CREATE OR REPLACE FUNCTION DAYOFMONTH (timestamp) RETURNS integer AS
+  'SELECT CAST (EXTRACT(DAY FROM $1) AS integer) AS result'
+LANGUAGE 'sql';
+
+CREATE OR REPLACE FUNCTION HOUR (timestamp) RETURNS integer AS
+  'SELECT CAST (EXTRACT(HOUR FROM $1) AS integer) AS result'
+LANGUAGE 'sql';
+
+CREATE OR REPLACE FUNCTION DATE_FORMAT (timestamp, text) RETURNS text AS
+  'SELECT
+    REPLACE(
+        REPLACE($2, ''%m'', to_char($1, ''MM'')),
+    ''%d'', to_char($1, ''DD'')) AS result'
+LANGUAGE 'sql';
+
+CREATE OR REPLACE FUNCTION TO_DAYS (timestamp) RETURNS integer AS
+  'SELECT DATE_PART(''DAY'', $1 - ''0001-01-01bc'')::integer AS result'
+LANGUAGE 'sql';
+
+CREATE OR REPLACE FUNCTION CONCAT (text, text) RETURNS text AS
+  'SELECT $1 || $2 AS result'
+LANGUAGE 'sql';
+
+CREATE OR REPLACE FUNCTION INSTR (text, text) RETURNS integer AS
+  'SELECT POSITION($2 in $1) AS result'
+LANGUAGE 'sql';
+
+CREATE OR REPLACE FUNCTION bool_not_eq_int (boolean, integer) RETURNS boolean AS
+  'SELECT CAST($1 AS integer) != $2 AS result'
+LANGUAGE 'sql';
+
+#
+# Create PostgreSQL operators.
+#
+
+CREATE OPERATOR + (PROCEDURE = add_num_text, LEFTARG = text, RIGHTARG = integer);
+CREATE OPERATOR != (PROCEDURE = bool_not_eq_int, LEFTARG = boolean, RIGHTARG = integer);
+
+#
+# Sequence for table `admin_info_files`
+#
+
+CREATE SEQUENCE {$db_prefix}admin_info_files_seq START WITH 8;
+
+#
+# Table structure for table `admin_info_files`
+#
+
+CREATE TABLE {$db_prefix}admin_info_files (
+  id_file smallint default nextval('{$db_prefix}admin_info_files_seq'),
+  filename varchar(255) NOT NULL,
+  path varchar(255) NOT NULL,
+  parameters varchar(255) NOT NULL,
+  data text NOT NULL,
+  filetype varchar(255) NOT NULL,
+  PRIMARY KEY (id_file)
+);
+
+#
+# Indexes for table `admin_info_files`
+#
+
+CREATE INDEX {$db_prefix}admin_info_files_filename ON {$db_prefix}admin_info_files (filename);
+
+#
+# Dumping data for table `admin_info_files`
+#
+
+INSERT INTO {$db_prefix}admin_info_files (id_file, filename, path, parameters, data, filetype) VALUES (1, 'current-version.js', '/smf/', 'version=%3$s', '', 'text/javascript');
+INSERT INTO {$db_prefix}admin_info_files (id_file, filename, path, parameters, data, filetype) VALUES (2, 'detailed-version.js', '/smf/', 'language=%1$s&version=%3$s', '', 'text/javascript');
+INSERT INTO {$db_prefix}admin_info_files (id_file, filename, path, parameters, data, filetype) VALUES (3, 'latest-news.js', '/smf/', 'language=%1$s&format=%2$s', '', 'text/javascript');
+INSERT INTO {$db_prefix}admin_info_files (id_file, filename, path, parameters, data, filetype) VALUES (4, 'latest-packages.js', '/smf/', 'language=%1$s&version=%3$s', '', 'text/javascript');
+INSERT INTO {$db_prefix}admin_info_files (id_file, filename, path, parameters, data, filetype) VALUES (5, 'latest-smileys.js', '/smf/', 'language=%1$s&version=%3$s', '', 'text/javascript');
+INSERT INTO {$db_prefix}admin_info_files (id_file, filename, path, parameters, data, filetype) VALUES (6, 'latest-support.js', '/smf/', 'language=%1$s&version=%3$s', '', 'text/javascript');
+INSERT INTO {$db_prefix}admin_info_files (id_file, filename, path, parameters, data, filetype) VALUES (7, 'latest-themes.js', '/smf/', 'language=%1$s&version=%3$s', '', 'text/javascript');
+# --------------------------------------------------------
+
+#
+# Table structure for table `approval_queue`
+#
+
+CREATE TABLE {$db_prefix}approval_queue (
+  id_msg int NOT NULL default '0',
+  id_attach int NOT NULL default '0',
+  id_event smallint NOT NULL default '0'
+);
+
+#
+# Sequence for table `attachments`
+#
+
+CREATE SEQUENCE {$db_prefix}attachments_seq;
+
+#
+# Table structure for table `attachments`
+#
+
+CREATE TABLE {$db_prefix}attachments (
+  id_attach int default nextval('{$db_prefix}attachments_seq'),
+  id_thumb int NOT NULL default '0',
+  id_msg int NOT NULL default '0',
+  id_member int NOT NULL default '0',
+  id_folder smallint NOT NULL default '1',
+  attachment_type smallint NOT NULL default '0',
+  filename varchar(255) NOT NULL,
+  file_hash varchar(40) NOT NULL default '',
+  fileext varchar(8) NOT NULL default '',
+  size int NOT NULL default '0',
+  downloads int NOT NULL default '0',
+  width int NOT NULL default '0',
+  height int NOT NULL default '0',
+  mime_type varchar(20) NOT NULL default '',
+  approved smallint NOT NULL default '1',
+  PRIMARY KEY (id_attach)
+);
+
+#
+# Indexes for table `attachments`
+#
+
+CREATE UNIQUE INDEX {$db_prefix}attachments_id_member ON {$db_prefix}attachments (id_member, id_attach);
+CREATE INDEX {$db_prefix}attachments_id_msg ON {$db_prefix}attachments (id_msg);
+CREATE INDEX {$db_prefix}attachments_attachment_type ON {$db_prefix}attachments (attachment_type);
+
+#
+# Sequence for table `ban_groups`
+#
+
+CREATE SEQUENCE {$db_prefix}ban_groups_seq;
+
+#
+# Table structure for table `ban_groups`
+#
+
+CREATE TABLE {$db_prefix}ban_groups (
+  id_ban_group int default nextval('{$db_prefix}ban_groups_seq'),
+  name varchar(20) NOT NULL default '',
+  ban_time int NOT NULL default '0',
+  expire_time int,
+  cannot_access smallint NOT NULL default '0',
+  cannot_register smallint NOT NULL default '0',
+  cannot_post smallint NOT NULL default '0',
+  cannot_login smallint NOT NULL default '0',
+  reason varchar(255) NOT NULL,
+  notes text NOT NULL,
+  PRIMARY KEY (id_ban_group)
+);
+
+#
+# Sequence for table `ban_items`
+#
+
+CREATE SEQUENCE {$db_prefix}ban_items_seq;
+
+#
+# Table structure for table `ban_items`
+#
+
+CREATE TABLE {$db_prefix}ban_items (
+  id_ban int default nextval('{$db_prefix}ban_items_seq'),
+  id_ban_group smallint NOT NULL default '0',
+  ip_low1 smallint(255) NOT NULL default '0',
+  ip_high1 smallint(255) NOT NULL default '0',
+  ip_low2 smallint(255) NOT NULL default '0',
+  ip_high2 smallint(255) NOT NULL default '0',
+  ip_low3 smallint(255) NOT NULL default '0',
+  ip_high3 smallint(255) NOT NULL default '0',
+  ip_low4 smallint(255) NOT NULL default '0',
+  ip_high4 smallint(255) NOT NULL default '0',
+  ip_low5 smallint(255) NOT NULL default '0',
+  ip_high5 smallint(255) NOT NULL default '0',
+  ip_low6 smallint(255) NOT NULL default '0',
+  ip_high6 smallint(255) NOT NULL default '0',
+  ip_low7 smallint(255) NOT NULL default '0',
+  ip_high7 smallint(255) NOT NULL default '0',
+  ip_low8 smallint(255) NOT NULL default '0',
+  ip_high8 smallint(255) NOT NULL default '0',
+  hostname varchar(255) NOT NULL,
+  email_address varchar(255) NOT NULL,
+  id_member int NOT NULL default '0',
+  hits int NOT NULL default '0',
+  PRIMARY KEY (id_ban)
+);
+
+#
+# Indexes for table `ban_items`
+#
+
+CREATE INDEX {$db_prefix}ban_items_id_ban_group ON {$db_prefix}ban_items (id_ban_group);
+
+#
+# Table structure for table `board_permissions`
+#
+
+CREATE TABLE {$db_prefix}board_permissions (
+  id_group smallint NOT NULL default '0',
+  id_profile smallint NOT NULL default '0',
+  permission varchar(30) NOT NULL default '',
+  add_deny smallint NOT NULL default '1',
+  PRIMARY KEY (id_group, id_profile, permission)
+);
+
+#
+# Dumping data for table `board_permissions`
+#
+
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (-1, 1, 'poll_view');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'remove_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'lock_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'mark_any_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'mark_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'modify_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'poll_add_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'poll_edit_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'poll_lock_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'poll_post');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'poll_view');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'poll_vote');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'post_attachment');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'post_new');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'post_reply_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'post_reply_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'post_unapproved_topics');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'post_unapproved_replies_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'post_unapproved_replies_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'post_unapproved_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'delete_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'report_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'send_topic');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'view_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'moderate_board');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'post_new');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'post_reply_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'post_reply_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'post_unapproved_topics');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'post_unapproved_replies_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'post_unapproved_replies_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'post_unapproved_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'poll_post');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'poll_add_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'poll_remove_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'poll_view');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'poll_vote');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'poll_lock_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'poll_edit_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'report_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'lock_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'send_topic');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'mark_any_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'mark_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'delete_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'modify_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'make_sticky');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'lock_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'remove_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'move_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'merge_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'split_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'delete_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'modify_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'approve_posts');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'post_attachment');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'view_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'moderate_board');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'post_new');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'post_reply_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'post_reply_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'post_unapproved_topics');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'post_unapproved_replies_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'post_unapproved_replies_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'post_unapproved_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'poll_post');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'poll_add_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'poll_remove_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'poll_view');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'poll_vote');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'poll_lock_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'poll_edit_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'report_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'lock_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'send_topic');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'mark_any_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'mark_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'delete_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'modify_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'make_sticky');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'lock_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'remove_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'move_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'merge_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'split_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'delete_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'modify_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'approve_posts');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'post_attachment');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'view_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (-1, 2, 'poll_view');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'remove_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'lock_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'mark_any_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'mark_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'modify_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'poll_view');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'poll_vote');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'post_attachment');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'post_new');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'post_reply_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'post_reply_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'post_unapproved_topics');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'post_unapproved_replies_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'post_unapproved_replies_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'post_unapproved_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'delete_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'report_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'send_topic');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'view_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'moderate_board');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'post_new');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'post_reply_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'post_reply_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'post_unapproved_topics');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'post_unapproved_replies_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'post_unapproved_replies_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'post_unapproved_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'poll_post');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'poll_add_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'poll_remove_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'poll_view');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'poll_vote');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'poll_lock_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'poll_edit_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'report_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'lock_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'send_topic');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'mark_any_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'mark_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'delete_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'modify_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'make_sticky');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'lock_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'remove_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'move_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'merge_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'split_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'delete_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'modify_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'approve_posts');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'post_attachment');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'view_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'moderate_board');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'post_new');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'post_reply_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'post_reply_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'post_unapproved_topics');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'post_unapproved_replies_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'post_unapproved_replies_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'post_unapproved_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'poll_post');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'poll_add_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'poll_remove_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'poll_view');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'poll_vote');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'poll_lock_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'poll_edit_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'report_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'lock_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'send_topic');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'mark_any_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'mark_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'delete_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'modify_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'make_sticky');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'lock_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'remove_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'move_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'merge_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'split_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'delete_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'modify_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'approve_posts');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'post_attachment');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'view_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (-1, 3, 'poll_view');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 3, 'remove_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 3, 'lock_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 3, 'mark_any_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 3, 'mark_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 3, 'modify_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 3, 'poll_view');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 3, 'poll_vote');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 3, 'post_attachment');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 3, 'post_reply_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 3, 'post_reply_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 3, 'post_unapproved_replies_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 3, 'post_unapproved_replies_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 3, 'post_unapproved_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 3, 'delete_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 3, 'report_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 3, 'send_topic');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 3, 'view_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'moderate_board');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'post_new');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'post_reply_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'post_reply_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'post_unapproved_topics');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'post_unapproved_replies_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'post_unapproved_replies_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'post_unapproved_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'poll_post');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'poll_add_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'poll_remove_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'poll_view');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'poll_vote');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'poll_lock_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'poll_edit_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'report_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'lock_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'send_topic');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'mark_any_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'mark_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'delete_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'modify_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'make_sticky');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'lock_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'remove_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'move_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'merge_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'split_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'delete_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'modify_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'approve_posts');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'post_attachment');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'view_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'moderate_board');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'post_new');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'post_reply_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'post_reply_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'post_unapproved_topics');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'post_unapproved_replies_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'post_unapproved_replies_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'post_unapproved_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'poll_post');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'poll_add_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'poll_remove_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'poll_view');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'poll_vote');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'poll_lock_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'poll_edit_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'report_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'lock_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'send_topic');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'mark_any_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'mark_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'delete_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'modify_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'make_sticky');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'lock_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'remove_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'move_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'merge_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'split_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'delete_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'modify_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'approve_posts');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'post_attachment');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'view_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (-1, 4, 'poll_view');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 4, 'mark_any_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 4, 'mark_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 4, 'poll_view');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 4, 'poll_vote');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 4, 'report_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 4, 'send_topic');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 4, 'view_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'moderate_board');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'post_new');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'post_reply_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'post_reply_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'post_unapproved_topics');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'post_unapproved_replies_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'post_unapproved_replies_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'post_unapproved_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'poll_post');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'poll_add_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'poll_remove_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'poll_view');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'poll_vote');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'poll_lock_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'poll_edit_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'report_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'lock_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'send_topic');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'mark_any_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'mark_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'delete_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'modify_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'make_sticky');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'lock_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'remove_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'move_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'merge_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'split_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'delete_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'modify_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'approve_posts');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'post_attachment');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'view_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'moderate_board');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'post_new');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'post_reply_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'post_reply_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'post_unapproved_topics');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'post_unapproved_replies_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'post_unapproved_replies_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'post_unapproved_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'poll_post');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'poll_add_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'poll_remove_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'poll_view');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'poll_vote');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'poll_lock_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'poll_edit_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'report_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'lock_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'send_topic');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'mark_any_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'mark_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'delete_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'modify_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'make_sticky');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'lock_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'remove_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'move_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'merge_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'split_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'delete_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'modify_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'approve_posts');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'post_attachment');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'view_attachments');
+# --------------------------------------------------------
+
+#
+# Sequence for table `boards`
+#
+
+CREATE SEQUENCE {$db_prefix}boards_seq START WITH 2;
+
+#
+# Table structure for table `boards`
+#
+
+CREATE TABLE {$db_prefix}boards (
+  id_board smallint default nextval('{$db_prefix}boards_seq'),
+  id_cat smallint NOT NULL default '0',
+  child_level smallint NOT NULL default '0',
+  id_parent smallint NOT NULL default '0',
+  board_order smallint NOT NULL default '0',
+  id_last_msg int NOT NULL default '0',
+  id_msg_updated int NOT NULL default '0',
+  member_groups varchar(255) NOT NULL default '-1,0',
+  id_profile smallint NOT NULL default '1',
+  name varchar(255) NOT NULL,
+  description text NOT NULL,
+  num_topics int NOT NULL default '0',
+  num_posts int NOT NULL default '0',
+  count_posts smallint NOT NULL default '0',
+  id_theme smallint NOT NULL default '0',
+  override_theme smallint NOT NULL default '0',
+  unapproved_posts smallint NOT NULL default '0',
+  unapproved_topics smallint NOT NULL default '0',
+  redirect varchar(255) NOT NULL default '',
+  PRIMARY KEY (id_board)
+);
+
+#
+# Indexes for table `ban_items`
+#
+
+CREATE UNIQUE INDEX {$db_prefix}boards_categories ON {$db_prefix}boards (id_cat, id_board);
+CREATE INDEX {$db_prefix}boards_id_parent ON {$db_prefix}boards (id_parent);
+CREATE INDEX {$db_prefix}boards_id_msg_updated ON {$db_prefix}boards (id_msg_updated);
+CREATE INDEX {$db_prefix}boards_member_groups ON {$db_prefix}boards (member_groups);
+
+#
+# Dumping data for table `boards`
+#
+
+INSERT INTO {$db_prefix}boards
+	(id_board, id_cat, board_order, id_last_msg, id_msg_updated, name, description, num_topics, num_posts, member_groups)
+VALUES (1, 1, 1, 1, 1, '{$default_board_name}', '{$default_board_description}', 1, 1, '-1,0,2');
+# --------------------------------------------------------
+
+#
+# Sequence for table `calendar`
+#
+
+CREATE SEQUENCE {$db_prefix}calendar_seq;
+
+#
+# Table structure for table `calendar`
+#
+
+CREATE TABLE {$db_prefix}calendar (
+  id_event smallint default nextval('{$db_prefix}calendar_seq'),
+  start_date date NOT NULL default '0001-01-01',
+  end_date date NOT NULL default '0001-01-01',
+  id_board smallint NOT NULL default '0',
+  id_topic int NOT NULL default '0',
+  title varchar(255) NOT NULL default '',
+  id_member int NOT NULL default '0',
+  PRIMARY KEY (id_event)
+);
+
+#
+# Indexes for table `calendar`
+#
+
+CREATE INDEX {$db_prefix}calendar_start_date ON {$db_prefix}calendar (start_date);
+CREATE INDEX {$db_prefix}calendar_end_date ON {$db_prefix}calendar (end_date);
+CREATE INDEX {$db_prefix}calendar_topic ON {$db_prefix}calendar (id_topic, id_member);
+
+#
+# Sequence for table `calendar_holidays`
+#
+
+CREATE SEQUENCE {$db_prefix}calendar_holidays_seq;
+
+#
+# Table structure for table `calendar_holidays`
+#
+
+CREATE TABLE {$db_prefix}calendar_holidays (
+  id_holiday smallint default nextval('{$db_prefix}calendar_holidays_seq'),
+  event_date date NOT NULL default '0001-01-01',
+  title varchar(255) NOT NULL default '',
+  PRIMARY KEY (id_holiday)
+);
+
+#
+# Indexes for table `calendar_holidays`
+#
+
+CREATE INDEX {$db_prefix}calendar_holidays_event_date ON {$db_prefix}calendar_holidays (event_date);
+
+#
+# Dumping data for table `calendar_holidays`
+#
+
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('New Year\'s', '0004-01-01');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Christmas', '0004-12-25');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Valentine\'s Day', '0004-02-14');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('St. Patrick\'s Day', '0004-03-17');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('April Fools', '0004-04-01');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Earth Day', '0004-04-22');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('United Nations Day', '0004-10-24');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Halloween', '0004-10-31');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Mother\'s Day', '2010-05-09');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Mother\'s Day', '2011-05-08');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Mother\'s Day', '2012-05-13');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Mother\'s Day', '2013-05-12');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Mother\'s Day', '2014-05-11');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Mother\'s Day', '2015-05-10');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Mother\'s Day', '2016-05-08');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Mother\'s Day', '2017-05-14');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Mother\'s Day', '2018-05-13');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Mother\'s Day', '2019-05-12');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Mother\'s Day', '2020-05-10');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Father\'s Day', '2010-06-20');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Father\'s Day', '2011-06-19');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Father\'s Day', '2012-06-17');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Father\'s Day', '2013-06-16');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Father\'s Day', '2014-06-15');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Father\'s Day', '2015-06-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Father\'s Day', '2016-06-19');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Father\'s Day', '2017-06-18');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Father\'s Day', '2018-06-17');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Father\'s Day', '2019-06-16');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Father\'s Day', '2020-06-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Summer Solstice', '2010-06-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Summer Solstice', '2011-06-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Summer Solstice', '2012-06-20');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Summer Solstice', '2013-06-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Summer Solstice', '2014-06-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Summer Solstice', '2015-06-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Summer Solstice', '2016-06-20');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Summer Solstice', '2017-06-20');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Summer Solstice', '2018-06-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Summer Solstice', '2019-06-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Summer Solstice', '2020-06-20');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Vernal Equinox', '2010-03-20');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Vernal Equinox', '2011-03-20');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Vernal Equinox', '2012-03-20');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Vernal Equinox', '2013-03-20');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Vernal Equinox', '2014-03-20');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Vernal Equinox', '2015-03-20');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Vernal Equinox', '2016-03-19');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Vernal Equinox', '2017-03-20');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Vernal Equinox', '2018-03-20');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Vernal Equinox', '2019-03-20');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Vernal Equinox', '2020-03-19');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Winter Solstice', '2010-12-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Winter Solstice', '2011-12-22');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Winter Solstice', '2012-12-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Winter Solstice', '2013-12-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Winter Solstice', '2014-12-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Winter Solstice', '2015-12-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Winter Solstice', '2016-12-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Winter Solstice', '2017-12-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Winter Solstice', '2018-12-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Winter Solstice', '2019-12-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Winter Solstice', '2020-12-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Autumnal Equinox', '2010-09-22');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Autumnal Equinox', '2011-09-23');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Autumnal Equinox', '2012-09-22');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Autumnal Equinox', '2013-09-22');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Autumnal Equinox', '2014-09-22');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Autumnal Equinox', '2015-09-23');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Autumnal Equinox', '2016-09-22');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Autumnal Equinox', '2017-09-22');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Autumnal Equinox', '2018-09-22');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Autumnal Equinox', '2019-09-23');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Autumnal Equinox', '2020-09-22');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Independence Day', '0004-07-04');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Cinco de Mayo', '0004-05-05');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Flag Day', '0004-06-14');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Veterans Day', '0004-11-11');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Groundhog Day', '0004-02-02');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Thanksgiving', '2010-11-25');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Thanksgiving', '2011-11-24');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Thanksgiving', '2012-11-22');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Thanksgiving', '2013-11-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Thanksgiving', '2014-11-20');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Thanksgiving', '2015-11-26');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Thanksgiving', '2016-11-24');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Thanksgiving', '2017-11-23');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Thanksgiving', '2018-11-22');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Thanksgiving', '2019-11-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Thanksgiving', '2020-11-26');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Memorial Day', '2010-05-31');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Memorial Day', '2011-05-30');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Memorial Day', '2012-05-28');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Memorial Day', '2013-05-27');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Memorial Day', '2014-05-26');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Memorial Day', '2015-05-25');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Memorial Day', '2016-05-30');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Memorial Day', '2017-05-29');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Memorial Day', '2018-05-28');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Memorial Day', '2019-05-27');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Memorial Day', '2020-05-25');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Labor Day', '2010-09-06');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Labor Day', '2011-09-05');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Labor Day', '2012-09-03');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Labor Day', '2013-09-09');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Labor Day', '2014-09-08');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Labor Day', '2015-09-07');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Labor Day', '2016-09-05');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Labor Day', '2017-09-04');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Labor Day', '2018-09-03');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Labor Day', '2019-09-09');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Labor Day', '2020-09-07');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('D-Day', '0004-06-06');
+# --------------------------------------------------------
+
+#
+# Sequence for table `categories`
+#
+
+CREATE SEQUENCE {$db_prefix}categories_seq START WITH 2;
+
+#
+# Table structure for table `categories`
+#
+
+CREATE TABLE {$db_prefix}categories (
+  id_cat smallint default nextval('{$db_prefix}categories_seq'),
+  cat_order smallint NOT NULL default '0',
+  name varchar(255) NOT NULL,
+  can_collapse smallint NOT NULL default '1',
+  PRIMARY KEY (id_cat)
+);
+
+#
+# Dumping data for table `categories`
+#
+
+INSERT INTO {$db_prefix}categories
+VALUES (1, 0, '{$default_category_name}', 1);
+# --------------------------------------------------------
+
+#
+# Table structure for table `collapsed_categories`
+#
+
+CREATE TABLE {$db_prefix}collapsed_categories (
+  id_cat smallint NOT NULL default '0',
+  id_member int NOT NULL default '0',
+  PRIMARY KEY (id_cat, id_member)
+);
+
+#
+# Sequence for table `custom_fields`
+#
+
+CREATE SEQUENCE {$db_prefix}custom_fields_seq;
+
+#
+# Table structure for table `custom_fields`
+#
+
+CREATE TABLE {$db_prefix}custom_fields (
+  id_field smallint default nextval('{$db_prefix}custom_fields_seq'),
+  col_name varchar(12) NOT NULL default '',
+  field_name varchar(40) NOT NULL default '',
+  field_desc varchar(255) NOT NULL,
+  field_type varchar(8) NOT NULL default 'text',
+  field_length smallint NOT NULL default '255',
+  field_options text NOT NULL,
+  mask varchar(255) NOT NULL,
+  show_reg smallint NOT NULL default '0',
+  show_display smallint NOT NULL default '0',
+  show_profile varchar(20) NOT NULL default 'forumprofile',
+  private smallint NOT NULL default '0',
+  active smallint NOT NULL default '1',
+  bbc smallint NOT NULL default '0',
+  can_search smallint NOT NULL default '0',
+  default_value varchar(255) NOT NULL,
+  enclose text NOT NULL,
+  placement smallint NOT NULL default '0',
+  PRIMARY KEY (id_field)
+);
+
+#
+# Indexes for table `custom_fields`
+#
+
+CREATE UNIQUE INDEX {$db_prefix}custom_fields_col_name ON {$db_prefix}custom_fields (col_name);
+
+#
+# Table structure for table `group_moderators`
+#
+
+CREATE TABLE {$db_prefix}group_moderators (
+  id_group smallint NOT NULL default '0',
+  id_member int NOT NULL default '0',
+  PRIMARY KEY (id_group, id_member)
+);
+
+#
+# Sequence for table `log_actions`
+#
+
+CREATE SEQUENCE {$db_prefix}log_actions_seq;
+
+#
+# Table structure for table `log_actions`
+#
+
+CREATE TABLE {$db_prefix}log_actions (
+  id_action int default nextval('{$db_prefix}log_actions_seq'),
+  id_log smallint NOT NULL default '1',
+  log_time int NOT NULL default '0',
+  id_member int NOT NULL default '0',
+  ip char(16) NOT NULL default '                ',
+  action varchar(30) NOT NULL default '',
+  id_board smallint NOT NULL default '0',
+  id_topic int NOT NULL default '0',
+  id_msg int NOT NULL default '0',
+  extra text NOT NULL,
+  PRIMARY KEY (id_action)
+);
+
+#
+# Indexes for table `log_actions`
+#
+
+CREATE INDEX {$db_prefix}log_actions_log_time ON {$db_prefix}log_actions (log_time);
+CREATE INDEX {$db_prefix}log_actions_id_member ON {$db_prefix}log_actions (id_member);
+CREATE INDEX {$db_prefix}log_actions_id_board ON {$db_prefix}log_actions (id_board);
+CREATE INDEX {$db_prefix}log_actions_id_msg ON {$db_prefix}log_actions (id_msg);
+CREATE INDEX {$db_prefix}log_actions_id_log ON {$db_prefix}log_actions (id_log);
+
+#
+# Table structure for table `log_activity`
+#
+
+CREATE TABLE {$db_prefix}log_activity (
+  date date NOT NULL default '0001-01-01',
+  hits int NOT NULL default '0',
+  topics smallint NOT NULL default '0',
+  posts smallint NOT NULL default '0',
+  registers smallint NOT NULL default '0',
+  most_on smallint NOT NULL default '0',
+  PRIMARY KEY (date)
+);
+
+#
+# Indexes for table `log_activity`
+#
+CREATE INDEX {$db_prefix}log_activity_most_on ON {$db_prefix}log_activity (most_on);
+
+#
+# Sequence for table `log_banned`
+#
+
+CREATE SEQUENCE {$db_prefix}log_banned_seq;
+
+#
+# Table structure for table `log_banned`
+#
+
+CREATE TABLE {$db_prefix}log_banned (
+  id_ban_log int default nextval('{$db_prefix}log_banned_seq'),
+  id_member int NOT NULL default '0',
+  ip char(16) NOT NULL default '                ',
+  email varchar(255) NOT NULL,
+  log_time int NOT NULL default '0',
+  PRIMARY KEY (id_ban_log)
+);
+
+#
+# Indexes for table `log_banned`
+#
+
+CREATE INDEX {$db_prefix}log_banned_log_time ON {$db_prefix}log_banned (log_time);
+
+#
+# Table structure for table `log_boards`
+#
+
+CREATE TABLE {$db_prefix}log_boards (
+  id_member int NOT NULL default '0',
+  id_board smallint NOT NULL default '0',
+  id_msg int NOT NULL default '0',
+  PRIMARY KEY (id_member, id_board)
+);
+
+#
+# Sequence for table `log_comments`
+#
+
+CREATE SEQUENCE {$db_prefix}log_comments_seq;
+
+#
+# Table structure for table `log_comments`
+#
+
+CREATE TABLE {$db_prefix}log_comments (
+  id_comment int default nextval('{$db_prefix}log_comments_seq'),
+  id_member int NOT NULL default '0',
+  member_name varchar(80) NOT NULL default '',
+  comment_type varchar(8) NOT NULL default 'warning',
+  id_recipient int NOT NULL default '0',
+  recipient_name varchar(255) NOT NULL,
+  log_time int NOT NULL default '0',
+  id_notice int NOT NULL default '0',
+  counter smallint NOT NULL default '0',
+  body text NOT NULL,
+  PRIMARY KEY (id_comment)
+);
+
+#
+# Indexes for table `log_comments`
+#
+
+CREATE INDEX {$db_prefix}log_comments_id_recipient ON {$db_prefix}log_comments (id_recipient);
+CREATE INDEX {$db_prefix}log_comments_log_time ON {$db_prefix}log_comments (log_time);
+CREATE INDEX {$db_prefix}log_comments_comment_type ON {$db_prefix}log_comments (comment_type);
+
+#
+# Table structure for table `log_digest`
+#
+
+CREATE TABLE {$db_prefix}log_digest (
+  id_topic int NOT NULL,
+  id_msg int NOT NULL,
+  note_type varchar(10) NOT NULL default 'post',
+  daily smallint NOT NULL default '0',
+  exclude int NOT NULL default '0'
+);
+
+#
+# Sequence for table `log_errors`
+#
+
+CREATE SEQUENCE {$db_prefix}log_errors_seq;
+
+#
+# Table structure for table `log_errors`
+#
+
+CREATE TABLE {$db_prefix}log_errors (
+  id_error int default nextval('{$db_prefix}log_errors_seq'),
+  log_time int NOT NULL default '0',
+  id_member int NOT NULL default '0',
+  ip varchar(16) NOT NULL default '',
+  url text NOT NULL,
+  message text NOT NULL,
+  session char(32) NOT NULL default '                                ',
+  error_type varchar(15) NOT NULL default 'general',
+  file varchar(255) NOT NULL,
+  line int NOT NULL default '0',
+  PRIMARY KEY (id_error)
+);
+
+#
+# Indexes for table `log_errors`
+#
+
+CREATE INDEX {$db_prefix}log_errors_log_time ON {$db_prefix}log_errors (log_time);
+CREATE INDEX {$db_prefix}log_errors_id_member ON {$db_prefix}log_errors (id_member);
+CREATE INDEX {$db_prefix}log_errors_ip ON {$db_prefix}log_errors (ip);
+
+#
+# Table structure for table `log_floodcontrol`
+#
+
+CREATE TABLE {$db_prefix}log_floodcontrol (
+  ip char(16) NOT NULL default '                ',
+  log_time int NOT NULL default '0',
+  log_type varchar(8) NOT NULL default 'post',
+  PRIMARY KEY (ip, log_type)
+);
+
+#
+# Sequence for table `log_group_requests`
+#
+
+CREATE SEQUENCE {$db_prefix}log_group_requests_seq;
+
+#
+# Table structure for table `log_group_requests`
+#
+
+CREATE TABLE {$db_prefix}log_group_requests (
+  id_request int default nextval('{$db_prefix}log_group_requests_seq'),
+  id_member int NOT NULL default '0',
+  id_group smallint NOT NULL default '0',
+  time_applied int NOT NULL default '0',
+  reason text NOT NULL,
+  PRIMARY KEY (id_request)
+);
+
+#
+# Indexes for table `log_group_requests`
+#
+
+CREATE UNIQUE INDEX {$db_prefix}log_group_requests_id_member ON {$db_prefix}log_group_requests (id_member, id_group);
+
+#
+# Table structure for table `log_karma`
+#
+
+CREATE TABLE {$db_prefix}log_karma (
+  id_target int NOT NULL default '0',
+  id_executor int NOT NULL default '0',
+  log_time int NOT NULL default '0',
+  action smallint NOT NULL default '0',
+  PRIMARY KEY (id_target, id_executor)
+);
+
+#
+# Indexes for table `log_karma`
+#
+
+CREATE INDEX {$db_prefix}log_karma_log_time ON {$db_prefix}log_karma (log_time);
+
+#
+# Table structure for table `log_mark_read`
+#
+
+CREATE TABLE {$db_prefix}log_mark_read (
+  id_member int NOT NULL default '0',
+  id_board smallint NOT NULL default '0',
+  id_msg int NOT NULL default '0',
+  PRIMARY KEY (id_member, id_board)
+);
+
+#
+# Sequence for table `log_member_notices`
+#
+
+CREATE SEQUENCE {$db_prefix}log_member_notices_seq;
+
+#
+# Table structure for table `log_member_notices`
+#
+
+CREATE TABLE {$db_prefix}log_member_notices (
+  id_notice int default nextval('{$db_prefix}log_member_notices_seq'),
+  subject varchar(255) NOT NULL,
+  body text NOT NULL,
+  PRIMARY KEY (id_notice)
+);
+
+#
+# Table structure for table `log_notify`
+#
+
+CREATE TABLE {$db_prefix}log_notify (
+  id_member int NOT NULL default '0',
+  id_topic int NOT NULL default '0',
+  id_board smallint NOT NULL default '0',
+  sent smallint NOT NULL default '0',
+  PRIMARY KEY (id_member, id_topic, id_board)
+);
+
+#
+# Indexes for table `log_notify`
+#
+
+CREATE INDEX {$db_prefix}log_notify_id_topic ON {$db_prefix}log_notify (id_topic, id_member);
+
+#
+# Table structure for table `log_online`
+#
+
+CREATE TABLE {$db_prefix}log_online (
+  session varchar(32) NOT NULL default '',
+  log_time int NOT NULL default '0',
+  id_member int NOT NULL default '0',
+  id_spider smallint NOT NULL default '0',
+  ip int8 NOT NULL default '0',
+  url text NOT NULL,
+  PRIMARY KEY (session)
+);
+
+#
+# Indexes for table `log_online`
+#
+
+CREATE INDEX {$db_prefix}log_online_log_time ON {$db_prefix}log_online (log_time);
+CREATE INDEX {$db_prefix}log_online_id_member ON {$db_prefix}log_online (id_member);
+
+#
+# Sequence for table `log_packages`
+#
+
+CREATE SEQUENCE {$db_prefix}log_packages_seq;
+
+#
+# Table structure for table `log_packages`
+#
+
+CREATE TABLE {$db_prefix}log_packages (
+  id_install int default nextval('{$db_prefix}log_packages_seq'),
+  filename varchar(255) NOT NULL,
+  package_id varchar(255) NOT NULL,
+  name varchar(255) NOT NULL,
+  version varchar(255) NOT NULL,
+  id_member_installed int NOT NULL default '0',
+  member_installed varchar(255) NOT NULL,
+  time_installed int NOT NULL default '0',
+  id_member_removed int NOT NULL default '0',
+  member_removed varchar(255) NOT NULL,
+  time_removed int NOT NULL default '0',
+  install_state smallint NOT NULL default '1',
+  failed_steps text NOT NULL,
+  themes_installed varchar(255) NOT NULL,
+  db_changes text NOT NULL,
+  PRIMARY KEY (id_install)
+);
+
+#
+# Indexes for table `log_packages`
+#
+
+CREATE INDEX {$db_prefix}log_packages_filename ON {$db_prefix}log_packages (filename);
+
+#
+# Table structure for table `log_polls`
+#
+
+CREATE TABLE {$db_prefix}log_polls (
+  id_poll int NOT NULL default '0',
+  id_member int NOT NULL default '0',
+  id_choice smallint NOT NULL default '0'
+);
+
+#
+# Indexes for table `log_polls`
+#
+
+CREATE INDEX {$db_prefix}log_polls_id_poll ON {$db_prefix}log_polls (id_poll, id_member, id_choice);
+
+#
+# Sequence for table `log_reported`
+#
+
+CREATE SEQUENCE {$db_prefix}log_reported_seq;
+
+#
+# Table structure for table `log_reported`
+#
+
+CREATE TABLE {$db_prefix}log_reported (
+  id_report int default nextval('{$db_prefix}log_reported_seq'),
+  id_msg int NOT NULL default '0',
+  id_topic int NOT NULL default '0',
+  id_board smallint NOT NULL default '0',
+  id_member int NOT NULL default '0',
+  membername varchar(255) NOT NULL,
+  subject varchar(255) NOT NULL,
+  body text NOT NULL,
+  time_started int NOT NULL default '0',
+  time_updated int NOT NULL default '0',
+  num_reports int NOT NULL default '0',
+  closed smallint NOT NULL default '0',
+  ignore_all smallint NOT NULL default '0',
+  PRIMARY KEY (id_report)
+);
+
+#
+# Indexes for table `log_reported`
+#
+
+CREATE INDEX {$db_prefix}log_reported_id_member ON {$db_prefix}log_reported (id_member);
+CREATE INDEX {$db_prefix}log_reported_id_topic ON {$db_prefix}log_reported (id_topic);
+CREATE INDEX {$db_prefix}log_reported_closed ON {$db_prefix}log_reported (closed);
+CREATE INDEX {$db_prefix}log_reported_time_started ON {$db_prefix}log_reported (time_started);
+CREATE INDEX {$db_prefix}log_reported_id_msg ON {$db_prefix}log_reported (id_msg);
+
+#
+# Sequence for table `log_reported_comments`
+#
+
+CREATE SEQUENCE {$db_prefix}log_reported_comments_seq;
+
+#
+# Table structure for table `log_reported_comments`
+#
+
+CREATE TABLE {$db_prefix}log_reported_comments (
+  id_comment int default nextval('{$db_prefix}log_reported_comments_seq'),
+  id_report int NOT NULL default '0',
+  id_member int NOT NULL,
+  membername varchar(255) NOT NULL,
+  email_address varchar(255) NOT NULL,
+  member_ip varchar(255) NOT NULL,
+  comment varchar(255) NOT NULL,
+  time_sent int NOT NULL,
+  PRIMARY KEY (id_comment)
+);
+
+#
+# Indexes for table `log_reported_comments`
+#
+
+CREATE INDEX {$db_prefix}log_reported_comments_id_report ON {$db_prefix}log_reported_comments (id_report);
+CREATE INDEX {$db_prefix}log_reported_comments_id_member ON {$db_prefix}log_reported_comments (id_member);
+CREATE INDEX {$db_prefix}log_reported_comments_time_sent ON {$db_prefix}log_reported_comments (time_sent);
+
+#
+# Sequence for table `log_scheduled_tasks`
+#
+
+CREATE SEQUENCE {$db_prefix}log_scheduled_tasks_seq;
+
+#
+# Table structure for table `log_scheduled_tasks`
+#
+
+CREATE TABLE {$db_prefix}log_scheduled_tasks (
+  id_log int default nextval('{$db_prefix}log_scheduled_tasks_seq'),
+  id_task smallint NOT NULL default '0',
+  time_run int NOT NULL default '0',
+  time_taken float NOT NULL default '0',
+  PRIMARY KEY (id_log)
+);
+
+#
+# Table structure for table `log_search_messages`
+#
+
+CREATE TABLE {$db_prefix}log_search_messages (
+  id_search smallint NOT NULL default '0',
+  id_msg int NOT NULL default '0',
+  PRIMARY KEY (id_search, id_msg)
+);
+
+#
+# Table structure for table `log_search_results`
+#
+
+CREATE TABLE {$db_prefix}log_search_results (
+  id_search smallint NOT NULL default '0',
+  id_topic int NOT NULL default '0',
+  id_msg int NOT NULL default '0',
+  relevance smallint NOT NULL default '0',
+  num_matches smallint NOT NULL default '0',
+  PRIMARY KEY (id_search, id_topic)
+);
+
+#
+# Table structure for table `log_search_subjects`
+#
+
+CREATE TABLE {$db_prefix}log_search_subjects (
+  word varchar(20) NOT NULL default '',
+  id_topic int NOT NULL default '0',
+  PRIMARY KEY (word, id_topic)
+);
+
+#
+# Indexes for table `log_search_subjects`
+#
+
+CREATE INDEX {$db_prefix}log_search_subjects_id_topic ON {$db_prefix}log_search_subjects (id_topic);
+
+#
+# Table structure for table `log_search_topics`
+#
+
+CREATE TABLE {$db_prefix}log_search_topics (
+  id_search smallint NOT NULL default '0',
+  id_topic int NOT NULL default '0',
+  PRIMARY KEY (id_search, id_topic)
+);
+
+#
+# Sequence for table `log_spider_hits`
+#
+
+CREATE SEQUENCE {$db_prefix}log_spider_hits_seq;
+
+#
+# Table structure for table `log_spider_hits`
+#
+
+CREATE TABLE {$db_prefix}log_spider_hits (
+  id_hit int default nextval('{$db_prefix}log_spider_hits_seq'),
+  id_spider smallint NOT NULL default '0',
+  log_time int NOT NULL default '0',
+  url varchar(255) NOT NULL,
+  processed smallint NOT NULL default '0',
+  PRIMARY KEY (id_hit)
+);
+
+#
+# Indexes for table `log_spider_hits`
+#
+
+CREATE INDEX {$db_prefix}log_spider_hits_id_spider ON {$db_prefix}log_spider_hits (id_spider);
+CREATE INDEX {$db_prefix}log_spider_hits_log_time ON {$db_prefix}log_spider_hits (log_time);
+CREATE INDEX {$db_prefix}log_spider_hits_processed ON {$db_prefix}log_spider_hits (processed);
+
+#
+# Table structure for table `log_spider_stats`
+#
+
+CREATE TABLE {$db_prefix}log_spider_stats (
+  id_spider smallint NOT NULL default '0',
+  page_hits smallint NOT NULL default '0',
+  last_seen int NOT NULL default '0',
+  stat_date date NOT NULL default '0001-01-01',
+  PRIMARY KEY (stat_date, id_spider)
+);
+
+#
+# Sequence for table `log_subscribed`
+#
+
+CREATE SEQUENCE {$db_prefix}log_subscribed_seq;
+
+#
+# Table structure for table `log_subscribed`
+#
+
+CREATE TABLE {$db_prefix}log_subscribed (
+  id_sublog int default nextval('{$db_prefix}log_subscribed_seq'),
+  id_subscribe smallint NOT NULL default '0',
+  id_member int NOT NULL default '0',
+  old_id_group int NOT NULL default '0',
+  start_time int NOT NULL default '0',
+  end_time int NOT NULL default '0',
+  payments_pending smallint NOT NULL default '0',
+  status smallint NOT NULL default '0',
+  pending_details text NOT NULL default '',
+  reminder_sent smallint NOT NULL default '0',
+  vendor_ref varchar(255) NOT NULL default '',
+  PRIMARY KEY (id_sublog)
+);
+
+#
+# Indexes for table `log_subscribed`
+#
+
+CREATE INDEX {$db_prefix}log_subscribed_id_subscribe ON {$db_prefix}log_subscribed (id_subscribe, id_member);
+CREATE INDEX {$db_prefix}log_subscribed_end_time ON {$db_prefix}log_subscribed (end_time);
+CREATE INDEX {$db_prefix}log_subscribed_reminder_sent ON {$db_prefix}log_subscribed (reminder_sent);
+CREATE INDEX {$db_prefix}log_subscribed_payments_pending ON {$db_prefix}log_subscribed (payments_pending);
+CREATE INDEX {$db_prefix}log_subscribed_status ON {$db_prefix}log_subscribed (status);
+CREATE INDEX {$db_prefix}log_subscribed_id_member ON {$db_prefix}log_subscribed (id_member);
+
+#
+# Table structure for table `log_topics`
+#
+
+CREATE TABLE {$db_prefix}log_topics (
+  id_member int NOT NULL default '0',
+  id_topic int NOT NULL default '0',
+  id_msg int NOT NULL default '0',
+  PRIMARY KEY (id_member, id_topic)
+);
+
+#
+# Indexes for table `log_topics`
+#
+
+CREATE INDEX {$db_prefix}log_topics_id_topic ON {$db_prefix}log_topics (id_topic);
+
+#
+# Sequence for table `mail_queue`
+#
+
+CREATE SEQUENCE {$db_prefix}mail_queue_seq;
+
+#
+# Table structure for table `mail_queue`
+#
+
+CREATE TABLE {$db_prefix}mail_queue (
+  id_mail int default nextval('{$db_prefix}mail_queue_seq'),
+  time_sent int NOT NULL default '0',
+  recipient varchar(255) NOT NULL,
+  body text NOT NULL,
+  subject varchar(255) NOT NULL,
+  headers text NOT NULL,
+  send_html smallint NOT NULL default '0',
+  priority smallint NOT NULL default '1',
+  private smallint NOT NULL default '0',
+  PRIMARY KEY (id_mail)
+);
+
+#
+# Indexes for table `mail_queue`
+#
+
+CREATE INDEX {$db_prefix}mail_queue_time_sent ON {$db_prefix}mail_queue (time_sent);
+CREATE INDEX {$db_prefix}mail_queue_mail_priority ON {$db_prefix}mail_queue (priority, id_mail);
+
+#
+# Sequence for table `membergroups`
+#
+
+CREATE SEQUENCE {$db_prefix}membergroups_seq START WITH 9;
+
+#
+# Table structure for table `membergroups`
+#
+
+CREATE TABLE {$db_prefix}membergroups (
+  id_group smallint default nextval('{$db_prefix}membergroups_seq'),
+  group_name varchar(80) NOT NULL default '',
+  description text NOT NULL,
+  online_color varchar(20) NOT NULL default '',
+  min_posts int NOT NULL default '-1',
+  max_messages smallint NOT NULL default '0',
+  stars varchar(255) NOT NULL,
+  group_type smallint NOT NULL default '0',
+  hidden smallint NOT NULL default '0',
+  id_parent smallint NOT NULL default '-2',
+  PRIMARY KEY (id_group)
+);
+
+#
+# Indexes for table `membergroups`
+#
+
+CREATE INDEX {$db_prefix}membergroups_min_posts ON {$db_prefix}membergroups (min_posts);
+
+#
+# Dumping data for table `membergroups`
+#
+
+INSERT INTO {$db_prefix}membergroups (id_group, group_name, description, online_color, min_posts, stars, group_type) VALUES (1, '{$default_administrator_group}', '', '#FF0000', -1, '5#staradmin.gif', 1);
+INSERT INTO {$db_prefix}membergroups (id_group, group_name, description, online_color, min_posts, stars) VALUES (2, '{$default_global_moderator_group}', '', '#0000FF', -1, '5#stargmod.gif');
+INSERT INTO {$db_prefix}membergroups (id_group, group_name, description, online_color, min_posts, stars) VALUES (3, '{$default_moderator_group}', '', '', -1, '5#starmod.gif');
+INSERT INTO {$db_prefix}membergroups (id_group, group_name, description, online_color, min_posts, stars) VALUES (4, '{$default_newbie_group}', '', '', 0, '1#star.gif');
+INSERT INTO {$db_prefix}membergroups (id_group, group_name, description, online_color, min_posts, stars) VALUES (5, '{$default_junior_group}', '', '', 50, '2#star.gif');
+INSERT INTO {$db_prefix}membergroups (id_group, group_name, description, online_color, min_posts, stars) VALUES (6, '{$default_full_group}', '', '', 100, '3#star.gif');
+INSERT INTO {$db_prefix}membergroups (id_group, group_name, description, online_color, min_posts, stars) VALUES (7, '{$default_senior_group}', '', '', 250, '4#star.gif');
+INSERT INTO {$db_prefix}membergroups (id_group, group_name, description, online_color, min_posts, stars) VALUES (8, '{$default_hero_group}', '', '', 500, '5#star.gif');
+# --------------------------------------------------------
+
+#
+# Sequence for table `members`
+#
+
+CREATE SEQUENCE {$db_prefix}members_seq;
+
+#
+# Table structure for table `members`
+#
+
+CREATE TABLE {$db_prefix}members (
+  id_member int default nextval('{$db_prefix}members_seq'),
+  member_name varchar(80) NOT NULL default '',
+  date_registered int NOT NULL default '0',
+  posts int NOT NULL default '0',
+  id_group smallint NOT NULL default '0',
+  lngfile varchar(255) NOT NULL,
+  last_login int NOT NULL default '0',
+  real_name varchar(255) NOT NULL,
+  instant_messages smallint NOT NULL default 0,
+  unread_messages smallint NOT NULL default 0,
+  new_pm smallint NOT NULL default '0',
+  buddy_list text NOT NULL,
+  pm_ignore_list varchar(255) NOT NULL,
+  pm_prefs int NOT NULL default '0',
+  mod_prefs varchar(20) NOT NULL default '',
+  message_labels text NOT NULL,
+  passwd varchar(64) NOT NULL default '',
+  openid_uri text NOT NULL,
+  email_address varchar(255) NOT NULL,
+  personal_text varchar(255) NOT NULL,
+  gender smallint NOT NULL default '0',
+  birthdate date NOT NULL default '0001-01-01',
+  website_title varchar(255) NOT NULL,
+  website_url varchar(255) NOT NULL,
+  location varchar(255) NOT NULL,
+  icq varchar(255) NOT NULL,
+  aim varchar(255) NOT NULL default '',
+  yim varchar(32) NOT NULL default '',
+  msn varchar(255) NOT NULL,
+  hide_email smallint NOT NULL default '0',
+  show_online smallint NOT NULL default '1',
+  time_format varchar(80) NOT NULL default '',
+  signature text NOT NULL,
+  time_offset float NOT NULL default '0',
+  avatar varchar(255) NOT NULL,
+  pm_email_notify smallint NOT NULL default '0',
+  karma_bad smallint NOT NULL default '0',
+  karma_good smallint NOT NULL default '0',
+  usertitle varchar(255) NOT NULL,
+  notify_announcements smallint NOT NULL default '1',
+  notify_regularity smallint NOT NULL default '1',
+  notify_send_body smallint NOT NULL default '0',
+  notify_types smallint NOT NULL default '2',
+  member_ip varchar(255) NOT NULL,
+  member_ip2 varchar(255) NOT NULL,
+  secret_question varchar(255) NOT NULL,
+  secret_answer varchar(64) NOT NULL default '',
+  id_theme smallint NOT NULL default '0',
+  is_activated smallint NOT NULL default '1',
+  validation_code varchar(10) NOT NULL default '',
+  id_msg_last_visit int NOT NULL default '0',
+  additional_groups varchar(255) NOT NULL,
+  smiley_set varchar(48) NOT NULL default '',
+  id_post_group smallint NOT NULL default '0',
+  total_time_logged_in int NOT NULL default '0',
+  password_salt varchar(255) NOT NULL default '',
+  ignore_boards text NOT NULL,
+  warning smallint NOT NULL default '0',
+  passwd_flood varchar(12) NOT NULL default '',
+  pm_receive_from smallint NOT NULL default '1',
+  PRIMARY KEY (id_member)
+);
+
+#
+# Indexes for table `members`
+#
+
+CREATE INDEX {$db_prefix}members_member_name ON {$db_prefix}members (member_name);
+CREATE INDEX {$db_prefix}members_real_name ON {$db_prefix}members (real_name);
+CREATE INDEX {$db_prefix}members_date_registered ON {$db_prefix}members (date_registered);
+CREATE INDEX {$db_prefix}members_id_group ON {$db_prefix}members (id_group);
+CREATE INDEX {$db_prefix}members_birthdate ON {$db_prefix}members (birthdate);
+CREATE INDEX {$db_prefix}members_posts ON {$db_prefix}members (posts);
+CREATE INDEX {$db_prefix}members_last_login ON {$db_prefix}members (last_login);
+CREATE INDEX {$db_prefix}members_lngfile ON {$db_prefix}members (lngfile);
+CREATE INDEX {$db_prefix}members_id_post_group ON {$db_prefix}members (id_post_group);
+CREATE INDEX {$db_prefix}members_warning ON {$db_prefix}members (warning);
+CREATE INDEX {$db_prefix}members_total_time_logged_in ON {$db_prefix}members (total_time_logged_in);
+CREATE INDEX {$db_prefix}members_id_theme ON {$db_prefix}members (id_theme);
+
+
+#
+# Sequence for table `member_logins`
+#
+
+CREATE SEQUENCE {$db_prefix}member_logins_seq;
+
+#
+# Table structure for table `member_logins`
+#
+
+CREATE TABLE {$db_prefix}member_logins (
+  id_login int default nextval('{$db_prefix}member_logins_seq'),
+  id_member int NOT NULL default '0',
+  time int NOT NULL default '0',
+  ip varchar(255) NOT NULL default '0',
+  ip2 varchar(255) NOT NULL default '0',
+  PRIMARY KEY (id_login)
+);
+
+#
+# Indexes for table `member_logins`
+#
+CREATE INDEX {$db_prefix}member_logins_id_member ON {$db_prefix}member_logins (id_member);
+CREATE INDEX {$db_prefix}member_logins_time ON {$db_prefix}member_logins (time);
+
+
+#
+# Sequence for table `message_icons`
+#
+
+CREATE SEQUENCE {$db_prefix}message_icons_seq;
+
+#
+# Table structure for table `message_icons`
+#
+
+CREATE TABLE {$db_prefix}message_icons (
+  id_icon smallint default nextval('{$db_prefix}message_icons_seq'),
+  title varchar(80) NOT NULL default '',
+  filename varchar(80) NOT NULL default '',
+  id_board smallint NOT NULL default '0',
+  icon_order smallint NOT NULL default '0',
+  PRIMARY KEY (id_icon)
+);
+
+#
+# Indexes for table `message_icons`
+#
+
+CREATE INDEX {$db_prefix}message_icons_id_board ON {$db_prefix}message_icons (id_board);
+
+#
+# Dumping data for table `message_icons`
+#
+
+# // !!! i18n
+INSERT INTO {$db_prefix}message_icons (filename, title, icon_order) VALUES ('xx', 'Standard', '0');
+INSERT INTO {$db_prefix}message_icons (filename, title, icon_order) VALUES ('thumbup', 'Thumb Up', '1');
+INSERT INTO {$db_prefix}message_icons (filename, title, icon_order) VALUES ('thumbdown', 'Thumb Down', '2');
+INSERT INTO {$db_prefix}message_icons (filename, title, icon_order) VALUES ('exclamation', 'Exclamation point', '3');
+INSERT INTO {$db_prefix}message_icons (filename, title, icon_order) VALUES ('question', 'Question mark', '4');
+INSERT INTO {$db_prefix}message_icons (filename, title, icon_order) VALUES ('lamp', 'Lamp', '5');
+INSERT INTO {$db_prefix}message_icons (filename, title, icon_order) VALUES ('smiley', 'Smiley', '6');
+INSERT INTO {$db_prefix}message_icons (filename, title, icon_order) VALUES ('angry', 'Angry', '7');
+INSERT INTO {$db_prefix}message_icons (filename, title, icon_order) VALUES ('cheesy', 'Cheesy', '8');
+INSERT INTO {$db_prefix}message_icons (filename, title, icon_order) VALUES ('grin', 'Grin', '9');
+INSERT INTO {$db_prefix}message_icons (filename, title, icon_order) VALUES ('sad', 'Sad', '10');
+INSERT INTO {$db_prefix}message_icons (filename, title, icon_order) VALUES ('wink', 'Wink', '11');
+# --------------------------------------------------------
+
+#
+# Sequence for table `messages`
+#
+
+CREATE SEQUENCE {$db_prefix}messages_seq START WITH 2;
+
+#
+# Table structure for table `messages`
+#
+
+CREATE TABLE {$db_prefix}messages (
+  id_msg int default nextval('{$db_prefix}messages_seq'),
+  id_topic int NOT NULL default '0',
+  id_board smallint NOT NULL default '0',
+  poster_time int NOT NULL default '0',
+  id_member int NOT NULL default '0',
+  id_msg_modified int NOT NULL default '0',
+  subject varchar(255) NOT NULL,
+  poster_name varchar(255) NOT NULL,
+  poster_email varchar(255) NOT NULL,
+  poster_ip varchar(255) NOT NULL,
+  smileys_enabled smallint NOT NULL default '1',
+  modified_time int NOT NULL default '0',
+  modified_name varchar(255) NOT NULL,
+  body text NOT NULL,
+  icon varchar(16) NOT NULL default 'xx',
+  approved smallint NOT NULL default '1',
+  PRIMARY KEY (id_msg)
+);
+
+#
+# Indexes for table `messages`
+#
+
+CREATE UNIQUE INDEX {$db_prefix}messages_topic ON {$db_prefix}messages (id_topic, id_msg);
+CREATE UNIQUE INDEX {$db_prefix}messages_id_board ON {$db_prefix}messages (id_board, id_msg);
+CREATE UNIQUE INDEX {$db_prefix}messages_id_member ON {$db_prefix}messages (id_member, id_msg);
+CREATE INDEX {$db_prefix}messages_approved ON {$db_prefix}messages (approved);
+CREATE INDEX {$db_prefix}messages_ip_index ON {$db_prefix}messages (poster_ip, id_topic);
+CREATE INDEX {$db_prefix}messages_participation ON {$db_prefix}messages (id_member, id_topic);
+CREATE INDEX {$db_prefix}messages_show_posts ON {$db_prefix}messages (id_member, id_board);
+CREATE INDEX {$db_prefix}messages_id_topic ON {$db_prefix}messages (id_topic);
+CREATE INDEX {$db_prefix}messages_id_member_msg ON {$db_prefix}messages (id_member, approved, id_msg);
+CREATE INDEX {$db_prefix}messages_current_topic ON {$db_prefix}messages (id_topic, id_msg, id_member, approved);
+CREATE INDEX {$db_prefix}messages_related_ip ON {$db_prefix}messages (id_member, poster_ip, id_msg);
+
+#
+# Dumping data for table `messages`
+#
+
+INSERT INTO {$db_prefix}messages
+	(id_msg, id_msg_modified, id_topic, id_board, poster_time, subject, poster_name, poster_email, poster_ip, modified_name, body, icon)
+VALUES (1, 1, 1, 1, {$current_time}, '{$default_topic_subject}', 'Simple Machines', '[email protected]', '127.0.0.1', '', '{$default_topic_message}', 'xx');
+# --------------------------------------------------------
+
+#
+# Table structure for table `moderators`
+#
+
+CREATE TABLE {$db_prefix}moderators (
+  id_board smallint NOT NULL default '0',
+  id_member int NOT NULL default '0',
+  PRIMARY KEY (id_board, id_member)
+);
+
+#
+# Table structure for table `openid_assoc`
+#
+
+CREATE TABLE {$db_prefix}openid_assoc (
+  server_url text NOT NULL,
+  handle varchar(255) NOT NULL,
+  secret text NOT NULL,
+  issued int NOT NULL default '0',
+  expires int NOT NULL default '0',
+  assoc_type varchar(64) NOT NULL,
+  PRIMARY KEY (server_url, handle)
+);
+
+#
+# Indexes for table `openid_assoc`
+#
+
+CREATE INDEX {$db_prefix}openid_assoc_expires ON {$db_prefix}openid_assoc (expires);
+
+#
+# Sequence for table `package_servers`
+#
+
+CREATE SEQUENCE {$db_prefix}package_servers_seq;
+
+#
+# Table structure for table `package_servers`
+#
+
+CREATE TABLE {$db_prefix}package_servers (
+  id_server smallint default nextval('{$db_prefix}package_servers_seq'),
+  name varchar(255) NOT NULL,
+  url varchar(255) NOT NULL,
+  PRIMARY KEY (id_server)
+);
+
+#
+# Dumping data for table `package_servers`
+#
+
+INSERT INTO {$db_prefix}package_servers
+	(name, url)
+VALUES ('Simple Machines Third-party Mod Site', 'http://custom.simplemachines.org/packages/mods');
+# --------------------------------------------------------
+
+#
+# Sequence for table `permission_profiles`
+#
+
+CREATE SEQUENCE {$db_prefix}permission_profiles_seq START WITH 5;
+
+#
+# Table structure for table `permission_profiles`
+#
+
+CREATE TABLE {$db_prefix}permission_profiles (
+  id_profile smallint default nextval('{$db_prefix}permission_profiles_seq'),
+  profile_name varchar(255) NOT NULL,
+  PRIMARY KEY (id_profile)
+);
+
+#
+# Dumping data for table `permission_profiles`
+#
+
+INSERT INTO {$db_prefix}permission_profiles (id_profile, profile_name) VALUES (1, 'default');
+INSERT INTO {$db_prefix}permission_profiles (id_profile, profile_name) VALUES (2, 'no_polls');
+INSERT INTO {$db_prefix}permission_profiles (id_profile, profile_name) VALUES (3, 'reply_only');
+INSERT INTO {$db_prefix}permission_profiles (id_profile, profile_name) VALUES (4, 'read_only');
+# --------------------------------------------------------
+
+#
+# Table structure for table `permissions`
+#
+
+CREATE TABLE {$db_prefix}permissions (
+  id_group smallint NOT NULL default '0',
+  permission varchar(30) NOT NULL default '',
+  add_deny smallint NOT NULL default '1',
+  PRIMARY KEY (id_group, permission)
+);
+
+#
+# Dumping data for table `permissions`
+#
+
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (-1, 'search_posts');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (-1, 'calendar_view');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (-1, 'view_stats');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (-1, 'profile_view_any');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (0, 'view_mlist');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (0, 'search_posts');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (0, 'profile_view_own');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (0, 'profile_view_any');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (0, 'pm_read');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (0, 'pm_send');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (0, 'calendar_view');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (0, 'view_stats');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (0, 'who_view');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (0, 'profile_identity_own');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (0, 'profile_extra_own');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (0, 'profile_remove_own');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (0, 'profile_server_avatar');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (0, 'profile_upload_avatar');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (0, 'profile_remote_avatar');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (0, 'karma_edit');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'view_mlist');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'search_posts');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'profile_view_own');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'profile_view_any');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'pm_read');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'pm_send');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'calendar_view');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'view_stats');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'who_view');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'profile_identity_own');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'profile_extra_own');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'profile_remove_own');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'profile_server_avatar');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'profile_upload_avatar');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'profile_remote_avatar');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'profile_title_own');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'calendar_post');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'calendar_edit_any');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'karma_edit');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'access_mod_center');
+# --------------------------------------------------------
+
+#
+# Sequence for table `personal_messages`
+#
+
+CREATE SEQUENCE {$db_prefix}personal_messages_seq;
+
+#
+# Table structure for table `personal_messages`
+#
+
+CREATE TABLE {$db_prefix}personal_messages (
+  id_pm int default nextval('{$db_prefix}personal_messages_seq'),
+  id_pm_head int NOT NULL default '0',
+  id_member_from int NOT NULL default '0',
+  deleted_by_sender smallint NOT NULL default '0',
+  from_name varchar(255) NOT NULL,
+  msgtime int NOT NULL default '0',
+  subject varchar(255) NOT NULL,
+  body text NOT NULL,
+  PRIMARY KEY (id_pm)
+);
+
+#
+# Indexes for table `personal_messages`
+#
+
+CREATE INDEX {$db_prefix}personal_messages_id_member ON {$db_prefix}personal_messages (id_member_from, deleted_by_sender);
+CREATE INDEX {$db_prefix}personal_messages_msgtime ON {$db_prefix}personal_messages (msgtime);
+CREATE INDEX {$db_prefix}personal_messages_id_pm_head ON {$db_prefix}personal_messages (id_pm_head);
+
+#
+# Table structure for table `pm_recipients`
+#
+
+CREATE TABLE {$db_prefix}pm_recipients (
+  id_pm int NOT NULL default '0',
+  id_member int NOT NULL default '0',
+  labels varchar(60) NOT NULL default '-1',
+  bcc smallint NOT NULL default '0',
+  is_read smallint NOT NULL default '0',
+  is_new smallint NOT NULL default '0',
+  deleted smallint NOT NULL default '0',
+  PRIMARY KEY (id_pm, id_member)
+);
+
+#
+# Indexes for table `pm_recipients`
+#
+
+CREATE UNIQUE INDEX {$db_prefix}pm_recipients_id_member ON {$db_prefix}pm_recipients (id_member, deleted, id_pm);
+
+#
+# Sequence for table `pm_rules`
+#
+
+CREATE SEQUENCE {$db_prefix}pm_rules_seq;
+
+#
+# Table structure for table `pm_rules`
+#
+
+CREATE TABLE {$db_prefix}pm_rules (
+  id_rule int default nextval('{$db_prefix}pm_rules_seq'),
+  id_member int NOT NULL default '0',
+  rule_name varchar(60) NOT NULL,
+  criteria text NOT NULL,
+  actions text NOT NULL,
+  delete_pm smallint NOT NULL default '0',
+  is_or smallint NOT NULL default '0',
+  PRIMARY KEY (id_rule)
+);
+
+#
+# Indexes for table `pm_rules`
+#
+
+CREATE INDEX {$db_prefix}pm_rules_id_member ON {$db_prefix}pm_rules (id_member);
+CREATE INDEX {$db_prefix}pm_rules_delete_pm ON {$db_prefix}pm_rules (delete_pm);
+
+#
+# Sequence for table `polls`
+#
+
+CREATE SEQUENCE {$db_prefix}polls_seq;
+
+#
+# Table structure for table `polls`
+#
+
+CREATE TABLE {$db_prefix}polls (
+  id_poll int default nextval('{$db_prefix}polls_seq'),
+  question varchar(255) NOT NULL,
+  voting_locked smallint NOT NULL default '0',
+  max_votes smallint NOT NULL default '1',
+  expire_time int NOT NULL default '0',
+  hide_results smallint NOT NULL default '0',
+  change_vote smallint NOT NULL default '0',
+  guest_vote smallint NOT NULL default '0',
+  num_guest_voters int NOT NULL default '0',
+  reset_poll int NOT NULL default '0',
+  id_member int NOT NULL default '0',
+  poster_name varchar(255) NOT NULL,
+  PRIMARY KEY (id_poll)
+);
+
+#
+# Table structure for table `poll_choices`
+#
+
+CREATE TABLE {$db_prefix}poll_choices (
+  id_poll int NOT NULL default '0',
+  id_choice smallint NOT NULL default '0',
+  label varchar(255) NOT NULL,
+  votes smallint NOT NULL default '0',
+  PRIMARY KEY (id_poll, id_choice)
+);
+
+#
+# Sequence for table `scheduled_tasks`
+#
+
+CREATE SEQUENCE {$db_prefix}scheduled_tasks_seq START WITH 9;
+
+#
+# Table structure for table `scheduled_tasks`
+#
+
+CREATE TABLE {$db_prefix}scheduled_tasks (
+  id_task smallint default nextval('{$db_prefix}scheduled_tasks_seq'),
+  next_time int NOT NULL default '0',
+  time_offset int NOT NULL default '0',
+  time_regularity smallint NOT NULL default '0',
+  time_unit varchar(1) NOT NULL default 'h',
+  disabled smallint NOT NULL default '0',
+  task varchar(24) NOT NULL default '',
+  PRIMARY KEY (id_task)
+);
+
+#
+# Indexes for table `scheduled_tasks`
+#
+
+CREATE INDEX {$db_prefix}scheduled_tasks_next_time ON {$db_prefix}scheduled_tasks (next_time);
+CREATE INDEX {$db_prefix}scheduled_tasks_disabled ON {$db_prefix}scheduled_tasks (disabled);
+CREATE UNIQUE INDEX {$db_prefix}scheduled_tasks_task ON {$db_prefix}scheduled_tasks (task);
+
+#
+# Dumping data for table `scheduled_tasks`
+#
+
+INSERT INTO {$db_prefix}scheduled_tasks	(id_task, next_time, time_offset, time_regularity, time_unit, disabled, task) VALUES (1, 0, 0, 2, 'h', 0, 'approval_notification');
+INSERT INTO {$db_prefix}scheduled_tasks	(id_task, next_time, time_offset, time_regularity, time_unit, disabled, task) VALUES (2, 0, 0, 7, 'd', 0, 'auto_optimize');
+INSERT INTO {$db_prefix}scheduled_tasks	(id_task, next_time, time_offset, time_regularity, time_unit, disabled, task) VALUES (3, 0, 60, 1, 'd', 0, 'daily_maintenance');
+INSERT INTO {$db_prefix}scheduled_tasks	(id_task, next_time, time_offset, time_regularity, time_unit, disabled, task) VALUES (5, 0, 0, 1, 'd', 0, 'daily_digest');
+INSERT INTO {$db_prefix}scheduled_tasks	(id_task, next_time, time_offset, time_regularity, time_unit, disabled, task) VALUES (6, 0, 0, 1, 'w', 0, 'weekly_digest');
+INSERT INTO {$db_prefix}scheduled_tasks	(id_task, next_time, time_offset, time_regularity, time_unit, disabled, task) VALUES (7, 0, {$sched_task_offset}, 1, 'd', 0, 'fetchSMfiles');
+INSERT INTO {$db_prefix}scheduled_tasks	(id_task, next_time, time_offset, time_regularity, time_unit, disabled, task) VALUES (8, 0, 0, 1, 'd', 1, 'birthdayemails');
+INSERT INTO {$db_prefix}scheduled_tasks	(id_task, next_time, time_offset, time_regularity, time_unit, disabled, task) VALUES (9, 0, 0, 1, 'w', 0, 'weekly_maintenance');
+INSERT INTO {$db_prefix}scheduled_tasks	(id_task, next_time, time_offset, time_regularity, time_unit, disabled, task) VALUES (10, 0, 120, 1, 'd', 1, 'paid_subscriptions');
+
+# --------------------------------------------------------
+
+#
+# Table structure for table `settings`
+#
+
+CREATE TABLE {$db_prefix}settings (
+  variable varchar(255) NOT NULL,
+  value text NOT NULL,
+  PRIMARY KEY (variable)
+);
+
+#
+# Dumping data for table `settings`
+#
+
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('smfVersion', '{$smf_version}');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('news', '{$default_news}');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('compactTopicPagesContiguous', '5');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('compactTopicPagesEnable', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enableStickyTopics', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('todayMod', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('karmaMode', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('karmaTimeRestrictAdmins', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enablePreviousNext', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('pollMode', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enableVBStyleLogin', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enableCompressedOutput', '{$enableCompressedOutput}');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('karmaWaitTime', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('karmaMinPosts', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('karmaLabel', '{$default_karmaLabel}');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('karmaSmiteLabel', '{$default_karmaSmiteLabel}');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('karmaApplaudLabel', '{$default_karmaApplaudLabel}');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachmentSizeLimit', '128');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachmentPostLimit', '192');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachmentNumPerPostLimit', '4');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachmentDirSizeLimit', '10240');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachmentUploadDir', '{$boarddir}/attachments');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachmentExtensions', 'doc,gif,jpg,mpg,pdf,png,txt,zip');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachmentCheckExtensions', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachmentShowImages', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachmentEnable', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachmentEncryptFilenames', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachmentThumbnails', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachmentThumbWidth', '150');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachmentThumbHeight', '150');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('censorIgnoreCase', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('mostOnline', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('mostOnlineToday', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('mostDate', {$current_time});
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('allow_disableAnnounce', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('trackStats', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('userLanguage', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('titlesEnable', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('topicSummaryPosts', '15');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enableErrorLogging', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('max_image_width', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('max_image_height', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('onlineEnable', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('cal_enabled', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('cal_maxyear', '2020');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('cal_minyear', '2008');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('cal_daysaslink', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('cal_defaultboard', '');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('cal_showholidays', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('cal_showbdays', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('cal_showevents', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('cal_showweeknum', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('cal_maxspan', '7');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('smtp_host', '');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('smtp_port', '25');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('smtp_username', '');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('smtp_password', '');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('mail_type', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('timeLoadPageEnable', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('totalMembers', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('totalTopics', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('totalMessages', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('simpleSearch', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('censor_vulgar', '');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('censor_proper', '');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enablePostHTML', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('theme_allow', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('theme_default', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('theme_guests', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enableEmbeddedFlash', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('xmlnews_enable', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('xmlnews_maxlen', '255');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('hotTopicPosts', '15');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('hotTopicVeryPosts', '25');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('registration_method', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('send_validation_onChange', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('send_welcomeEmail', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('allow_editDisplayName', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('allow_hideOnline', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('guest_hideContacts', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('spamWaitTime', '5');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('pm_spam_settings', '10,5,20');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('reserveWord', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('reserveCase', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('reserveUser', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('reserveName', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('reserveNames', '{$default_reserved_names}');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('autoLinkUrls', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('banLastUpdated', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('smileys_dir', '{$boarddir}/Smileys');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('smileys_url', '{$boardurl}/Smileys');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_directory', '{$boarddir}/avatars');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_url', '{$boardurl}/avatars');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_max_height_external', '65');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_max_width_external', '65');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_action_too_large', 'option_html_resize');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_max_height_upload', '65');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_max_width_upload', '65');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_resize_upload', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_download_png', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('failed_login_threshold', '3');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('oldTopicDays', '120');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('edit_wait_time', '90');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('edit_disable_time', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('autoFixDatabase', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('allow_guestAccess', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('time_format', '{$default_time_format}');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('number_format', '1234.00');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enableBBC', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('max_messageLength', '20000');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('signature_settings', '1,300,0,0,0,0,0,0:');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('autoOptMaxOnline', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('defaultMaxMessages', '15');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('defaultMaxTopics', '20');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('defaultMaxMembers', '30');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enableParticipation', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('recycle_enable', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('recycle_board', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('maxMsgID', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enableAllMessages', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('fixLongWords', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('knownThemes', '1,2,3');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('who_enabled', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('time_offset', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('cookieTime', '60');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('lastActive', '15');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('smiley_sets_known', 'default,aaron,akyhne');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('smiley_sets_names', '{$default_smileyset_name}\n{$default_aaron_smileyset_name}\n{$default_akyhne_smileyset_name}');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('smiley_sets_default', 'default');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('cal_days_for_index', '7');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('requireAgreement', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('unapprovedMembers', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('default_personal_text', '');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('package_make_backups', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('databaseSession_enable', '{$databaseSession_enable}');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('databaseSession_loose', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('databaseSession_lifetime', '2880');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('search_cache_size', '50');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('search_results_per_page', '30');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('search_weight_frequency', '30');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('search_weight_age', '25');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('search_weight_length', '20');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('search_weight_subject', '15');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('search_weight_first_message', '10');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('search_max_results', '1200');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('search_floodcontrol_time', '5');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('permission_enable_deny', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('permission_enable_postgroups', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('mail_next_send', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('mail_recent', '0000000000|0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('settings_updated', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('next_task_time', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('warning_settings', '1,20,0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('warning_watch', '10');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('warning_moderate', '35');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('warning_mute', '60');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('admin_features', '');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('last_mod_report_action', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('pruningOptions', '30,180,180,180,30,0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('cache_enable', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('reg_verification', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('visual_verification_type', '3');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enable_buddylist', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('birthday_email', 'happy_birthday');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('dont_repeat_theme_core', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('dont_repeat_smileys_20', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('dont_repeat_buddylists', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachment_image_reencode', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachment_image_paranoid', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachment_thumb_png', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_reencode', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_paranoid', '0');
+# --------------------------------------------------------
+
+#
+# Table structure for table `sessions`
+#
+
+CREATE TABLE {$db_prefix}sessions (
+  session_id char(32) NOT NULL,
+  last_update int NOT NULL,
+  data text NOT NULL,
+  PRIMARY KEY (session_id)
+);
+
+#
+# Sequence for table `smileys`
+#
+
+CREATE SEQUENCE {$db_prefix}smileys_seq;
+
+#
+# Table structure for table `smileys`
+#
+
+CREATE TABLE {$db_prefix}smileys (
+  id_smiley smallint default nextval('{$db_prefix}smileys_seq'),
+  code varchar(30) NOT NULL default '',
+  filename varchar(48) NOT NULL default '',
+  description varchar(80) NOT NULL default '',
+  smiley_row smallint NOT NULL default '0',
+  smiley_order smallint NOT NULL default '0',
+  hidden smallint NOT NULL default '0',
+  PRIMARY KEY (id_smiley)
+);
+
+#
+# Dumping data for table `smileys`
+#
+
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES (':)', 'smiley.gif', '{$default_smiley_smiley}', 0, 0);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES (';)', 'wink.gif', '{$default_wink_smiley}', 1, 0);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES (':D', 'cheesy.gif', '{$default_cheesy_smiley}', 2, 0);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES (';D', 'grin.gif', '{$default_grin_smiley}', 3, 0);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES ('>:(', 'angry.gif', '{$default_angry_smiley}', 4, 0);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES (':(', 'sad.gif', '{$default_sad_smiley}', 5, 0);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES (':o', 'shocked.gif', '{$default_shocked_smiley}', 6, 0);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES ('8)', 'cool.gif', '{$default_cool_smiley}', 7, 0);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES ('???', 'huh.gif', '{$default_huh_smiley}', 8, 0);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES ('::)', 'rolleyes.gif', '{$default_roll_eyes_smiley}', 9, 0);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES (':P', 'tongue.gif', '{$default_tongue_smiley}', 10, 0);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES (':-[', 'embarrassed.gif', '{$default_embarrassed_smiley}', 11, 0);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES (':-X', 'lipsrsealed.gif', '{$default_lips_sealed_smiley}', 12, 0);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES (':-\\', 'undecided.gif', '{$default_undecided_smiley}', 13, 0);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES (':-*', 'kiss.gif', '{$default_kiss_smiley}', 14, 0);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES (':\'(', 'cry.gif', '{$default_cry_smiley}', 15, 0);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES ('>:D', 'evil.gif', '{$default_evil_smiley}', 16, 1);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES ('^-^', 'azn.gif', '{$default_azn_smiley}', 17, 1);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES ('O0', 'afro.gif', '{$default_afro_smiley}', 18, 1);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES (':))', 'laugh.gif', '{$default_laugh_smiley}', 19, 1);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES ('C:-)', 'police.gif', '{$default_police_smiley}', 20, 1);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES ('O:-)', 'angel.gif', '{$default_angel_smiley}', 21, 1);
+# --------------------------------------------------------
+
+#
+# Sequence for table `spiders`
+#
+
+CREATE SEQUENCE {$db_prefix}spiders_seq;
+
+#
+# Table structure for table `spiders`
+#
+
+CREATE TABLE {$db_prefix}spiders (
+  id_spider smallint NOT NULL default nextval('{$db_prefix}spiders_seq'),
+  spider_name varchar(255) NOT NULL,
+  user_agent varchar(255) NOT NULL,
+  ip_info varchar(255) NOT NULL,
+  PRIMARY KEY (id_spider)
+);
+
+#
+# Dumping data for table `spiders`
+#
+
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (1, 'Google', 'googlebot', '');
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (2, 'Yahoo!', 'slurp', '');
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (3, 'MSN', 'msnbot', '');
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (4, 'Google (Mobile)', 'Googlebot-Mobile', '');
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (5, 'Google (Image)', 'Googlebot-Image', '');
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (6, 'Google (AdSense)', 'Mediapartners-Google', '');
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (7, 'Google (Adwords)', 'AdsBot-Google', '');
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (8, 'Yahoo! (Mobile)', 'YahooSeeker/M1A1-R2D2', '');
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (9, 'Yahoo! (Image)', 'Yahoo-MMCrawler', '');
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (10, 'MSN (Mobile)', 'MSNBOT_Mobile', '');
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (11, 'MSN (Media)', 'msnbot-media', '');
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (12, 'Cuil', 'twiceler', '');
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (13, 'Ask', 'Teoma', '');
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (14, 'Baidu', 'Baiduspider', '');
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (15, 'Gigablast', 'Gigabot', '');
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (16, 'InternetArchive', 'ia_archiver-web.archive.org', '');
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (17, 'Alexa', 'ia_archiver', '');
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (18, 'Omgili', 'omgilibot', '');
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (19, 'EntireWeb', 'Speedy Spider', '');
+
+#
+# Sequence for table `subscriptions`
+#
+
+CREATE SEQUENCE {$db_prefix}subscriptions_seq;
+
+#
+# Table structure for table `subscriptions`
+#
+
+CREATE TABLE {$db_prefix}subscriptions(
+  id_subscribe smallint NOT NULL default nextval('{$db_prefix}subscriptions_seq'),
+  name varchar(60) NOT NULL,
+  description varchar(255) NOT NULL,
+  cost text NOT NULL,
+  length varchar(6) NOT NULL,
+  id_group int NOT NULL default '0',
+  add_groups varchar(40) NOT NULL,
+  active smallint NOT NULL default '1',
+  repeatable smallint NOT NULL default '0',
+  allow_partial smallint NOT NULL default '0',
+  reminder smallint NOT NULL default '0',
+  email_complete text NOT NULL,
+  PRIMARY KEY (id_subscribe)
+);
+
+#
+# Indexes for table `subscriptions`
+#
+
+CREATE INDEX {$db_prefix}subscriptions_active ON {$db_prefix}subscriptions (active);
+
+#
+# Table structure for table `themes`
+#
+
+CREATE TABLE {$db_prefix}themes (
+  id_member int NOT NULL default '0',
+  id_theme smallint NOT NULL default '1',
+  variable varchar(255) NOT NULL,
+  value text NOT NULL,
+  PRIMARY KEY (id_theme, id_member, variable)
+);
+
+#
+# Indexes for table `themes`
+#
+
+CREATE INDEX {$db_prefix}themes_id_member ON {$db_prefix}themes (id_member);
+
+#
+# Dumping data for table `themes`
+#
+
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'name', '{$default_theme_name}');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'theme_url', '{$boardurl}/Themes/default');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'images_url', '{$boardurl}/Themes/default/images');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'theme_dir', '{$boarddir}/Themes/default');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'show_bbc', '1');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'show_latest_member', '1');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'show_modify', '1');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'show_user_images', '1');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'show_blurb', '1');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'show_gender', '0');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'show_newsfader', '0');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'number_recent_posts', '0');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'show_member_bar', '1');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'linktree_link', '1');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'show_profile_buttons', '1');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'show_mark_read', '1');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'show_stats_index', '1');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'linktree_inline', '0');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'show_board_desc', '1');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'newsfader_time', '5000');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'allow_no_censored', '0');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'additional_options_collapsable', '1');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'use_image_buttons', '1');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'enable_news', '1');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'forum_width', '90%');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (2, 'name', '{$default_core_theme_name}');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (2, 'theme_url', '{$boardurl}/Themes/core');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (2, 'images_url', '{$boardurl}/Themes/core/images');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (2, 'theme_dir', '{$boarddir}/Themes/core');
+INSERT INTO {$db_prefix}themes (id_member, id_theme, variable, value) VALUES (-1, 1, 'display_quick_reply', '1');
+INSERT INTO {$db_prefix}themes (id_member, id_theme, variable, value) VALUES (-1, 1, 'posts_apply_ignore_list', '1');
+# --------------------------------------------------------
+
+#
+# Sequence for table `topics`
+#
+
+CREATE SEQUENCE {$db_prefix}topics_seq START WITH 2;
+
+#
+# Table structure for table `topics`
+#
+
+CREATE TABLE {$db_prefix}topics (
+  id_topic int default nextval('{$db_prefix}topics_seq'),
+  is_sticky smallint NOT NULL default '0',
+  id_board smallint NOT NULL default '0',
+  id_first_msg int NOT NULL default '0',
+  id_last_msg int NOT NULL default '0',
+  id_member_started int NOT NULL default '0',
+  id_member_updated int NOT NULL default '0',
+  id_poll int NOT NULL default '0',
+  id_previous_board smallint NOT NULL default '0',
+  id_previous_topic int NOT NULL default '0',
+  num_replies int NOT NULL default '0',
+  num_views int NOT NULL default '0',
+  locked smallint NOT NULL default '0',
+  unapproved_posts smallint NOT NULL default '0',
+  approved smallint NOT NULL default '1',
+  PRIMARY KEY (id_topic)
+);
+
+#
+# Indexes for table `topics`
+#
+
+CREATE UNIQUE INDEX {$db_prefix}topics_last_message ON {$db_prefix}topics (id_last_msg, id_board);
+CREATE UNIQUE INDEX {$db_prefix}topics_first_message ON {$db_prefix}topics (id_first_msg, id_board);
+CREATE UNIQUE INDEX {$db_prefix}topics_poll ON {$db_prefix}topics (id_poll, id_topic);
+CREATE INDEX {$db_prefix}topics_is_sticky ON {$db_prefix}topics (is_sticky);
+CREATE INDEX {$db_prefix}topics_approved ON {$db_prefix}topics (approved);
+CREATE INDEX {$db_prefix}topics_id_board ON {$db_prefix}topics (id_board);
+CREATE INDEX {$db_prefix}topics_member_started ON {$db_prefix}topics (id_member_started, id_board);
+CREATE INDEX {$db_prefix}topics_last_message_sticky ON {$db_prefix}topics (id_board, is_sticky, id_last_msg);
+CREATE INDEX {$db_prefix}topics_board_news ON {$db_prefix}topics (id_board, id_first_msg);
+
+#
+# Dumping data for table `topics`
+#
+
+INSERT INTO {$db_prefix}topics
+	(id_topic, id_board, id_first_msg, id_last_msg, id_member_started, id_member_updated)
+VALUES (1, 1, 1, 1, 0, 0);
+# --------------------------------------------------------

+ 2168 - 0
other/install_2-1_sqlite.sql

@@ -0,0 +1,2168 @@
+#### ATTENTION: You do not need to run or use this file!  The install.php script does everything for you!
+#### Install script for SQLite
+
+#
+# Table structure for table `admin_info_files`
+#
+
+CREATE TABLE {$db_prefix}admin_info_files (
+  id_file integer primary key,
+  filename varchar(255) NOT NULL,
+  path varchar(255) NOT NULL,
+  parameters varchar(255) NOT NULL,
+  data text NOT NULL,
+  filetype varchar(255) NOT NULL
+);
+
+#
+# Indexes for table `admin_info_files`
+#
+
+CREATE INDEX {$db_prefix}admin_info_files_filename ON {$db_prefix}admin_info_files (filename);
+
+#
+# Dumping data for table `admin_info_files`
+#
+
+BEGIN TRANSACTION;
+INSERT INTO {$db_prefix}admin_info_files (id_file, filename, path, parameters, data, filetype) VALUES (1, 'current-version.js', '/smf/', 'version=%3$s', '', 'text/javascript');
+INSERT INTO {$db_prefix}admin_info_files (id_file, filename, path, parameters, data, filetype) VALUES (2, 'detailed-version.js', '/smf/', 'language=%1$s&version=%3$s', '', 'text/javascript');
+INSERT INTO {$db_prefix}admin_info_files (id_file, filename, path, parameters, data, filetype) VALUES (3, 'latest-news.js', '/smf/', 'language=%1$s&format=%2$s', '', 'text/javascript');
+INSERT INTO {$db_prefix}admin_info_files (id_file, filename, path, parameters, data, filetype) VALUES (4, 'latest-packages.js', '/smf/', 'language=%1$s&version=%3$s', '', 'text/javascript');
+INSERT INTO {$db_prefix}admin_info_files (id_file, filename, path, parameters, data, filetype) VALUES (5, 'latest-smileys.js', '/smf/', 'language=%1$s&version=%3$s', '', 'text/javascript');
+INSERT INTO {$db_prefix}admin_info_files (id_file, filename, path, parameters, data, filetype) VALUES (6, 'latest-support.js', '/smf/', 'language=%1$s&version=%3$s', '', 'text/javascript');
+INSERT INTO {$db_prefix}admin_info_files (id_file, filename, path, parameters, data, filetype) VALUES (7, 'latest-themes.js', '/smf/', 'language=%1$s&version=%3$s', '', 'text/javascript');
+COMMIT;
+
+# --------------------------------------------------------
+
+#
+# Table structure for table `approval_queue`
+#
+
+CREATE TABLE {$db_prefix}approval_queue (
+  id_msg int NOT NULL default '0',
+  id_attach int NOT NULL default '0',
+  id_event smallint NOT NULL default '0'
+);
+
+#
+# Table structure for table `attachments`
+#
+
+CREATE TABLE {$db_prefix}attachments (
+  id_attach integer primary key,
+  id_thumb int NOT NULL default '0',
+  id_msg int NOT NULL default '0',
+  id_member int NOT NULL default '0',
+  id_folder smallint NOT NULL default '1',
+  attachment_type smallint NOT NULL default '0',
+  filename varchar(255) NOT NULL,
+  file_hash varchar(40) NOT NULL default '',
+  fileext varchar(8) NOT NULL default '',
+  size int NOT NULL default '0',
+  downloads int NOT NULL default '0',
+  width int NOT NULL default '0',
+  height int NOT NULL default '0',
+  mime_type varchar(20) NOT NULL default '',
+  approved smallint NOT NULL default '1'
+);
+
+#
+# Indexes for table `attachments`
+#
+
+CREATE UNIQUE INDEX {$db_prefix}attachments_id_member ON {$db_prefix}attachments (id_member, id_attach);
+CREATE INDEX {$db_prefix}attachments_id_msg ON {$db_prefix}attachments (id_msg);
+CREATE INDEX {$db_prefix}attachments_attachment_type ON {$db_prefix}attachments (attachment_type);
+
+#
+# Table structure for table `ban_groups`
+#
+
+CREATE TABLE {$db_prefix}ban_groups (
+  id_ban_group integer primary key,
+  name varchar(20) NOT NULL default '',
+  ban_time int NOT NULL default '0',
+  expire_time int,
+  cannot_access smallint NOT NULL default '0',
+  cannot_register smallint NOT NULL default '0',
+  cannot_post smallint NOT NULL default '0',
+  cannot_login smallint NOT NULL default '0',
+  reason varchar(255) NOT NULL,
+  notes text NOT NULL
+);
+
+#
+# Table structure for table `ban_items`
+#
+
+CREATE TABLE {$db_prefix}ban_items (
+  id_ban integer primary key,
+  id_ban_group smallint NOT NULL default '0',
+  ip_low1 smallint NOT NULL default '0',
+  ip_high1 smallint NOT NULL default '0',
+  ip_low2 smallint NOT NULL default '0',
+  ip_high2 smallint NOT NULL default '0',
+  ip_low3 smallint NOT NULL default '0',
+  ip_high3 smallint NOT NULL default '0',
+  ip_low4 smallint NOT NULL default '0',
+  ip_high4 smallint NOT NULL default '0',
+  ip_low5 smallint NOT NULL default '0',
+  ip_high5 smallint NOT NULL default '0',
+  ip_low6 smallint NOT NULL default '0',
+  ip_high6 smallint NOT NULL default '0',
+  ip_low7 smallint NOT NULL default '0',
+  ip_high7 smallint NOT NULL default '0',
+  ip_low8 smallint NOT NULL default '0',
+  ip_high8 smallint NOT NULL default '0',
+  hostname varchar(255) NOT NULL,
+  email_address varchar(255) NOT NULL,
+  id_member int NOT NULL default '0',
+  hits int NOT NULL default '0'
+);
+
+#
+# Indexes for table `ban_items`
+#
+
+CREATE INDEX {$db_prefix}ban_items_id_ban_group ON {$db_prefix}ban_items (id_ban_group);
+
+#
+# Table structure for table `board_permissions`
+#
+
+CREATE TABLE {$db_prefix}board_permissions (
+  id_group smallint NOT NULL default '0',
+  id_profile smallint NOT NULL default '0',
+  permission varchar(30) NOT NULL default '',
+  add_deny smallint NOT NULL default '1',
+  PRIMARY KEY (id_group, id_profile, permission)
+);
+
+#
+# Dumping data for table `board_permissions`
+#
+
+BEGIN TRANSACTION;
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (-1, 1, 'poll_view');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'remove_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'lock_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'mark_any_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'mark_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'modify_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'poll_add_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'poll_edit_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'poll_lock_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'poll_post');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'poll_view');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'poll_vote');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'post_attachment');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'post_new');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'post_reply_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'post_reply_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'post_unapproved_topics');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'post_unapproved_replies_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'post_unapproved_replies_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'post_unapproved_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'delete_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'report_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'send_topic');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 1, 'view_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'moderate_board');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'post_new');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'post_reply_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'post_reply_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'post_unapproved_topics');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'post_unapproved_replies_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'post_unapproved_replies_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'post_unapproved_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'poll_post');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'poll_add_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'poll_remove_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'poll_view');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'poll_vote');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'poll_lock_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'poll_edit_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'report_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'lock_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'send_topic');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'mark_any_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'mark_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'delete_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'modify_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'make_sticky');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'lock_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'remove_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'move_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'merge_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'split_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'delete_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'modify_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'approve_posts');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'post_attachment');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 1, 'view_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'moderate_board');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'post_new');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'post_reply_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'post_reply_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'post_unapproved_topics');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'post_unapproved_replies_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'post_unapproved_replies_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'post_unapproved_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'poll_post');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'poll_add_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'poll_remove_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'poll_view');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'poll_vote');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'poll_lock_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'poll_edit_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'report_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'lock_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'send_topic');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'mark_any_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'mark_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'delete_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'modify_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'make_sticky');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'lock_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'remove_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'move_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'merge_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'split_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'delete_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'modify_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'approve_posts');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'post_attachment');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 1, 'view_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (-1, 2, 'poll_view');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'remove_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'lock_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'mark_any_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'mark_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'modify_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'poll_view');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'poll_vote');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'post_attachment');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'post_new');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'post_reply_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'post_reply_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'post_unapproved_topics');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'post_unapproved_replies_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'post_unapproved_replies_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'post_unapproved_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'delete_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'report_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'send_topic');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 2, 'view_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'moderate_board');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'post_new');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'post_reply_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'post_reply_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'post_unapproved_topics');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'post_unapproved_replies_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'post_unapproved_replies_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'post_unapproved_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'poll_post');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'poll_add_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'poll_remove_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'poll_view');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'poll_vote');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'poll_lock_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'poll_edit_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'report_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'lock_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'send_topic');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'mark_any_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'mark_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'delete_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'modify_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'make_sticky');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'lock_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'remove_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'move_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'merge_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'split_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'delete_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'modify_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'approve_posts');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'post_attachment');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 2, 'view_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'moderate_board');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'post_new');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'post_reply_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'post_reply_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'post_unapproved_topics');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'post_unapproved_replies_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'post_unapproved_replies_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'post_unapproved_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'poll_post');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'poll_add_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'poll_remove_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'poll_view');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'poll_vote');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'poll_lock_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'poll_edit_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'report_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'lock_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'send_topic');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'mark_any_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'mark_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'delete_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'modify_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'make_sticky');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'lock_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'remove_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'move_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'merge_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'split_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'delete_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'modify_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'approve_posts');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'post_attachment');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 2, 'view_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (-1, 3, 'poll_view');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 3, 'remove_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 3, 'lock_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 3, 'mark_any_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 3, 'mark_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 3, 'modify_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 3, 'poll_view');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 3, 'poll_vote');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 3, 'post_attachment');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 3, 'post_reply_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 3, 'post_reply_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 3, 'post_unapproved_replies_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 3, 'post_unapproved_replies_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 3, 'post_unapproved_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 3, 'delete_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 3, 'report_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 3, 'send_topic');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 3, 'view_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'moderate_board');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'post_new');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'post_reply_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'post_reply_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'post_unapproved_topics');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'post_unapproved_replies_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'post_unapproved_replies_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'post_unapproved_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'poll_post');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'poll_add_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'poll_remove_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'poll_view');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'poll_vote');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'poll_lock_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'poll_edit_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'report_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'lock_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'send_topic');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'mark_any_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'mark_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'delete_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'modify_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'make_sticky');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'lock_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'remove_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'move_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'merge_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'split_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'delete_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'modify_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'approve_posts');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'post_attachment');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 3, 'view_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'moderate_board');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'post_new');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'post_reply_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'post_reply_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'post_unapproved_topics');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'post_unapproved_replies_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'post_unapproved_replies_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'post_unapproved_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'poll_post');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'poll_add_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'poll_remove_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'poll_view');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'poll_vote');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'poll_lock_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'poll_edit_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'report_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'lock_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'send_topic');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'mark_any_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'mark_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'delete_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'modify_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'make_sticky');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'lock_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'remove_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'move_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'merge_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'split_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'delete_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'modify_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'approve_posts');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'post_attachment');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 3, 'view_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (-1, 4, 'poll_view');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 4, 'mark_any_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 4, 'mark_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 4, 'poll_view');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 4, 'poll_vote');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 4, 'report_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 4, 'send_topic');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (0, 4, 'view_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'moderate_board');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'post_new');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'post_reply_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'post_reply_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'post_unapproved_topics');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'post_unapproved_replies_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'post_unapproved_replies_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'post_unapproved_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'poll_post');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'poll_add_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'poll_remove_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'poll_view');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'poll_vote');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'poll_lock_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'poll_edit_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'report_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'lock_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'send_topic');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'mark_any_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'mark_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'delete_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'modify_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'make_sticky');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'lock_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'remove_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'move_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'merge_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'split_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'delete_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'modify_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'approve_posts');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'post_attachment');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (2, 4, 'view_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'moderate_board');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'post_new');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'post_reply_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'post_reply_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'post_unapproved_topics');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'post_unapproved_replies_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'post_unapproved_replies_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'post_unapproved_attachments');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'poll_post');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'poll_add_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'poll_remove_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'poll_view');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'poll_vote');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'poll_lock_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'poll_edit_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'report_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'lock_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'send_topic');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'mark_any_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'mark_notify');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'delete_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'modify_own');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'make_sticky');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'lock_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'remove_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'move_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'merge_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'split_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'delete_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'modify_any');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'approve_posts');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'post_attachment');
+INSERT INTO {$db_prefix}board_permissions (id_group, id_profile, permission) VALUES (3, 4, 'view_attachments');
+COMMIT;
+
+# --------------------------------------------------------
+
+#
+# Table structure for table `boards`
+#
+
+CREATE TABLE {$db_prefix}boards (
+  id_board integer primary key,
+  id_cat smallint NOT NULL default '0',
+  child_level smallint NOT NULL default '0',
+  id_parent smallint NOT NULL default '0',
+  board_order smallint NOT NULL default '0',
+  id_last_msg int NOT NULL default '0',
+  id_msg_updated int NOT NULL default '0',
+  member_groups varchar(255) NOT NULL default '-1,0',
+  id_profile smallint NOT NULL default '1',
+  name varchar(255) NOT NULL,
+  description text NOT NULL,
+  num_topics int NOT NULL default '0',
+  num_posts int NOT NULL default '0',
+  count_posts smallint NOT NULL default '0',
+  id_theme smallint NOT NULL default '0',
+  override_theme smallint NOT NULL default '0',
+  unapproved_posts smallint NOT NULL default '0',
+  unapproved_topics smallint NOT NULL default '0',
+  redirect varchar(255) NOT NULL default ''
+);
+
+#
+# Indexes for table `ban_items`
+#
+
+CREATE UNIQUE INDEX {$db_prefix}boards_categories ON {$db_prefix}boards (id_cat, id_board);
+CREATE INDEX {$db_prefix}boards_id_parent ON {$db_prefix}boards (id_parent);
+CREATE INDEX {$db_prefix}boards_id_msg_updated ON {$db_prefix}boards (id_msg_updated);
+CREATE INDEX {$db_prefix}boards_member_groups ON {$db_prefix}boards (member_groups);
+
+#
+# Dumping data for table `boards`
+#
+
+INSERT INTO {$db_prefix}boards
+	(id_board, id_cat, board_order, id_last_msg, id_msg_updated, name, description, num_topics, num_posts, member_groups)
+VALUES (1, 1, 1, 1, 1, '{$default_board_name}', '{$default_board_description}', 1, 1, '-1,0,2');
+# --------------------------------------------------------
+
+#
+# Table structure for table `calendar`
+#
+
+CREATE TABLE {$db_prefix}calendar (
+  id_event integer primary key,
+  start_date date NOT NULL default '0001-01-01',
+  end_date date NOT NULL default '0001-01-01',
+  id_board smallint NOT NULL default '0',
+  id_topic int NOT NULL default '0',
+  title varchar(255) NOT NULL default '',
+  id_member int NOT NULL default '0'
+);
+
+#
+# Indexes for table `calendar`
+#
+
+CREATE INDEX {$db_prefix}calendar_start_date ON {$db_prefix}calendar (start_date);
+CREATE INDEX {$db_prefix}calendar_end_date ON {$db_prefix}calendar (end_date);
+CREATE INDEX {$db_prefix}calendar_topic ON {$db_prefix}calendar (id_topic, id_member);
+
+#
+# Table structure for table `calendar_holidays`
+#
+
+CREATE TABLE {$db_prefix}calendar_holidays (
+  id_holiday integer primary key,
+  event_date date NOT NULL default '0001-01-01',
+  title varchar(255) NOT NULL default ''
+);
+
+#
+# Indexes for table `calendar_holidays`
+#
+
+CREATE INDEX {$db_prefix}calendar_holidays_event_date ON {$db_prefix}calendar_holidays (event_date);
+
+#
+# Dumping data for table `calendar_holidays`
+#
+
+BEGIN TRANSACTION;
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('New Year''s', '0004-01-01');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Christmas', '0004-12-25');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Valentine''s Day', '0004-02-14');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('St. Patrick''s Day', '0004-03-17');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('April Fools', '0004-04-01');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Earth Day', '0004-04-22');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('United Nations Day', '0004-10-24');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Halloween', '0004-10-31');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Mother''s Day', '2010-05-09');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Mother''s Day', '2011-05-08');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Mother''s Day', '2012-05-13');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Mother''s Day', '2013-05-12');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Mother''s Day', '2014-05-11');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Mother''s Day', '2015-05-10');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Mother''s Day', '2016-05-08');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Mother''s Day', '2017-05-14');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Mother''s Day', '2018-05-13');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Mother''s Day', '2019-05-12');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Mother''s Day', '2020-05-10');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Father''s Day', '2010-06-20');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Father''s Day', '2011-06-19');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Father''s Day', '2012-06-17');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Father''s Day', '2013-06-16');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Father''s Day', '2014-06-15');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Father''s Day', '2015-06-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Father''s Day', '2016-06-19');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Father''s Day', '2017-06-18');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Father''s Day', '2018-06-17');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Father''s Day', '2019-06-16');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Father''s Day', '2020-06-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Summer Solstice', '2010-06-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Summer Solstice', '2011-06-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Summer Solstice', '2012-06-20');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Summer Solstice', '2013-06-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Summer Solstice', '2014-06-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Summer Solstice', '2015-06-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Summer Solstice', '2016-06-20');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Summer Solstice', '2017-06-20');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Summer Solstice', '2018-06-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Summer Solstice', '2019-06-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Summer Solstice', '2020-06-20');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Vernal Equinox', '2010-03-20');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Vernal Equinox', '2011-03-20');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Vernal Equinox', '2012-03-20');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Vernal Equinox', '2013-03-20');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Vernal Equinox', '2014-03-20');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Vernal Equinox', '2015-03-20');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Vernal Equinox', '2016-03-19');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Vernal Equinox', '2017-03-20');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Vernal Equinox', '2018-03-20');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Vernal Equinox', '2019-03-20');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Vernal Equinox', '2020-03-19');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Winter Solstice', '2010-12-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Winter Solstice', '2011-12-22');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Winter Solstice', '2012-12-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Winter Solstice', '2013-12-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Winter Solstice', '2014-12-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Winter Solstice', '2015-12-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Winter Solstice', '2016-12-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Winter Solstice', '2017-12-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Winter Solstice', '2018-12-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Winter Solstice', '2019-12-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Winter Solstice', '2020-12-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Autumnal Equinox', '2010-09-22');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Autumnal Equinox', '2011-09-23');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Autumnal Equinox', '2012-09-22');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Autumnal Equinox', '2013-09-22');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Autumnal Equinox', '2014-09-22');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Autumnal Equinox', '2015-09-23');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Autumnal Equinox', '2016-09-22');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Autumnal Equinox', '2017-09-22');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Autumnal Equinox', '2018-09-22');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Autumnal Equinox', '2019-09-23');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Autumnal Equinox', '2020-09-22');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Independence Day', '0004-07-04');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Cinco de Mayo', '0004-05-05');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Flag Day', '0004-06-14');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Veterans Day', '0004-11-11');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Groundhog Day', '0004-02-02');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Thanksgiving', '2010-11-25');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Thanksgiving', '2011-11-24');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Thanksgiving', '2012-11-22');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Thanksgiving', '2013-11-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Thanksgiving', '2014-11-20');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Thanksgiving', '2015-11-26');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Thanksgiving', '2016-11-24');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Thanksgiving', '2017-11-23');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Thanksgiving', '2018-11-22');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Thanksgiving', '2019-11-21');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Thanksgiving', '2020-11-26');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Memorial Day', '2010-05-31');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Memorial Day', '2011-05-30');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Memorial Day', '2012-05-28');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Memorial Day', '2013-05-27');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Memorial Day', '2014-05-26');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Memorial Day', '2015-05-25');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Memorial Day', '2016-05-30');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Memorial Day', '2017-05-29');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Memorial Day', '2018-05-28');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Memorial Day', '2019-05-27');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Memorial Day', '2020-05-25');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Labor Day', '2010-09-06');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Labor Day', '2011-09-05');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Labor Day', '2012-09-03');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Labor Day', '2013-09-09');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Labor Day', '2014-09-08');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Labor Day', '2015-09-07');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Labor Day', '2016-09-05');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Labor Day', '2017-09-04');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Labor Day', '2018-09-03');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Labor Day', '2019-09-09');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('Labor Day', '2020-09-07');
+INSERT INTO {$db_prefix}calendar_holidays (title, event_date) VALUES ('D-Day', '0004-06-06');
+COMMIT;
+
+# --------------------------------------------------------
+
+#
+# Table structure for table `categories`
+#
+
+CREATE TABLE {$db_prefix}categories (
+  id_cat integer primary key,
+  cat_order smallint NOT NULL default '0',
+  name varchar(255) NOT NULL,
+  can_collapse smallint NOT NULL default '1'
+);
+
+#
+# Dumping data for table `categories`
+#
+
+INSERT INTO {$db_prefix}categories
+VALUES (1, 0, '{$default_category_name}', 1);
+# --------------------------------------------------------
+
+#
+# Table structure for table `collapsed_categories`
+#
+
+CREATE TABLE {$db_prefix}collapsed_categories (
+  id_cat smallint NOT NULL default '0',
+  id_member int NOT NULL default '0',
+  PRIMARY KEY (id_cat, id_member)
+);
+
+#
+# Table structure for table `custom_fields`
+#
+
+CREATE TABLE {$db_prefix}custom_fields (
+  id_field integer primary key,
+  col_name varchar(12) NOT NULL default '',
+  field_name varchar(40) NOT NULL default '',
+  field_desc varchar(255) NOT NULL,
+  field_type varchar(8) NOT NULL default 'text',
+  field_length smallint NOT NULL default '255',
+  field_options text NOT NULL,
+  mask varchar(255) NOT NULL,
+  show_reg smallint NOT NULL default '0',
+  show_display smallint NOT NULL default '0',
+  show_profile varchar(20) NOT NULL default 'forumprofile',
+  private smallint NOT NULL default '0',
+  active smallint NOT NULL default '1',
+  bbc smallint NOT NULL default '0',
+  can_search smallint NOT NULL default '0',
+  default_value varchar(255) NOT NULL,
+  enclose text NOT NULL,
+  placement smallint NOT NULL default '0'
+);
+
+#
+# Indexes for table `custom_fields`
+#
+
+CREATE UNIQUE INDEX {$db_prefix}custom_fields_col_name ON {$db_prefix}custom_fields (col_name);
+
+#
+# Table structure for table `group_moderators`
+#
+
+CREATE TABLE {$db_prefix}group_moderators (
+  id_group smallint NOT NULL default '0',
+  id_member int NOT NULL default '0',
+  PRIMARY KEY (id_group, id_member)
+);
+
+#
+# Table structure for table `log_actions`
+#
+
+CREATE TABLE {$db_prefix}log_actions (
+  id_action integer primary key,
+  id_log smallint NOT NULL default '1',
+  log_time int NOT NULL default '0',
+  id_member int NOT NULL default '0',
+  ip char(16) NOT NULL default '                ',
+  action varchar(30) NOT NULL default '',
+  id_board smallint NOT NULL default '0',
+  id_topic int NOT NULL default '0',
+  id_msg int NOT NULL default '0',
+  extra text NOT NULL
+);
+
+#
+# Indexes for table `log_actions`
+#
+
+CREATE INDEX {$db_prefix}log_actions_log_time ON {$db_prefix}log_actions (log_time);
+CREATE INDEX {$db_prefix}log_actions_id_member ON {$db_prefix}log_actions (id_member);
+CREATE INDEX {$db_prefix}log_actions_id_board ON {$db_prefix}log_actions (id_board);
+CREATE INDEX {$db_prefix}log_actions_id_msg ON {$db_prefix}log_actions (id_msg);
+CREATE INDEX {$db_prefix}log_actions_id_log ON {$db_prefix}log_actions (id_log);
+
+#
+# Table structure for table `log_activity`
+#
+
+CREATE TABLE {$db_prefix}log_activity (
+  date date NOT NULL default '0001-01-01',
+  hits int NOT NULL default '0',
+  topics smallint NOT NULL default '0',
+  posts smallint NOT NULL default '0',
+  registers smallint NOT NULL default '0',
+  most_on smallint NOT NULL default '0',
+  PRIMARY KEY (date)
+);
+
+#
+# Indexes for table `log_activity`
+#
+CREATE INDEX {$db_prefix}log_activity_most_on ON {$db_prefix}log_activity (most_on);
+
+#
+# Table structure for table `log_banned`
+#
+
+CREATE TABLE {$db_prefix}log_banned (
+  id_ban_log integer primary key,
+  id_member int NOT NULL default '0',
+  ip char(16) NOT NULL default '                ',
+  email varchar(255) NOT NULL,
+  log_time int NOT NULL default '0'
+);
+
+#
+# Indexes for table `log_banned`
+#
+
+CREATE INDEX {$db_prefix}log_banned_log_time ON {$db_prefix}log_banned (log_time);
+
+#
+# Table structure for table `log_boards`
+#
+
+CREATE TABLE {$db_prefix}log_boards (
+  id_member int NOT NULL default '0',
+  id_board smallint NOT NULL default '0',
+  id_msg int NOT NULL default '0',
+  PRIMARY KEY (id_member, id_board)
+);
+
+#
+# Table structure for table `log_comments`
+#
+
+CREATE TABLE {$db_prefix}log_comments (
+  id_comment integer primary key,
+  id_member int NOT NULL default '0',
+  member_name varchar(80) NOT NULL default '',
+  comment_type varchar(8) NOT NULL default 'warning',
+  id_recipient int NOT NULL default '0',
+  recipient_name varchar(255) NOT NULL,
+  log_time int NOT NULL default '0',
+  id_notice int NOT NULL default '0',
+  counter smallint NOT NULL default '0',
+  body text NOT NULL
+);
+
+#
+# Indexes for table `log_comments`
+#
+
+CREATE INDEX {$db_prefix}log_comments_id_recipient ON {$db_prefix}log_comments (id_recipient);
+CREATE INDEX {$db_prefix}log_comments_log_time ON {$db_prefix}log_comments (log_time);
+CREATE INDEX {$db_prefix}log_comments_comment_type ON {$db_prefix}log_comments (comment_type);
+
+#
+# Table structure for table `log_digest`
+#
+
+CREATE TABLE {$db_prefix}log_digest (
+  id_topic int NOT NULL,
+  id_msg int NOT NULL,
+  note_type varchar(10) NOT NULL default 'post',
+  daily smallint NOT NULL default '0',
+  exclude int NOT NULL default '0'
+);
+
+#
+# Table structure for table `log_errors`
+#
+
+CREATE TABLE {$db_prefix}log_errors (
+  id_error integer primary key,
+  log_time int NOT NULL default '0',
+  id_member int NOT NULL default '0',
+  ip char(16) NOT NULL default '                ',
+  url text NOT NULL,
+  message text NOT NULL,
+  session char(32) NOT NULL default '                                ',
+  error_type char(15) NOT NULL default 'general',
+  file varchar(255) NOT NULL,
+  line int NOT NULL default '0'
+);
+
+#
+# Indexes for table `log_errors`
+#
+
+CREATE INDEX {$db_prefix}log_errors_log_time ON {$db_prefix}log_errors (log_time);
+CREATE INDEX {$db_prefix}log_errors_id_member ON {$db_prefix}log_errors (id_member);
+CREATE INDEX {$db_prefix}log_errors_ip ON {$db_prefix}log_errors (ip);
+
+#
+# Table structure for table `log_floodcontrol`
+#
+
+CREATE TABLE {$db_prefix}log_floodcontrol (
+  ip char(16) NOT NULL default '                ',
+  log_time int NOT NULL default '0',
+  log_type varchar(8) NOT NULL default 'post',
+  PRIMARY KEY (ip, log_type)
+);
+
+#
+# Table structure for table `log_group_requests`
+#
+
+CREATE TABLE {$db_prefix}log_group_requests (
+  id_request integer primary key,
+  id_member int NOT NULL default '0',
+  id_group smallint NOT NULL default '0',
+  time_applied int NOT NULL default '0',
+  reason text NOT NULL
+);
+
+#
+# Indexes for table `log_group_requests`
+#
+
+CREATE UNIQUE INDEX {$db_prefix}log_group_requests_id_member ON {$db_prefix}log_group_requests (id_member, id_group);
+
+#
+# Table structure for table `log_karma`
+#
+
+CREATE TABLE {$db_prefix}log_karma (
+  id_target int NOT NULL default '0',
+  id_executor int NOT NULL default '0',
+  log_time int NOT NULL default '0',
+  action smallint NOT NULL default '0',
+  PRIMARY KEY (id_target, id_executor)
+);
+
+#
+# Indexes for table `log_karma`
+#
+
+CREATE INDEX {$db_prefix}log_karma_log_time ON {$db_prefix}log_karma (log_time);
+
+#
+# Table structure for table `log_mark_read`
+#
+
+CREATE TABLE {$db_prefix}log_mark_read (
+  id_member int NOT NULL default '0',
+  id_board smallint NOT NULL default '0',
+  id_msg int NOT NULL default '0',
+  PRIMARY KEY (id_member, id_board)
+);
+
+#
+# Table structure for table `log_member_notices`
+#
+
+CREATE TABLE {$db_prefix}log_member_notices (
+  id_notice integer primary key,
+  subject varchar(255) NOT NULL,
+  body text NOT NULL
+);
+
+#
+# Table structure for table `log_notify`
+#
+
+CREATE TABLE {$db_prefix}log_notify (
+  id_member int NOT NULL default '0',
+  id_topic int NOT NULL default '0',
+  id_board smallint NOT NULL default '0',
+  sent smallint NOT NULL default '0',
+  PRIMARY KEY (id_member, id_topic, id_board)
+);
+
+#
+# Indexes for table `log_notify`
+#
+
+CREATE INDEX {$db_prefix}log_notify_id_topic ON {$db_prefix}log_notify (id_topic, id_member);
+
+#
+# Table structure for table `log_online`
+#
+
+CREATE TABLE {$db_prefix}log_online (
+  session varchar(32) NOT NULL default '',
+  log_time int(10) NOT NULL default '0',
+  id_member int NOT NULL default '0',
+  id_spider smallint NOT NULL default '0',
+  ip int NOT NULL default '0',
+  url text NOT NULL,
+  PRIMARY KEY (session)
+);
+
+#
+# Indexes for table `log_online`
+#
+
+CREATE INDEX {$db_prefix}log_online_log_time ON {$db_prefix}log_online (log_time);
+CREATE INDEX {$db_prefix}log_online_id_member ON {$db_prefix}log_online (id_member);
+
+#
+# Table structure for table `log_packages`
+#
+
+CREATE TABLE {$db_prefix}log_packages (
+  id_install integer primary key,
+  filename varchar(255) NOT NULL,
+  package_id varchar(255) NOT NULL,
+  name varchar(255) NOT NULL,
+  version varchar(255) NOT NULL,
+  id_member_installed int NOT NULL default '0',
+  member_installed varchar(255) NOT NULL,
+  time_installed int NOT NULL default '0',
+  id_member_removed int NOT NULL default '0',
+  member_removed varchar(255) NOT NULL,
+  time_removed int NOT NULL default '0',
+  install_state smallint NOT NULL default '1',
+  failed_steps text NOT NULL,
+  db_changes text NOT NULL,
+  themes_installed varchar(255) NOT NULL
+);
+
+#
+# Indexes for table `log_packages`
+#
+
+CREATE INDEX {$db_prefix}log_packages_filename ON {$db_prefix}log_packages (filename);
+
+#
+# Table structure for table `log_polls`
+#
+
+CREATE TABLE {$db_prefix}log_polls (
+  id_poll int NOT NULL default '0',
+  id_member int NOT NULL default '0',
+  id_choice smallint NOT NULL default '0'
+);
+
+#
+# Indexes for table `log_polls`
+#
+
+CREATE INDEX {$db_prefix}log_polls_id_poll ON {$db_prefix}log_polls (id_poll, id_member, id_choice);
+
+#
+# Table structure for table `log_reported`
+#
+
+CREATE TABLE {$db_prefix}log_reported (
+  id_report integer primary key,
+  id_msg int NOT NULL default '0',
+  id_topic int NOT NULL default '0',
+  id_board smallint NOT NULL default '0',
+  id_member int NOT NULL default '0',
+  membername varchar(255) NOT NULL,
+  subject varchar(255) NOT NULL,
+  body text NOT NULL,
+  time_started int NOT NULL default '0',
+  time_updated int NOT NULL default '0',
+  num_reports int NOT NULL default '0',
+  closed smallint NOT NULL default '0',
+  ignore_all smallint NOT NULL default '0'
+);
+
+#
+# Indexes for table `log_reported`
+#
+
+CREATE INDEX {$db_prefix}log_reported_id_member ON {$db_prefix}log_reported (id_member);
+CREATE INDEX {$db_prefix}log_reported_id_topic ON {$db_prefix}log_reported (id_topic);
+CREATE INDEX {$db_prefix}log_reported_closed ON {$db_prefix}log_reported (closed);
+CREATE INDEX {$db_prefix}log_reported_time_started ON {$db_prefix}log_reported (time_started);
+CREATE INDEX {$db_prefix}log_reported_id_msg ON {$db_prefix}log_reported (id_msg);
+
+#
+# Table structure for table `log_reported_comments`
+#
+
+CREATE TABLE {$db_prefix}log_reported_comments (
+  id_comment integer primary key,
+  id_report int NOT NULL default '0',
+  id_member int NOT NULL,
+  membername varchar(255) NOT NULL,
+  email_address varchar(255) NOT NULL,
+  member_ip varchar(255) NOT NULL,
+  comment varchar(255) NOT NULL,
+  time_sent int NOT NULL
+);
+
+#
+# Indexes for table `log_reported_comments`
+#
+
+CREATE INDEX {$db_prefix}log_reported_comments_id_report ON {$db_prefix}log_reported_comments (id_report);
+CREATE INDEX {$db_prefix}log_reported_comments_id_member ON {$db_prefix}log_reported_comments (id_member);
+CREATE INDEX {$db_prefix}log_reported_comments_time_sent ON {$db_prefix}log_reported_comments (time_sent);
+
+#
+# Table structure for table `log_scheduled_tasks`
+#
+
+CREATE TABLE {$db_prefix}log_scheduled_tasks (
+  id_log integer primary key,
+  id_task smallint NOT NULL default '0',
+  time_run int NOT NULL default '0',
+  time_taken float NOT NULL default '0'
+);
+
+#
+# Table structure for table `log_search_messages`
+#
+
+CREATE TABLE {$db_prefix}log_search_messages (
+  id_search smallint NOT NULL default '0',
+  id_msg int NOT NULL default '0',
+  PRIMARY KEY (id_search, id_msg)
+);
+
+#
+# Table structure for table `log_search_results`
+#
+
+CREATE TABLE {$db_prefix}log_search_results (
+  id_search smallint NOT NULL default '0',
+  id_topic int NOT NULL default '0',
+  id_msg int NOT NULL default '0',
+  relevance smallint NOT NULL default '0',
+  num_matches smallint NOT NULL default '0',
+  PRIMARY KEY (id_search, id_topic)
+);
+
+#
+# Table structure for table `log_search_subjects`
+#
+
+CREATE TABLE {$db_prefix}log_search_subjects (
+  word varchar(20) NOT NULL default '',
+  id_topic int NOT NULL default '0',
+  PRIMARY KEY (word, id_topic)
+);
+
+#
+# Indexes for table `log_search_subjects`
+#
+
+CREATE INDEX {$db_prefix}log_search_subjects_id_topic ON {$db_prefix}log_search_subjects (id_topic);
+
+#
+# Table structure for table `log_search_topics`
+#
+
+CREATE TABLE {$db_prefix}log_search_topics (
+  id_search smallint NOT NULL default '0',
+  id_topic int NOT NULL default '0',
+  PRIMARY KEY (id_search, id_topic)
+);
+
+#
+# Table structure for table `log_spider_hits`
+#
+
+CREATE TABLE {$db_prefix}log_spider_hits (
+	id_hit integer primary key,
+  id_spider smallint NOT NULL default '0',
+  log_time int NOT NULL default '0',
+  url varchar(255) NOT NULL,
+  processed smallint NOT NULL default '0'
+);
+
+#
+# Indexes for table `log_spider_hits`
+#
+
+CREATE INDEX {$db_prefix}log_spider_hits_id_spider ON {$db_prefix}log_spider_hits (id_spider);
+CREATE INDEX {$db_prefix}log_spider_hits_log_time ON {$db_prefix}log_spider_hits (log_time);
+CREATE INDEX {$db_prefix}log_spider_hits_processed ON {$db_prefix}log_spider_hits (processed);
+
+#
+# Table structure for table `log_spider_stats`
+#
+
+CREATE TABLE {$db_prefix}log_spider_stats (
+  id_spider smallint NOT NULL default '0',
+  page_hits smallint NOT NULL default '0',
+  last_seen int NOT NULL default '0',
+  stat_date date NOT NULL default '0001-01-01',
+  PRIMARY KEY (stat_date, id_spider)
+);
+
+#
+# Table structure for table `log_subscribed`
+#
+
+CREATE TABLE {$db_prefix}log_subscribed (
+  id_sublog integer primary key,
+  id_subscribe smallint unsigned NOT NULL default '0',
+  id_member int NOT NULL default '0',
+  old_id_group int NOT NULL default '0',
+  start_time int NOT NULL default '0',
+  end_time int NOT NULL default '0',
+  status smallint NOT NULL default '0',
+  payments_pending smallint NOT NULL default '0',
+  pending_details text NOT NULL,
+  reminder_sent smallint NOT NULL default '0',
+  vendor_ref varchar(255) NOT NULL
+);
+
+#
+# Indexes for table `log_subscribed`
+#
+
+CREATE INDEX {$db_prefix}log_subscribed_id_subscribe ON {$db_prefix}log_subscribed (id_subscribe, id_member);
+CREATE INDEX {$db_prefix}log_subscribed_end_time ON {$db_prefix}log_subscribed (end_time);
+CREATE INDEX {$db_prefix}log_subscribed_reminder_sent ON {$db_prefix}log_subscribed (reminder_sent);
+CREATE INDEX {$db_prefix}log_subscribed_payments_pending ON {$db_prefix}log_subscribed (payments_pending);
+CREATE INDEX {$db_prefix}log_subscribed_status ON {$db_prefix}log_subscribed (status);
+CREATE INDEX {$db_prefix}log_subscribed_id_member ON {$db_prefix}log_subscribed (id_member);
+
+#
+# Table structure for table `log_topics`
+#
+
+CREATE TABLE {$db_prefix}log_topics (
+  id_member int NOT NULL default '0',
+  id_topic int NOT NULL default '0',
+  id_msg int NOT NULL default '0',
+  PRIMARY KEY (id_member, id_topic)
+);
+
+#
+# Indexes for table `log_topics`
+#
+
+CREATE INDEX {$db_prefix}log_topics_id_topic ON {$db_prefix}log_topics (id_topic);
+
+#
+# Table structure for table `mail_queue`
+#
+
+CREATE TABLE {$db_prefix}mail_queue (
+  id_mail integer primary key,
+  time_sent int NOT NULL default '0',
+  recipient varchar(255) NOT NULL,
+  body text NOT NULL,
+  subject varchar(255) NOT NULL,
+  headers text NOT NULL,
+  send_html smallint NOT NULL default '0',
+  priority smallint NOT NULL default '1',
+  private smallint NOT NULL default '0'
+);
+
+#
+# Indexes for table `mail_queue`
+#
+
+CREATE INDEX {$db_prefix}mail_queue_time_sent ON {$db_prefix}mail_queue (time_sent);
+CREATE INDEX {$db_prefix}mail_queue_mail_priority ON {$db_prefix}mail_queue (priority, id_mail);
+
+#
+# Table structure for table `membergroups`
+#
+
+CREATE TABLE {$db_prefix}membergroups (
+  id_group integer primary key,
+  group_name varchar(80) NOT NULL default '',
+  description text NOT NULL,
+  online_color varchar(20) NOT NULL default '',
+  min_posts int NOT NULL default '-1',
+  max_messages smallint NOT NULL default '0',
+  stars varchar(255) NOT NULL,
+  group_type smallint NOT NULL default '0',
+  hidden smallint NOT NULL default '0',
+  id_parent smallint NOT NULL default '-2'
+);
+
+#
+# Indexes for table `membergroups`
+#
+
+CREATE INDEX {$db_prefix}membergroups_min_posts ON {$db_prefix}membergroups (min_posts);
+
+#
+# Dumping data for table `membergroups`
+#
+
+BEGIN TRANSACTION;
+INSERT INTO {$db_prefix}membergroups (id_group, group_name, description, online_color, min_posts, stars, group_type) VALUES (1, '{$default_administrator_group}', '', '#FF0000', -1, '5#staradmin.gif', 1);
+INSERT INTO {$db_prefix}membergroups (id_group, group_name, description, online_color, min_posts, stars) VALUES (2, '{$default_global_moderator_group}', '', '#0000FF', -1, '5#stargmod.gif');
+INSERT INTO {$db_prefix}membergroups (id_group, group_name, description, online_color, min_posts, stars) VALUES (3, '{$default_moderator_group}', '', '', -1, '5#starmod.gif');
+INSERT INTO {$db_prefix}membergroups (id_group, group_name, description, online_color, min_posts, stars) VALUES (4, '{$default_newbie_group}', '', '', 0, '1#star.gif');
+INSERT INTO {$db_prefix}membergroups (id_group, group_name, description, online_color, min_posts, stars) VALUES (5, '{$default_junior_group}', '', '', 50, '2#star.gif');
+INSERT INTO {$db_prefix}membergroups (id_group, group_name, description, online_color, min_posts, stars) VALUES (6, '{$default_full_group}', '', '', 100, '3#star.gif');
+INSERT INTO {$db_prefix}membergroups (id_group, group_name, description, online_color, min_posts, stars) VALUES (7, '{$default_senior_group}', '', '', 250, '4#star.gif');
+INSERT INTO {$db_prefix}membergroups (id_group, group_name, description, online_color, min_posts, stars) VALUES (8, '{$default_hero_group}', '', '', 500, '5#star.gif');
+COMMIT;
+
+# --------------------------------------------------------
+
+#
+# Table structure for table `members`
+#
+
+CREATE TABLE {$db_prefix}members (
+  id_member integer primary key,
+  member_name varchar(80) NOT NULL default '',
+  date_registered int NOT NULL default '0',
+  posts int NOT NULL default '0',
+  id_group smallint NOT NULL default '0',
+  lngfile varchar(255) NOT NULL,
+  last_login int NOT NULL default '0',
+  real_name varchar(255) NOT NULL,
+  instant_messages smallint NOT NULL default 0,
+  unread_messages smallint NOT NULL default 0,
+  new_pm smallint NOT NULL default '0',
+  buddy_list text NOT NULL,
+  pm_ignore_list varchar(255) NOT NULL,
+  pm_prefs int NOT NULL default '0',
+  mod_prefs varchar(20) NOT NULL default '',
+  message_labels text NOT NULL,
+  passwd varchar(64) NOT NULL default '',
+  openid_uri text NOT NULL,
+  email_address varchar(255) NOT NULL,
+  personal_text varchar(255) NOT NULL,
+  gender smallint NOT NULL default '0',
+  birthdate date NOT NULL default '0001-01-01',
+  website_title varchar(255) NOT NULL,
+  website_url varchar(255) NOT NULL,
+  location varchar(255) NOT NULL,
+  icq varchar(255) NOT NULL,
+  aim varchar(255) NOT NULL default '',
+  yim varchar(32) NOT NULL default '',
+  msn varchar(255) NOT NULL,
+  hide_email smallint NOT NULL default '0',
+  show_online smallint NOT NULL default '1',
+  time_format varchar(80) NOT NULL default '',
+  signature text NOT NULL,
+  time_offset float NOT NULL default '0',
+  avatar varchar(255) NOT NULL,
+  pm_email_notify smallint NOT NULL default '0',
+  karma_bad smallint NOT NULL default '0',
+  karma_good smallint NOT NULL default '0',
+  usertitle varchar(255) NOT NULL,
+  notify_announcements smallint NOT NULL default '1',
+  notify_regularity smallint NOT NULL default '1',
+  notify_send_body smallint NOT NULL default '0',
+  notify_types smallint NOT NULL default '2',
+  member_ip varchar(255) NOT NULL,
+  member_ip2 varchar(255) NOT NULL,
+  secret_question varchar(255) NOT NULL,
+  secret_answer varchar(64) NOT NULL default '',
+  id_theme smallint NOT NULL default '0',
+  is_activated smallint NOT NULL default '1',
+  validation_code varchar(10) NOT NULL default '',
+  id_msg_last_visit int NOT NULL default '0',
+  additional_groups varchar(255) NOT NULL,
+  smiley_set varchar(48) NOT NULL default '',
+  id_post_group smallint NOT NULL default '0',
+  total_time_logged_in int NOT NULL default '0',
+  password_salt varchar(255) NOT NULL default '',
+  ignore_boards text NOT NULL,
+  warning smallint NOT NULL default '0',
+  passwd_flood varchar(12) NOT NULL default '',
+  pm_receive_from smallint NOT NULL default '1'
+);
+
+#
+# Indexes for table `members`
+#
+
+CREATE INDEX {$db_prefix}members_member_name ON {$db_prefix}members (member_name);
+CREATE INDEX {$db_prefix}members_real_name ON {$db_prefix}members (real_name);
+CREATE INDEX {$db_prefix}members_date_registered ON {$db_prefix}members (date_registered);
+CREATE INDEX {$db_prefix}members_id_group ON {$db_prefix}members (id_group);
+CREATE INDEX {$db_prefix}members_birthdate ON {$db_prefix}members (birthdate);
+CREATE INDEX {$db_prefix}members_posts ON {$db_prefix}members (posts);
+CREATE INDEX {$db_prefix}members_last_login ON {$db_prefix}members (last_login);
+CREATE INDEX {$db_prefix}members_lngfile ON {$db_prefix}members (lngfile);
+CREATE INDEX {$db_prefix}members_id_post_group ON {$db_prefix}members (id_post_group);
+CREATE INDEX {$db_prefix}members_warning ON {$db_prefix}members (warning);
+CREATE INDEX {$db_prefix}members_total_time_logged_in ON {$db_prefix}members (total_time_logged_in);
+CREATE INDEX {$db_prefix}members_id_theme ON {$db_prefix}members (id_theme);
+
+
+#
+# Table structure for table `member_logins`
+#
+
+CREATE TABLE {$db_prefix}member_logins (
+  id_login integer primary key,
+  id_member int NOT NULL default '0',
+  time int(10) NOT NULL default '0',
+  ip varchar(255) NOT NULL default '0',
+  ip2 varchar(255) NOT NULL default '0'
+);
+
+#
+# Indexes for table `member_logins`
+#
+CREATE INDEX {$db_prefix}member_logins_id_member ON {$db_prefix}member_logins (id_member);
+CREATE INDEX {$db_prefix}member_logins_time ON {$db_prefix}member_logins (time);
+
+#
+# Table structure for table `message_icons`
+#
+
+CREATE TABLE {$db_prefix}message_icons (
+  id_icon integer primary key,
+  title varchar(80) NOT NULL default '',
+  filename varchar(80) NOT NULL default '',
+  id_board smallint NOT NULL default '0',
+  icon_order smallint NOT NULL default '0'
+);
+
+#
+# Indexes for table `message_icons`
+#
+
+CREATE INDEX {$db_prefix}message_icons_id_board ON {$db_prefix}message_icons (id_board);
+
+#
+# Dumping data for table `message_icons`
+#
+
+# // !!! i18n
+BEGIN TRANSACTION;
+INSERT INTO {$db_prefix}message_icons (filename, title, icon_order) VALUES ('xx', 'Standard', '0');
+INSERT INTO {$db_prefix}message_icons (filename, title, icon_order) VALUES ('thumbup', 'Thumb Up', '1');
+INSERT INTO {$db_prefix}message_icons (filename, title, icon_order) VALUES ('thumbdown', 'Thumb Down', '2');
+INSERT INTO {$db_prefix}message_icons (filename, title, icon_order) VALUES ('exclamation', 'Exclamation point', '3');
+INSERT INTO {$db_prefix}message_icons (filename, title, icon_order) VALUES ('question', 'Question mark', '4');
+INSERT INTO {$db_prefix}message_icons (filename, title, icon_order) VALUES ('lamp', 'Lamp', '5');
+INSERT INTO {$db_prefix}message_icons (filename, title, icon_order) VALUES ('smiley', 'Smiley', '6');
+INSERT INTO {$db_prefix}message_icons (filename, title, icon_order) VALUES ('angry', 'Angry', '7');
+INSERT INTO {$db_prefix}message_icons (filename, title, icon_order) VALUES ('cheesy', 'Cheesy', '8');
+INSERT INTO {$db_prefix}message_icons (filename, title, icon_order) VALUES ('grin', 'Grin', '9');
+INSERT INTO {$db_prefix}message_icons (filename, title, icon_order) VALUES ('sad', 'Sad', '10');
+INSERT INTO {$db_prefix}message_icons (filename, title, icon_order) VALUES ('wink', 'Wink', '11');
+COMMIT;
+
+# --------------------------------------------------------
+
+#
+# Table structure for table `messages`
+#
+
+CREATE TABLE {$db_prefix}messages (
+  id_msg integer primary key,
+  id_topic int NOT NULL default '0',
+  id_board smallint NOT NULL default '0',
+  poster_time int NOT NULL default '0',
+  id_member int NOT NULL default '0',
+  id_msg_modified int NOT NULL default '0',
+  subject varchar(255) NOT NULL,
+  poster_name varchar(255) NOT NULL,
+  poster_email varchar(255) NOT NULL,
+  poster_ip varchar(255) NOT NULL,
+  smileys_enabled smallint NOT NULL default '1',
+  modified_time int NOT NULL default '0',
+  modified_name varchar(255) NOT NULL,
+  body text NOT NULL,
+  icon varchar(16) NOT NULL default 'xx',
+  approved smallint NOT NULL default '1'
+);
+
+#
+# Indexes for table `messages`
+#
+
+CREATE UNIQUE INDEX {$db_prefix}messages_topic ON {$db_prefix}messages (id_topic, id_msg);
+CREATE UNIQUE INDEX {$db_prefix}messages_id_board ON {$db_prefix}messages (id_board, id_msg);
+CREATE UNIQUE INDEX {$db_prefix}messages_id_member ON {$db_prefix}messages (id_member, id_msg);
+CREATE INDEX {$db_prefix}messages_approved ON {$db_prefix}messages (approved);
+CREATE INDEX {$db_prefix}messages_ip_index ON {$db_prefix}messages (poster_ip, id_topic);
+CREATE INDEX {$db_prefix}messages_participation ON {$db_prefix}messages (id_member, id_topic);
+CREATE INDEX {$db_prefix}messages_show_posts ON {$db_prefix}messages (id_member, id_board);
+CREATE INDEX {$db_prefix}messages_id_topic ON {$db_prefix}messages (id_topic);
+CREATE INDEX {$db_prefix}messages_id_member_msg ON {$db_prefix}messages (id_member, approved, id_msg);
+CREATE INDEX {$db_prefix}messages_current_topic ON {$db_prefix}messages (id_topic, id_msg, id_member, approved);
+CREATE INDEX {$db_prefix}messages_related_ip ON {$db_prefix}messages (id_member, poster_ip, id_msg);
+#
+# Dumping data for table `messages`
+#
+
+INSERT INTO {$db_prefix}messages
+	(id_msg, id_msg_modified, id_topic, id_board, poster_time, subject, poster_name, poster_email, poster_ip, modified_name, body, icon)
+VALUES (1, 1, 1, 1, {$current_time}, '{$default_topic_subject}', 'Simple Machines', '[email protected]', '127.0.0.1', '', '{$default_topic_message}', 'xx');
+# --------------------------------------------------------
+
+#
+# Table structure for table `moderators`
+#
+
+CREATE TABLE {$db_prefix}moderators (
+  id_board smallint NOT NULL default '0',
+  id_member int NOT NULL default '0',
+  PRIMARY KEY (id_board, id_member)
+);
+
+#
+# Table structure for table `openid_assoc`
+#
+
+CREATE TABLE {$db_prefix}openid_assoc (
+  server_url text NOT NULL,
+  handle varchar(255) NOT NULL,
+  secret text NOT NULL,
+  issued int NOT NULL default '0',
+  expires int NOT NULL default '0',
+  assoc_type varchar(64) NOT NULL,
+  PRIMARY KEY (server_url, handle)
+);
+
+#
+# Indexes for table `openid_assoc`
+#
+
+CREATE INDEX {$db_prefix}openid_assoc_expires ON {$db_prefix}openid_assoc (expires);
+
+#
+# Table structure for table `package_servers`
+#
+
+CREATE TABLE {$db_prefix}package_servers (
+  id_server integer primary key,
+  name varchar(255) NOT NULL,
+  url varchar(255) NOT NULL
+);
+
+#
+# Dumping data for table `package_servers`
+#
+
+INSERT INTO {$db_prefix}package_servers
+	(name, url)
+VALUES ('Simple Machines Third-party Mod Site', 'http://custom.simplemachines.org/packages/mods');
+# --------------------------------------------------------
+
+#
+# Table structure for table `permission_profiles`
+#
+
+CREATE TABLE {$db_prefix}permission_profiles (
+  id_profile integer primary key,
+  profile_name varchar(255) NOT NULL
+);
+
+#
+# Dumping data for table `permission_profiles`
+#
+
+BEGIN TRANSACTION;
+INSERT INTO {$db_prefix}permission_profiles (id_profile, profile_name) VALUES (1, 'default');
+INSERT INTO {$db_prefix}permission_profiles (id_profile, profile_name) VALUES (2, 'no_polls');
+INSERT INTO {$db_prefix}permission_profiles (id_profile, profile_name) VALUES (3, 'reply_only');
+INSERT INTO {$db_prefix}permission_profiles (id_profile, profile_name) VALUES (4, 'read_only');
+COMMIT;
+
+# --------------------------------------------------------
+
+#
+# Table structure for table `permissions`
+#
+
+CREATE TABLE {$db_prefix}permissions (
+  id_group smallint NOT NULL default '0',
+  permission varchar(30) NOT NULL default '',
+  add_deny smallint NOT NULL default '1',
+  PRIMARY KEY (id_group, permission)
+);
+
+#
+# Dumping data for table `permissions`
+#
+
+BEGIN TRANSACTION;
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (-1, 'search_posts');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (-1, 'calendar_view');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (-1, 'view_stats');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (-1, 'profile_view_any');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (0, 'view_mlist');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (0, 'search_posts');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (0, 'profile_view_own');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (0, 'profile_view_any');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (0, 'pm_read');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (0, 'pm_send');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (0, 'calendar_view');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (0, 'view_stats');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (0, 'who_view');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (0, 'profile_identity_own');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (0, 'profile_extra_own');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (0, 'profile_remove_own');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (0, 'profile_server_avatar');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (0, 'profile_upload_avatar');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (0, 'profile_remote_avatar');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (0, 'karma_edit');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'view_mlist');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'search_posts');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'profile_view_own');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'profile_view_any');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'pm_read');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'pm_send');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'calendar_view');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'view_stats');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'who_view');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'profile_identity_own');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'profile_extra_own');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'profile_remove_own');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'profile_server_avatar');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'profile_upload_avatar');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'profile_remote_avatar');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'profile_title_own');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'calendar_post');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'calendar_edit_any');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'karma_edit');
+INSERT INTO {$db_prefix}permissions (id_group, permission) VALUES (2, 'access_mod_center');
+COMMIT;
+
+# --------------------------------------------------------
+
+#
+# Table structure for table `personal_messages`
+#
+
+CREATE TABLE {$db_prefix}personal_messages (
+  id_pm integer primary key,
+  id_pm_head int NOT NULL default '0',
+  id_member_from int NOT NULL default '0',
+  deleted_by_sender smallint NOT NULL default '0',
+  from_name varchar(255) NOT NULL,
+  msgtime int NOT NULL default '0',
+  subject varchar(255) NOT NULL,
+  body text NOT NULL
+);
+
+#
+# Indexes for table `personal_messages`
+#
+
+CREATE INDEX {$db_prefix}personal_messages_id_member ON {$db_prefix}personal_messages (id_member_from, deleted_by_sender);
+CREATE INDEX {$db_prefix}personal_messages_msgtime ON {$db_prefix}personal_messages (msgtime);
+CREATE INDEX {$db_prefix}personal_messages_id_pm_head ON {$db_prefix}personal_messages (id_pm_head);
+
+#
+# Table structure for table `pm_recipients`
+#
+
+CREATE TABLE {$db_prefix}pm_recipients (
+  id_pm int NOT NULL default '0',
+  id_member int NOT NULL default '0',
+  labels varchar(60) NOT NULL default '-1',
+  bcc smallint NOT NULL default '0',
+  is_read smallint NOT NULL default '0',
+  is_new smallint NOT NULL default '0',
+  deleted smallint NOT NULL default '0',
+  PRIMARY KEY (id_pm, id_member)
+);
+
+#
+# Indexes for table `pm_recipients`
+#
+
+CREATE UNIQUE INDEX {$db_prefix}pm_recipients_id_member ON {$db_prefix}pm_recipients (id_member, deleted, id_pm);
+
+#
+# Table structure for table `pm_rules`
+#
+
+CREATE TABLE {$db_prefix}pm_rules (
+  id_rule integer primary key,
+  id_member integer NOT NULL default '0',
+  rule_name varchar(60) NOT NULL,
+  criteria text NOT NULL,
+  actions text NOT NULL,
+  delete_pm smallint NOT NULL default '0',
+  is_or smallint NOT NULL default '0'
+);
+
+#
+# Indexes for table `pm_rules`
+#
+
+CREATE INDEX {$db_prefix}pm_rules_id_member ON {$db_prefix}pm_rules (id_member);
+CREATE INDEX {$db_prefix}pm_rules_delete_pm ON {$db_prefix}pm_rules (delete_pm);
+
+#
+# Table structure for table `polls`
+#
+
+CREATE TABLE {$db_prefix}polls (
+  id_poll integer primary key,
+  question varchar(255) NOT NULL,
+  voting_locked smallint NOT NULL default '0',
+  max_votes smallint NOT NULL default '1',
+  expire_time int NOT NULL default '0',
+  hide_results smallint NOT NULL default '0',
+  change_vote smallint NOT NULL default '0',
+  guest_vote smallint NOT NULL default '0',
+  num_guest_voters int NOT NULL default '0',
+  reset_poll int NOT NULL default '0',
+  id_member int NOT NULL default '0',
+  poster_name varchar(255) NOT NULL
+);
+
+#
+# Table structure for table `poll_choices`
+#
+
+CREATE TABLE {$db_prefix}poll_choices (
+  id_poll int NOT NULL default '0',
+  id_choice smallint NOT NULL default '0',
+  label varchar(255) NOT NULL,
+  votes smallint NOT NULL default '0',
+  PRIMARY KEY (id_poll, id_choice)
+);
+
+#
+# Table structure for table `scheduled_tasks`
+#
+
+CREATE TABLE {$db_prefix}scheduled_tasks (
+  id_task integer primary key,
+  next_time int NOT NULL default '0',
+  time_offset int NOT NULL default '0',
+  time_regularity smallint NOT NULL default '0',
+  time_unit varchar(1) NOT NULL default 'h',
+  disabled smallint NOT NULL default '0',
+  task varchar(24) NOT NULL default ''
+);
+
+#
+# Indexes for table `scheduled_tasks`
+#
+
+CREATE INDEX {$db_prefix}scheduled_tasks_next_time ON {$db_prefix}scheduled_tasks (next_time);
+CREATE INDEX {$db_prefix}scheduled_tasks_disabled ON {$db_prefix}scheduled_tasks (disabled);
+CREATE UNIQUE INDEX {$db_prefix}scheduled_tasks_task ON {$db_prefix}scheduled_tasks (task);
+
+#
+# Dumping data for table `scheduled_tasks`
+#
+
+BEGIN TRANSACTION;
+INSERT INTO {$db_prefix}scheduled_tasks	(id_task, next_time, time_offset, time_regularity, time_unit, disabled, task) VALUES (1, 0, 0, 2, 'h', 0, 'approval_notification');
+INSERT INTO {$db_prefix}scheduled_tasks	(id_task, next_time, time_offset, time_regularity, time_unit, disabled, task) VALUES (2, 0, 0, 7, 'd', 0, 'auto_optimize');
+INSERT INTO {$db_prefix}scheduled_tasks	(id_task, next_time, time_offset, time_regularity, time_unit, disabled, task) VALUES (3, 0, 60, 1, 'd', 0, 'daily_maintenance');
+INSERT INTO {$db_prefix}scheduled_tasks	(id_task, next_time, time_offset, time_regularity, time_unit, disabled, task) VALUES (5, 0, 0, 1, 'd', 0, 'daily_digest');
+INSERT INTO {$db_prefix}scheduled_tasks	(id_task, next_time, time_offset, time_regularity, time_unit, disabled, task) VALUES (6, 0, 0, 1, 'w', 0, 'weekly_digest');
+INSERT INTO {$db_prefix}scheduled_tasks	(id_task, next_time, time_offset, time_regularity, time_unit, disabled, task) VALUES (7, 0, {$sched_task_offset}, 1, 'd', 0, 'fetchSMfiles');
+INSERT INTO {$db_prefix}scheduled_tasks	(id_task, next_time, time_offset, time_regularity, time_unit, disabled, task) VALUES (8, 0, 0, 1, 'd', 1, 'birthdayemails');
+INSERT INTO {$db_prefix}scheduled_tasks	(id_task, next_time, time_offset, time_regularity, time_unit, disabled, task) VALUES (9, 0, 0, 1, 'w', 0, 'weekly_maintenance');
+INSERT INTO {$db_prefix}scheduled_tasks	(id_task, next_time, time_offset, time_regularity, time_unit, disabled, task) VALUES (10, 0, 120, 1, 'd', 1, 'paid_subscriptions');
+COMMIT;
+
+# --------------------------------------------------------
+
+#
+# Table structure for table `settings`
+#
+
+CREATE TABLE {$db_prefix}settings (
+  variable varchar(255) NOT NULL,
+  value text NOT NULL,
+  PRIMARY KEY (variable)
+);
+
+#
+# Dumping data for table `settings`
+#
+
+BEGIN TRANSACTION;
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('smfVersion', '{$smf_version}');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('news', '{$default_news}');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('compactTopicPagesContiguous', '5');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('compactTopicPagesEnable', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enableStickyTopics', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('todayMod', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('karmaMode', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('karmaTimeRestrictAdmins', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enablePreviousNext', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('pollMode', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enableVBStyleLogin', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enableCompressedOutput', '{$enableCompressedOutput}');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('karmaWaitTime', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('karmaMinPosts', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('karmaLabel', '{$default_karmaLabel}');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('karmaSmiteLabel', '{$default_karmaSmiteLabel}');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('karmaApplaudLabel', '{$default_karmaApplaudLabel}');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachmentSizeLimit', '128');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachmentPostLimit', '192');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachmentNumPerPostLimit', '4');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachmentDirSizeLimit', '10240');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachmentUploadDir', '{$boarddir}/attachments');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachmentExtensions', 'doc,gif,jpg,mpg,pdf,png,txt,zip');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachmentCheckExtensions', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachmentShowImages', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachmentEnable', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachmentEncryptFilenames', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachmentThumbnails', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachmentThumbWidth', '150');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachmentThumbHeight', '150');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('censorIgnoreCase', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('mostOnline', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('mostOnlineToday', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('mostDate', {$current_time});
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('allow_disableAnnounce', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('trackStats', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('userLanguage', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('titlesEnable', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('topicSummaryPosts', '15');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enableErrorLogging', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('max_image_width', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('max_image_height', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('onlineEnable', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('cal_enabled', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('cal_maxyear', '2020');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('cal_minyear', '2008');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('cal_daysaslink', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('cal_defaultboard', '');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('cal_showholidays', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('cal_showbdays', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('cal_showevents', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('cal_showweeknum', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('cal_maxspan', '7');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('smtp_host', '');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('smtp_port', '25');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('smtp_username', '');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('smtp_password', '');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('mail_type', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('timeLoadPageEnable', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('totalMembers', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('totalTopics', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('totalMessages', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('simpleSearch', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('censor_vulgar', '');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('censor_proper', '');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enablePostHTML', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('theme_allow', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('theme_default', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('theme_guests', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enableEmbeddedFlash', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('xmlnews_enable', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('xmlnews_maxlen', '255');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('hotTopicPosts', '15');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('hotTopicVeryPosts', '25');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('registration_method', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('send_validation_onChange', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('send_welcomeEmail', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('allow_editDisplayName', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('allow_hideOnline', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('guest_hideContacts', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('spamWaitTime', '5');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('pm_spam_settings', '10,5,20');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('reserveWord', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('reserveCase', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('reserveUser', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('reserveName', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('reserveNames', '{$default_reserved_names}');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('autoLinkUrls', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('banLastUpdated', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('smileys_dir', '{$boarddir}/Smileys');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('smileys_url', '{$boardurl}/Smileys');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_directory', '{$boarddir}/avatars');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_url', '{$boardurl}/avatars');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_max_height_external', '65');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_max_width_external', '65');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_action_too_large', 'option_html_resize');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_max_height_upload', '65');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_max_width_upload', '65');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_resize_upload', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_download_png', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('failed_login_threshold', '3');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('oldTopicDays', '120');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('edit_wait_time', '90');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('edit_disable_time', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('autoFixDatabase', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('allow_guestAccess', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('time_format', '{$default_time_format}');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('number_format', '1234.00');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enableBBC', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('max_messageLength', '20000');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('signature_settings', '1,300,0,0,0,0,0,0:');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('autoOptMaxOnline', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('defaultMaxMessages', '15');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('defaultMaxTopics', '20');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('defaultMaxMembers', '30');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enableParticipation', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('recycle_enable', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('recycle_board', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('maxMsgID', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enableAllMessages', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('fixLongWords', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('knownThemes', '1,2,3');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('who_enabled', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('time_offset', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('cookieTime', '60');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('lastActive', '15');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('smiley_sets_known', 'default,aaron,akyhne');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('smiley_sets_names', '{$default_smileyset_name}
+{$default_aaron_smileyset_name}
+{$default_akyhne_smileyset_name}');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('smiley_sets_default', 'default');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('cal_days_for_index', '7');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('requireAgreement', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('unapprovedMembers', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('default_personal_text', '');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('package_make_backups', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('databaseSession_enable', '{$databaseSession_enable}');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('databaseSession_loose', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('databaseSession_lifetime', '2880');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('search_cache_size', '50');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('search_results_per_page', '30');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('search_weight_frequency', '30');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('search_weight_age', '25');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('search_weight_length', '20');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('search_weight_subject', '15');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('search_weight_first_message', '10');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('search_max_results', '1200');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('search_floodcontrol_time', '5');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('permission_enable_deny', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('permission_enable_postgroups', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('mail_next_send', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('mail_recent', '0000000000|0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('settings_updated', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('next_task_time', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('warning_settings', '1,20,0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('warning_watch', '10');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('warning_moderate', '35');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('warning_mute', '60');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('admin_features', '');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('last_mod_report_action', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('pruningOptions', '30,180,180,180,30,0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('cache_enable', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('reg_verification', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('visual_verification_type', '3');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enable_buddylist', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('birthday_email', 'happy_birthday');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('dont_repeat_theme_core', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('dont_repeat_smileys_20', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('dont_repeat_buddylists', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachment_image_reencode', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachment_image_paranoid', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachment_thumb_png', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_reencode', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_paranoid', '0');
+COMMIT;
+
+# --------------------------------------------------------
+
+#
+# Table structure for table `sessions`
+#
+
+CREATE TABLE {$db_prefix}sessions (
+  session_id char(32) NOT NULL,
+  last_update int NOT NULL,
+  data text NOT NULL,
+  PRIMARY KEY (session_id)
+);
+
+#
+# Table structure for table `smileys`
+#
+
+CREATE TABLE {$db_prefix}smileys (
+  id_smiley integer primary key,
+  code varchar(30) NOT NULL default '',
+  filename varchar(48) NOT NULL default '',
+  description varchar(80) NOT NULL default '',
+  smiley_row smallint NOT NULL default '0',
+  smiley_order smallint NOT NULL default '0',
+  hidden smallint NOT NULL default '0'
+);
+
+#
+# Dumping data for table `smileys`
+#
+
+BEGIN TRANSACTION;
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES (':)', 'smiley.gif', '{$default_smiley_smiley}', 0, 0);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES (';)', 'wink.gif', '{$default_wink_smiley}', 1, 0);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES (':D', 'cheesy.gif', '{$default_cheesy_smiley}', 2, 0);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES (';D', 'grin.gif', '{$default_grin_smiley}', 3, 0);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES ('>:(', 'angry.gif', '{$default_angry_smiley}', 4, 0);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES (':(', 'sad.gif', '{$default_sad_smiley}', 5, 0);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES (':o', 'shocked.gif', '{$default_shocked_smiley}', 6, 0);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES ('8)', 'cool.gif', '{$default_cool_smiley}', 7, 0);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES ('???', 'huh.gif', '{$default_huh_smiley}', 8, 0);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES ('::)', 'rolleyes.gif', '{$default_roll_eyes_smiley}', 9, 0);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES (':P', 'tongue.gif', '{$default_tongue_smiley}', 10, 0);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES (':-[', 'embarrassed.gif', '{$default_embarrassed_smiley}', 11, 0);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES (':-X', 'lipsrsealed.gif', '{$default_lips_sealed_smiley}', 12, 0);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES (':-\', 'undecided.gif', '{$default_undecided_smiley}', 13, 0);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES (':-*', 'kiss.gif', '{$default_kiss_smiley}', 14, 0);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES (':''(', 'cry.gif', '{$default_cry_smiley}', 15, 0);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES ('>:D', 'evil.gif', '{$default_evil_smiley}', 16, 1);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES ('^-^', 'azn.gif', '{$default_azn_smiley}', 17, 1);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES ('O0', 'afro.gif', '{$default_afro_smiley}', 18, 1);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES (':))', 'laugh.gif', '{$default_laugh_smiley}', 19, 1);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES ('C:-)', 'police.gif', '{$default_police_smiley}', 20, 1);
+INSERT INTO {$db_prefix}smileys	(code, filename, description, smiley_order, hidden) VALUES ('O:-)', 'angel.gif', '{$default_angel_smiley}', 21, 1);
+COMMIT;
+
+# --------------------------------------------------------
+
+#
+# Table structure for table `spiders`
+#
+
+CREATE TABLE {$db_prefix}spiders (
+  id_spider integer primary key,
+  spider_name varchar(255) NOT NULL,
+  user_agent varchar(255) NOT NULL,
+  ip_info varchar(255) NOT NULL
+);
+
+#
+# Dumping data for table `spiders`
+#
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (1, 'Google', 'googlebot', '');
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (2, 'Yahoo!', 'slurp', '');
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (3, 'MSN', 'msnbot', '');
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (4, 'Google (Mobile)', 'Googlebot-Mobile', '');
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (5, 'Google (Image)', 'Googlebot-Image', '');
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (6, 'Google (AdSense)', 'Mediapartners-Google', '');
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (7, 'Google (Adwords)', 'AdsBot-Google', '');
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (8, 'Yahoo! (Mobile)', 'YahooSeeker/M1A1-R2D2', '');
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (9, 'Yahoo! (Image)', 'Yahoo-MMCrawler', '');
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (10, 'MSN (Mobile)', 'MSNBOT_Mobile', '');
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (11, 'MSN (Media)', 'msnbot-media', '');
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (12, 'Cuil', 'twiceler', '');
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (13, 'Ask', 'Teoma', '');
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (14, 'Baidu', 'Baiduspider', '');
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (15, 'Gigablast', 'Gigabot', '');
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (16, 'InternetArchive', 'ia_archiver-web.archive.org', '');
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (17, 'Alexa', 'ia_archiver', '');
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (18, 'Omgili', 'omgilibot', '');
+INSERT INTO {$db_prefix}spiders (id_spider, spider_name, user_agent, ip_info) VALUES (19, 'EntireWeb', 'Speedy Spider', '');
+
+#
+# Table structure for table `subscriptions`
+#
+
+CREATE TABLE {$db_prefix}subscriptions(
+  id_subscribe integer primary key,
+  name varchar(60) NOT NULL,
+  description varchar(255) NOT NULL,
+  cost text NOT NULL,
+  length varchar(6) NOT NULL,
+  id_group int NOT NULL default '0',
+  add_groups varchar(40) NOT NULL,
+  active smallint NOT NULL default '1',
+  repeatable smallint NOT NULL default '0',
+  allow_partial smallint NOT NULL default '0',
+  reminder smallint NOT NULL default '0',
+  email_complete text NOT NULL
+);
+
+#
+# Indexes for table `subscriptions`
+#
+
+CREATE INDEX {$db_prefix}subscriptions_active ON {$db_prefix}subscriptions (active);
+
+#
+# Table structure for table `themes`
+#
+
+CREATE TABLE {$db_prefix}themes (
+  id_member int NOT NULL default '0',
+  id_theme smallint NOT NULL default '1',
+  variable varchar(255) NOT NULL,
+  value text NOT NULL,
+  PRIMARY KEY (id_theme, id_member, variable)
+);
+
+#
+# Indexes for table `themes`
+#
+
+CREATE INDEX {$db_prefix}themes_id_member ON {$db_prefix}themes (id_member);
+
+#
+# Dumping data for table `themes`
+#
+
+BEGIN TRANSACTION;
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'name', '{$default_theme_name}');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'theme_url', '{$boardurl}/Themes/default');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'images_url', '{$boardurl}/Themes/default/images');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'theme_dir', '{$boarddir}/Themes/default');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'show_bbc', '1');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'show_latest_member', '1');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'show_modify', '1');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'show_user_images', '1');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'show_blurb', '1');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'show_gender', '0');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'show_newsfader', '0');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'number_recent_posts', '0');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'show_member_bar', '1');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'linktree_link', '1');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'show_profile_buttons', '1');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'show_mark_read', '1');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'show_stats_index', '1');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'linktree_inline', '0');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'show_board_desc', '1');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'newsfader_time', '5000');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'allow_no_censored', '0');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'additional_options_collapsable', '1');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'use_image_buttons', '1');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'enable_news', '1');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (1, 'forum_width', '90%');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (2, 'name', '{$default_core_theme_name}');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (2, 'theme_url', '{$boardurl}/Themes/core');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (2, 'images_url', '{$boardurl}/Themes/core/images');
+INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES (2, 'theme_dir', '{$boarddir}/Themes/core');
+INSERT INTO {$db_prefix}themes (id_member, id_theme, variable, value) VALUES (-1, 1, 'display_quick_reply', '1');
+INSERT INTO {$db_prefix}themes (id_member, id_theme, variable, value) VALUES (-1, 1, 'posts_apply_ignore_list', '1');
+COMMIT;
+
+# --------------------------------------------------------
+
+#
+# Table structure for table `topics`
+#
+
+CREATE TABLE {$db_prefix}topics (
+  id_topic integer primary key,
+  is_sticky smallint NOT NULL default '0',
+  id_board smallint NOT NULL default '0',
+  id_first_msg int NOT NULL default '0',
+  id_last_msg int NOT NULL default '0',
+  id_member_started int NOT NULL default '0',
+  id_member_updated int NOT NULL default '0',
+  id_poll int NOT NULL default '0',
+  id_previous_board smallint NOT NULL default '0',
+  id_previous_topic int NOT NULL default '0',
+  num_replies int NOT NULL default '0',
+  num_views int NOT NULL default '0',
+  locked smallint NOT NULL default '0',
+  unapproved_posts smallint NOT NULL default '0',
+  approved smallint NOT NULL default '1'
+);
+
+#
+# Indexes for table `topics`
+#
+
+CREATE UNIQUE INDEX {$db_prefix}topics_last_message ON {$db_prefix}topics (id_last_msg, id_board);
+CREATE UNIQUE INDEX {$db_prefix}topics_first_message ON {$db_prefix}topics (id_first_msg, id_board);
+CREATE UNIQUE INDEX {$db_prefix}topics_poll ON {$db_prefix}topics (id_poll, id_topic);
+CREATE INDEX {$db_prefix}topics_is_sticky ON {$db_prefix}topics (is_sticky);
+CREATE INDEX {$db_prefix}topics_approved ON {$db_prefix}topics (approved);
+CREATE INDEX {$db_prefix}topics_id_board ON {$db_prefix}topics (id_board);
+CREATE INDEX {$db_prefix}topics_member_started ON {$db_prefix}topics (id_member_started, id_board);
+CREATE INDEX {$db_prefix}topics_last_message_sticky ON {$db_prefix}topics (id_board, is_sticky, id_last_msg);
+CREATE INDEX {$db_prefix}topics_board_news ON {$db_prefix}topics (id_board, id_first_msg);
+
+#
+# Dumping data for table `topics`
+#
+
+INSERT INTO {$db_prefix}topics
+	(id_topic, id_board, id_first_msg, id_last_msg, id_member_started, id_member_updated)
+VALUES (1, 1, 1, 1, 0, 0);
+# --------------------------------------------------------

+ 308 - 0
other/readme_install.html

@@ -0,0 +1,308 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+	<head>
+		<title>SMF 2.0 Installation Guide</title>
+		<link rel="stylesheet" type="text/css" href="Themes/default/css/index.css?fin20" />
+		<style type="text/css">
+			h1.forumtitle
+			{
+				color: #346;
+			}
+			#upper_section .user
+			{
+				height: 4em;
+			}
+			#upper_section .news
+			{
+				height: 80px;
+			}
+			#main_screen
+			{
+				padding: 0 40px;
+			}
+			#main_screen h2
+			{
+				font-size: 2em;
+				border-bottom: solid 1px #d05800;
+				line-height: 2em;
+				margin: 0 0 0.5em 0;
+				color: #d05800;
+			}
+			h3
+			{
+				color: #d05800;
+			}
+			#content_section
+			{
+				position: relative;
+				top: -20px;
+			}
+			#main_content_section .panel
+			{
+				padding: 1em 2em 1em 1em;
+				line-height: 1.6em;
+			}
+			#main_content_section h2
+			{
+				font-size: 1.5em;
+				border-bottom: solid 1px #d05800;
+				line-height: 1.5em;
+				margin: 0 2em 0.5em 0;
+				color: #d05800;
+			}
+			#main_content_section li
+			{
+				line-height: 1.6em;
+				font-weight: bold;
+				color: #555;
+			}
+			#main_content_section li ul
+			{
+				padding-bottom: 0.7em;
+			}
+			#main_content_section li li
+			{
+				font-weight: normal;
+				line-height: 1.6em;
+			}
+			#liftup
+			{
+				position: relative;
+				top: -70px;
+			}
+			#footer_section
+			{
+				position: relative;
+				top: -60px;
+			}
+			tt
+			{
+				font-family: verdana, sans-serif;
+				letter-spacing: 1px;
+				font-weight: bold;
+				font-size: 90%;
+				font-style: italic;
+			}
+			dt
+			{
+				font-weight: bold;
+				color: #555;
+				margin-bottom: .1em;
+			}
+			dl
+			{
+				margin-top: .2em;
+				margin-left: 2em;
+				margin-bottom: .5em;
+			}
+			dd
+			{
+				line-height: 1.5em;
+				margin-left: 2em;
+				margin-bottom: .1em;
+			}
+			#header, #content_section, #footer_section
+			{
+				width: 90%;
+				margin: 0 auto;
+			}
+			a:link, a:visited
+			{
+				color: #3E5D8F;
+			}
+			a:hover
+			{
+				color: #346;
+			}
+		</style>
+	</head>
+	<body>
+		<div id="header"><div class="frame">
+			<div id="top_section">
+				<h1 class="forumtitle">SMF 2.0 Installation Guide</h1>
+				<img id="smflogo" src="Themes/default/images/smflogo.png" alt="Simple Machines Forum" title="Simple Machines Forum" />
+			</div>
+			<div id="upper_section" class="middletext" style="overflow: hidden;">
+				<div class="user"></div>
+				<div class="news normaltext">
+				</div>
+			</div>
+		</div></div>
+		<div id="content_section"><div class="frame">
+			<div id="main_content_section">
+				<div id="liftup">
+					<div class="panel">
+						<h2 id="contents">Installing your forum</h2>
+						<p>Thank you for deciding to use, or at least try, <a href="http://www.simplemachines.org/smf/">SMF</a>.  Before you get started, please remember that there is <a href="http://www.simplemachines.org/community/index.php">a place for help at www.simplemachines.org</a> if you run into any problems at all.</p>
+						<p>If you are looking to upgrade an installation of SMF, or convert from YaBB SE, you may have downloaded the wrong package.  Please check <a href="http://download.simplemachines.org/">the downloads page</a> for more information.</p>
+						<p>You can find the following information in this file:</p>
+						<ul style="list-style-type: none;">
+							<li>&raquo; <a href="#requirements">Minimum installation requirements</a></li>
+							<li>&raquo; <a href="#recommendations">Recommendations for best performance</a></li>
+							<li>&raquo; <a href="#uploadingftp">Upload files method 1: manually uploading files</a></li>
+							<li>&raquo; <a href="#Set_File_Permissions">Set file permissions</a></li>
+							<li>&raquo; <a href="#Create_a_Database_and_a_Database_User">Create a database and a database user</a></li>
+							<li>&raquo; <a href="#Run_the_installer">Run the installer</a></li>
+							<li>&raquo; <a href="#webinstall">Upload files method 2: using webinstall.php</a></li>
+							<li>&raquo; <a href="#finishing">Finishing the installation and cleaning up.</a></li>
+						</ul>
+					</div>
+					<div class="panel">
+						<h2 id="requirements">Minimum installation requirements</h2>
+						<p>Your server must meet a few requirements to be able to run SMF.  If you are unsure as to whether your webserver meets these, please try to upgrade anyway - it should detect any problems.</p>
+						<ul>
+							<li>Any webserver that properly supports PHP, such as <a href="http://httpd.apache.org/" target="_blank">Apache</a> or <a href="http://www.microsoft.com/iis" target="_blank">Internet Information Services (IIS)</a>.</li>
+							<li>
+								<a href="http://www.php.net" target="_blank">PHP</a> 4.1.0 or higher.  The following directives are required to be set correctly in php.ini:
+								<ul>
+									<li>the engine directive must be On.</li>
+									<li>the <a href="http://www.php.net/sybase#ini.magic-quotes-sybase" target="_blank">magic_quotes_sybase</a> directive must be set to Off.</li>
+									<li>the <a href="http://www.php.net/session#ini.session.save-path" target="_blank">session.save_path</a> directive must be set to a valid directory.</li>
+									<li>the <a href="http://www.php.net/manual/en/ini.core.php#ini.file-uploads" target="_blank">file_uploads</a> directive must be On.</li>
+									<li>the <a href="http://www.php.net/manual/en/ini.core.php#ini.upload-tmp-dir" target="_blank">upload_tmp_dir</a> must be set to a valid directory.</li>
+								</ul>
+							</li>
+							<li>Any of the following database systems
+								<ul>
+									<li><a href="http://www.mysql.com/" target="_blank">MySQL</a> 4.0.18 or higher.</li>
+									<li><a href="http://www.postgresql.org/" target="_blank">PostgreSQL</a> 8.0 or higher.</li>
+									<li><a href="http://www.sqlite.org/" target="_blank">SQLite</a> 1.x - 2.x.</li>
+								</ul>
+							</li>
+							<li>at least 2 megabytes of storage space in the database, although more is highly recommended.</li>
+							<li>The database user must have at least the following privileges: SELECT, INSERT, UPDATE, DELETE, ALTER, and INDEX.</li>
+							<li>about 20 megabytes of storage space on the web server, although more is recommended.</li>
+						</ul><br />
+						<h2 id="recommendations">Recommendations for best performance</h2>
+						<ul>
+							<li>Windows, <a href="http://www.linux.org/" target="_blank">Linux</a> or another Unix based operating system.</li>
+							<li>the <a href="http://aspell.sf.net/" target="_blank">GNU Aspell</a> 0.50 or higher and <a href="http://ftp.gnu.org/gnu/aspell/dict/" target="_blank">its dictionaries</a> for spell checking functionality.</li>
+							<li><a href="http://httpd.apache.org/" target="_blank">Apache</a> 2.0.0 or higher with <a href="http://httpd.apache.org/docs-2.0/mod/core.html#acceptpathinfo" target="_blank">AcceptPathInfo</a> set to On (Apache 2 and later only) for queryless URL support.</li>
+							<li>
+								<a href="http://www.php.net" target="_blank">PHP</a> 5.2.0 or higher, with the following set in php.ini:
+								<ul>
+									<li>the <a href="http://www.php.net/manual/en/info.configuration.php#ini.max-input-time" target="_blank">max_input_time</a> directive is set to a value of at least 30.</li>
+									<li>the <a href="http://www.php.net/manual/en/ini.core.php#ini.post-max-size" target="_blank">post_max_size</a> and <a href="http://www.php.net/configuration.directives#ini.upload-max-filesize" target="_blank">upload_max_filesize</a> directives set to the size of the largest attachments you wish to be able to upload.</li>
+									<li>the <a href="http://www.php.net/session#ini.session.use-trans-sid" target="_blank">session.use_trans_sid</a> directive set to Off.</li>
+									<li>the <a href="http://www.php.net/manual/en/ini.core.php#ini.memory-limit" target="_blank">memory_limit</a> directive is set to at least 8M.</li>
+									<li>the <a href="http://www.php.net/manual/en/info.configuration.php#ini.max-execution-time" target="_blank">max_execution_time</a> directive is set to at least 15.</li>
+									<li>the <a href="http://www.php.net/manual/en/ini.core.php#ini.register-globals" target="_blank">register_globals</a> directive is set to Off.</li>
+									<li>the <a href="http://www.php.net/manual/en/features.safe-mode.php" target="_blank">safe mode</a> disabled or <a href="http://httpd.apache.org/docs/2.0/suexec.html" target="_blank">suEXEC</a> ensabled.</li>
+									<li>the <a href="http://www.php.net/manual/en/book.bc.php" target="_blank">BCMath</a> library enabled for using the <a href="/smf/Registration#Settings" title="Registration">OpenID</a> registration method.</li>
+								</ul>
+							</li>
+							<li>Any of the following database systems
+								<ul>
+									<li><a href="http://www.mysql.com/" target="_blank">MySQL</a> 5.0 or higher.</li>
+									<li><a href="http://www.postgresql.org/" target="_blank">PostgreSQL</a> 8.3.3 or higher.</li>
+									<li><a href="http://www.sqlite.org/" target="_blank">SQLite</a> 2.8.</li>
+								</ul>
+							</li>
+							<li><a href="http://www.boutell.com/gd/" target="_blank">GD Graphics Library</a> 2.0 or higher.</li>
+						</ul>
+						<p>If your server does not meet these requirements, SMF may not work properly.</p>
+					</div>
+					<div class="panel">
+						<h2 id="uploadingftp">Upload files method 1: manually uploading files</h2>
+						<p>The first thing you need to do is upload all of the files in this package, excluding this file itself, to your server.  You can upload it to any directory accessible by URL, but if you're not sure where to put it, a directory named &quot;forum&quot; is a good choice.  You may wish to make sure that all of the folders were uploaded, such as <tt>Themes/default/languages</tt>, because some FTP clients have been known to drop files.</p>
+						<p>If you want or need to install any languages other than English, download the corresponding versions from the download page, and upload them to the same directory you uploaded SMF to.  This should put additional files in <tt>Themes/default/languages</tt> and, in most cases, <tt>Themes/default/images</tt>.</p>
+						<h3>Language files</h3>
+						<p>If you are using additional languages it will be useful to upload also the updated versions of the language files along with the upgrading packages. Doing so all updated text strings will appear correctly after the upgrade, and will allow the upgrade to run in your selected language.</p>
+					</div>
+					<div class="panel">
+						<h2 id="Set_File_Permissions">Set file permissions</h2>
+						<p>After the install archive has been uploaded and extracted, you need to set the files' permissions. This is commonly done by use of the Unix utility <b>CHMOD</b>. The correct CHMOD value for SMF files is either 777, 775 or 755, depending on your hosting service. There are two methods for this step, the method used depends on the hosting service that you use.</p>
+						<h3>Setting File Permissions With the Installer</h3>
+						<p>The SMF installer can set file permissions simply and easily. Navigating to the directory where SMF is located should redirect you to the install.php file and prompt the installer. For example: www.yourdomain.com/forum/install.php. If the installer detects files that need their permissions adjusted it will prompt for FTP details so it can <b>CHMOD</b> the files it requires for the install. This may not work on some servers.
+						</p>
+						<h3>Setting File Permissions With FTP</h3>
+						<p>Using a control panel or FTP client, file permissions can be changed quickly and easily. Usually, FTP programs will allow permissions to be changed by right-clicking files/directories and selecting &quot;Properties&quot;, &quot;Attributes&quot; or &quot;Permissions&quot;. The desired numerical value can be entered, or if provided, check boxes can be changed.</p>
+						<p>The following files and directories must be writable. Depending on how your server is set up, this could mean that they must have <b>CHMOD</b> values of 644, 664 or 666 for files, and 755, 775 or 777 for folders:</p>
+						<ul><li>/attachments
+						</li><li>/avatars
+						</li><li>/Packages
+						</li><li>/Packages/installed.list
+						</li><li>/Smileys
+						</li><li>/Themes
+						</li><li>/Themes/default/languages/Install.english.php
+						</li><li>agreement.txt
+						</li><li>Settings.php
+						</li><li>Settings_bak.php
+						</li><li>install.php
+						</li></ul>
+						<p>If the permission on your files or folders does not make them writable, the SMF installer will report the problem. In that case, use your FTP client or host panel to reset the permissions for the files or folders the installer reports.</p>
+					</div>
+					<div class="panel">
+						<h2 id="Create_a_Database_and_a_Database_User">Create a database and a database user</h2>
+						<p>Before running the installer, a database and a database user will need to be created. A database will store all of the information a forum requires, such as members, posts, and topics. A database user will allow the forum to access the stored information. Remember this information about the database and database user. You will need it when it comes time to run the installer.</p>
+						<h3>Creating a database using PHPMyAdmin</h3>
+						<p>Most shared hosting services disable this option. If the option to create databases through PHPMyAdmin is available through the hosting service you use, the database can be created from the PHPMyAdmin home page.</p>
+						<h3>Creating a database using a control panel</h3>
+						<p>Shared hosting services usually disable the ability to create a database through PHPMyAdmin. If the hosting service provides a control panel interface, then this can be used to create a database. Selecting the &quot;MySQL Databases&quot; or &quot;Database Wizard&quot; options should take you to a page prompting you to creating a MySQL database. With different hosts, these options may have different names.</p><p>SMF 2.0 has the ability to support other database types, including PostgreSQL and SQLite. SMF 1.1 supports only MySQL database types.</p>
+						<h3>Creating a database user</h3>
+						<p>A database user can be created through the control panel provided by your hosting service. Selecting the &quot;MySQL Databases&quot; or &quot;Database Wizard&quot; options should take you to a page, prompting you to create a MySQL database user. With different hosts, these options may have different names.</p>
+						<p>The database user requires the following permissions: SELECT, INSERT, UPDATE, DELETE, ALTER, and INDEX. Additional permissions may be granted, if desired.</p>
+					</div>
+					<div class="panel">
+						<h2 id="Run_the_installer">Run the installer</h2>
+						<p>The final step in installing SMF is running the installer. The information from the previous steps will be used in the installation process.</p>
+						<p>The first page you see may request your FTP information.  If you see this screen, it is because the installer found some files or folders with inadequate permissions for SMF to run properly.  If you enter your FTP information here, the installer can automatically fix these permissions for you.  Please note that the path should be the same path you see in your FTP client.  For example, it might be &quot;public_html/forum&quot;.  And remember, the installer will not save your FTP password anywhere.</p>
+						<p>The SMF install screen looks different for SMF 2.0 and SMF 1.1, however, both still require the same information. Navigating to the directory where SMF is located, should redirect you to the install.php file, and prompt the installer to run. For example: www.yourdomain.com/forum/install.php</p>
+						<h3>Basic forum settings</h3>
+						<dl>
+							<dt>Forum Name</dt>
+							<dd>The name for the forum being installed should go here. By default this is set to &quot;My Community&quot;. This can be changed later via the server settings section of the administration center if needed.</dd>
+							<dt>Forum URL</dt>
+							<dd>The URL the forum can be found at, without the trailing slash. The SMF installer will most likely have this correct, so it is safe to leave this field alone.</dd>
+							<dt>Gzip Output</dt>
+							<dd>If Gzip output tests pass, this can be used to save bandwidth and make pages load faster.</dd>
+							<dt>Database Sessions</dt>
+							<dd>Sessions can be stored in the database, or in files. Database sessions are more reliable, secure, and may work better on sites with multiple servers.</dd>
+							<dt>UTF-8 Character Set</dt>
+							<dd>UTF-8 character sets are useful for international forums, or forums that use languages other than English.</dd>
+							<dt>Allow Stat Collection</dt>
+							<dd>This option allows Simple Machines to collect statistics from your forum, anonymously, so the software can grow to meet the needs of its user base.</dd>
+						</dl>
+						<h3>Database server settings</h3>
+						<dl>
+							<dt>Database type</dt>
+							<dd>The database schema can be selected here from a list of database schemas supported by the server being used. Newer schemas (for SMF 2.0) such as PostgreSQL and SQLite may be listed here if available. MySQL and PostgreSQL are recommended.</dd>
+							<dt>Server name</dt>
+							<dd>The location of the database is specified here. 99% of the time this will be localhost.</dd>
+							<dt>Username</dt>
+							<dd>The username used for the database user should be placed here. If help is required for this, the hosting service provider should be contacted.</dd>
+							<dt>Password</dt>
+							<dd>The password for the database user is entered here.</dd>
+							<dt>Database name</dt>
+							<dd>The name used for the database should be placed here. If help is required for this, the hosting service provider should be contacted.</dd>
+							<dt>Database prefix</dt>
+							<dd>The prefix for all tables associated with this install is specified here. Prefixing tables with unique prefixes enables more than one application, or SMF install, to use the same database safely.</dd>
+						</dl>
+						<h3>Creating an administrator account</h3>
+						<p>The SMF installer will ask for information to create the forum's administrator account. This information includes username, password, and e-mail address, just like a regular account. Once created, this account can be used to visit the Administration Center to manage and configure the forum.</p>
+					</div>
+					<div class="panel">
+						<h2 id="webinstall">Upload files method 2: using webinstall.php</h2>
+						<p>Your server may support webinstall.php. This script will automatically download SMF to your server. This may not work on all servers and also may require providing it with FTP details.</p>
+						<p>The first thing you need to do is upload webinstall.php to the location of where SMF is to exist on your server.</p>
+						<p>After you have finished uploading the file, point your browser to http://www.yourdomain.tld/forum/webinstall.php - where www.yourdomain.tld/forum is the URL to where you uploaded it.  You should then see the webinstall interface.</p>
+						<p>The first page you see may request your FTP information.  If you see this screen, it is because the webinstaller found some files or folders with inadequate permissions for SMF to run properly.  If you enter your FTP information here, the webinstaller can automatically fix these permissions for you.  Please note that the path should be the same path you see in your FTP client.  For example, it might be &quot;public_html/forum&quot;.  And remember, the webinstaller will not save your FTP password anywhere.</p>
+						<p>On the webinstall interface you have an option to login, this is useful for charter members to easily download early releases. You may have an option to select multiple versions of SMF to download. It is up to you to decide which version of SMF you wish to install. Additionally you may have options of additional languages to download.</p>
+						<p>After specifying these options and agreeing to the agreement, webinstall will attempt to download al SMF files and decompress them in the same folder as webinstall.php. If successful you will be prompted to the SMF upgrade screen. If this fails you will need to follow the process below to upload files.</p>
+						<p>In most cases, you'll want to have &quot;Put the forum into maintenance mode during upgrade.&quot; checked, because it will ensure that nothing is messed with while the upgrader is working.  You may also wish to check &quot;Backup tables in your database...&quot;, which will make a backup of your old information and tables before making any changes in the database.</p>
+					</div>
+					<div class="panel">
+						<h2 id="finishing">Finishing everything up</h2>
+						<p>Once all steps of the installation process have been completed, check the box to remove the install files from the server. If this does not work, they will need to be deleted via FTP. All installer files should be removed from the server once the installation process is complete, as they are a major security risk if left on a server unattended. Once SMF is installed they are no longer needed.</p>
+						<p>Good luck!<br />
+						Simple Machines</p>
+					</div>
+				</div>
+			</div>
+		</div></div>
+		<div id="footer_section"><div class="frame">
+			<div class="smalltext padding"><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0; margin-bottom: 0.7em;" src="http://i.creativecommons.org/l/by-sa/3.0/80x15.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</div>
+			<div class="smalltext"><a href="http://www.simplemachines.org">Simple Machines Forum</a></div>
+		</div></div>
+	</body>
+</html>

+ 280 - 0
other/readme_update.html

@@ -0,0 +1,280 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+	<head>
+		<title>SMF 2.0 Update Guide</title>
+		<link rel="stylesheet" type="text/css" href="Themes/default/css/index.css?fin20" />
+		<style type="text/css">
+			h1.forumtitle
+			{
+				color: #346;
+			}
+			#upper_section .user
+			{
+				height: 4em;
+			}
+			#upper_section .news
+			{
+				height: 80px;
+			}
+			#main_screen
+			{
+				padding: 0 40px;
+			}
+			#main_screen h2
+			{
+				font-size: 2em;
+				border-bottom: solid 1px #d05800;
+				line-height: 2em;
+				margin: 0 0 0.5em 0;
+				color: #d05800;
+			}
+			h3
+			{
+				color: #d05800;
+			}
+			#content_section
+			{
+				position: relative;
+				top: -20px;
+			}
+			#main_content_section .panel
+			{
+				padding: 1em 2em 1em 1em;
+				line-height: 1.6em;
+			}
+			#main_content_section h2
+			{
+				font-size: 1.5em;
+				border-bottom: solid 1px #d05800;
+				line-height: 1.5em;
+				margin: 0 2em 0.5em 0;
+				color: #d05800;
+			}
+			#main_content_section li
+			{
+				line-height: 1.6em;
+				font-weight: bold;
+				color: #555;
+			}
+			#main_content_section li ul
+			{
+				padding-bottom: 0.7em;
+			}
+			#main_content_section li li
+			{
+				font-weight: normal;
+				line-height: 1.6em;
+			}
+			#liftup
+			{
+				position: relative;
+				top: -70px;
+			}
+			#footer_section
+			{
+				position: relative;
+				top: -60px;
+			}
+			tt
+			{
+				font-family: verdana, sans-serif;
+				letter-spacing: 1px;
+				font-weight: bold;
+				font-size: 90%;
+				font-style: italic;
+			}
+			dt
+			{
+				font-weight: bold;
+				color: #555;
+				margin-bottom: .1em;
+			}
+			dl
+			{
+				margin-top: .2em;
+				margin-left: 2em;
+				margin-bottom: .5em;
+			}
+			dd
+			{
+				line-height: 1.5em;
+				margin-left: 2em;
+				margin-bottom: .1em;
+			}
+			#header, #content_section, #footer_section
+			{
+				width: 90%;
+				margin: 0 auto;
+			}
+			a:link, a:visited
+			{
+				color: #3E5D8F;
+			}
+			a:hover
+			{
+				color: #346;
+			}
+		</style>
+	</head>
+	<body>
+		<div id="header"><div class="frame">
+			<div id="top_section">
+				<h1 class="forumtitle">SMF 2.0 Update Guide</h1>
+				<img id="smflogo" src="Themes/default/images/smflogo.png" alt="Simple Machines Forum" title="Simple Machines Forum" />
+			</div>
+			<div id="upper_section" class="middletext" style="overflow: hidden;">
+				<div class="user"></div>
+				<div class="news normaltext">
+				</div>
+			</div>
+		</div></div>
+		<div id="content_section"><div class="frame">
+			<div id="main_content_section">
+				<div id="liftup">
+					<div class="panel">
+						<h2 id="contents">Updating your forum</h2>
+						<p>Thank you for deciding to update your installation of <a href="http://www.simplemachines.org/smf/">SMF</a>.  Before you get started, please remember that there is <a href="http://www.simplemachines.org/community/index.php">a place for help at www.simplemachines.org</a> if you run into any problems at all.</p>
+						<p>If you are looking to convert from YaBB SE or a version of SMF older than the previous release, you may have downloaded the wrong package.  Please check <a href="http://download.simplemachines.org/">the downloads page</a> for more information.</p>
+						<p>You can find the following information in this file:</p>
+						<ul style="list-style-type: none;">
+							<li>&raquo; <a href="#requirements">Minimum installation requirements</a></li>
+							<li>&raquo; <a href="#recommendations">Recommendations for best performance</a></li>
+							<li>&raquo; <a href="#backups">Backing up data</a></li>
+							<li>&raquo; <a href="#uploadingftp">Upload files method 1: using FTP</a></li>
+							<li>&raquo; <a href="#Set_File_Permissions">Set file permissions</a></li>
+							<li>&raquo; <a href="#Run_the_upgrading_tool">Run the upgrading tool</a></li>
+							<li>&raquo; <a href="#webinstall">Upload files method 2: using webinstall.php</a></li>
+							<li>&raquo; <a href="#finishing">Finishing the update and cleaning up</a></li>
+						</ul>
+					</div>
+					<div class="panel">
+						<h2 id="requirements">Minimum installation requirements</h2>
+						<p>Your server must meet a few requirements to be able to run SMF.  If you are unsure as to whether your webserver meets these, please try to update anyway - it should detect any problems.</p>
+						<ul>
+							<li>Any webserver that properly supports PHP, such as <a href="http://httpd.apache.org/" target="_blank">Apache</a> or <a href="http://www.microsoft.com/iis" target="_blank">Internet Information Services (IIS)</a>.</li>
+							<li>
+								<a href="http://www.php.net" target="_blank">PHP</a> 4.1.0 or higher.  The following directives are required to be set correctly in php.ini:
+								<ul>
+									<li>the engine directive must be On.</li>
+									<li>the <a href="http://www.php.net/sybase#ini.magic-quotes-sybase" target="_blank">magic_quotes_sybase</a> directive must be set to Off.</li>
+									<li>the <a href="http://www.php.net/session#ini.session.save-path" target="_blank">session.save_path</a> directive must be set to a valid directory.</li>
+									<li>the <a href="http://www.php.net/manual/en/ini.core.php#ini.file-uploads" target="_blank">file_uploads</a> directive must be On.</li>
+									<li>the <a href="http://www.php.net/manual/en/ini.core.php#ini.upload-tmp-dir" target="_blank">upload_tmp_dir</a> must be set to a valid directory.</li>
+								</ul>
+							</li>
+							<li>Any of the following database systems
+								<ul>
+									<li><a href="http://www.mysql.com/" target="_blank">MySQL</a> 4.0.18 or higher.</li>
+									<li><a href="http://www.postgresql.org/" target="_blank">PostgreSQL</a> 8.0 or higher.</li>
+									<li><a href="http://www.sqlite.org/" target="_blank">SQLite</a> 1.x - 2.x.</li>
+								</ul>
+							</li>
+							<li>at least 2 megabytes of storage space in the database, although more is highly recommended.</li>
+							<li>The database user must have at least the following privileges: SELECT, INSERT, UPDATE, DELETE, ALTER, and INDEX.</li>
+							<li>about 20 megabytes of storage space on the web server, although more is recommended.</li>
+						</ul><br />
+						<h2 id="recommendations">Recommendations for best performance</h2>
+						<ul>
+							<li>Windows, <a href="http://www.linux.org/" target="_blank">Linux</a> or another Unix based operating system.</li>
+							<li>the <a href="http://aspell.sf.net/" target="_blank">GNU Aspell</a> 0.50 or higher and <a href="http://ftp.gnu.org/gnu/aspell/dict/" target="_blank">its dictionaries</a> for spell checking functionality.</li>
+							<li><a href="http://httpd.apache.org/" target="_blank">Apache</a> 2.0.0 or higher with <a href="http://httpd.apache.org/docs-2.0/mod/core.html#acceptpathinfo" target="_blank">AcceptPathInfo</a> set to On (Apache 2 and later only) for queryless URL support.</li>
+							<li>
+								<a href="http://www.php.net" target="_blank">PHP</a> 5.2.0 or higher, with the following set in php.ini:
+								<ul>
+									<li>the <a href="http://www.php.net/manual/en/info.configuration.php#ini.max-input-time" target="_blank">max_input_time</a> directive is set to a value of at least 30.</li>
+									<li>the <a href="http://www.php.net/manual/en/ini.core.php#ini.post-max-size" target="_blank">post_max_size</a> and <a href="http://www.php.net/configuration.directives#ini.upload-max-filesize" target="_blank">upload_max_filesize</a> directives set to the size of the largest attachments you wish to be able to upload.</li>
+									<li>the <a href="http://www.php.net/session#ini.session.use-trans-sid" target="_blank">session.use_trans_sid</a> directive set to Off.</li>
+									<li>the <a href="http://www.php.net/manual/en/ini.core.php#ini.memory-limit" target="_blank">memory_limit</a> directive is set to at least 8M.</li>
+									<li>the <a href="http://www.php.net/manual/en/info.configuration.php#ini.max-execution-time" target="_blank">max_execution_time</a> directive is set to at least 15.</li>
+									<li>the <a href="http://www.php.net/manual/en/ini.core.php#ini.register-globals" target="_blank">register_globals</a> directive is set to Off.</li>
+									<li>the <a href="http://www.php.net/manual/en/features.safe-mode.php" target="_blank">safe mode</a> disabled or <a href="http://httpd.apache.org/docs/2.0/suexec.html" target="_blank">suEXEC</a> enabled.</li>
+									<li>the <a href="http://www.php.net/manual/en/book.bc.php" target="_blank">BCMath</a> library enabled for using the <a href="/smf/Registration#Settings" title="Registration">OpenID</a> registration method.</li>
+								</ul>
+							</li>
+							<li>Any of the following database systems
+								<ul>
+									<li><a href="http://www.mysql.com/" target="_blank">MySQL</a> 5.0 or higher.</li>
+									<li><a href="http://www.postgresql.org/" target="_blank">PostgreSQL</a> 8.3.3 or higher.</li>
+									<li><a href="http://www.sqlite.org/" target="_blank">SQLite</a> 2.8.</li>
+								</ul>
+							</li>
+							<li><a href="http://www.boutell.com/gd/" target="_blank">GD Graphics Library</a> 2.0 or higher.</li>
+						</ul>
+						<p>If your server does not meet these requirements, SMF may not work properly.</p>
+					</div>
+					<div class="panel">
+						<h2 id="backups">Backing up data</h2>
+						<p>Before starting the update process, a backup of the live database should be taken. This protects the forum from accidental damage and any issues from updating. Although all steps are taken, and extensive testing carried out, sometimes issues develop. Therefore, having a backup is crucial. The upgrading tool can backup all database tables before it runs, however the best practice is to have a full backup available. </p>
+						<h3>Back up a database using SMF</h3>
+						<p>From SMF, navigate to Forum Maintenance. (Administration Center -&gt; Maintenance -&gt; Forum Maintenance) On the database section, save the data and the structure. Then, compress the file. Select &quot;Download&quot; and wait for the database to complete the download completely. It is recommended if you use this method to verify that the backup is complete by opening the file and checking the last line. If the file is not complete and has an error please try one of the other methods to backup your database.</p>
+						<h3>Back up a database using PHPMyAdmin</h3>
+						<p>PHPMyAdmin gives the option to export a database, from the initial page, select the &quot;Export&quot; option and follow the instructions. Select your SMF database. These are different based on host. </p>
+						<h3>Back up a database using a control panel</h3>
+						<p>If your hosting service provides a control panel interface, this can be used to back up a database. Selecting the &quot;Backups&quot; or &quot;Backups Wizard&quot; options should take you to a page, prompting you to back up your database. With different hosts, these options may have different titles. </p>
+					</div>
+					<div class="panel">
+						<h2 id="uploadingftp">Upload files method 1: manually uploading files</h2>
+						<p>If your server doesn't support webinstall.php than you can use an FTP client and an FTP access to upload the files to your server.</p>
+						<p>All you need to do is upload all of the files in this package, excluding this file itself, to your server.  You should upload it to the same directory as your previous installation of SMF. If you are given the option to &quot;resume&quot; uploads, make sure you do not do that - you must upload all of the files.  You may wish to make sure that all of the files were uploaded, such as those in <tt>Themes/default/languages</tt>, because some FTP clients have been known to drop files.</p>
+					</div>
+					<div class="panel">
+						<h2 id="Set_File_Permissions">Set file permissions</h2>
+						<p>After the upgrade archive has been uploaded and extracted, you need to set the files' permissions. This is commonly done by use of the Unix utility <b>CHMOD</b>. The correct CHMOD value for SMF files is either 777, 775 or 755, depending on your hosting service. There are two methods for this step, the method used depends on the hosting service that you use.</p>
+						<h3>Setting File Permissions With the Upgrader</h3>
+						<p>The SMF upgrader can set file permissions simply and easily. Navigating to the directory where SMF is located should redirect you to the upgrade.php file and prompt the upgrader. For example: www.yourdomain.com/forum/upgrade.php. If the upgrader detects files that need their permissions adjusted it will prompt for FTP details so it can <b>CHMOD</b> the files it requires for the upgrade. This may not work on some servers.
+						</p>
+						<h3>Setting File Permissions With FTP</h3>
+						<p>Using a control panel or FTP client, file permissions can be changed quickly and easily. Usually, FTP programs will allow permissions to be changed by right-clicking files/directories and selecting &quot;Properties&quot;, &quot;Attributes&quot; or &quot;Permissions&quot;. The desired numerical value can be entered, or if provided, check boxes can be changed.</p>
+						<p>The following files and directories must be writable. Depending on how your server is set up, this could mean that they must have <b>CHMOD</b> values of 644, 664 or 666 for files, and 755, 775 or 777 for folders:</p>
+						<ul><li>/attachments
+						</li><li>/avatars
+						</li><li>/Packages
+						</li><li>/Packages/installed.list
+						</li><li>/Smileys
+						</li><li>/Themes
+						</li><li>agreement.txt
+						</li><li>Settings.php
+						</li><li>Settings_bak.php
+						</li><li>upgrade.php
+						</li></ul>
+						<p>If the permission on your files or folders does not make them writable, the SMF upgrader will report the problem. In that case, use your FTP client or host panel to reset the permissions for the files or folders the upgrader reports.</p>
+					</div>
+					<div class="panel">
+						<h2 id="Run_the_upgrading_tool">Run the upgrading tool</h2>
+						<p>The final step in updating SMF, is to run the upgrading tool. Navigate to the directory where SMF is located. It should redirect you to the upgrade.php file and prompt you to run the upgrade. In example: www.yourdomain.com/forum/upgrade.php. </p>
+						<p>The first page you see may request your FTP information.  If you see this screen, it is because the installer found some files or folders with inadequate permissions for SMF to run properly.  If you enter your FTP information here, the installer can automatically fix these permissions for you.  Please note that the path should be the same path you see in your FTP client.  For example, it might be &quot;public_html/forum&quot;.  And remember, the installer will not save your FTP password anywhere.</p>
+						<h3>Upgrade settings</h3>
+						<dl>
+							<dt>Backup database with the prefix "backup_"</dt>
+							<dd>Selecting this option will get the upgrade tool to copy all data in the database before upgrading within the original database.</dd>
+							<dt>Maintenance Mode</dt>
+							<dd>Selecting this option will place the forum into maintenance mode while upgrading rather than showing errors, this is highly recommended.</dd>
+							<dt>Output extra debugging information.</dt>
+							<dd>The upgrade tool can give detailed information while performing an upgrade by selecting this option, it will aid the support team to solve any errors if they occur while upgrading.</dd>
+						</dl>
+					</div>
+					<div class="panel">
+						<h2 id="webinstall">Upload files method 2: using webinstall.php</h2>
+						<p>Your server may support webinstall.php. This script will automatically download SMF to your server. This may not work on all servers and also may require providing it with FTP details.</p>
+						<p>The first thing you need to do is upload webinstall.php to the location of where SMF is to exist on your server.</p>
+						<p>After you have finished uploading the file, point your browser to http://www.yourdomain.tld/forum/webinstall.php - where www.yourdomain.tld/forum is the URL to where you uploaded it.  You should then see the webinstall interface.</p>
+						<p>The first page you see may request your FTP information.  If you see this screen, it is because the webinstaller found some files or folders with inadequate permissions for SMF to run properly.  If you enter your FTP information here, the webinstaller can automatically fix these permissions for you.  Please note that the path should be the same path you see in your FTP client.  For example, it might be &quot;public_html/forum&quot;.  And remember, the webinstaller will not save your FTP password anywhere.</p>
+						<p>On the webinstall interface you have an option to login, this is useful for charter members to easily download early releases. You may have an option to select multiple versions of SMF to download. It is up to you to decide which version of SMF you wish to install. Additionally you may have options of additional languages to download.</p>
+						<p>After specifying these options and agreeing to the agreement, webinstall will attempt to download al SMF files and decompress them in the same folder as webinstall.php. If successful you will be prompted to the SMF upgrade screen. If this fails you will need to follow the process below to upload files.</p>
+						<p>In most cases, you'll want to have &quot;Put the forum into maintenance mode during upgrade.&quot; checked, because it will ensure that nothing is messed with while the upgrader is working.  You may also wish to check &quot;Backup tables in your database...&quot;, which will make a backup of your old information and tables before making any changes in the database.</p>
+					</div>
+					<div class="panel">
+						<h2 id="finishing">Finishing the update and cleaning up</h2>
+						<p>Once all parts of the update have completed, check the box to remove the upgrade files from the server. If this does not work, they will need to be deleted via FTP. All upgrade files should be removed from the server once the update process is complete. These files are upgrade.php and the .sql files whose name starts with 'upgrade'. They are a major security risk if they are left on a server unattended. Once SMF has been updated, they are no longer needed.</p>
+						<p>Good luck!<br />
+						Simple Machines</p>
+					</div>
+				</div>
+			</div>
+		</div></div>
+		<div id="footer_section"><div class="frame">
+			<div class="smalltext padding"><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0; margin-bottom: 0.7em;" src="http://i.creativecommons.org/l/by-sa/3.0/80x15.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</div>
+			<div class="smalltext"><a href="http://www.simplemachines.org">Simple Machines Forum</a></div>
+		</div></div>
+	</body>
+</html>

+ 255 - 0
other/readme_upgrade.html

@@ -0,0 +1,255 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+	<head>
+		<title>SMF 2.0 Upgrade Guide</title>
+		<link rel="stylesheet" type="text/css" href="Themes/default/css/index.css?fin20" />
+		<style type="text/css">
+			#upper_section .user
+			{
+				height: 4em;
+			}
+			#upper_section .news
+			{
+				height: 80px;
+			}
+			#main_screen
+			{
+				padding: 0 40px;
+			}
+			#main_screen h2
+			{
+				font-size: 2em;
+				border-bottom: solid 1px #d05800;
+				line-height: 2em;
+				margin: 0 0 0.5em 0;
+				color: #d05800;
+			}
+			#content_section
+			{
+				position: relative;
+				top: -20px;
+			}
+			#main_content_section .panel
+			{
+				padding: 1em 2em 1em 1em;
+				line-height: 1.6em;
+			}
+			#main_content_section h2
+			{
+				font-size: 1.5em;
+				border-bottom: solid 1px #d05800;
+				line-height: 1.5em;
+				margin: 0 2em 0.5em 0;
+				color: #d05800;
+			}
+			#main_content_section li
+			{
+				line-height: 1.6em;
+				font-weight: bold;
+			}
+			#main_content_section li li
+			{
+				font-weight: normal;
+				line-height: 1.6em;
+			}
+			#liftup
+			{
+				position: relative;
+				top: -70px;
+			}
+			#footer_section
+			{
+				position: relative;
+				top: -20px;
+			}
+			#footer_section
+			{
+				position: relative;
+				top: -20px;
+			}
+			tt
+			{
+				font-family: verdana, sans-serif;
+				letter-spacing: 1px;
+				font-weight: bold;
+				font-size: 90%;
+				font-style: italic;
+			}
+			dt {
+				font-weight: bold;
+				margin-bottom: .1em;
+			}
+			dl {
+				margin-top: .2em;
+				margin-left: 2em;
+				margin-bottom: .5em;
+			}
+			dd {
+				line-height: 1.5em;
+				margin-left: 2em;
+				margin-bottom: .1em;
+			}
+		</style>
+	</head>
+	<body>
+		<div id="header"><div class="frame">
+			<div id="top_section">
+				<h1 class="forumtitle">SMF 2.0 Upgrade Guide</h1>
+				<img id="smflogo" src="Themes/default/images/smflogo.png" alt="Simple Machines Forum" title="Simple Machines Forum" />
+			</div>
+			<div id="upper_section" class="middletext" style="overflow: hidden;">
+				<div class="user"></div>
+				<div class="news normaltext">
+				</div>
+			</div>
+		</div></div>
+		<div id="content_section"><div class="frame">
+			<div id="main_content_section">
+				<div id="liftup">
+					<div class="panel">
+						<h2 id="contents">Upgrading your forum</h2>
+						<p>Thank you for deciding to upgrade to <a href="http://www.simplemachines.org/smf/">SMF</a>.  Before you get started, please remember that there is <a href="http://www.simplemachines.org/community/index.php">a place for help at www.simplemachines.org</a> if you run into any problems at all.</p>
+						<p>You can find the following information in this file:</p>
+						<ul style="list-style-type: none;">
+							<li>&raquo; <a href="#requirements">Minimum installation requirements</a></li>
+							<li>&raquo; <a href="#backups">Backing up data</a></li>
+							<li>&raquo; <a href="#uploadingftp">Upload files method 1: using FTP</a></li>
+							<li>&raquo; <a href="#Set_File_Permissions">Set file permissions</a></li>
+							<li>&raquo; <a href="#Run_the_upgrading_tool">Run the upgrading tool</a></li>
+							<li>&raquo; <a href="#webinstall">Upload files method 2: using webinstall.php</a></li>
+							<li>&raquo; <a href="#finishing">Finishing the upgrade and cleaning up</a></li>
+						</ul>
+					</div>
+					<div class="panel">
+						<h2 id="requirements">Minimum installation requirements</h2>
+						<p>Your server must meet a few requirements to be able to run SMF.  If you are unsure as to whether your webserver meets these, please try to upgrade anyway - it should detect any problems.</p>
+						<ul>
+							<li>Any webserver that properly supports PHP, such as <a href="http://httpd.apache.org/" target="_blank">Apache</a> or <a href="http://www.microsoft.com/iis" target="_blank">Internet Information Services (IIS)</a>.</li>
+							<li>
+								<a href="http://www.php.net" target="_blank">PHP</a> 4.1.0 or higher.  The following directives are required to be set correctly in php.ini:
+								<ul>
+									<li>the engine directive must be On.</li>
+									<li>the <a href="http://www.php.net/sybase#ini.magic-quotes-sybase" target="_blank">magic_quotes_sybase</a> directive must be set to Off.</li>
+									<li>the <a href="http://www.php.net/session#ini.session.save-path" target="_blank">session.save_path</a> directive must be set to a valid directory.</li>
+									<li>the <a href="http://www.php.net/manual/en/ini.core.php#ini.file-uploads" target="_blank">file_uploads</a> directive must be On.</li>
+									<li>the <a href="http://www.php.net/manual/en/ini.core.php#ini.upload-tmp-dir" target="_blank">upload_tmp_dir</a> must be set to a valid directory.</li>
+								</ul>
+							</li>
+							<li>Any of the following database systems
+								<ul>
+									<li><a href="http://www.mysql.com/" target="_blank">MySQL</a> 4.0.18 or higher.</li>
+									<li><a href="http://www.postgresql.org/" target="_blank">PostgreSQL</a> 8.0 or higher.</li>
+									<li><a href="http://www.sqlite.org/" target="_blank">SQLite</a> 1.x - 2.x.</li>
+								</ul>
+							</li>
+							<li>at least 2 megabytes of storage space in the database, although more is highly recommended.</li>
+							<li>The database user must have at least the following privileges: SELECT, INSERT, UPDATE, DELETE, ALTER, and INDEX.</li>
+							<li>about 20 megabytes of storage space on the web server, although more is recommended.</li>
+						</ul>
+						<p>Recommendations for best performance:</p>
+						<ul>
+							<li>Windows, <a href="http://www.linux.org/" target="_blank">Linux</a> or another Unix based operating system.</li>
+							<li>the <a href="http://aspell.sf.net/" target="_blank">GNU Aspell</a> 0.50 or higher and <a href="http://ftp.gnu.org/gnu/aspell/dict/" target="_blank">its dictionaries</a> for spell checking functionality.</li>
+							<li><a href="http://httpd.apache.org/" target="_blank">Apache</a> 2.0.0 or higher with <a href="http://httpd.apache.org/docs-2.0/mod/core.html#acceptpathinfo" target="_blank">AcceptPathInfo</a> set to On (Apache 2 and later only) for queryless URL support.</li>
+							<li>
+								<a href="http://www.php.net" target="_blank">PHP</a> 5.2.0 or higher, with the following set in php.ini:
+								<ul>
+									<li>the <a href="http://www.php.net/manual/en/info.configuration.php#ini.max-input-time" target="_blank">max_input_time</a> directive is set to a value of at least 30.</li>
+									<li>the <a href="http://www.php.net/manual/en/ini.core.php#ini.post-max-size" target="_blank">post_max_size</a> and <a href="http://www.php.net/configuration.directives#ini.upload-max-filesize" target="_blank">upload_max_filesize</a> directives set to the size of the largest attachments you wish to be able to upload.</li>
+									<li>the <a href="http://www.php.net/session#ini.session.use-trans-sid" target="_blank">session.use_trans_sid</a> directive set to Off.</li>
+									<li>the <a href="http://www.php.net/manual/en/ini.core.php#ini.memory-limit" target="_blank">memory_limit</a> directive is set to at least 8M.</li>
+									<li>the <a href="http://www.php.net/manual/en/info.configuration.php#ini.max-execution-time" target="_blank">max_execution_time</a> directive is set to at least 15.</li>
+									<li>the <a href="http://www.php.net/manual/en/ini.core.php#ini.register-globals" target="_blank">register_globals</a> directive is set to Off.</li>
+									<li>the <a href="http://www.php.net/manual/en/features.safe-mode.php" target="_blank">safe mode</a> disabled or <a href="http://httpd.apache.org/docs/2.0/suexec.html" target="_blank">suEXEC</a> ensabled.</li>
+									<li>the <a href="http://www.php.net/manual/en/book.bc.php" target="_blank">BCMath</a> library enabled for using the <a href="/smf/Registration#Settings" title="Registration">OpenID</a> registration method.</li>
+								</ul>
+							</li>
+							<li>Any of the following database systems
+								<ul>
+									<li><a href="http://www.mysql.com/" target="_blank">MySQL</a> 5.0 or higher.</li>
+									<li><a href="http://www.postgresql.org/" target="_blank">PostgreSQL</a> 8.3.3 or higher.</li>
+									<li><a href="http://www.sqlite.org/" target="_blank">SQLite</a> 2.8.</li>
+								</ul>
+							</li>
+							<li><a href="http://www.boutell.com/gd/" target="_blank">GD Graphics Library</a> 2.0 or higher.</li>
+						</ul>
+						<p>If your server does not meet these requirements, SMF may not work properly.</p>
+					</div>
+					<div class="panel">
+						<h2 id="backups">Backing up data</h2>
+						<p>Before starting the upgrade process, a backup of the live database should be taken. This protects the forum from accidental damage and any issues from upgrading. Although all steps are taken, and extensive testing carried out, sometimes issues develop. Therefore, having a backup is crucial. The upgrading tool can backup all database tables before it runs, however the best practice is to have a full backup available. </p>
+						<h3>Back up a database using SMF</h3>
+						<p>From SMF, navigate to Forum Maintenance. (Administration Center -&gt; Maintenance -&gt; Forum Maintenance) On the database section, save the data and the structure. Then, compress the file. Select &quot;Download&quot; and wait for the database to complete the download completely. It is recommended if you use this method to verify that the backup is complete by opening the file and checking the last line. If the file is not complete and has an error please try one of the other methods to backup your database.</p>
+						<h3>Back up a database using PHPMyAdmin</h3>
+						<p>PHPMyAdmin gives the option to export a database, from the initial page, select the &quot;Export&quot; option and follow the instructions. Select your SMF database. These are different based on host. </p>
+						<h3>Back up a database using a control panel</h3>
+						<p>If your hosting service provides a control panel interface, this can be used to back up a database. Selecting the &quot;Backups&quot; or &quot;Backups Wizard&quot; options should take you to a page, prompting you to back up your database. With different hosts, these options may have different titles. </p>
+					</div>
+					<div class="panel">
+						<h2 id="uploadingftp">Upload files method 1: using FTP</h2>
+						<p>If your server doesn't support webinstall.php than you can use an FTP client and an FTP access to upload the files to your server.</p>
+						<p>All you need to do is upload all of the files in this package, excluding this file itself, to your server.  You should upload it to the same directory as your previous installation of SMF or YaBB SE. If you are given the option to &quot;resume&quot; uploads, make sure you do not do that - you must upload all of the files.  You may wish to make sure that all of the files were uploaded, such as those in <tt>Themes/default/languages</tt>, because some FTP clients have been known to drop files.</p>
+						<h3>Language files</h3>
+						<p>If you are using additional languages it will be useful to upload also the updated versions of the language files along with the upgrading packages. Doing so all updated text strings will appear correctly after the upgrade, and will allow the upgrade to run in your selected language.</p>
+					</div>
+					<div class="panel">
+						<h2 id="Set_File_Permissions">Set file permissions</h2>
+						<p>After the upgrade archive has been uploaded and extracted, you need to set the files' permissions. This is commonly done by use of the Unix utility <b>CHMOD</b>. The correct CHMOD value for SMF files is either 777, 775 or 755, depending on your hosting service. There are two methods for this step, the method used depends on the hosting service that you use.</p>
+						<h3>Setting File Permissions With the Upgrader</h3>
+						<p>The SMF upgrader can set file permissions simply and easily. Navigating to the directory where SMF is located should redirect you to the upgrade.php file and prompt the upgrader. For example: www.yourdomain.com/forum/upgrade.php. If the upgrader detects files that need their permissions adjusted it will prompt for FTP details so it can <b>CHMOD</b> the files it requires for the upgrade. This may not work on some servers.
+						</p>
+						<h3>Setting File Permissions With FTP</h3>
+						<p>Using a control panel or FTP client, file permissions can be changed quickly and easily. Usually, FTP programs will allow permissions to be changed by right-clicking files/directories and selecting &quot;Properties&quot;, &quot;Attributes&quot; or &quot;Permissions&quot;. The desired numerical value can be entered, or if provided, check boxes can be changed.</p>
+						<p>The following files and directories must be writable. Depending on how your server is set up, this could mean that they must have <b>CHMOD</b> values of 644, 664 or 666 for files, and 755, 775 or 777 for folders:</p>
+						<ul><li>/attachments
+						</li><li>/avatars
+						</li><li>/Packages
+						</li><li>/Packages/installed.list
+						</li><li>/Smileys
+						</li><li>/Themes
+						</li><li>agreement.txt
+						</li><li>Settings.php
+						</li><li>Settings_bak.php
+						</li><li>upgrade.php
+						</li></ul>
+						<p>If the permission on your files or folders does not make them writable, the SMF upgrader will report the problem. In that case, use your FTP client or host panel to reset the permissions for the files or folders the upgrader reports.</p>
+					</div>
+					<div class="panel">
+						<h2 id="Run_the_upgrading_tool">Run the upgrading tool</h2>
+						<p>The final step in upgrading SMF, is to run the upgrading tool. Navigate to the directory where SMF is located. It should redirect you to the upgrade.php file and prompt you to run the upgrade. In example: www.yourdomain.com/forum/upgrade.php. </p>
+						<p>The first page you see may request your FTP information.  If you see this screen, it is because the installer found some files or folders with inadequate permissions for SMF to run properly.  If you enter your FTP information here, the installer can automatically fix these permissions for you.  Please note that the path should be the same path you see in your FTP client.  For example, it might be &quot;public_html/forum&quot;.  And remember, the installer will not save your FTP password anywhere.</p>
+						<h3>Upgrade settings</h3>
+						<dl>
+							<dt>Backup database with the prefix "backup_"</dt>
+							<dd>Selecting this option will get the upgrade tool to copy all data in the database before upgrading within the original database.</dd>
+							<dt>Maintenance Mode</dt>
+							<dd>Selecting this option will place the forum into maintenance mode while upgrading rather than showing errors, this is highly recommended.</dd>
+							<dt>Output extra debugging information.</dt>
+							<dd>The upgrade tool can give detailed information while performing an upgrade by selecting this option, it will aid the support team to solve any errors if they occur while upgrading.</dd>
+						</dl>
+					</div>
+					<div class="panel">
+						<h2 id="webinstall">Upload files method 2: using webinstall.php</h2>
+						<p>Your server may support webinstall.php. This script will automatically download SMF to your server. This may not work on all servers and also may require providing it with FTP details.</p>
+						<p>The first thing you need to do is upload webinstall.php to the location of where SMF is to exist on your server.</p>
+						<p>After you have finished uploading the file, point your browser to http://www.yourdomain.tld/forum/webinstall.php - where www.yourdomain.tld/forum is the URL to where you uploaded it.  You should then see the webinstall interface.</p>
+						<p>The first page you see may request your FTP information.  If you see this screen, it is because the webinstaller found some files or folders with inadequate permissions for SMF to run properly.  If you enter your FTP information here, the webinstaller can automatically fix these permissions for you.  Please note that the path should be the same path you see in your FTP client.  For example, it might be &quot;public_html/forum&quot;.  And remember, the webinstaller will not save your FTP password anywhere.</p>
+						<p>On the webinstall interface you have an option to login, this is useful for charter members to easily download early releases. You may have an option to select multiple versions of SMF to download. It is up to you to decide which version of SMF you wish to install. Additionally you may have options of additional languages to download.</p>
+						<p>After specifying these options and agreeing to the agreement, webinstall will attempt to download al SMF files and decompress them in the same folder as webinstall.php. If successful you will be prompted to the SMF upgrade screen. If this fails you will need to follow the process below to upload files.</p>
+						<p>In most cases, you'll want to have &quot;Put the forum into maintenance mode during upgrade.&quot; checked, because it will ensure that nothing is messed with while the upgrader is working.  You may also wish to check &quot;Backup tables in your database...&quot;, which will make a backup of your old information and tables before making any changes in the database.</p>
+					</div>
+					<div class="panel">
+						<h2 id="finishing">Finishing the upgrade and cleaning up</h2>
+						<p>Once all parts of the upgrade have completed, check the box to remove the upgrade files from the server. If this does not work, they will need to be deleted via FTP. All upgrade files should be removed from the server once the upgrade process is complete. These files are upgrade.php and the .sql files whose name starts with 'upgrade'. They are a major security risk if they are left on a server unattended. Once SMF has been upgraded, they are no longer needed.</p>
+						<p>Good luck!<br />
+						Simple Machines</p>
+					</div>
+				</div>
+			</div>
+		</div></div>
+		<div id="footer_section"><div class="frame">
+			<div class="smalltext"><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/80x15.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</div>
+			<div class="smalltext"><a href="http://www.simplemachines.org">Simple Machines Forum</a></div>
+		</div></div>
+	</body>
+</html>

+ 4514 - 0
other/upgrade.php

@@ -0,0 +1,4514 @@
+<?php
+
+/**
+ * Simple Machines Forum (SMF)
+ *
+ * @package SMF
+ * @author Simple Machines http://www.simplemachines.org
+ * @copyright 2011 Simple Machines
+ * @license http://www.simplemachines.org/about/smf/license.php BSD
+ *
+ * @version 2.1 Alpha 1
+ */
+
+// Version information...
+define('SMF_VERSION', '2.1 Alpha 1');
+define('SMF_LANG_VERSION', '2.0');
+
+$GLOBALS['required_php_version'] = '5.0.0';
+$GLOBALS['required_mysql_version'] = '4.0.18';
+
+$databases = array(
+	'mysql' => array(
+		'name' => 'MySQL',
+		'version' => '4.0.18',
+		'version_check' => 'return min(mysql_get_server_info(), mysql_get_client_info());',
+		'utf8_support' => true,
+		'utf8_version' => '4.1.0',
+		'utf8_version_check' => 'return mysql_get_server_info();',
+		'alter_support' => true,
+	),
+	'postgresql' => array(
+		'name' => 'PostgreSQL',
+		'version' => '8.0',
+		'version_check' => '$version = pg_version(); return $version[\'client\'];',
+		'always_has_db' => true,
+	),
+	'sqlite' => array(
+		'name' => 'SQLite',
+		'version' => '1',
+		'version_check' => 'return 1;',
+		'always_has_db' => true,
+	),
+);
+
+// General options for the script.
+$timeLimitThreshold = 3;
+$upgrade_path = dirname(__FILE__);
+$upgradeurl = $_SERVER['PHP_SELF'];
+// Where the SMF images etc are kept.
+$smfsite = 'http://www.simplemachines.org/smf';
+// Disable the need for admins to login?
+$disable_security = false;
+// How long, in seconds, must admin be inactive to allow someone else to run?
+$upcontext['inactive_timeout'] = 10;
+
+// All the steps in detail.
+// Number,Name,Function,Progress Weight.
+$upcontext['steps'] = array(
+	0 => array(1, 'Login', 'WelcomeLogin', 2),
+	1 => array(2, 'Upgrade Options', 'UpgradeOptions', 2),
+	2 => array(3, 'Backup', 'BackupDatabase', 10),
+	3 => array(4, 'Database Changes', 'DatabaseChanges', 70),
+	// This is removed as it doesn't really work right at the moment.
+	//4 => array(5, 'Cleanup Mods', 'CleanupMods', 10),
+	4 => array(5, 'Delete Upgrade', 'DeleteUpgrade', 1),
+);
+// Just to remember which one has files in it.
+$upcontext['database_step'] = 3;
+@set_time_limit(600);
+if (!ini_get('safe_mode'))
+{
+	ini_set('mysql.connect_timeout', -1); 
+	ini_set('default_socket_timeout', 900);
+}
+// Clean the upgrade path if this is from the client.
+if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR']))
+	for ($i = 1; $i < $_SERVER['argc']; $i++)
+	{
+		if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0)
+			$upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1];
+	}
+
+// Are we from the client?
+if (php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR']))
+{
+	$command_line = true;
+	$disable_security = 1;
+}
+else
+	$command_line = false;
+
+// Load this now just because we can.
+require_once($upgrade_path . '/Settings.php');
+
+// Are we logged in?
+if (isset($upgradeData))
+{
+	$upcontext['user'] = unserialize(base64_decode($upgradeData));
+
+	// Check for sensible values.
+	if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400)
+		$upcontext['user']['started'] = time();
+	if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400)
+		$upcontext['user']['updated'] = 0;
+
+	$upcontext['started'] = $upcontext['user']['started'];
+	$upcontext['updated'] = $upcontext['user']['updated'];
+}
+
+// Nothing sensible?
+if (empty($upcontext['updated']))
+{
+	$upcontext['started'] = time();
+	$upcontext['updated'] = 0;
+	$upcontext['user'] = array(
+		'id' => 0,
+		'name' => 'Guest',
+		'pass' => 0,
+		'started' => $upcontext['started'],
+		'updated' => $upcontext['updated'],
+	);
+}
+
+// Load up some essential data...
+loadEssentialData();
+
+// Are we going to be mimic'ing SSI at this point?
+if (isset($_GET['ssi']))
+{
+	require_once($sourcedir . '/Subs.php');
+	require_once($sourcedir . '/Errors.php');
+	require_once($sourcedir . '/Logging.php');
+	require_once($sourcedir . '/Load.php');
+	require_once($sourcedir . '/Security.php');
+	require_once($sourcedir . '/Subs-Package.php');
+
+	loadUserSettings();
+	loadPermissions();
+}
+
+// All the non-SSI stuff.
+if (!function_exists('ip2range'))
+	require_once($sourcedir . '/Subs.php');
+
+if (!function_exists('un_htmlspecialchars'))
+{
+	function un_htmlspecialchars($string)
+	{
+		return strtr($string, array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES)) + array('&#039;' => '\'', '&nbsp;' => ' '));
+	}
+}
+
+if (!function_exists('text2words'))
+{
+	function text2words($text)
+	{
+		global $smcFunc;
+
+		// Step 1: Remove entities/things we don't consider words:
+		$words = preg_replace('~(?:[\x0B\0\xA0\t\r\s\n(){}\\[\\]<>!@$%^*.,:+=`\~\?/\\\\]+|&(?:amp|lt|gt|quot);)+~', ' ', $text);
+
+		// Step 2: Entities we left to letters, where applicable, lowercase.
+		$words = preg_replace('~([^&\d]|^)[#;]~', '$1 ', un_htmlspecialchars(strtolower($words)));
+
+		// Step 3: Ready to split apart and index!
+		$words = explode(' ', $words);
+		$returned_words = array();
+		foreach ($words as $word)
+		{
+			$word = trim($word, '-_\'');
+
+			if ($word != '')
+				$returned_words[] = substr($word, 0, 20);
+		}
+
+		return array_unique($returned_words);
+	}
+}
+
+if (!function_exists('clean_cache'))
+{
+	// Empty out the cache folder.
+	function clean_cache($type = '')
+	{
+		global $cachedir, $sourcedir;
+
+		// No directory = no game.
+		if (!is_dir($cachedir))
+			return;
+
+		// Remove the files in SMF's own disk cache, if any
+		$dh = opendir($cachedir);
+		while ($file = readdir($dh))
+		{
+			if ($file != '.' && $file != '..' && $file != 'index.php' && $file != '.htaccess' && (!$type || substr($file, 0, strlen($type)) == $type))
+				@unlink($cachedir . '/' . $file);
+		}
+		closedir($dh);
+
+		// Invalidate cache, to be sure!
+		// ... as long as Load.php can be modified, anyway.
+		@touch($sourcedir . '/' . 'Load.php');
+		clearstatcache();
+	}
+}
+
+// MD5 Encryption.
+if (!function_exists('md5_hmac'))
+{
+	function md5_hmac($data, $key)
+	{
+		if (strlen($key) > 64)
+			$key = pack('H*', md5($key));
+		$key = str_pad($key, 64, chr(0x00));
+
+		$k_ipad = $key ^ str_repeat(chr(0x36), 64);
+		$k_opad = $key ^ str_repeat(chr(0x5c), 64);
+
+		return md5($k_opad . pack('H*', md5($k_ipad . $data)));
+	}
+}
+
+// http://www.faqs.org/rfcs/rfc959.html
+if (!class_exists('ftp_connection'))
+{
+	class ftp_connection
+	{
+		var $connection = 'no_connection', $error = false, $last_message, $pasv = array();
+
+		// Create a new FTP connection...
+		function ftp_connection($ftp_server, $ftp_port = 21, $ftp_user = 'anonymous', $ftp_pass = '[email protected]')
+		{
+			if ($ftp_server !== null)
+				$this->connect($ftp_server, $ftp_port, $ftp_user, $ftp_pass);
+		}
+
+		function connect($ftp_server, $ftp_port = 21, $ftp_user = 'anonymous', $ftp_pass = '[email protected]')
+		{
+			if (substr($ftp_server, 0, 6) == 'ftp://')
+				$ftp_server = substr($ftp_server, 6);
+			elseif (substr($ftp_server, 0, 7) == 'ftps://')
+				$ftp_server = 'ssl://' . substr($ftp_server, 7);
+			if (substr($ftp_server, 0, 7) == 'http://')
+				$ftp_server = substr($ftp_server, 7);
+			$ftp_server = strtr($ftp_server, array('/' => '', ':' => '', '@' => ''));
+
+			// Connect to the FTP server.
+			$this->connection = @fsockopen($ftp_server, $ftp_port, $err, $err, 5);
+			if (!$this->connection)
+			{
+				$this->error = 'bad_server';
+				return;
+			}
+
+			// Get the welcome message...
+			if (!$this->check_response(220))
+			{
+				$this->error = 'bad_response';
+				return;
+			}
+
+			// Send the username, it should ask for a password.
+			fwrite($this->connection, 'USER ' . $ftp_user . "\r\n");
+			if (!$this->check_response(331))
+			{
+				$this->error = 'bad_username';
+				return;
+			}
+
+			// Now send the password... and hope it goes okay.
+			fwrite($this->connection, 'PASS ' . $ftp_pass . "\r\n");
+			if (!$this->check_response(230))
+			{
+				$this->error = 'bad_password';
+				return;
+			}
+		}
+
+		function chdir($ftp_path)
+		{
+			if (!is_resource($this->connection))
+				return false;
+
+			// No slash on the end, please...
+			if (substr($ftp_path, -1) == '/' && $ftp_path !== '/')
+				$ftp_path = substr($ftp_path, 0, -1);
+
+			fwrite($this->connection, 'CWD ' . $ftp_path . "\r\n");
+			if (!$this->check_response(250))
+			{
+				$this->error = 'bad_path';
+				return false;
+			}
+
+			return true;
+		}
+
+		function chmod($ftp_file, $chmod)
+		{
+			if (!is_resource($this->connection))
+				return false;
+
+			// Convert the chmod value from octal (0777) to text ("777").
+			fwrite($this->connection, 'SITE CHMOD ' . decoct($chmod) . ' ' . $ftp_file . "\r\n");
+			if (!$this->check_response(200))
+			{
+				$this->error = 'bad_file';
+				return false;
+			}
+
+			return true;
+		}
+
+		function unlink($ftp_file)
+		{
+			// We are actually connected, right?
+			if (!is_resource($this->connection))
+				return false;
+
+			// Delete file X.
+			fwrite($this->connection, 'DELE ' . $ftp_file . "\r\n");
+			if (!$this->check_response(250))
+			{
+				fwrite($this->connection, 'RMD ' . $ftp_file . "\r\n");
+
+				// Still no love?
+				if (!$this->check_response(250))
+				{
+					$this->error = 'bad_file';
+					return false;
+				}
+			}
+
+			return true;
+		}
+
+		function check_response($desired)
+		{
+			// Wait for a response that isn't continued with -, but don't wait too long.
+			$time = time();
+			do
+				$this->last_message = fgets($this->connection, 1024);
+			while (substr($this->last_message, 3, 1) != ' ' && time() - $time < 5);
+
+			// Was the desired response returned?
+			return is_array($desired) ? in_array(substr($this->last_message, 0, 3), $desired) : substr($this->last_message, 0, 3) == $desired;
+		}
+
+		function passive()
+		{
+			// We can't create a passive data connection without a primary one first being there.
+			if (!is_resource($this->connection))
+				return false;
+
+			// Request a passive connection - this means, we'll talk to you, you don't talk to us.
+			@fwrite($this->connection, 'PASV' . "\r\n");
+			$time = time();
+			do
+				$response = fgets($this->connection, 1024);
+			while (substr($response, 3, 1) != ' ' && time() - $time < 5);
+
+			// If it's not 227, we weren't given an IP and port, which means it failed.
+			if (substr($response, 0, 4) != '227 ')
+			{
+				$this->error = 'bad_response';
+				return false;
+			}
+
+			// Snatch the IP and port information, or die horribly trying...
+			if (preg_match('~\((\d+),\s*(\d+),\s*(\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+))\)~', $response, $match) == 0)
+			{
+				$this->error = 'bad_response';
+				return false;
+			}
+
+			// This is pretty simple - store it for later use ;).
+			$this->pasv = array('ip' => $match[1] . '.' . $match[2] . '.' . $match[3] . '.' . $match[4], 'port' => $match[5] * 256 + $match[6]);
+
+			return true;
+		}
+
+		function create_file($ftp_file)
+		{
+			// First, we have to be connected... very important.
+			if (!is_resource($this->connection))
+				return false;
+
+			// I'd like one passive mode, please!
+			if (!$this->passive())
+				return false;
+
+			// Seems logical enough, so far...
+			fwrite($this->connection, 'STOR ' . $ftp_file . "\r\n");
+
+			// Okay, now we connect to the data port.  If it doesn't work out, it's probably "file already exists", etc.
+			$fp = @fsockopen($this->pasv['ip'], $this->pasv['port'], $err, $err, 5);
+			if (!$fp || !$this->check_response(150))
+			{
+				$this->error = 'bad_file';
+				@fclose($fp);
+				return false;
+			}
+
+			// This may look strange, but we're just closing it to indicate a zero-byte upload.
+			fclose($fp);
+			if (!$this->check_response(226))
+			{
+				$this->error = 'bad_response';
+				return false;
+			}
+
+			return true;
+		}
+
+		function list_dir($ftp_path = '', $search = false)
+		{
+			// Are we even connected...?
+			if (!is_resource($this->connection))
+				return false;
+
+			// Passive... non-agressive...
+			if (!$this->passive())
+				return false;
+
+			// Get the listing!
+			fwrite($this->connection, 'LIST -1' . ($search ? 'R' : '') . ($ftp_path == '' ? '' : ' ' . $ftp_path) . "\r\n");
+
+			// Connect, assuming we've got a connection.
+			$fp = @fsockopen($this->pasv['ip'], $this->pasv['port'], $err, $err, 5);
+			if (!$fp || !$this->check_response(array(150, 125)))
+			{
+				$this->error = 'bad_response';
+				@fclose($fp);
+				return false;
+			}
+
+			// Read in the file listing.
+			$data = '';
+			while (!feof($fp))
+				$data .= fread($fp, 4096);
+			fclose($fp);
+
+			// Everything go okay?
+			if (!$this->check_response(226))
+			{
+				$this->error = 'bad_response';
+				return false;
+			}
+
+			return $data;
+		}
+
+		function locate($file, $listing = null)
+		{
+			if ($listing === null)
+				$listing = $this->list_dir('', true);
+			$listing = explode("\n", $listing);
+
+			@fwrite($this->connection, 'PWD' . "\r\n");
+			$time = time();
+			do
+				$response = fgets($this->connection, 1024);
+			while (substr($response, 3, 1) != ' ' && time() - $time < 5);
+
+			// Check for 257!
+			if (preg_match('~^257 "(.+?)" ~', $response, $match) != 0)
+				$current_dir = strtr($match[1], array('""' => '"'));
+			else
+				$current_dir = '';
+
+			for ($i = 0, $n = count($listing); $i < $n; $i++)
+			{
+				if (trim($listing[$i]) == '' && isset($listing[$i + 1]))
+				{
+					$current_dir = substr(trim($listing[++$i]), 0, -1);
+					$i++;
+				}
+
+				// Okay, this file's name is:
+				$listing[$i] = $current_dir . '/' . trim(strlen($listing[$i]) > 30 ? strrchr($listing[$i], ' ') : $listing[$i]);
+
+				if (substr($file, 0, 1) == '*' && substr($listing[$i], -(strlen($file) - 1)) == substr($file, 1))
+					return $listing[$i];
+				if (substr($file, -1) == '*' && substr($listing[$i], 0, strlen($file) - 1) == substr($file, 0, -1))
+					return $listing[$i];
+				if (basename($listing[$i]) == $file || $listing[$i] == $file)
+					return $listing[$i];
+			}
+
+			return false;
+		}
+
+		function create_dir($ftp_dir)
+		{
+			// We must be connected to the server to do something.
+			if (!is_resource($this->connection))
+				return false;
+
+			// Make this new beautiful directory!
+			fwrite($this->connection, 'MKD ' . $ftp_dir . "\r\n");
+			if (!$this->check_response(257))
+			{
+				$this->error = 'bad_file';
+				return false;
+			}
+
+			return true;
+		}
+
+		function detect_path($filesystem_path, $lookup_file = null)
+		{
+			$username = '';
+
+			if (isset($_SERVER['DOCUMENT_ROOT']))
+			{
+				if (preg_match('~^/home[2]?/([^/]+?)/public_html~', $_SERVER['DOCUMENT_ROOT'], $match))
+				{
+					$username = $match[1];
+
+					$path = strtr($_SERVER['DOCUMENT_ROOT'], array('/home/' . $match[1] . '/' => '', '/home2/' . $match[1] . '/' => ''));
+
+					if (substr($path, -1) == '/')
+						$path = substr($path, 0, -1);
+
+					if (strlen(dirname($_SERVER['PHP_SELF'])) > 1)
+						$path .= dirname($_SERVER['PHP_SELF']);
+				}
+				elseif (substr($filesystem_path, 0, 9) == '/var/www/')
+					$path = substr($filesystem_path, 8);
+				else
+					$path = strtr(strtr($filesystem_path, array('\\' => '/')), array($_SERVER['DOCUMENT_ROOT'] => ''));
+			}
+			else
+				$path = '';
+
+			if (is_resource($this->connection) && $this->list_dir($path) == '')
+			{
+				$data = $this->list_dir('', true);
+
+				if ($lookup_file === null)
+					$lookup_file = $_SERVER['PHP_SELF'];
+
+				$found_path = dirname($this->locate('*' . basename(dirname($lookup_file)) . '/' . basename($lookup_file), $data));
+				if ($found_path == false)
+					$found_path = dirname($this->locate(basename($lookup_file)));
+				if ($found_path != false)
+					$path = $found_path;
+			}
+			elseif (is_resource($this->connection))
+				$found_path = true;
+
+			return array($username, $path, isset($found_path));
+		}
+
+		function close()
+		{
+			// Goodbye!
+			fwrite($this->connection, 'QUIT' . "\r\n");
+			fclose($this->connection);
+
+			return true;
+		}
+	}
+}
+
+// Have we got tracking data - if so use it (It will be clean!)
+if (isset($_GET['data']))
+{
+	$upcontext['upgrade_status'] = unserialize(base64_decode($_GET['data']));
+	$upcontext['current_step'] = $upcontext['upgrade_status']['curstep'];
+	$upcontext['language'] = $upcontext['upgrade_status']['lang'];
+	$upcontext['rid'] = $upcontext['upgrade_status']['rid'];
+	$is_debug = $upcontext['upgrade_status']['debug'];
+	$support_js = $upcontext['upgrade_status']['js'];
+
+	// Load the language.
+	if (file_exists($boarddir . '/Themes/default/languages/Install.' . $upcontext['language'] . '.php'))
+		require_once($boarddir . '/Themes/default/languages/Install.' . $upcontext['language'] . '.php');
+}
+// Set the defaults.
+else
+{
+	$upcontext['current_step'] = 0;
+	$upcontext['rid'] = mt_rand(0, 5000);
+	$upcontext['upgrade_status'] = array(
+		'curstep' => 0,
+		'lang' => isset($_GET['lang']) ? $_GET['lang'] : basename($language, '.lng'),
+		'rid' => $upcontext['rid'],
+		'pass' => 0,
+		'debug' => 0,
+		'js' => 0,
+	);
+	$upcontext['language'] = $upcontext['upgrade_status']['lang'];
+}
+
+// Don't do security check if on Yabbse
+if (!isset($modSettings['smfVersion']))
+	$disable_security = true;
+
+// If this isn't the first stage see whether they are logging in and resuming.
+if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step']))
+	checkLogin();
+
+// This only exists if we're on SMF ;)
+if (isset($modSettings['smfVersion']))
+{
+	$request = $smcFunc['db_query']('', '
+		SELECT variable, value
+		FROM {db_prefix}themes
+		WHERE id_theme = {int:id_theme}
+			AND variable IN ({string:theme_url}, {string:theme_dir}, {string:images_url})',
+		array(
+			'id_theme' => 1,
+			'theme_url' => 'theme_url',
+			'theme_dir' => 'theme_dir',
+			'images_url' => 'images_url',
+			'db_error_skip' => true,
+		)
+	);
+	while ($row = $smcFunc['db_fetch_assoc']($request))
+		$modSettings[$row['variable']] = $row['value'];
+	$smcFunc['db_free_result']($request);
+}
+
+if (!isset($modSettings['theme_url']))
+{
+	$modSettings['theme_dir'] = $boarddir . '/Themes/default';
+	$modSettings['theme_url'] = 'Themes/default';
+	$modSettings['images_url'] = 'Themes/default/images';
+}
+if (!isset($settings['default_theme_url']))
+	$settings['default_theme_url'] = $modSettings['theme_url'];
+if (!isset($settings['default_theme_dir']))
+	$settings['default_theme_dir'] = $modSettings['theme_dir'];
+
+$upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000;
+// Default title...
+$upcontext['page_title'] = isset($modSettings['smfVersion']) ? 'Updating Your SMF Install!' : 'Upgrading from YaBB SE!';
+
+$upcontext['right_to_left'] = isset($txt['lang_rtl']) ? $txt['lang_rtl'] : false;
+
+if ($command_line)
+	cmdStep0();
+
+// Don't error if we're using xml.
+if (isset($_GET['xml']))
+	$upcontext['return_error'] = true;
+
+// Loop through all the steps doing each one as required.
+$upcontext['overall_percent'] = 0;
+foreach ($upcontext['steps'] as $num => $step)
+{
+	if ($num >= $upcontext['current_step'])
+	{
+		// The current weight of this step in terms of overall progress.
+		$upcontext['step_weight'] = $step[3];
+		// Make sure we reset the skip button.
+		$upcontext['skip'] = false;
+
+		// We cannot proceed if we're not logged in.
+		if ($num != 0 && !$disable_security && $upcontext['user']['pass'] != $upcontext['upgrade_status']['pass'])
+		{
+			$upcontext['steps'][0][2]();
+			break;
+		}
+
+		// Call the step and if it returns false that means pause!
+		if (function_exists($step[2]) && $step[2]() === false)
+			break;
+		elseif (function_exists($step[2]))
+			$upcontext['current_step']++;
+	}
+	$upcontext['overall_percent'] += $step[3];
+}
+
+upgradeExit();
+
+// Exit the upgrade script.
+function upgradeExit($fallThrough = false)
+{
+	global $upcontext, $upgradeurl, $boarddir, $command_line;
+
+	// Save where we are...
+	if (!empty($upcontext['current_step']) && !empty($upcontext['user']['id']))
+	{
+		$upcontext['user']['step'] = $upcontext['current_step'];
+		$upcontext['user']['substep'] = $_GET['substep'];
+		$upcontext['user']['updated'] = time();
+		$upgradeData = base64_encode(serialize($upcontext['user']));
+		copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php');
+		changeSettings(array('upgradeData' => '"' . $upgradeData . '"'));
+	}
+
+	// Handle the progress of the step, if any.
+	if (!empty($upcontext['step_progress']) && isset($upcontext['steps'][$upcontext['current_step']]))
+	{
+		$upcontext['step_progress'] = round($upcontext['step_progress'], 1);
+		$upcontext['overall_percent'] += $upcontext['step_progress'] * ($upcontext['steps'][$upcontext['current_step']][3] / 100);
+	}
+	$upcontext['overall_percent'] = (int) $upcontext['overall_percent'];
+
+	// We usually dump our templates out.
+	if (!$fallThrough)
+	{
+		// This should not happen my dear... HELP ME DEVELOPERS!!
+		if (!empty($command_line))
+		{
+			if (function_exists('debug_print_backtrace'))
+				debug_print_backtrace();
+
+			echo "\n" . 'Error: Unexpected call to use the ' . (isset($upcontext['sub_template']) ? $upcontext['sub_template'] : '') . ' template. Please copy and paste all the text above and visit the SMF support forum to tell the Developers that they\'ve made a boo boo; they\'ll get you up and running again.';
+			flush();
+			die();
+		}
+
+		if (!isset($_GET['xml']))
+			template_upgrade_above();
+		else
+		{
+			header('Content-Type: text/xml; charset=ISO-8859-1');
+			// Sadly we need to retain the $_GET data thanks to the old upgrade scripts.
+			$upcontext['get_data'] = array();
+			foreach ($_GET as $k => $v)
+			{
+				if (substr($k, 0, 3) != 'amp' && !in_array($k, array('xml', 'substep', 'lang', 'data', 'step', 'filecount')))
+				{
+					$upcontext['get_data'][$k] = $v;
+				}
+			}
+			template_xml_above();
+		}
+
+		// Call the template.
+		if (isset($upcontext['sub_template']))
+		{
+			$upcontext['upgrade_status']['curstep'] = $upcontext['current_step'];
+			$upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&amp;substep=' . $_GET['substep'] . '&amp;data=' . base64_encode(serialize($upcontext['upgrade_status']));
+
+			// Custom stuff to pass back?
+			if (!empty($upcontext['query_string']))
+				$upcontext['form_url'] .= $upcontext['query_string'];
+
+			call_user_func('template_' . $upcontext['sub_template']);
+		}
+
+		// Was there an error?
+		if (!empty($upcontext['forced_error_message']))
+			echo $upcontext['forced_error_message'];
+
+		// Show the footer.
+		if (!isset($_GET['xml']))
+			template_upgrade_below();
+		else
+			template_xml_below();
+	}
+
+	// Bang - gone!
+	die();
+}
+
+// Used to direct the user to another location.
+function redirectLocation($location, $addForm = true)
+{
+	global $upgradeurl, $upcontext, $command_line;
+
+	// Command line users can't be redirected.
+	if ($command_line)
+		upgradeExit(true);
+
+	// Are we providing the core info?
+	if ($addForm)
+	{
+		$upcontext['upgrade_status']['curstep'] = $upcontext['current_step'];
+		$location = $upgradeurl . '?step=' . $upcontext['current_step'] . '&substep=' . $_GET['substep'] . '&data=' . base64_encode(serialize($upcontext['upgrade_status'])) . $location;
+	}
+
+	while (@ob_end_clean());
+	header('Location: ' . strtr($location, array('&amp;' => '&')));
+
+	// Exit - saving status as we go.
+	upgradeExit(true);
+}
+
+// Load all essential data and connect to the DB as this is pre SSI.php
+function loadEssentialData()
+{
+	global $db_server, $db_user, $db_passwd, $db_name, $db_connection, $db_prefix, $db_character_set, $db_type;
+	global $modSettings, $sourcedir, $smcFunc, $upcontext;
+
+	// Do the non-SSI stuff...
+	@set_magic_quotes_runtime(0);
+	error_reporting(E_ALL);
+	define('SMF', 1);
+
+	// Start the session.
+	if (@ini_get('session.save_handler') == 'user')
+		@ini_set('session.save_handler', 'files');
+	@session_start();
+
+	if (empty($smcFunc))
+		$smcFunc = array();
+
+	// Check we don't need some compatibility.
+	if (@version_compare(PHP_VERSION, '5.1', '<='))
+		require_once($sourcedir . '/Subs-Compat.php');
+
+	// Initialize everything...
+	initialize_inputs();
+
+	// Get the database going!
+	if (empty($db_type))
+		$db_type = 'mysql';
+	if (file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php'))
+	{
+		require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
+
+		// Make the connection...
+		$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true));
+
+		// Oh dear god!!
+		if ($db_connection === null)
+			die('Unable to connect to database - please check username and password are correct in Settings.php');
+
+		if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1)
+			$smcFunc['db_query']('', '
+			SET NAMES ' . $db_character_set,
+			array(
+				'db_error_skip' => true,
+			)
+		);
+
+		// Load the modSettings data...
+		$request = $smcFunc['db_query']('', '
+			SELECT variable, value
+			FROM {db_prefix}settings',
+			array(
+				'db_error_skip' => true,
+			)
+		);
+		$modSettings = array();
+		while ($row = $smcFunc['db_fetch_assoc']($request))
+			$modSettings[$row['variable']] = $row['value'];
+		$smcFunc['db_free_result']($request);
+	}
+	else
+	{
+		return throw_error('Cannot find ' . $sourcedir . '/Subs-Db-' . $db_type . '.php' . '. Please check you have uploaded all source files and have the correct paths set.');
+	}
+
+	// If they don't have the file, they're going to get a warning anyway so we won't need to clean request vars.
+	if (file_exists($sourcedir . '/QueryString.php'))
+	{
+		require_once($sourcedir . '/QueryString.php');
+		cleanRequest();
+	}
+
+	if (!isset($_GET['substep']))
+		$_GET['substep'] = 0;
+}
+
+function initialize_inputs()
+{
+	global $sourcedir, $start_time, $upcontext, $db_type;
+
+	$start_time = time();
+
+	umask(0);
+
+	// Fun.  Low PHP version...
+	if (!isset($_GET))
+	{
+		$GLOBALS['_GET']['step'] = 0;
+		return;
+	}
+
+	ob_start();
+
+	// Better to upgrade cleanly and fall apart than to screw everything up if things take too long.
+	ignore_user_abort(true);
+
+	// This is really quite simple; if ?delete is on the URL, delete the upgrader...
+	if (isset($_GET['delete']))
+	{
+		@unlink(__FILE__);
+
+		// And the extra little files ;).
+		@unlink(dirname(__FILE__) . '/upgrade_1-0.sql');
+		@unlink(dirname(__FILE__) . '/upgrade_1-1.sql');
+		@unlink(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql');
+		@unlink(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql');
+		@unlink(dirname(__FILE__) . '/webinstall.php');
+
+		$dh = opendir(dirname(__FILE__));
+		while ($file = readdir($dh))
+		{
+			if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1]))
+				@unlink(dirname(__FILE__) . '/' . $file);
+		}
+		closedir($dh);
+
+		header('Location: http://' . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT']) . dirname($_SERVER['PHP_SELF']) . '/Themes/default/images/blank.gif');
+		exit;
+	}
+
+	// Are we calling the backup css file?
+	if (isset($_GET['infile_css']))
+	{
+		header('Content-Type: text/css');
+		template_css();
+		exit;
+	}
+
+	// Anybody home?
+	if (!isset($_GET['xml']))
+	{
+		$upcontext['remote_files_available'] = false;
+		$test = @fsockopen('www.simplemachines.org', 80, $errno, $errstr, 1);
+		if ($test)
+			$upcontext['remote_files_available'] = true;
+		@fclose($test);
+	}
+
+	// Something is causing this to happen, and it's annoying.  Stop it.
+	$temp = 'upgrade_php?step';
+	while (strlen($temp) > 4)
+	{
+		if (isset($_GET[$temp]))
+			unset($_GET[$temp]);
+		$temp = substr($temp, 1);
+	}
+
+	// Force a step, defaulting to 0.
+	$_GET['step'] = (int) @$_GET['step'];
+	$_GET['substep'] = (int) @$_GET['substep'];
+}
+
+// Step 0 - Let's welcome them in and ask them to login!
+function WelcomeLogin()
+{
+	global $boarddir, $sourcedir, $db_prefix, $language, $modSettings, $cachedir, $upgradeurl, $upcontext, $disable_security;
+	global $smcFunc, $db_type, $databases, $txt;
+
+	$upcontext['sub_template'] = 'welcome_message';
+
+	// Check for some key files - one template, one language, and a new and an old source file.
+	$check = @file_exists($boarddir . '/Themes/default/index.template.php')
+		&& @file_exists($sourcedir . '/QueryString.php')
+		&& @file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')
+		&& @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql');
+
+	// Need legacy scripts?
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1)
+		$check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql');
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0)
+		$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql');
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1)
+		$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql');
+
+	if (!$check)
+		// Don't tell them what files exactly because it's a spot check - just like teachers don't tell which problems they are spot checking, that's dumb.
+		return throw_error('The upgrader was unable to find some crucial files.<br /><br />Please make sure you uploaded all of the files included in the package, including the Themes, Sources, and other directories.');
+
+	// Do they meet the install requirements?
+	if (!php_version_check())
+		return throw_error('Warning!  You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br /><br />Please ask your host to upgrade.');
+
+	if (!db_version_check())
+		return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br /><br />Please ask your host to upgrade.');
+
+	// Do they have ALTER privileges?
+	if (!empty($databases[$db_type]['alter_support']) && $smcFunc['db_query']('alter_boards', 'ALTER TABLE {db_prefix}boards ORDER BY id_board', array()) === false)
+		return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br /><br />Please ask your host to give this user the ALTER, CREATE, and DROP privileges.');
+
+	// Do a quick version spot check.
+	$temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096);
+	preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match);
+	if (empty($match[1]) || $match[1] != SMF_VERSION)
+		return throw_error('The upgrader found some old or outdated files.<br /><br />Please make certain you uploaded the new versions of all the files included in the package.');
+
+	// What absolutely needs to be writable?
+	$writable_files = array(
+		$boarddir . '/Settings.php',
+		$boarddir . '/Settings_bak.php',
+	);
+
+	// Check the cache directory.
+	$cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir;
+	if (!file_exists($cachedir_temp))
+		@mkdir($cachedir_temp);
+	if (!file_exists($cachedir_temp))
+		return throw_error('The cache directory could not be found.<br /><br />Please make sure you have a directory called &quot;cache&quot; in your forum directory before continuing.');
+
+	if (!file_exists($boarddir . '/Themes/default/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang']))
+		return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br />SMF will not work without the primary language files installed.<br /><br />Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.');
+	elseif (!isset($_GET['skiplang']))
+	{
+		$temp = substr(@implode('', @file($boarddir . '/Themes/default/languages/index.' . $upcontext['language'] . '.php')), 0, 4096);
+		preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
+
+		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
+			return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br /><br />Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br />&nbsp;&nbsp;&nbsp;[<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]');
+	}
+
+	// This needs to exist!
+	if (!file_exists($boarddir . '/Themes/default/languages/Install.' . $upcontext['language'] . '.php'))
+		return throw_error('The upgrader could not find the &quot;Install&quot; language file for the forum default language, ' . $upcontext['language'] . '.<br /><br />Please make certain you uploaded all the files included in the package, even the theme and language files for the default theme.<br />&nbsp;&nbsp;&nbsp;[<a href="' . $upgradeurl . '?lang=english">Try English</a>]');
+	else
+		require_once($boarddir . '/Themes/default/languages/Install.' . $upcontext['language'] . '.php');
+
+	if (!makeFilesWritable($writable_files))
+		return false;
+
+	// Check agreement.txt. (it may not exist, in which case $boarddir must be writable.)
+	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt'))
+		return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br /><br />If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br />If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.');
+
+	// Upgrade the agreement.
+	elseif (isset($modSettings['agreement']))
+	{
+		$fp = fopen($boarddir . '/agreement.txt', 'w');
+		fwrite($fp, $modSettings['agreement']);
+		fclose($fp);
+	}
+
+	// We're going to check that their board dir setting is right incase they've been moving stuff around.
+	if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => '')))
+		$upcontext['warning'] = '
+			It looks as if your board directory settings <em>might</em> be incorrect. Your board directory is currently set to &quot;' . $boarddir . '&quot; but should probably be &quot;' . dirname(__FILE__) . '&quot;. Settings.php currently lists your paths as:<br />
+			<ul>
+				<li>Board Directory: ' . $boarddir . '</li>
+				<li>Source Directory: ' . $boarddir . '</li>
+				<li>Cache Directory: ' . $cachedir_temp . '</li>
+			</ul>
+			If these seem incorrect please open Settings.php in a text editor before proceeding with this upgrade. If they are incorrect due to you moving your forum to a new location please download and execute the <a href="http://download.simplemachines.org/?tools">Repair Settings</a> tool from the Simple Machines website before continuing.';
+
+	// Either we're logged in or we're going to present the login.
+	if (checkLogin())
+		return true;
+
+	return false;
+}
+
+// Step 0.5: Does the login work?
+function checkLogin()
+{
+	global $boarddir, $sourcedir, $db_prefix, $language, $modSettings, $cachedir, $upgradeurl, $upcontext, $disable_security;
+	global $smcFunc, $db_type, $databases, $support_js, $txt;
+
+	// Are we trying to login?
+	if (isset($_POST['contbutt']) && (!empty($_POST['user']) || $disable_security))
+	{
+		// If we've disabled security pick a suitable name!
+		if (empty($_POST['user']))
+			$_POST['user'] = 'Administrator';
+
+		// Before 2.0 these column names were different!
+		$oldDB = false;
+		if (empty($db_type) || $db_type == 'mysql')
+		{
+			$request = $smcFunc['db_query']('', '
+				SHOW COLUMNS
+				FROM {db_prefix}members
+				LIKE {string:member_name}',
+				array(
+					'member_name' => 'memberName',
+					'db_error_skip' => true,
+				)
+			);
+			if ($smcFunc['db_num_rows']($request) != 0)
+				$oldDB = true;
+			$smcFunc['db_free_result']($request);
+		}
+
+		// Get what we believe to be their details.
+		if (!$disable_security)
+		{
+			if ($oldDB)
+				$request = $smcFunc['db_query']('', '
+					SELECT id_member, memberName AS member_name, passwd, id_group,
+					additionalGroups AS additional_groups, lngfile
+					FROM {db_prefix}members
+					WHERE memberName = {string:member_name}',
+					array(
+						'member_name' => $_POST['user'],
+						'db_error_skip' => true,
+					)
+				);
+			else
+				$request = $smcFunc['db_query']('', '
+					SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile
+					FROM {db_prefix}members
+					WHERE member_name = {string:member_name}',
+					array(
+						'member_name' => $_POST['user'],
+						'db_error_skip' => true,
+					)
+				);
+			if ($smcFunc['db_num_rows']($request) != 0)
+			{
+				list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request);
+
+				$groups = explode(',', $addGroups);
+				$groups[] = $id_group;
+
+				foreach ($groups as $k => $v)
+					$groups[$k] = (int) $v;
+
+				// Figure out the password using SMF's encryption - if what they typed is right.
+				if (isset($_REQUEST['hash_passwrd']) && strlen($_REQUEST['hash_passwrd']) == 40)
+				{
+					// Challenge passed.
+					if ($_REQUEST['hash_passwrd'] == sha1($password . $upcontext['rid']))
+						$sha_passwd = $password;
+				}
+				else
+					$sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd']));
+			}
+			else
+				$upcontext['username_incorrect'] = true;
+			$smcFunc['db_free_result']($request);
+		}
+		$upcontext['username'] = $_POST['user'];
+
+		// Track whether javascript works!
+		if (!empty($_POST['js_works']))
+		{
+			$upcontext['upgrade_status']['js'] = 1;
+			$support_js = 1;
+		}
+		else
+			$support_js = 0;
+
+		// Note down the version we are coming from.
+		if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version']))
+			$upcontext['user']['version'] = $modSettings['smfVersion'];
+
+		// Didn't get anywhere?
+		if ((empty($sha_passwd) || $password != $sha_passwd) && empty($upcontext['username_incorrect']) && !$disable_security)
+		{
+			// MD5?
+			$md5pass = md5_hmac($_REQUEST['passwrd'], strtolower($_POST['user']));
+			if ($md5pass != $password)
+			{
+				$upcontext['password_failed'] = true;
+				// Disable the hashing this time.
+				$upcontext['disable_login_hashing'] = true;
+			}
+		}
+
+		if ((empty($upcontext['password_failed']) && !empty($name)) || $disable_security)
+		{
+			// Set the password.
+			if (!$disable_security)
+			{
+				// Do we actually have permission?
+				if (!in_array(1, $groups))
+				{
+					$request = $smcFunc['db_query']('', '
+						SELECT permission
+						FROM {db_prefix}permissions
+						WHERE id_group IN ({array_int:groups})
+							AND permission = {string:admin_forum}',
+						array(
+							'groups' => $groups,
+							'admin_forum' => 'admin_forum',
+							'db_error_skip' => true,
+						)
+					);
+					if ($smcFunc['db_num_rows']($request) == 0)
+						return throw_error('You need to be an admin to perform an upgrade!');
+					$smcFunc['db_free_result']($request);
+				}
+
+				$upcontext['user']['id'] = $id_member;
+				$upcontext['user']['name'] = $name;
+			}
+			else
+			{
+				$upcontext['user']['id'] = 1;
+				$upcontext['user']['name'] = 'Administrator';
+			}
+			$upcontext['user']['pass'] = mt_rand(0,60000);
+			// This basically is used to match the GET variables to Settings.php.
+			$upcontext['upgrade_status']['pass'] = $upcontext['user']['pass'];
+
+			// Set the language to that of the user?
+			if (isset($user_language) && $user_language != $upcontext['language'] && file_exists($boarddir . '/Themes/default/languages/index.' . basename($user_language, '.lng') . '.php'))
+			{
+				$user_language = basename($user_language, '.lng');
+				$temp = substr(@implode('', @file($boarddir . '/Themes/default/languages/index.' . $user_language . '.php')), 0, 4096);
+				preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
+
+				if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
+					$upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been updated to the latest version. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.';
+				elseif (!file_exists($boarddir . '/Themes/default/languages/Install.' . basename($user_language, '.lng') . '.php'))
+					$upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the &quot;Install&quot; language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.';
+				else
+				{
+					// Set this as the new language.
+					$upcontext['language'] = $user_language;
+					$upcontext['upgrade_status']['lang'] = $upcontext['language'];
+
+					// Include the file.
+					require_once($boarddir . '/Themes/default/languages/Install.' . $user_language . '.php');
+				}
+			}
+
+			// If we're resuming set the step and substep to be correct.
+			if (isset($_POST['cont']))
+			{
+				$upcontext['current_step'] = $upcontext['user']['step'];
+				$_GET['substep'] = $upcontext['user']['substep'];
+			}
+
+			return true;
+		}
+	}
+
+	return false;
+}
+
+// Step 1: Do the maintenance and backup.
+function UpgradeOptions()
+{
+	global $db_prefix, $command_line, $modSettings, $is_debug, $smcFunc;
+	global $boarddir, $boardurl, $sourcedir, $maintenance, $mmessage, $cachedir, $upcontext, $db_type;
+
+	$upcontext['sub_template'] = 'upgrade_options';
+	$upcontext['page_title'] = 'Upgrade Options';
+
+	// If we've not submitted then we're done.
+	if (empty($_POST['upcont']))
+		return false;
+
+	// Firstly, if they're enabling SM stat collection just do it.
+	if (!empty($_POST['stats']) && substr($boardurl, 0, 16) != 'http://localhost' && empty($modSettings['allow_sm_stats']))
+	{
+		// Attempt to register the site etc.
+		$fp = @fsockopen('www.simplemachines.org', 80, $errno, $errstr);
+		if ($fp)
+		{
+			$out = 'GET /smf/stats/register_stats.php?site=' . base64_encode($boardurl) . ' HTTP/1.1' . "\r\n";
+			$out .= 'Host: www.simplemachines.org' . "\r\n";
+			$out .= 'Connection: Close' . "\r\n\r\n";
+			fwrite($fp, $out);
+
+			$return_data = '';
+			while (!feof($fp))
+				$return_data .= fgets($fp, 128);
+
+			fclose($fp);
+
+			// Get the unique site ID.
+			preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID);
+
+			if (!empty($ID[1]))
+				$smcFunc['db_insert']('replace',
+					$db_prefix . 'settings',
+					array('variable' => 'string', 'value' => 'string'),
+					array('allow_sm_stats', $ID[1]),
+					array('variable')
+				);
+		}
+	}
+	else
+		$smcFunc['db_query']('', '
+			DELETE FROM {db_prefix}settings
+			WHERE variable = {string:allow_sm_stats}',
+			array(
+				'allow_sm_stats' => 'allow_sm_stats',
+				'db_error_skip' => true,
+			)
+		);
+
+	// Emptying the error log?
+	if (!empty($_POST['empty_error']))
+		$smcFunc['db_query']('truncate_table', '
+			TRUNCATE {db_prefix}log_errors',
+			array(
+			)
+		);
+
+	$changes = array();
+
+	// If we're overriding the language follow it through.
+	if (isset($_GET['lang']) && file_exists($boarddir . '/Themes/default/languages/index.' . $_GET['lang'] . '.php'))
+		$changes['language'] = '\'' . $_GET['lang'] . '\'';
+
+	if (!empty($_POST['maint']))
+	{
+		$changes['maintenance'] = '2';
+		// Remember what it was...
+		$upcontext['user']['main'] = $maintenance;
+
+		if (!empty($_POST['maintitle']))
+		{
+			$changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\'';
+			$changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\'';
+		}
+		else
+		{
+			$changes['mtitle'] = '\'Upgrading the forum...\'';
+			$changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum.  It will only be a minute ;).\'';
+		}
+	}
+
+	if ($command_line)
+		echo ' * Updating Settings.php...';
+
+	// Backup the current one first.
+	copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php');
+
+	// Fix some old paths.
+	if (substr($boarddir, 0, 1) == '.')
+		$changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\'';
+
+	if (substr($sourcedir, 0, 1) == '.')
+		$changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\'';
+
+	if (empty($cachedir) || substr($cachedir, 0, 1) == '.')
+		$changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\'';
+
+	// Not had the database type added before?
+	if (empty($db_type))
+		$changes['db_type'] = 'mysql';
+
+	// @todo Maybe change the cookie name if going to 1.1, too?
+
+	// Update Settings.php with the new settings.
+	changeSettings($changes);
+
+	if ($command_line)
+		echo ' Successful.' . "\n";
+
+	// Are we doing debug?
+	if (isset($_POST['debug']))
+	{
+		$upcontext['upgrade_status']['debug'] = true;
+		$is_debug = true;
+	}
+
+	// If we're not backing up then jump one.
+	if (empty($_POST['backup']))
+		$upcontext['current_step']++;
+
+	// If we've got here then let's proceed to the next step!
+	return true;
+}
+
+// Backup the database - why not...
+function BackupDatabase()
+{
+	global $upcontext, $db_prefix, $command_line, $is_debug, $support_js, $file_steps, $smcFunc;
+
+	$upcontext['sub_template'] = isset($_GET['xml']) ? 'backup_xml' : 'backup_database';
+	$upcontext['page_title'] = 'Backup Database';
+
+	// Done it already - js wise?
+	if (!empty($_POST['backup_done']))
+		return true;
+
+	// Some useful stuff here.
+	db_extend();
+
+	// Get all the table names.
+	$filter = str_replace('_', '\_', preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) != 0 ? $match[2] : $db_prefix) . '%';
+	$db = preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) != 0 ? strtr($match[1], array('`' => '')) : false;
+	$tables = $smcFunc['db_list_tables']($db, $filter);
+
+	$table_names = array();
+	foreach ($tables as $table)
+		if (substr($table, 0, 7) !== 'backup_')
+			$table_names[] = $table;
+
+	$upcontext['table_count'] = count($table_names);
+	$upcontext['cur_table_num'] = $_GET['substep'];
+	$upcontext['cur_table_name'] = str_replace($db_prefix, '', isset($table_names[$_GET['substep']]) ? $table_names[$_GET['substep']] : $table_names[0]);
+	$upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100);
+	// For non-java auto submit...
+	$file_steps = $upcontext['table_count'];
+
+	// What ones have we already done?
+	foreach ($table_names as $id => $table)
+		if ($id < $_GET['substep'])
+			$upcontext['previous_tables'][] = $table;
+
+	if ($command_line)
+		echo 'Backing Up Tables.';
+
+	// If we don't support javascript we backup here.
+	if (!$support_js || isset($_GET['xml']))
+	{
+		// Backup each table!
+		for ($substep = $_GET['substep'], $n = count($table_names); $substep < $n; $substep++)
+		{
+			$upcontext['cur_table_name'] = str_replace($db_prefix, '', (isset($table_names[$substep + 1]) ? $table_names[$substep + 1] : $table_names[$substep]));
+			$upcontext['cur_table_num'] = $substep + 1;
+
+			$upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100);
+
+			// Do we need to pause?
+			nextSubstep($substep);
+
+			backupTable($table_names[$substep]);
+
+			// If this is XML to keep it nice for the user do one table at a time anyway!
+			if (isset($_GET['xml']))
+				return upgradeExit();
+		}
+
+		if ($is_debug && $command_line)
+		{
+			echo "\n" . ' Successful.\'' . "\n";
+			flush();
+		}
+		$upcontext['step_progress'] = 100;
+
+		$_GET['substep'] = 0;
+		// Make sure we move on!
+		return true;
+	}
+
+	// Either way next place to post will be database changes!
+	$_GET['substep'] = 0;
+	return false;
+}
+
+// Backup one table...
+function backupTable($table)
+{
+	global $is_debug, $command_line, $db_prefix, $smcFunc;
+
+	if ($is_debug && $command_line)
+	{
+		echo "\n" . ' +++ Backing up \"' . str_replace($db_prefix, '', $table) . '"...';
+		flush();
+	}
+
+	$smcFunc['db_backup_table']($table, 'backup_' . $table);
+
+	if ($is_debug && $command_line)
+		echo ' done.';
+}
+
+// Step 2: Everything.
+function DatabaseChanges()
+{
+	global $db_prefix, $modSettings, $command_line, $smcFunc;
+	global $language, $boardurl, $sourcedir, $boarddir, $upcontext, $support_js, $db_type;
+
+	// Have we just completed this?
+	if (!empty($_POST['database_done']))
+		return true;
+
+	$upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes';
+	$upcontext['page_title'] = 'Database Changes';
+
+	// All possible files.
+	// Name, <version, insert_on_complete
+	$files = array(
+		array('upgrade_1-0.sql', '1.1', '1.1 RC0'),
+		array('upgrade_1-1.sql', '2.0', '2.0 a'),
+		array('upgrade_2-0_' . $db_type . '.sql', '2.1', '2.1 dev0'),
+		array('upgrade_2-1_' . $db_type . '.sql', '3.0', SMF_VERSION),
+	);
+
+	// How many files are there in total?
+	if (isset($_GET['filecount']))
+		$upcontext['file_count'] = (int) $_GET['filecount'];
+	else
+	{
+		$upcontext['file_count'] = 0;
+		foreach ($files as $file)
+		{
+			if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1])
+				$upcontext['file_count']++;
+		}
+	}
+
+	// Do each file!
+	$did_not_do = count($files) - $upcontext['file_count'];
+	$upcontext['step_progress'] = 0;
+	$upcontext['cur_file_num'] = 0;
+	foreach ($files as $file)
+	{
+		if ($did_not_do)
+			$did_not_do--;
+		else
+		{
+			$upcontext['cur_file_num']++;
+			$upcontext['cur_file_name'] = $file[0];
+			// Do we actually need to do this still?
+			if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1])
+			{
+				$nextFile = parse_sql(dirname(__FILE__) . '/' . $file[0]);
+				if ($nextFile)
+				{
+					// Only update the version of this if complete.
+					$smcFunc['db_insert']('replace',
+						$db_prefix . 'settings',
+						array('variable' => 'string', 'value' => 'string'),
+						array('smfVersion', $file[2]),
+						array('variable')
+					);
+
+					$modSettings['smfVersion'] = $file[2];
+				}
+
+				// If this is XML we only do this stuff once.
+				if (isset($_GET['xml']))
+				{
+					// Flag to move on to the next.
+					$upcontext['completed_step'] = true;
+					// Did we complete the whole file?
+					if ($nextFile)
+						$upcontext['current_debug_item_num'] = -1;
+					return upgradeExit();
+				}
+				elseif ($support_js)
+					break;
+			}
+			// Set the progress bar to be right as if we had - even if we hadn't...
+			$upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100;
+		}
+	}
+
+	$_GET['substep'] = 0;
+	// So the template knows we're done.
+	if (!$support_js)
+	{
+		$upcontext['changes_complete'] = true;
+
+		// If this is the command line we can't do any more.
+		if ($command_line)
+			return DeleteUpgrade();
+
+		return true;
+	}
+	return false;
+}
+
+// Clean up any mods installed...
+function CleanupMods()
+{
+	global $db_prefix, $modSettings, $upcontext, $boarddir, $sourcedir, $settings, $smcFunc, $command_line;
+
+	// Sorry. Not supported for command line users.
+	if ($command_line)
+		return true;
+
+	// Skipping first?
+	if (!empty($_POST['skip']))
+	{
+		unset($_POST['skip']);
+		return true;
+	}
+
+	// If we get here withOUT SSI we need to redirect to ensure we get it!
+	if (!isset($_GET['ssi']) || !function_exists('mktree'))
+		redirectLocation('&ssi=1');
+
+	$upcontext['sub_template'] = 'clean_mods';
+	$upcontext['page_title'] = 'Cleanup Modifications';
+
+	// This can be skipped.
+	$upcontext['skip'] = true;
+
+	// If we're on the second redirect continue...
+	if (isset($_POST['cleandone2']))
+		return true;
+
+	// Do we already know about some writable files?
+	if (isset($_POST['writable_files']))
+	{
+		$writable_files = unserialize(base64_decode($_POST['writable_files']));
+		if (!makeFilesWritable($writable_files))
+		{
+			// What have we left?
+			$upcontext['writable_files'] = $writable_files;
+			return false;
+		}
+	}
+
+	// Load all theme paths....
+	$request = $smcFunc['db_query']('', '
+		SELECT id_theme, variable, value
+		FROM {db_prefix}themes
+		WHERE id_member = {int:id_member}
+			AND variable IN ({string:theme_dir}, {string:images_url})',
+		array(
+			'id_member' => 0,
+			'theme_dir' => 'theme_dir',
+			'images_url' => 'images_url',
+			'db_error_skip' => true,
+		)
+	);
+	$theme_paths = array();
+	while ($row = $smcFunc['db_fetch_assoc']($request))
+	{
+		if ($row['id_theme'] == 1)
+			$settings['default_' . $row['variable']] = $row['value'];
+		elseif ($row['variable'] == 'theme_dir')
+			$theme_paths[$row['id_theme']][$row['variable']] = $row['value'];
+	}
+	$smcFunc['db_free_result']($request);
+
+	// Are there are mods installed that may need uninstalling?
+	$request = $smcFunc['db_query']('', '
+		SELECT id_install, filename, name, themes_installed, version
+		FROM {db_prefix}log_packages
+		WHERE install_state = {int:installed}
+		ORDER BY time_installed DESC',
+		array(
+			'installed' => 1,
+			'db_error_skip' => true,
+		)
+	);
+	$upcontext['packages'] = array();
+	while ($row = $smcFunc['db_fetch_assoc']($request))
+	{
+		// Work out the status.
+		if (!file_exists($boarddir . '/Packages/' . $row['filename']))
+		{
+			$status = 'Missing';
+			$status_color = 'red';
+			$result = 'Removed';
+		}
+		else
+		{
+			$status = 'Installed';
+			$status_color = 'green';
+			$result = 'No Action Needed';
+		}
+
+		$upcontext['packages'][$row['id_install']] = array(
+			'id' => $row['id_install'],
+			'themes' => explode(',', $row['themes_installed']),
+			'name' => $row['name'],
+			'filename' => $row['filename'],
+			'missing_file' => file_exists($boarddir . '/Packages/' . $row['filename']) ? 0 : 1,
+			'files' => array(),
+			'file_count' => 0,
+			'status' => $status,
+			'result' => $result,
+			'color' => $status_color,
+			'version' => $row['version'],
+			'needs_removing' => false,
+		);
+	}
+	$smcFunc['db_free_result']($request);
+
+	// Don't carry on if there are none.
+	if (empty($upcontext['packages']))
+		return true;
+
+	// Setup some basics.
+	if (!empty($upcontext['user']['version']))
+		$_SESSION['version_emulate'] = $upcontext['user']['version'];
+
+	// Before we get started, don't report notice errors.
+	$oldErrorReporting = error_reporting(E_ALL ^ E_NOTICE);
+
+	if (!mktree($boarddir . '/Packages/temp', 0755))
+	{
+		deltree($boarddir . '/Packages/temp', false);
+		if (!mktree($boarddir . '/Packages/temp', 0777))
+		{
+			deltree($boarddir . '/Packages/temp', false);
+			// @todo Error here - plus chmod!
+		}
+	}
+
+	// Anything which reinstalled should not have its entry removed.
+	$reinstall_worked = array();
+
+	// We're gonna be doing some removin'
+	$test = isset($_POST['cleandone']) ? false : true;
+	foreach ($upcontext['packages'] as $id => $package)
+	{
+		// Can't do anything about this....
+		if ($package['missing_file'])
+			continue;
+
+		// Not testing *and* this wasn't checked?
+		if (!$test && (!isset($_POST['remove']) || !isset($_POST['remove'][$id])))
+			continue;
+
+		// What are the themes this was installed into?
+		$cur_theme_paths = array();
+		foreach ($theme_paths as $tid => $data)
+			if ($tid != 1 && in_array($tid, $package['themes']))
+				$cur_theme_paths[$tid] = $data;
+
+		// Get the modifications data if applicable.
+		$filename = $package['filename'];
+		$packageInfo = getPackageInfo($filename);
+		if (!is_array($packageInfo))
+			continue;
+
+		$info = parsePackageInfo($packageInfo['xml'], $test, 'uninstall');
+		// Also get the reinstall details...
+		if (isset($_POST['remove']))
+			$infoInstall = parsePackageInfo($packageInfo['xml'], true);
+
+		if (is_file($boarddir . '/Packages/' . $filename))
+			read_tgz_file($boarddir . '/Packages/' . $filename, $boarddir . '/Packages/temp');
+		else
+			copytree($boarddir . '/Packages/' . $filename, $boarddir . '/Packages/temp');
+
+		// Work out how we uninstall...
+		$files = array();
+		foreach ($info as $change)
+		{
+			// Work out two things:
+			// 1) Whether it's installed at the moment - and if so whether its fully installed, and:
+			// 2) Whether it could be installed on the new version.
+			if ($change['type'] == 'modification')
+			{
+				$contents = @file_get_contents($boarddir . '/Packages/temp/' . $upcontext['base_path'] . $change['filename']);
+				if ($change['boardmod'])
+					$results = parseBoardMod($contents, $test, $change['reverse'], $cur_theme_paths);
+				else
+					$results = parseModification($contents, $test, $change['reverse'], $cur_theme_paths);
+
+				foreach ($results as $action)
+				{
+					// Something we can remove? Probably means it existed!
+					if (($action['type'] == 'replace' || $action['type'] == 'append' || (!empty($action['filename']) && $action['type'] == 'failure')) && !in_array($action['filename'], $files))
+						$files[] = $action['filename'];
+					if ($action['type'] == 'failure')
+					{
+						$upcontext['packages'][$id]['needs_removing'] = true;
+						$upcontext['packages'][$id]['status'] = 'Reinstall Required';
+						$upcontext['packages'][$id]['color'] = '#FD6435';
+					}
+				}
+			}
+		}
+
+		// Store this info for the template as appropriate.
+		$upcontext['packages'][$id]['files'] = $files;
+		$upcontext['packages'][$id]['file_count'] = count($files);
+
+		// If we've done something save the changes!
+		if (!$test)
+			package_flush_cache();
+
+		// Are we attempting to reinstall this thing?
+		if (isset($_POST['remove']) && !$test && isset($infoInstall))
+		{
+			// Need to extract again I'm afraid.
+			if (is_file($boarddir . '/Packages/' . $filename))
+				read_tgz_file($boarddir . '/Packages/' . $filename, $boarddir . '/Packages/temp');
+			else
+				copytree($boarddir . '/Packages/' . $filename, $boarddir . '/Packages/temp');
+
+			$errors = false;
+			$upcontext['packages'][$id]['result'] = 'Removed';
+			foreach ($infoInstall as $change)
+			{
+				if ($change['type'] == 'modification')
+				{
+					$contents = @file_get_contents($boarddir . '/Packages/temp/' . $upcontext['base_path'] . $change['filename']);
+					if ($change['boardmod'])
+						$results = parseBoardMod($contents, true, $change['reverse'], $cur_theme_paths);
+					else
+						$results = parseModification($contents, true, $change['reverse'], $cur_theme_paths);
+
+					// Are there any errors?
+					foreach ($results as $action)
+						if ($action['type'] == 'failure')
+							$errors = true;
+				}
+			}
+			if (!$errors)
+			{
+				$reinstall_worked[] = $id;
+				$upcontext['packages'][$id]['result'] = 'Reinstalled';
+				$upcontext['packages'][$id]['color'] = 'green';
+				foreach ($infoInstall as $change)
+				{
+					if ($change['type'] == 'modification')
+					{
+						$contents = @file_get_contents($boarddir . '/Packages/temp/' . $upcontext['base_path'] . $change['filename']);
+						if ($change['boardmod'])
+							$results = parseBoardMod($contents, false, $change['reverse'], $cur_theme_paths);
+						else
+							$results = parseModification($contents, false, $change['reverse'], $cur_theme_paths);
+					}
+				}
+
+				// Save the changes.
+				package_flush_cache();
+			}
+		}
+	}
+
+	// Put errors back on a sec.
+	error_reporting($oldErrorReporting);
+
+	// Check everything is writable.
+	if ($test && !empty($upcontext['packages']))
+	{
+		$writable_files = array();
+		foreach ($upcontext['packages'] as $package)
+		{
+			if (!empty($package['files']))
+				foreach ($package['files'] as $file)
+					$writable_files[] = $file;
+		}
+
+		if (!empty($writable_files))
+		{
+			$writable_files = array_unique($writable_files);
+			$upcontext['writable_files'] = $writable_files;
+
+			if (!makeFilesWritable($writable_files))
+				return false;
+		}
+	}
+
+	if (file_exists($boarddir . '/Packages/temp'))
+		deltree($boarddir . '/Packages/temp');
+
+	// Removing/Reinstalling any packages?
+	if (isset($_POST['remove']))
+	{
+		$deletes = array();
+		foreach ($_POST['remove'] as $id => $dummy)
+		{
+			if (!in_array((int) $id, $reinstall_worked))
+				$deletes[] = (int) $id;
+		}
+
+		if (!empty($deletes))
+			upgrade_query( '
+				UPDATE ' . $db_prefix . 'log_packages
+				SET install_state = 0
+				WHERE id_install IN (' . implode(',', $deletes) . ')');
+
+		// Ensure we don't lose our changes!
+		package_put_contents($boarddir . '/Packages/installed.list', time());
+
+		$upcontext['sub_template'] = 'cleanup_done';
+		return false;
+	}
+	else
+	{
+		$allgood = true;
+		// Is there actually anything that needs our attention?
+		foreach ($upcontext['packages'] as $package)
+			if ($package['color'] != 'green')
+				$allgood = false;
+
+		if ($allgood)
+			return true;
+	}
+
+	$_GET['substep'] = 0;
+	return isset($_POST['cleandone']) ? true : false;
+}
+
+
+// Delete the damn thing!
+function DeleteUpgrade()
+{
+	global $command_line, $language, $upcontext, $boarddir, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type;
+
+	// Now it's nice to have some of the basic SMF source files.
+	if (!isset($_GET['ssi']) && !$command_line)
+		redirectLocation('&ssi=1');
+
+	$upcontext['sub_template'] = 'upgrade_complete';
+	$upcontext['page_title'] = 'Upgrade Complete';
+
+	$endl = $command_line ? "\n" : '<br />' . "\n";
+
+	$changes = array(
+		'language' => '\'' . (substr($language, -4) == '.lng' ? substr($language, 0, -4) : $language) . '\'',
+		'db_error_send' => '1',
+		'upgradeData' => '#remove#',
+	);
+
+	// Are we in maintenance mode?
+	if (isset($upcontext['user']['main']))
+	{
+		if ($command_line)
+			echo ' * ';
+		$upcontext['removed_maintenance'] = true;
+		$changes['maintenance'] = $upcontext['user']['main'];
+	}
+	// Otherwise if somehow we are in 2 let's go to 1.
+	elseif (!empty($maintenance) && $maintenance == 2)
+		$changes['maintenance'] = 1;
+
+	// Wipe this out...
+	$upcontext['user'] = array();
+
+	// Make a backup of Settings.php first as otherwise earlier changes are lost.
+	copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php');
+	changeSettings($changes);
+
+	// Clean any old cache files away.
+	clean_cache();
+
+	// Can we delete the file?
+	$upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__);
+
+	// Now is the perfect time to fetch the SM files.
+	if ($command_line)
+		cli_scheduled_fetchSMfiles();
+	else
+	{
+		require_once($sourcedir . '/ScheduledTasks.php');
+		$forum_version = SMF_VERSION;  // The variable is usually defined in index.php so lets just use the constant to do it for us.
+		scheduled_fetchSMfiles(); // Now go get those files!
+	}
+
+	// Log what we've done.
+	if (empty($user_info['id']))
+		$user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0;
+
+	// Log the action manually, so CLI still works.
+	$smcFunc['db_insert']('',
+		'{db_prefix}log_actions',
+		array(
+			'log_time' => 'int', 'id_log' => 'int', 'id_member' => 'int', 'ip' => 'string-16', 'action' => 'string',
+			'id_board' => 'int', 'id_topic' => 'int', 'id_msg' => 'int', 'extra' => 'string-65534',
+		),
+		array(
+			time(), 3, $user_info['id'], $command_line ? '127.0.0.1' : $user_info['ip'], 'upgrade',
+			0, 0, 0, serialize(array('version' => $forum_version, 'member' => $user_info['id'])),
+		),
+		array('id_action')
+	);
+	$user_info['id'] = 0;
+
+	// Save the current database version.
+	$server_version = $smcFunc['db_server_info']();
+	if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51')))
+		updateSettings(array('db_mysql_group_by_fix' => '1'));
+
+	if ($command_line)
+	{
+		echo $endl;
+		echo 'Upgrade Complete!', $endl;
+		echo 'Please delete this file as soon as possible for security reasons.', $endl;
+		exit;
+	}
+
+	// Make sure it says we're done.
+	$upcontext['overall_percent'] = 100;
+	if (isset($upcontext['step_progress']))
+		unset($upcontext['step_progress']);
+
+	$_GET['substep'] = 0;
+	return false;
+}
+
+// Just like the built in one, but setup for CLI to not use themes.
+function cli_scheduled_fetchSMfiles()
+{
+	global $sourcedir, $txt, $language, $settings, $forum_version, $modSettings, $smcFunc;
+
+	if (empty($modSettings['time_format']))
+		$modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p';
+
+	// What files do we want to get
+	$request = $smcFunc['db_query']('', '
+		SELECT id_file, filename, path, parameters
+		FROM {db_prefix}admin_info_files',
+		array(
+		)
+	);
+
+	$js_files = array();
+	while ($row = $smcFunc['db_fetch_assoc']($request))
+	{
+		$js_files[$row['id_file']] = array(
+			'filename' => $row['filename'],
+			'path' => $row['path'],
+			'parameters' => sprintf($row['parameters'], $language, urlencode($modSettings['time_format']), urlencode($forum_version)),
+		);
+	}
+	$smcFunc['db_free_result']($request);
+
+	// We're gonna need fetch_web_data() to pull this off.
+	require_once($sourcedir . '/Subs-Package.php');
+
+	foreach ($js_files as $ID_FILE => $file)
+	{
+		// Create the url
+		$server = empty($file['path']) || substr($file['path'], 0, 7) != 'http://' ? 'http://www.simplemachines.org' : '';
+		$url = $server . (!empty($file['path']) ? $file['path'] : $file['path']) . $file['filename'] . (!empty($file['parameters']) ? '?' . $file['parameters'] : '');
+
+		// Get the file
+		$file_data = fetch_web_data($url);
+
+		// If we got an error - give up - the site might be down.
+		if ($file_data === false)
+			return throw_error(sprintf('Could not retrieve the file %1$s.', $url));
+
+		// Save the file to the database.
+		$smcFunc['db_query']('substring', '
+			UPDATE {db_prefix}admin_info_files
+			SET data = SUBSTRING({string:file_data}, 1, 65534)
+			WHERE id_file = {int:id_file}',
+			array(
+				'id_file' => $ID_FILE,
+				'file_data' => $file_data,
+			)
+		);
+	}
+	return true;
+}
+
+function convertSettingsToTheme()
+{
+	global $db_prefix, $modSettings, $smcFunc;
+
+	$values = array(
+		'show_latest_member' => @$GLOBALS['showlatestmember'],
+		'show_bbc' => isset($GLOBALS['showyabbcbutt']) ? $GLOBALS['showyabbcbutt'] : @$GLOBALS['showbbcbutt'],
+		'show_modify' => @$GLOBALS['showmodify'],
+		'show_user_images' => @$GLOBALS['showuserpic'],
+		'show_blurb' => @$GLOBALS['showusertext'],
+		'show_gender' => @$GLOBALS['showgenderimage'],
+		'show_newsfader' => @$GLOBALS['shownewsfader'],
+		'display_recent_bar' => @$GLOBALS['Show_RecentBar'],
+		'show_member_bar' => @$GLOBALS['Show_MemberBar'],
+		'linktree_link' => @$GLOBALS['curposlinks'],
+		'show_profile_buttons' => @$GLOBALS['profilebutton'],
+		'show_mark_read' => @$GLOBALS['showmarkread'],
+		'show_board_desc' => @$GLOBALS['ShowBDescrip'],
+		'newsfader_time' => @$GLOBALS['fadertime'],
+		'use_image_buttons' => empty($GLOBALS['MenuType']) ? 1 : 0,
+		'enable_news' => @$GLOBALS['enable_news'],
+		'linktree_inline' => @$modSettings['enableInlineLinks'],
+		'return_to_post' => @$modSettings['returnToPost'],
+	);
+
+	$themeData = array();
+	foreach ($values as $variable => $value)
+	{
+		if (!isset($value) || $value === null)
+			$value = 0;
+
+		$themeData[] = array(0, 1, $variable, $value);
+	}
+	if (!empty($themeData))
+	{
+		$smcFunc['db_insert']('ignore',
+			$db_prefix . 'themes',
+			array('id_member' => 'int', 'id_theme' => 'int', 'variable' => 'string', 'value' => 'string'),
+			$themeData,
+			array('id_member', 'id_theme', 'variable')
+		);
+	}
+}
+
+// This function only works with MySQL but that's fine as it is only used for v1.0.
+function convertSettingstoOptions()
+{
+	global $db_prefix, $modSettings, $smcFunc;
+
+	// Format: new_setting -> old_setting_name.
+	$values = array(
+		'calendar_start_day' => 'cal_startmonday',
+		'view_newest_first' => 'viewNewestFirst',
+		'view_newest_pm_first' => 'viewNewestFirst',
+	);
+
+	foreach ($values as $variable => $value)
+	{
+		if (empty($modSettings[$value[0]]))
+			continue;
+
+		$smcFunc['db_query']('', '
+			INSERT IGNORE INTO {db_prefix}themes
+				(id_member, id_theme, variable, value)
+			SELECT id_member, 1, {string:variable}, {string:value}
+			FROM {db_prefix}members',
+			array(
+				'variable' => $variable,
+				'value' => $modSettings[$value[0]],
+				'db_error_skip' => true,
+			)
+		);
+
+		$smcFunc['db_query']('', '
+			INSERT IGNORE INTO {db_prefix}themes
+				(id_member, id_theme, variable, value)
+			VALUES (-1, 1, {string:variable}, {string:value})',
+			array(
+				'variable' => $variable,
+				'value' => $modSettings[$value[0]],
+				'db_error_skip' => true,
+			)
+		);
+	}
+}
+
+function changeSettings($config_vars)
+{
+	global $boarddir;
+
+	$settingsArray = file($boarddir . '/Settings_bak.php');
+
+	if (count($settingsArray) == 1)
+		$settingsArray = preg_split('~[\r\n]~', $settingsArray[0]);
+
+	for ($i = 0, $n = count($settingsArray); $i < $n; $i++)
+	{
+		// Don't trim or bother with it if it's not a variable.
+		if (substr($settingsArray[$i], 0, 1) == '$')
+		{
+			$settingsArray[$i] = trim($settingsArray[$i]) . "\n";
+
+			foreach ($config_vars as $var => $val)
+			{
+				if (isset($settingsArray[$i]) && strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
+				{
+					if ($val == '#remove#')
+						unset($settingsArray[$i]);
+					else
+					{
+						$comment = strstr(substr($settingsArray[$i], strpos($settingsArray[$i], ';')), '#');
+						$settingsArray[$i] = '$' . $var . ' = ' . $val . ';' . ($comment != '' ? "\t\t" . $comment : "\n");
+					}
+
+					unset($config_vars[$var]);
+				}
+			}
+		}
+		if (isset($settingsArray[$i]))
+		{
+			if (trim(substr($settingsArray[$i], 0, 2)) == '?' . '>')
+				$end = $i;
+		}
+	}
+
+	// Assume end-of-file if the end wasn't found.
+	if (empty($end) || $end < 10)
+		$end = count($settingsArray);
+
+	if (!empty($config_vars))
+	{
+		$settingsArray[$end++] = '';
+		foreach ($config_vars as $var => $val)
+		{
+			if ($val != '#remove#')
+				$settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n";
+		}
+	}
+	// This should be the last line and even last bytes of the file.
+	$settingsArray[$end] = '?' . '>';
+
+	// Blank out the file - done to fix a oddity with some servers.
+	$fp = fopen($boarddir . '/Settings.php', 'w');
+	fclose($fp);
+
+	$fp = fopen($boarddir . '/Settings.php', 'r+');
+	for ($i = 0; $i < $end; $i++)
+	{
+		if (isset($settingsArray[$i]))
+			fwrite($fp, strtr($settingsArray[$i], "\r", ''));
+	}
+	fwrite($fp, rtrim($settingsArray[$i]));
+	fclose($fp);
+}
+
+function php_version_check()
+{
+	$minver = explode('.', $GLOBALS['required_php_version']);
+	$curver = explode('.', PHP_VERSION);
+
+	return !(($curver[0] <= $minver[0]) && ($curver[1] <= $minver[1]) && ($curver[1] <= $minver[1]) && ($curver[2][0] < $minver[2][0]));
+}
+
+function db_version_check()
+{
+	global $db_type, $databases;
+
+	$curver = eval($databases[$db_type]['version_check']);
+	$curver = preg_replace('~\-.+?$~', '', $curver);
+
+	return version_compare($databases[$db_type]['version'], $curver, '<=');
+}
+
+function getMemberGroups()
+{
+	global $db_prefix, $smcFunc;
+	static $member_groups = array();
+
+	if (!empty($member_groups))
+		return $member_groups;
+
+	$request = $smcFunc['db_query']('', '
+		SELECT group_name, id_group
+		FROM {db_prefix}membergroups
+		WHERE id_group = {int:admin_group} OR id_group > {int:old_group}',
+		array(
+			'admin_group' => 1,
+			'old_group' => 7,
+			'db_error_skip' => true,
+		)
+	);
+	if ($request === false)
+	{
+		$request = $smcFunc['db_query']('', '
+			SELECT membergroup, id_group
+			FROM {db_prefix}membergroups
+			WHERE id_group = {int:admin_group} OR id_group > {int:old_group}',
+			array(
+				'admin_group' => 1,
+				'old_group' => 7,
+				'db_error_skip' => true,
+			)
+		);
+	}
+	while ($row = $smcFunc['db_fetch_row']($request))
+		$member_groups[trim($row[0])] = $row[1];
+	$smcFunc['db_free_result']($request);
+
+	return $member_groups;
+}
+
+function fixRelativePath($path)
+{
+	global $install_path;
+
+	// Fix the . at the start, clear any duplicate slashes, and fix any trailing slash...
+	return addslashes(preg_replace(array('~^\.([/\\\]|$)~', '~[/]+~', '~[\\\]+~', '~[/\\\]$~'), array($install_path . '$1', '/', '\\', ''), $path));
+}
+
+function parse_sql($filename)
+{
+	global $db_prefix, $db_collation, $boarddir, $boardurl, $command_line, $file_steps, $step_progress, $custom_warning;
+	global $upcontext, $support_js, $is_debug, $smcFunc, $db_connection, $databases, $db_type, $db_character_set;
+
+/*
+	Failure allowed on:
+		- INSERT INTO but not INSERT IGNORE INTO.
+		- UPDATE IGNORE but not UPDATE.
+		- ALTER TABLE and ALTER IGNORE TABLE.
+		- DROP TABLE.
+	Yes, I realize that this is a bit confusing... maybe it should be done differently?
+
+	If a comment...
+		- begins with --- it is to be output, with a break only in debug mode. (and say successful\n\n if there was one before.)
+		- begins with ---# it is a debugging statement, no break - only shown at all in debug.
+		- is only ---#, it is "done." and then a break - only shown in debug.
+		- begins with ---{ it is a code block terminating at ---}.
+
+	Every block of between "--- ..."s is a step.  Every "---#" section represents a substep.
+
+	Replaces the following variables:
+		- {$boarddir}
+		- {$boardurl}
+		- {$db_prefix}
+		- {$db_collation}
+*/
+
+	// May want to use extended functionality.
+	db_extend();
+	db_extend('packages');
+
+	// Our custom error handler - does nothing but does stop public errors from XML!
+	if (!function_exists('sql_error_handler'))
+	{
+		function sql_error_handler($errno, $errstr, $errfile, $errline)
+		{
+			global $support_js;
+
+			if ($support_js)
+				return true;
+			else
+				echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline;
+		}
+	}
+
+	// Make our own error handler.
+	set_error_handler('sql_error_handler');
+
+	// If we're on MySQL supporting collations then let's find out what the members table uses and put it in a global var - to allow upgrade script to match collations!
+	if (!empty($databases[$db_type]['utf8_support']) && version_compare($databases[$db_type]['utf8_version'], eval($databases[$db_type]['utf8_version_check']), '>'))
+	{
+		$request = $smcFunc['db_query']('', '
+			SHOW TABLE STATUS
+			LIKE {string:table_name}',
+			array(
+				'table_name' => "{$db_prefix}members",
+				'db_error_skip' => true,
+			)
+		);
+		if ($smcFunc['db_num_rows']($request) === 0)
+			die('Unable to find members table!');
+		$table_status = $smcFunc['db_fetch_assoc']($request);
+		$smcFunc['db_free_result']($request);
+
+		if (!empty($table_status['Collation']))
+		{
+			$request = $smcFunc['db_query']('', '
+				SHOW COLLATION
+				LIKE {string:collation}',
+				array(
+					'collation' => $table_status['Collation'],
+					'db_error_skip' => true,
+				)
+			);
+			// Got something?
+			if ($smcFunc['db_num_rows']($request) !== 0)
+				$collation_info = $smcFunc['db_fetch_assoc']($request);
+			$smcFunc['db_free_result']($request);
+
+			// Excellent!
+			if (!empty($collation_info['Collation']) && !empty($collation_info['Charset']))
+				$db_collation = ' CHARACTER SET ' . $collation_info['Charset'] . ' COLLATE ' . $collation_info['Collation'];
+		}
+	}
+	if (empty($db_collation))
+		$db_collation = '';
+
+	$endl = $command_line ? "\n" : '<br />' . "\n";
+
+	$lines = file($filename);
+
+	$current_type = 'sql';
+	$current_data = '';
+	$substep = 0;
+	$last_step = '';
+
+	// Make sure all newly created tables will have the proper characters set.
+	if (isset($db_character_set) && $db_character_set === 'utf8')
+		$lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines);
+
+	// Count the total number of steps within this file - for progress.
+	$file_steps = substr_count(implode('', $lines), '---#');
+	$upcontext['total_items'] = substr_count(implode('', $lines), '--- ');
+	$upcontext['debug_items'] = $file_steps;
+	$upcontext['current_item_num'] = 0;
+	$upcontext['current_item_name'] = '';
+	$upcontext['current_debug_item_num'] = 0;
+	$upcontext['current_debug_item_name'] = '';
+	// This array keeps a record of what we've done in case java is dead...
+	$upcontext['actioned_items'] = array();
+
+	$done_something = false;
+
+	foreach ($lines as $line_number => $line)
+	{
+		$do_current = $substep >= $_GET['substep'];
+
+		// Get rid of any comments in the beginning of the line...
+		if (substr(trim($line), 0, 2) === '/*')
+			$line = preg_replace('~/\*.+?\*/~', '', $line);
+
+		// Always flush.  Flush, flush, flush.  Flush, flush, flush, flush!  FLUSH!
+		if ($is_debug && !$support_js && $command_line)
+			flush();
+
+		if (trim($line) === '')
+			continue;
+
+		if (trim(substr($line, 0, 3)) === '---')
+		{
+			$type = substr($line, 3, 1);
+
+			// An error??
+			if (trim($current_data) != '' && $type !== '}')
+			{
+				$upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl;
+				if ($command_line)
+					echo $upcontext['error_message'];
+			}
+
+			if ($type == ' ')
+			{
+				if (!$support_js && $do_current && $_GET['substep'] != 0 && $command_line)
+				{
+					echo ' Successful.', $endl;
+					flush();
+				}
+
+				$last_step = htmlspecialchars(rtrim(substr($line, 4)));
+				$upcontext['current_item_num']++;
+				$upcontext['current_item_name'] = $last_step;
+
+				if ($do_current)
+				{
+					$upcontext['actioned_items'][] = $last_step;
+					if ($command_line)
+						echo ' * ';
+				}
+			}
+			elseif ($type == '#')
+			{
+				$upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps;
+
+				$upcontext['current_debug_item_num']++;
+				if (trim($line) != '---#')
+					$upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4)));
+
+				// Have we already done something?
+				if (isset($_GET['xml']) && $done_something)
+				{
+					restore_error_handler();
+					return $upcontext['current_debug_item_num'] >= $upcontext['debug_items'] ? true : false;
+				}
+
+				if ($do_current)
+				{
+					if (trim($line) == '---#' && $command_line)
+						echo ' done.', $endl;
+					elseif ($command_line)
+						echo ' +++ ', rtrim(substr($line, 4));
+					elseif (trim($line) != '---#')
+					{
+						if ($is_debug)
+							$upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4)));
+					}
+				}
+
+				if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep'])
+				{
+					if ($command_line)
+						echo ' * ';
+					else
+						$upcontext['actioned_items'][] = $last_step;
+				}
+
+				// Small step - only if we're actually doing stuff.
+				if ($do_current)
+					nextSubstep(++$substep);
+				else
+					$substep++;
+			}
+			elseif ($type == '{')
+				$current_type = 'code';
+			elseif ($type == '}')
+			{
+				$current_type = 'sql';
+
+				if (!$do_current)
+				{
+					$current_data = '';
+					continue;
+				}
+
+				if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false)
+				{
+					$upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl;
+					if ($command_line)
+						echo $upcontext['error_message'];
+				}
+
+				// Done with code!
+				$current_data = '';
+				$done_something = true;
+			}
+
+			continue;
+		}
+
+		$current_data .= $line;
+		if (substr(rtrim($current_data), -1) === ';' && $current_type === 'sql')
+		{
+			if ((!$support_js || isset($_GET['xml'])))
+			{
+				if (!$do_current)
+				{
+					$current_data = '';
+					continue;
+				}
+
+				$current_data = strtr(substr(rtrim($current_data), 0, -1), array('{$db_prefix}' => $db_prefix, '{$boarddir}' => $boarddir, '{$sboarddir}' => addslashes($boarddir), '{$boardurl}' => $boardurl, '{$db_collation}' => $db_collation));
+
+				upgrade_query($current_data);
+
+				// @todo This will be how it kinda does it once mysql all stripped out - needed for postgre (etc).
+				/*
+				$result = $smcFunc['db_query']('', $current_data, false, false);
+				// Went wrong?
+				if (!$result)
+				{
+					// Bit of a bodge - do we want the error?
+					if (!empty($upcontext['return_error']))
+					{
+						$upcontext['error_message'] = $smcFunc['db_error']($db_connection);
+						return false;
+					}
+				}*/
+				$done_something = true;
+			}
+			$current_data = '';
+		}
+		// If this is xml based and we're just getting the item name then that's grand.
+		elseif ($support_js && !isset($_GET['xml']) && $upcontext['current_debug_item_name'] != '' && $do_current)
+		{
+			restore_error_handler();
+			return false;
+		}
+
+		// Clean up by cleaning any step info.
+		$step_progress = array();
+		$custom_warning = '';
+	}
+
+	// Put back the error handler.
+	restore_error_handler();
+
+	if ($command_line)
+	{
+		echo ' Successful.' . "\n";
+		flush();
+	}
+
+	$_GET['substep'] = 0;
+	return true;
+}
+
+function upgrade_query($string, $unbuffered = false)
+{
+	global $db_connection, $db_server, $db_user, $db_passwd, $db_type, $command_line, $upcontext, $upgradeurl, $modSettings;
+	global $db_name, $db_unbuffered, $smcFunc;
+
+	// Get the query result - working around some SMF specific security - just this once!
+	$modSettings['disableQueryCheck'] = true;
+	$db_unbuffered = $unbuffered;
+	$result = $smcFunc['db_query']('', $string, 'security_override');
+	$db_unbuffered = false;
+
+	// Failure?!
+	if ($result !== false)
+		return $result;
+
+	$db_error_message = $smcFunc['db_error']($db_connection);
+	// If MySQL we do something more clever.
+	if ($db_type == 'mysql')
+	{
+		$mysql_errno = mysql_errno($db_connection);
+		$error_query = in_array(substr(trim($string), 0, 11), array('INSERT INTO', 'UPDATE IGNO', 'ALTER TABLE', 'DROP TABLE ', 'ALTER IGNOR'));
+
+		// Error numbers:
+		//    1016: Can't open file '....MYI'
+		//    1050: Table already exists.
+		//    1054: Unknown column name.
+		//    1060: Duplicate column name.
+		//    1061: Duplicate key name.
+		//    1062: Duplicate entry for unique key.
+		//    1068: Multiple primary keys.
+		//    1072: Key column '%s' doesn't exist in table.
+		//    1091: Can't drop key, doesn't exist.
+		//    1146: Table doesn't exist.
+		//    2013: Lost connection to server during query.
+
+		if ($mysql_errno == 1016)
+		{
+			if (preg_match('~\'([^\.\']+)~', $db_error_message, $match) != 0 && !empty($match[1]))
+				mysql_query( '
+					REPAIR TABLE `' . $match[1] . '`');
+
+			$result = mysql_query($string);
+			if ($result !== false)
+				return $result;
+		}
+		elseif ($mysql_errno == 2013)
+		{
+			$db_connection = mysql_connect($db_server, $db_user, $db_passwd);
+			mysql_select_db($db_name, $db_connection);
+
+			if ($db_connection)
+			{
+				$result = mysql_query($string);
+
+				if ($result !== false)
+					return $result;
+			}
+		}
+		// Duplicate column name... should be okay ;).
+		elseif (in_array($mysql_errno, array(1060, 1061, 1068, 1091)))
+			return false;
+		// Duplicate insert... make sure it's the proper type of query ;).
+		elseif (in_array($mysql_errno, array(1054, 1062, 1146)) && $error_query)
+			return false;
+		// Creating an index on a non-existent column.
+		elseif ($mysql_errno == 1072)
+			return false;
+		elseif ($mysql_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE')
+			return false;
+	}
+	// If a table already exists don't go potty.
+	else
+	{
+		if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I')))
+		{
+			if (strpos($db_error_message, 'exist') !== false)
+				return true;
+			// SQLite
+			if (strpos($db_error_message, 'missing') !== false)
+				return true;
+		}
+		elseif (strpos(trim($string), 'INSERT ') !== false)
+		{
+			if (strpos($db_error_message, 'duplicate') !== false)
+				return true;
+		}
+	}
+
+	// Get the query string so we pass everything.
+	$query_string = '';
+	foreach ($_GET as $k => $v)
+		$query_string .= ';' . $k . '=' . $v;
+	if (strlen($query_string) != 0)
+		$query_string = '?' . substr($query_string, 1);
+
+	if ($command_line)
+	{
+		echo 'Unsuccessful!  Database error message:', "\n", $db_error_message, "\n";
+		die;
+	}
+
+	// Bit of a bodge - do we want the error?
+	if (!empty($upcontext['return_error']))
+	{
+		$upcontext['error_message'] = $db_error_message;
+		return false;
+	}
+
+	// Otherwise we have to display this somewhere appropriate if possible.
+	$upcontext['forced_error_message'] = '
+			<strong>Unsuccessful!</strong><br />
+
+			<div style="margin: 2ex;">
+				This query:
+				<blockquote><tt>' . nl2br(htmlspecialchars(trim($string))) . ';</tt></blockquote>
+
+				Caused the error:
+				<blockquote>' . nl2br(htmlspecialchars($db_error_message)) . '</blockquote>
+			</div>
+
+			<form action="' . $upgradeurl . $query_string . '" method="post">
+				<input type="submit" value="Try again" class="button_submit" />
+			</form>
+		</div>';
+
+	upgradeExit();
+}
+
+// This performs a table alter, but does it unbuffered so the script can time out professionally.
+function protected_alter($change, $substep, $is_test = false)
+{
+	global $db_prefix, $smcFunc;
+
+	db_extend('packages');
+
+	// Firstly, check whether the current index/column exists.
+	$found = false;
+	if ($change['type'] === 'column')
+	{
+		$columns = $smcFunc['db_list_columns']('{db_prefix}' . $change['table'], true);
+		foreach ($columns as $column)
+		{
+			// Found it?
+			if ($column['name'] === $change['name'])
+			{
+				$found |= 1;
+				// Do some checks on the data if we have it set.
+				if (isset($change['col_type']))
+					$found &= $change['col_type'] === $column['type'];
+				if (isset($change['null_allowed']))
+					$found &= $column['null'] == $change['null_allowed'];
+				if (isset($change['default']))
+					$found &= $change['default'] === $column['default'];
+			}
+		}
+	}
+	elseif ($change['type'] === 'index')
+	{
+		$request = upgrade_query( '
+			SHOW INDEX
+			FROM ' . $db_prefix . $change['table']);
+		if ($request !== false)
+		{
+			$cur_index = array();
+
+			while ($row = $smcFunc['db_fetch_assoc']($request))
+				if ($row['Key_name'] === $change['name'])
+					$cur_index[(int) $row['Seq_in_index']] = $row['Column_name'];
+
+			ksort($cur_index, SORT_NUMERIC);
+			$found = array_values($cur_index) === $change['target_columns'];
+
+			$smcFunc['db_free_result']($request);
+		}
+	}
+
+	// If we're trying to add and it's added, we're done.
+	if ($found && in_array($change['method'], array('add', 'change')))
+		return true;
+	// Otherwise if we're removing and it wasn't found we're also done.
+	elseif (!$found && in_array($change['method'], array('remove', 'change_remove')))
+		return true;
+	// Otherwise is it just a test?
+	elseif ($is_test)
+		return false;
+
+	// Not found it yet? Bummer! How about we see if we're currently doing it?
+	$running = false;
+	$found = false;
+	while (1 == 1)
+	{
+		$request = upgrade_query('
+			SHOW FULL PROCESSLIST');
+		while ($row = $smcFunc['db_fetch_assoc']($request))
+		{
+			if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false)
+				$found = true;
+		}
+
+		// Can't find it? Then we need to run it fools!
+		if (!$found && !$running)
+		{
+			$smcFunc['db_free_result']($request);
+
+			$success = upgrade_query('
+				ALTER TABLE ' . $db_prefix . $change['table'] . '
+				' . $change['text'], true) !== false;
+
+			if (!$success)
+				return false;
+
+			// Return
+			$running = true;
+		}
+		// What if we've not found it, but we'd ran it already? Must of completed.
+		elseif (!$found)
+		{
+			$smcFunc['db_free_result']($request);
+			return true;
+		}
+
+		// Pause execution for a sec or three.
+		sleep(3);
+
+		// Can never be too well protected.
+		nextSubstep($substep);
+	}
+
+	// Protect it.
+	nextSubstep($substep);
+}
+
+// Alter a text column definition preserving its character set.
+function textfield_alter($change, $substep)
+{
+	global $db_prefix, $databases, $db_type, $smcFunc;
+
+	// Versions of MySQL < 4.1 wouldn't benefit from character set detection.
+	if (empty($databases[$db_type]['utf8_support']) || version_compare($databases[$db_type]['utf8_version'], eval($databases[$db_type]['utf8_version_check']), '>'))
+	{
+		$column_fix = true;
+		$null_fix = !$change['null_allowed'];
+	}
+	else
+	{
+		$request = $smcFunc['db_query']('', '
+			SHOW FULL COLUMNS
+			FROM {db_prefix}' . $change['table'] . '
+			LIKE {string:column}',
+			array(
+				'column' => $change['column'],
+				'db_error_skip' => true,
+			)
+		);
+		if ($smcFunc['db_num_rows']($request) === 0)
+			die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']);
+		$table_row = $smcFunc['db_fetch_assoc']($request);
+		$smcFunc['db_free_result']($request);
+
+		// If something of the current column definition is different, fix it.
+		$column_fix = $table_row['Type'] !== $change['type'] || (strtolower($table_row['Null']) === 'yes') !== $change['null_allowed'] || ($table_row['Default'] === null) !== !isset($change['default']) || (isset($change['default']) && $change['default'] !== $table_row['Default']);
+
+		// Columns that previously allowed null, need to be converted first.
+		$null_fix = strtolower($table_row['Null']) === 'yes' && !$change['null_allowed'];
+
+		// Get the character set that goes with the collation of the column.
+		if ($column_fix && !empty($table_row['Collation']))
+		{
+			$request = $smcFunc['db_query']('', '
+				SHOW COLLATION
+				LIKE {string:collation}',
+				array(
+					'collation' => $table_row['Collation'],
+					'db_error_skip' => true,
+				)
+			);
+			// No results? Just forget it all together.
+			if ($smcFunc['db_num_rows']($request) === 0)
+				unset($table_row['Collation']);
+			else
+				$collation_info = $smcFunc['db_fetch_assoc']($request);
+			$smcFunc['db_free_result']($request);
+		}
+	}
+
+	if ($column_fix)
+	{
+		// Make sure there are no NULL's left.
+		if ($null_fix)
+			$smcFunc['db_query']('', '
+				UPDATE {db_prefix}' . $change['table'] . '
+				SET ' . $change['column'] . ' = {string:default}
+				WHERE ' . $change['column'] . ' IS NULL',
+				array(
+					'default' => isset($change['default']) ? $change['default'] : '',
+					'db_error_skip' => true,
+				)
+			);
+
+		// Do the actual alteration.
+		$smcFunc['db_query']('', '
+			ALTER TABLE {db_prefix}' . $change['table'] . '
+			CHANGE COLUMN ' . $change['column'] . ' ' . $change['column'] . ' ' . $change['type'] . (isset($collation_info['Charset']) ? ' CHARACTER SET ' . $collation_info['Charset'] . ' COLLATE ' . $collation_info['Collation'] : '') . ($change['null_allowed'] ? '' : ' NOT NULL') . (isset($change['default']) ? ' default {string:default}' : ''),
+			array(
+				'default' => isset($change['default']) ? $change['default'] : '',
+				'db_error_skip' => true,
+			)
+		);
+	}
+	nextSubstep($substep);
+}
+
+// Check if we need to alter this query.
+function checkChange(&$change)
+{
+	global $smcFunc, $db_type, $databases;
+	static $database_version, $where_field_support;
+
+	// Attempt to find a database_version.
+	if (empty($database_version))
+	{
+		$database_version = $databases[$db_type]['version_check'];
+		$where_field_support = $db_type == 'mysql' && version_compare('5.0', $database_version, '<=');
+	}
+
+	// Not a column we need to check on?
+	if (!in_array($change['name'], array('memberGroups', 'passwordSalt')))
+		return;
+
+	// Break it up you (six|seven).
+	$temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text']));
+
+	// Can we support a shortcut method?
+	if ($where_field_support)
+	{
+		// Get the details about this change.
+		$request = $smcFunc['db_query']('', '
+			SHOW FIELDS
+			FROM {db_prefix}{raw:table}
+			WHERE Field = {string:old_name} OR Field = {string:new_name}',
+			array(
+				'table' => $change['table'],
+				'old_name' => $temp[1],
+				'new_name' => $temp[2],
+		));
+		if ($smcFunc['db_num_rows'] != 1)
+			return;
+
+		list (, $current_type) = $smcFunc['db_fetch_assoc']($request);
+		$smcFunc['db_free_result']($request);
+	}
+	else
+	{
+		// Do this the old fashion, sure method way.
+		$request = $smcFunc['db_query']('', '
+			SHOW FIELDS
+			FROM {db_prefix}{raw:table}',
+			array(
+				'table' => $change['table'],
+		));
+		// Mayday!
+		if ($smcFunc['db_num_rows'] == 0)
+			return;
+
+		// Oh where, oh where has my little field gone. Oh where can it be...
+		while ($row = $smcFunc['db_query']($request))
+			if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2])
+			{
+				$current_type = $row['Type'];
+				break;
+			}
+	}
+
+	// If this doesn't match, the column may of been altered for a reason.
+	if (trim($current_type) != trim($temp[3]))
+		$temp[3] = $current_type;
+
+	// Piece this back together.
+	$change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp));
+}
+
+// The next substep.
+function nextSubstep($substep)
+{
+	global $start_time, $timeLimitThreshold, $command_line, $file_steps, $modSettings, $custom_warning;
+	global $step_progress, $is_debug, $upcontext;
+
+	if ($_GET['substep'] < $substep)
+		$_GET['substep'] = $substep;
+
+	if ($command_line)
+	{
+		if (time() - $start_time > 1 && empty($is_debug))
+		{
+			echo '.';
+			$start_time = time();
+		}
+		return;
+	}
+
+	@set_time_limit(300);
+	if (function_exists('apache_reset_timeout'))
+		@apache_reset_timeout();
+
+	if (time() - $start_time <= $timeLimitThreshold)
+		return;
+
+	// Do we have some custom step progress stuff?
+	if (!empty($step_progress))
+	{
+		$upcontext['substep_progress'] = 0;
+		$upcontext['substep_progress_name'] = $step_progress['name'];
+		if ($step_progress['current'] > $step_progress['total'])
+			$upcontext['substep_progress'] = 99.9;
+		else
+			$upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100;
+
+		// Make it nicely rounded.
+		$upcontext['substep_progress'] = round($upcontext['substep_progress'], 1);
+	}
+
+	// If this is XML we just exit right away!
+	if (isset($_GET['xml']))
+		return upgradeExit();
+
+	// We're going to pause after this!
+	$upcontext['pause'] = true;
+
+	$upcontext['query_string'] = '';
+	foreach ($_GET as $k => $v)
+	{
+		if ($k != 'data' && $k != 'substep' && $k != 'step')
+			$upcontext['query_string'] .= ';' . $k . '=' . $v;
+	}
+
+	// Custom warning?
+	if (!empty($custom_warning))
+		$upcontext['custom_warning'] = $custom_warning;
+
+	upgradeExit();
+}
+
+function cmdStep0()
+{
+	global $boarddir, $sourcedir, $db_prefix, $language, $modSettings, $start_time, $cachedir, $databases, $db_type, $smcFunc, $upcontext;
+	global $language, $is_debug, $txt;
+	$start_time = time();
+
+	ob_end_clean();
+	ob_implicit_flush(true);
+	@set_time_limit(600);
+
+	if (!isset($_SERVER['argv']))
+		$_SERVER['argv'] = array();
+	$_GET['maint'] = 1;
+
+	foreach ($_SERVER['argv'] as $i => $arg)
+	{
+		if (preg_match('~^--language=(.+)$~', $arg, $match) != 0)
+			$_GET['lang'] = $match[1];
+		elseif (preg_match('~^--path=(.+)$~', $arg) != 0)
+			continue;
+		elseif ($arg == '--no-maintenance')
+			$_GET['maint'] = 0;
+		elseif ($arg == '--debug')
+			$is_debug = true;
+		elseif ($arg == '--backup')
+			$_POST['backup'] = 1;
+		elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($boarddir . '/Themes/converted')))
+			$_GET['conv'] = 1;
+		elseif ($i != 0)
+		{
+			echo 'SMF Command-line Upgrader
+Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]...
+
+    --language=LANG         Reset the forum\'s language to LANG.
+    --no-maintenance        Don\'t put the forum into maintenance mode.
+    --debug                 Output debugging information.
+    --backup                Create backups of tables with "backup_" prefix.';
+			echo "\n";
+			exit;
+		}
+	}
+
+	if (!php_version_check())
+		print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true);
+	if (!db_version_check())
+		print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true);
+
+	if (!empty($databases[$db_type]['alter_support']) && $smcFunc['db_query']('alter_boards', 'ALTER TABLE {db_prefix}boards ORDER BY id_board', array()) === false)
+		print_error('Error: The ' . $databases[$db_type]['name'] . ' account in Settings.php does not have sufficient privileges.', true);
+
+	$check = @file_exists($boarddir . '/Themes/default/index.template.php')
+		&& @file_exists($sourcedir . '/QueryString.php')
+		&& @file_exists($sourcedir . '/ManageBoards.php');
+	if (!$check && !isset($modSettings['smfVersion']))
+		print_error('Error: Some files are missing or out-of-date.', true);
+
+	// Do a quick version spot check.
+	$temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096);
+	preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match);
+	if (empty($match[1]) || $match[1] != SMF_VERSION)
+		print_error('Error: Some files have not yet been updated properly.');
+
+	// Make sure Settings.php is writable.
+	if (!is_writable($boarddir . '/Settings.php'))
+		@chmod($boarddir . '/Settings.php', 0777);
+	if (!is_writable($boarddir . '/Settings.php'))
+		print_error('Error: Unable to obtain write access to "Settings.php".', true);
+
+	// Make sure Settings.php is writable.
+	if (!is_writable($boarddir . '/Settings_bak.php'))
+		@chmod($boarddir . '/Settings_bak.php', 0777);
+	if (!is_writable($boarddir . '/Settings_bak.php'))
+		print_error('Error: Unable to obtain write access to "Settings_bak.php".');
+
+	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt'))
+		print_error('Error: Unable to obtain write access to "agreement.txt".');
+	elseif (isset($modSettings['agreement']))
+	{
+		$fp = fopen($boarddir . '/agreement.txt', 'w');
+		fwrite($fp, $modSettings['agreement']);
+		fclose($fp);
+	}
+
+	// Make sure Themes is writable.
+	if (!is_writable($boarddir . '/Themes'))
+		@chmod($boarddir . '/Themes', 0777);
+
+	if (!is_writable($boarddir . '/Themes') && !isset($modSettings['smfVersion']))
+		print_error('Error: Unable to obtain write access to "Themes".');
+
+	// Make sure cache directory exists and is writable!
+	$cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir;
+	if (!file_exists($cachedir_temp))
+		@mkdir($cachedir_temp);
+
+	if (!is_writable($cachedir_temp))
+		@chmod($cachedir_temp, 0777);
+
+	if (!is_writable($cachedir_temp))
+		print_error('Error: Unable to obtain write access to "cache".', true);
+
+	if (!file_exists($boarddir . '/Themes/default/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang']))
+		print_error('Error: Unable to find language files!', true);
+	else
+	{
+		$temp = substr(@implode('', @file($boarddir . '/Themes/default/languages/index.' . $upcontext['language'] . '.php')), 0, 4096);
+		preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
+
+		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
+			print_error('Error: Language files out of date.', true);
+		if (!file_exists($boarddir . '/Themes/default/languages/Install.' . $upcontext['language'] . '.php'))
+			print_error('Error: Install language is missing for selected language.', true);
+
+		// Otherwise include it!
+		require_once($boarddir . '/Themes/default/languages/Install.' . $upcontext['language'] . '.php');
+	}
+
+	// Make sure we skip the HTML for login.
+	$_POST['upcont'] = true;
+	$upcontext['current_step'] = 1;
+}
+
+function print_error($message, $fatal = false)
+{
+	static $fp = null;
+
+	if ($fp === null)
+		$fp = fopen('php://stderr', 'wb');
+
+	fwrite($fp, $message . "\n");
+
+	if ($fatal)
+		exit;
+}
+
+function throw_error($message)
+{
+	global $upcontext;
+
+	$upcontext['error_msg'] = $message;
+	$upcontext['sub_template'] = 'error_message';
+
+	return false;
+}
+
+// Check files are writable - make them writable if necessary...
+function makeFilesWritable(&$files)
+{
+	global $upcontext, $boarddir;
+
+	if (empty($files))
+		return true;
+
+	$failure = false;
+	// On linux, it's easy - just use is_writable!
+	if (substr(__FILE__, 1, 2) != ':\\')
+	{
+		foreach ($files as $k => $file)
+		{
+			if (!is_writable($file))
+			{
+				@chmod($file, 0755);
+
+				// Well, 755 hopefully worked... if not, try 777.
+				if (!is_writable($file) && !@chmod($file, 0777))
+					$failure = true;
+				// Otherwise remove it as it's good!
+				else
+					unset($files[$k]);
+			}
+			else
+				unset($files[$k]);
+		}
+	}
+	// Windows is trickier.  Let's try opening for r+...
+	else
+	{
+		foreach ($files as $k => $file)
+		{
+			// Folders can't be opened for write... but the index.php in them can ;).
+			if (is_dir($file))
+				$file .= '/index.php';
+
+			// Funny enough, chmod actually does do something on windows - it removes the read only attribute.
+			@chmod($file, 0777);
+			$fp = @fopen($file, 'r+');
+
+			// Hmm, okay, try just for write in that case...
+			if (!$fp)
+				$fp = @fopen($file, 'w');
+
+			if (!$fp)
+				$failure = true;
+			else
+				unset($files[$k]);
+			@fclose($fp);
+		}
+	}
+
+	if (empty($files))
+		return true;
+
+	if (!isset($_SERVER))
+		return !$failure;
+
+	// What still needs to be done?
+	$upcontext['chmod']['files'] = $files;
+
+	// If it's windows it's a mess...
+	if ($failure && substr(__FILE__, 1, 2) == ':\\')
+	{
+		$upcontext['chmod']['ftp_error'] = 'total_mess';
+
+		return false;
+	}
+	// We're going to have to use... FTP!
+	elseif ($failure)
+	{
+		// Load any session data we might have...
+		if (!isset($_POST['ftp_username']) && isset($_SESSION['installer_temp_ftp']))
+		{
+			$upcontext['chmod']['server'] = $_SESSION['installer_temp_ftp']['server'];
+			$upcontext['chmod']['port'] = $_SESSION['installer_temp_ftp']['port'];
+			$upcontext['chmod']['username'] = $_SESSION['installer_temp_ftp']['username'];
+			$upcontext['chmod']['password'] = $_SESSION['installer_temp_ftp']['password'];
+			$upcontext['chmod']['path'] = $_SESSION['installer_temp_ftp']['path'];
+		}
+		// Or have we submitted?
+		elseif (isset($_POST['ftp_username']))
+		{
+			$upcontext['chmod']['server'] = $_POST['ftp_server'];
+			$upcontext['chmod']['port'] = $_POST['ftp_port'];
+			$upcontext['chmod']['username'] = $_POST['ftp_username'];
+			$upcontext['chmod']['password'] = $_POST['ftp_password'];
+			$upcontext['chmod']['path'] = $_POST['ftp_path'];
+		}
+
+		if (isset($upcontext['chmod']['username']))
+		{
+			$ftp = new ftp_connection($upcontext['chmod']['server'], $upcontext['chmod']['port'], $upcontext['chmod']['username'], $upcontext['chmod']['password']);
+
+			if ($ftp->error === false)
+			{
+				// Try it without /home/abc just in case they messed up.
+				if (!$ftp->chdir($upcontext['chmod']['path']))
+				{
+					$upcontext['chmod']['ftp_error'] = $ftp->last_message;
+					$ftp->chdir(preg_replace('~^/home[2]?/[^/]+?~', '', $upcontext['chmod']['path']));
+				}
+			}
+		}
+
+		if (!isset($ftp) || $ftp->error !== false)
+		{
+			if (!isset($ftp))
+				$ftp = new ftp_connection(null);
+			// Save the error so we can mess with listing...
+			elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error']))
+				$upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message;
+
+			list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__));
+
+			if ($found_path || !isset($upcontext['chmod']['path']))
+				$upcontext['chmod']['path'] = $detect_path;
+
+			if (!isset($upcontext['chmod']['username']))
+				$upcontext['chmod']['username'] = $username;
+
+			return false;
+		}
+		else
+		{
+			// We want to do a relative path for FTP.
+			if (!in_array($upcontext['chmod']['path'], array('', '/')))
+			{
+				$ftp_root = strtr($boarddir, array($upcontext['chmod']['path'] => ''));
+				if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/'))
+				$ftp_root = substr($ftp_root, 0, -1);
+			}
+			else
+				$ftp_root = $boarddir;
+
+			// Save the info for next time!
+			$_SESSION['installer_temp_ftp'] = array(
+				'server' => $upcontext['chmod']['server'],
+				'port' => $upcontext['chmod']['port'],
+				'username' => $upcontext['chmod']['username'],
+				'password' => $upcontext['chmod']['password'],
+				'path' => $upcontext['chmod']['path'],
+				'root' => $ftp_root,
+			);
+
+			foreach ($files as $k => $file)
+			{
+				if (!is_writable($file))
+					$ftp->chmod($file, 0755);
+				if (!is_writable($file))
+					$ftp->chmod($file, 0777);
+
+				// Assuming that didn't work calculate the path without the boarddir.
+				if (!is_writable($file))
+				{
+					if (strpos($file, $boarddir) === 0)
+					{
+						$ftp_file = strtr($file, array($_SESSION['installer_temp_ftp']['root'] => ''));
+						$ftp->chmod($ftp_file, 0755);
+						if (!is_writable($file))
+							$ftp->chmod($ftp_file, 0777);
+						// Sometimes an extra slash can help...
+						$ftp_file = '/' . $ftp_file;
+						if (!is_writable($file))
+							$ftp->chmod($ftp_file, 0755);
+						if (!is_writable($file))
+							$ftp->chmod($ftp_file, 0777);
+					}
+				}
+
+				if (is_writable($file))
+					unset($files[$k]);
+			}
+
+			$ftp->close();
+		}
+	}
+
+	// What remains?
+	$upcontext['chmod']['files'] = $files;
+
+	if (empty($files))
+		return true;
+
+	return false;
+}
+
+/******************************************************************************
+******************* Templates are below this point ****************************
+******************************************************************************/
+
+// This is what is displayed if there's any chmod to be done. If not it returns nothing...
+function template_chmod()
+{
+	global $upcontext, $upgradeurl, $settings;
+
+	// Don't call me twice!
+	if (!empty($upcontext['chmod_called']))
+		return;
+
+	$upcontext['chmod_called'] = true;
+
+	// Nothing?
+	if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error']))
+		return;
+
+	// @todo Temporary!
+	$txt['error_ftp_no_connect'] = 'Unable to connect to FTP server with this combination of details.';
+	$txt['ftp_login'] = 'Your FTP connection information';
+	$txt['ftp_login_info'] = 'This web installer needs your FTP information in order to automate the installation for you.  Please note that none of this information is saved in your installation, it is just used to setup SMF.';
+	$txt['ftp_server'] = 'Server';
+	$txt['ftp_server_info'] = 'The address (often localhost) and port for your FTP server.';
+	$txt['ftp_port'] = 'Port';
+	$txt['ftp_username'] = 'Username';
+	$txt['ftp_username_info'] = 'The username to login with. <em>This will not be saved anywhere.</em>';
+	$txt['ftp_password'] = 'Password';
+	$txt['ftp_password_info'] = 'The password to login with. <em>This will not be saved anywhere.</em>';
+	$txt['ftp_path'] = 'Install Path';
+	$txt['ftp_path_info'] = 'This is the <em>relative</em> path you use in your FTP client <a href="' . $_SERVER['PHP_SELF'] . '?ftphelp" onclick="window.open(this.href, \'\', \'width=450,height=250\');return false;" target="_blank">(more help)</a>.';
+	$txt['ftp_path_found_info'] = 'The path in the box above was automatically detected.';
+	$txt['ftp_path_help'] = 'Your FTP path is the path you see when you log in to your FTP client.  It commonly starts with &quot;<tt>www</tt>&quot;, &quot;<tt>public_html</tt>&quot;, or &quot;<tt>httpdocs</tt>&quot; - but it should include the directory SMF is in too, such as &quot;/public_html/forum&quot;.  It is different from your URL and full path.<br /><br />Files in this path may be overwritten, so make sure it\'s correct.';
+	$txt['ftp_path_help_close'] = 'Close';
+	$txt['ftp_connect'] = 'Connect';
+
+	// Was it a problem with Windows?
+	if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess')
+	{
+		echo '
+			<div class="error_message">
+				<div style="color: red;">The following files need to be writable to continue the upgrade. Please ensure the Windows permissions are correctly set to allow this:</div>
+				<ul style="margin: 2.5ex; font-family: monospace;">
+				<li>' . implode('</li>
+				<li>', $upcontext['chmod']['files']). '</li>
+			</ul>
+			</div>';
+
+		return false;
+	}
+
+	echo '
+		<div class="panel">
+			<h2>Your FTP connection information</h2>
+			<h3>The upgrader can fix any issues with file permissions to make upgrading as simple as possible. Simply enter your connection information below or alternatively click <a href="#" onclick="warning_popup();">here</a> for a list of files which need to be changed.</h3>
+			<script type="text/javascript"><!-- // --><![CDATA[
+				function warning_popup()
+				{
+					popup = window.open(\'\',\'popup\',\'height=150,width=400,scrollbars=yes\');
+					var content = popup.document;
+					content.write(\'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n\');
+					content.write(\'<html xmlns="http://www.w3.org/1999/xhtml"', $upcontext['right_to_left'] ? ' dir="rtl"' : '', '>\n\t<head>\n\t\t<meta name="robots" content="noindex" />\n\t\t\');
+					content.write(\'<title>Warning</title>\n\t\t<link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/css/index.css" />\n\t</head>\n\t<body id="popup">\n\t\t\');
+					content.write(\'<div class="windowbg description">\n\t\t\t<h4>The following files needs to be made writable to continue:</h4>\n\t\t\t\');
+					content.write(\'<p>', implode('<br />\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');
+					content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\');
+					content.close();
+				}
+		// ]]></script>';
+
+	if (!empty($upcontext['chmod']['ftp_error']))
+		echo '
+			<div class="error_message">
+				<div style="color: red;">
+					The following error was encountered when trying to connect:<br />
+					<br />
+					<code>', $upcontext['chmod']['ftp_error'], '</code>
+				</div>
+			</div>
+			<br />';
+
+	if (empty($upcontext['chmod_in_form']))
+		echo '
+	<form action="', $upcontext['form_url'], '" method="post">';
+
+	echo '
+		<table width="520" cellspacing="0" cellpadding="0" border="0" align="center" style="margin-bottom: 1ex;">
+			<tr>
+				<td width="26%" valign="top" class="textbox"><label for="ftp_server">', $txt['ftp_server'], ':</label></td>
+				<td>
+					<div style="float: right; margin-right: 1px;"><label for="ftp_port" class="textbox"><strong>', $txt['ftp_port'], ':&nbsp;</strong></label> <input type="text" size="3" name="ftp_port" id="ftp_port" value="', isset($upcontext['chmod']['port']) ? $upcontext['chmod']['port'] : '21', '" class="input_text" /></div>
+					<input type="text" size="30" name="ftp_server" id="ftp_server" value="', isset($upcontext['chmod']['server']) ? $upcontext['chmod']['server'] : 'localhost', '" style="width: 70%;" class="input_text" />
+					<div style="font-size: smaller; margin-bottom: 2ex;">', $txt['ftp_server_info'], '</div>
+				</td>
+			</tr><tr>
+				<td width="26%" valign="top" class="textbox"><label for="ftp_username">', $txt['ftp_username'], ':</label></td>
+				<td>
+					<input type="text" size="50" name="ftp_username" id="ftp_username" value="', isset($upcontext['chmod']['username']) ? $upcontext['chmod']['username'] : '', '" style="width: 99%;" class="input_text" />
+					<div style="font-size: smaller; margin-bottom: 2ex;">', $txt['ftp_username_info'], '</div>
+				</td>
+			</tr><tr>
+				<td width="26%" valign="top" class="textbox"><label for="ftp_password">', $txt['ftp_password'], ':</label></td>
+				<td>
+					<input type="password" size="50" name="ftp_password" id="ftp_password" style="width: 99%;" class="input_password" />
+					<div style="font-size: smaller; margin-bottom: 3ex;">', $txt['ftp_password_info'], '</div>
+				</td>
+			</tr><tr>
+				<td width="26%" valign="top" class="textbox"><label for="ftp_path">', $txt['ftp_path'], ':</label></td>
+				<td style="padding-bottom: 1ex;">
+					<input type="text" size="50" name="ftp_path" id="ftp_path" value="', isset($upcontext['chmod']['path']) ? $upcontext['chmod']['path'] : '', '" style="width: 99%;" class="input_text" />
+					<div style="font-size: smaller; margin-bottom: 2ex;">', !empty($upcontext['chmod']['path']) ? $txt['ftp_path_found_info'] : $txt['ftp_path_info'], '</div>
+				</td>
+			</tr>
+		</table>
+
+		<div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button_submit" /></div>
+	</div>';
+
+	if (empty($upcontext['chmod_in_form']))
+		echo '
+	</form>';
+}
+
+function template_upgrade_above()
+{
+	global $modSettings, $txt, $smfsite, $settings, $upcontext, $upgradeurl;
+
+	echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"', $upcontext['right_to_left'] ? ' dir="rtl"' : '', '>
+	<head>
+		<meta http-equiv="Content-Type" content="text/html; charset=', isset($txt['lang_character_set']) ? $txt['lang_character_set'] : 'ISO-8859-1', '" />
+		<meta name="robots" content="noindex" />
+		<title>', $txt['upgrade_upgrade_utility'], '</title>
+		<link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/css/index.css?fin20" />
+		<link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/css/install.css?fin20" />
+				<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/script.js"></script>
+		<script type="text/javascript"><!-- // --><![CDATA[
+			var smf_scripturl = \'', $upgradeurl, '\';
+			var smf_charset = \'', (empty($modSettings['global_character_set']) ? (empty($txt['lang_character_set']) ? 'ISO-8859-1' : $txt['lang_character_set']) : $modSettings['global_character_set']), '\';
+			var startPercent = ', $upcontext['overall_percent'], ';
+
+			// This function dynamically updates the step progress bar - and overall one as required.
+			function updateStepProgress(current, max, overall_weight)
+			{
+				// What out the actual percent.
+				var width = parseInt((current / max) * 100);
+				if (document.getElementById(\'step_progress\'))
+				{
+					document.getElementById(\'step_progress\').style.width = width + "%";
+					setInnerHTML(document.getElementById(\'step_text\'), width + "%");
+				}
+				if (overall_weight && document.getElementById(\'overall_progress\'))
+				{
+					overall_width = parseInt(startPercent + width * (overall_weight / 100));
+					document.getElementById(\'overall_progress\').style.width = overall_width + "%";
+					setInnerHTML(document.getElementById(\'overall_text\'), overall_width + "%");
+				}
+			}
+		// ]]></script>
+	</head>
+	<body>
+	<div id="header"><div class="frame">
+		<div id="top_section">
+			<h1 class="forumtitle">', $txt['upgrade_upgrade_utility'], '</h1>
+			<img id="smflogo" src="Themes/default/images/smflogo.png" alt="Simple Machines Forum" title="Simple Machines Forum" />
+		</div>
+		<div id="upper_section" class="middletext flow_hidden">
+			<div class="user"></div>
+			<div class="news normaltext">
+			</div>
+		</div>
+	</div></div>
+	<div id="content_section"><div class="frame">
+		<div id="main_content_section">
+			<div id="main-steps">
+				<h2>', $txt['upgrade_progress'], '</h2>
+				<ul>';
+
+	foreach ($upcontext['steps'] as $num => $step)
+		echo '
+						<li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>';
+
+	echo '
+					</ul>
+			</div>
+			<div style="float: left; width: 40%;">
+				<div style="font-size: 8pt; height: 12pt; border: 1px solid black; background-color: white; width: 50%; margin: auto;">
+					<div id="overall_text" style="color: #000; position: absolute; margin-left: -5em;">', $upcontext['overall_percent'], '%</div>
+					<div id="overall_progress" style="width: ', $upcontext['overall_percent'], '%; height: 12pt; z-index: 1; background-color: lime;">&nbsp;</div>
+					<div class="progress">', $txt['upgrade_overall_progress'], '</div>
+				</div>
+				';
+
+	if (isset($upcontext['step_progress']))
+		echo '
+				<div style="font-size: 8pt; height: 12pt; border: 1px solid black; background-color: white; width: 50%; margin: 5px auto; ">
+					<div id="step_text" style="color: #000; position: absolute; margin-left: -5em;">', $upcontext['step_progress'], '%</div>
+					<div id="step_progress" style="width: ', $upcontext['step_progress'], '%; height: 12pt; z-index: 1; background-color: #ffd000;">&nbsp;</div>
+					<div class="progress">', $txt['upgrade_step_progress'], '</div>
+				</div>
+				';
+
+	echo '
+				<div id="substep_bar_div" class="smalltext" style="display: ', isset($upcontext['substep_progress']) ? '' : 'none', ';">', isset($upcontext['substep_progress_name']) ? trim(strtr($upcontext['substep_progress_name'], array('.' => ''))) : '', ':</div>
+				<div id="substep_bar_div2" style="font-size: 8pt; height: 12pt; border: 1px solid black; background-color: white; width: 50%; margin: 5px auto; display: ', isset($upcontext['substep_progress']) ? '' : 'none', ';">
+					<div id="substep_text" style="color: #000; position: absolute; margin-left: -5em;">', isset($upcontext['substep_progress']) ? $upcontext['substep_progress'] : '', '%</div>
+				<div id="substep_progress" style="width: ', isset($upcontext['substep_progress']) ? $upcontext['substep_progress'] : 0, '%; height: 12pt; z-index: 1; background-color: #eebaf4;">&nbsp;</div>
+								</div>';
+
+	// How long have we been running this?
+	$elapsed = time() - $upcontext['started'];
+	$mins = (int) ($elapsed / 60);
+	$seconds = $elapsed - $mins * 60;
+	echo '
+								<div class="smalltext" style="padding: 5px; text-align: center;">', $txt['upgrade_time_elapsed'], ':
+									<span id="mins_elapsed">', $mins, '</span> ', $txt['upgrade_time_mins'], ', <span id="secs_elapsed">', $seconds, '</span> ', $txt['upgrade_time_secs'], '.
+								</div>';
+	echo '
+			</div>
+			<div id="main_screen" class="clear">
+				<h2>', $upcontext['page_title'], '</h2>
+				<div class="panel">
+					<div style="max-height: 360px; overflow: auto;">';
+}
+
+function template_upgrade_below()
+{
+	global $upcontext, $txt;
+
+	if (!empty($upcontext['pause']))
+		echo '
+								<em>', $txt['upgrade_incomplete'], '.</em><br />
+
+								<h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2>
+								<h3>
+									', $txt['upgrade_paused_overload'], '
+								</h3>';
+
+	if (!empty($upcontext['custom_warning']))
+		echo '
+								<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
+									<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
+									<strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br />
+									<div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div>
+								</div>';
+
+	echo '
+								<div class="righttext" style="margin: 1ex;">';
+
+	if (!empty($upcontext['continue']))
+		echo '
+									<input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled="disabled"' : '', ' class="button_submit" />';
+	if (!empty($upcontext['skip']))
+		echo '
+									<input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button_submit" />';
+
+	echo '
+								</div>
+							</form>
+						</div>
+				</div>
+			</div>
+		</div>
+	</div></div>
+	<div id="footer_section"><div class="frame" style="height: 40px;">
+		<div class="smalltext"><a href="http://www.simplemachines.org/" title="Simple Machines Forum" target="_blank" class="new_win">SMF &copy;2011, Simple Machines</a></div>
+	</div></div>
+	</body>
+</html>';
+
+	// Are we on a pause?
+	if (!empty($upcontext['pause']))
+	{
+		echo '
+		<script type="text/javascript"><!-- // --><![CDATA[
+			window.onload = doAutoSubmit;
+			var countdown = 3;
+			var dontSubmit = false;
+
+			function doAutoSubmit()
+			{
+				if (countdown == 0 && !dontSubmit)
+					document.upform.submit();
+				else if (countdown == -1)
+					return;
+
+				document.getElementById(\'contbutt\').value = "', $txt['upgrade_continue'], ' (" + countdown + ")";
+				countdown--;
+
+				setTimeout("doAutoSubmit();", 1000);
+			}
+		// ]]></script>';
+	}
+}
+
+function template_xml_above()
+{
+	global $upcontext;
+
+	echo '<', '?xml version="1.0" encoding="ISO-8859-1"?', '>
+	<smf>';
+
+	if (!empty($upcontext['get_data']))
+		foreach ($upcontext['get_data'] as $k => $v)
+			echo '
+		<get key="', $k, '">', $v, '</get>';
+}
+
+function template_xml_below()
+{
+	global $upcontext;
+
+	echo '
+		</smf>';
+}
+
+function template_error_message()
+{
+	global $upcontext;
+
+	echo '
+	<div class="error_message">
+		<div style="color: red;">
+			', $upcontext['error_msg'], '
+		</div>
+		<br />
+		<a href="', $_SERVER['PHP_SELF'], '">Click here to try again.</a>
+	</div>';
+}
+
+function template_welcome_message()
+{
+	global $upcontext, $modSettings, $upgradeurl, $disable_security, $settings, $txt;
+
+	echo '
+		<script type="text/javascript" src="http://www.simplemachines.org/smf/current-version.js?version=' . SMF_VERSION . '"></script>
+		<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/sha1.js"></script>
+			<h3>', sprintf($txt['upgrade_ready_proceed'], SMF_VERSION), '</h3>
+	<form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform" ', empty($upcontext['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $upcontext['rid'] . '\');"' : '', '>
+		<div id="version_warning" style="margin: 2ex; padding: 2ex; border: 2px dashed #a92174; color: black; background-color: #fbbbe2; display: none;">
+			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
+			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br />
+			<div style="padding-left: 6ex;">
+				', sprintf($txt['upgrade_warning_out_of_date'], SMF_VERSION), '
+			</div>
+		</div>';
+
+	$upcontext['chmod_in_form'] = true;
+	template_chmod();
+
+	// For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade!
+	if ($upcontext['is_large_forum'])
+		echo '
+		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
+			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
+			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br />
+			<div style="padding-left: 6ex;">
+				', $txt['upgrade_warning_lots_data'], '
+			</div>
+		</div>';
+
+	// A warning message?
+	if (!empty($upcontext['warning']))
+		echo '
+		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
+			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
+			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br />
+			<div style="padding-left: 6ex;">
+				', $upcontext['warning'], '
+			</div>
+		</div>';
+
+	// Paths are incorrect?
+	echo '
+		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #804840; color: black; background-color: #fe5a44; ', (file_exists($settings['default_theme_dir'] . '/scripts/script.js') ? 'display: none;' : ''), '" id="js_script_missing_error">
+			<div style="float: left; width: 2ex; font-size: 2em; color: black;">!!</div>
+			<strong style="text-decoration: underline;">', $txt['upgrade_critical_error'], '</strong><br />
+			<div style="padding-left: 6ex;">
+				', $txt['upgrade_error_script_js'], '
+			</div>
+		</div>';
+
+	// Is there someone already doing this?
+	if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600))
+	{
+		$ago = time() - $upcontext['started'];
+		if ($ago < 60)
+			$ago = $ago . ' seconds';
+		elseif ($ago < 3600)
+			$ago = (int) ($ago / 60) . ' minutes';
+		else
+			$ago = (int) ($ago / 3600) . ' hours';
+
+		$active = time() - $upcontext['updated'];
+		if ($active < 60)
+			$updated = $active . ' seconds';
+		elseif ($active < 3600)
+			$updated = (int) ($active / 60) . ' minutes';
+		else
+			$updated = (int) ($active / 3600) . ' hours';
+
+		echo '
+		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
+			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
+			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br />
+			<div style="padding-left: 6ex;">
+				&quot;', $upcontext['user']['name'], '&quot; has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.';
+
+		if ($active < 600)
+			echo '
+				We recommend that you do not run this script unless you are sure that ', $upcontext['user']['name'], ' has completed their upgrade.';
+
+		if ($active > $upcontext['inactive_timeout'])
+			echo '
+				<br /><br />You can choose to either run the upgrade again from the beginning - or alternatively continue from the last step reached during the last upgrade.';
+		else
+			echo '
+				<br /><br />This upgrade script cannot be run until ', $upcontext['user']['name'], ' has been inactive for at least ', ($upcontext['inactive_timeout'] > 120 ? round($upcontext['inactive_timeout'] / 60, 1) . ' minutes!' : $upcontext['inactive_timeout'] . ' seconds!');
+
+		echo '
+			</div>
+		</div>';
+	}
+
+	echo '
+			<strong>Admin Login: ', $disable_security ? '(DISABLED)' : '', '</strong>
+			<h3>For security purposes please login with your admin account to proceed with the upgrade.</h3>
+			<table>
+				<tr valign="top">
+					<td><strong ', $disable_security ? 'style="color: gray;"' : '', '>Username:</strong></td>
+					<td>
+						<input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '" ', $disable_security ? 'disabled="disabled"' : '', ' class="input_text" />';
+
+	if (!empty($upcontext['username_incorrect']))
+		echo '
+						<div class="smalltext" style="color: red;">Username Incorrect</div>';
+
+	echo '
+					</td>
+				</tr>
+				<tr valign="top">
+					<td><strong ', $disable_security ? 'style="color: gray;"' : '', '>Password:</strong></td>
+					<td>
+						<input type="password" name="passwrd" value=""', $disable_security ? ' disabled="disabled"' : '', ' class="input_password" />
+						<input type="hidden" name="hash_passwrd" value="" />';
+
+	if (!empty($upcontext['password_failed']))
+		echo '
+						<div class="smalltext" style="color: red;">Password Incorrect</div>';
+
+	echo '
+					</td>
+				</tr>';
+
+	// Can they continue?
+	if (!empty($upcontext['user']['id']) && time() - $upcontext['user']['updated'] >= $upcontext['inactive_timeout'] && $upcontext['user']['step'] > 1)
+	{
+		echo '
+				<tr>
+					<td colspan="2">
+						<label for="cont"><input type="checkbox" id="cont" name="cont" checked="checked" class="input_check" />Continue from step reached during last execution of upgrade script.</label>
+					</td>
+				</tr>';
+	}
+
+	echo '
+			</table><br />
+			<span class="smalltext">
+				<strong>Note:</strong> If necessary the above security check can be bypassed for users who may administrate a server but not have admin rights on the forum. In order to bypass the above check simply open &quot;upgrade.php&quot; in a text editor and replace &quot;$disable_security = 0;&quot; with &quot;$disable_security = 1;&quot; and refresh this page.
+			</span>
+			<input type="hidden" name="login_attempt" id="login_attempt" value="1" />
+			<input type="hidden" name="js_works" id="js_works" value="0" />';
+
+	// Say we want the continue button!
+	$upcontext['continue'] = !empty($upcontext['user']['id']) && time() - $upcontext['user']['updated'] < $upcontext['inactive_timeout'] ? 2 : 1;
+
+	// This defines whether javascript is going to work elsewhere :D
+	echo '
+		<script type="text/javascript"><!-- // --><![CDATA[
+			if (\'XMLHttpRequest\' in window && document.getElementById(\'js_works\'))
+				document.getElementById(\'js_works\').value = 1;
+
+			// Latest version?
+			function smfCurrentVersion()
+			{
+				var smfVer, yourVer;
+
+				if (!(\'smfVersion\' in window))
+					return;
+
+				window.smfVersion = window.smfVersion.replace(/SMF\s?/g, \'\');
+
+				smfVer = document.getElementById(\'smfVersion\');
+				yourVer = document.getElementById(\'yourVersion\');
+
+				setInnerHTML(smfVer, window.smfVersion);
+
+				var currentVersion = getInnerHTML(yourVer);
+				if (currentVersion < window.smfVersion)
+					document.getElementById(\'version_warning\').style.display = \'\';
+			}
+			addLoadEvent(smfCurrentVersion);
+
+			// This checks that the script file even exists!
+			if (typeof(smfSelectText) == \'undefined\')
+				document.getElementById(\'js_script_missing_error\').style.display = \'\';
+
+		// ]]></script>';
+}
+
+function template_upgrade_options()
+{
+	global $upcontext, $modSettings, $upgradeurl, $disable_security, $settings, $boarddir, $db_prefix, $mmessage, $mtitle, $db_type;
+
+	echo '
+			<h3>Before the upgrade gets underway please review the options below - and hit continue when you\'re ready to begin.</h3>
+			<form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">';
+
+	// Warning message?
+	if (!empty($upcontext['upgrade_options_warning']))
+		echo '
+		<div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;">
+			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
+			<strong style="text-decoration: underline;">Warning!</strong><br />
+			<div style="padding-left: 4ex;">
+				', $upcontext['upgrade_options_warning'], '
+			</div>
+		</div>';
+
+	echo '
+				<table cellpadding="1" cellspacing="0">
+					<tr valign="top">
+						<td width="2%">
+							<input type="checkbox" name="backup" id="backup" value="1"', $db_type != 'mysql' && $db_type != 'postgresql' ? ' disabled="disabled"' : '', ' class="input_check" />
+						</td>
+						<td width="100%">
+							<label for="backup">Backup tables in your database with the prefix &quot;backup_' . $db_prefix . '&quot;.</label>', isset($modSettings['smfVersion']) ? '' : ' (recommended!)', '
+						</td>
+					</tr>
+					<tr valign="top">
+						<td width="2%">
+							<input type="checkbox" name="maint" id="maint" value="1" checked="checked" class="input_check" />
+						</td>
+						<td width="100%">
+							<label for="maint">Put the forum into maintenance mode during upgrade.</label> <span class="smalltext">(<a href="#" onclick="document.getElementById(\'mainmess\').style.display = document.getElementById(\'mainmess\').style.display == \'\' ? \'none\' : \'\'">Customize</a>)</span>
+							<div id="mainmess" style="display: none;">
+								<strong class="smalltext">Maintenance Title: </strong><br />
+								<input type="text" name="maintitle" size="30" value="', htmlspecialchars($mtitle), '" class="input_text" /><br />
+								<strong class="smalltext">Maintenance Message: </strong><br />
+								<textarea name="mainmessage" rows="3" cols="50">', htmlspecialchars($mmessage), '</textarea>
+							</div>
+						</td>
+					</tr>
+					<tr valign="top">
+						<td width="2%">
+							<input type="checkbox" name="debug" id="debug" value="1" class="input_check" />
+						</td>
+						<td width="100%">
+							<label for="debug">Output extra debugging information</label>
+						</td>
+					</tr>
+					<tr valign="top">
+						<td width="2%">
+							<input type="checkbox" name="empty_error" id="empty_error" value="1" class="input_check" />
+						</td>
+						<td width="100%">
+							<label for="empty_error">Empty error log before upgrading</label>
+						</td>
+					</tr>
+					<tr valign="top">
+						<td width="2%">
+							<input type="checkbox" name="stats" id="stats" value="1"', empty($modSettings['allow_sm_stats']) ? '' : ' checked="checked"', ' class="input_check" />
+						</td>
+						<td width="100%">
+							<label for="stats">
+								Allow Simple Machines to Collect Basic Stats Monthly.<br />
+								<span class="smalltext">If enabled, this will allow Simple Machines to visit your site once a month to collect basic statistics. This will help us make decisions as to which configurations to optimise the software for. For more information please visit our <a href="http://www.simplemachines.org/about/stats.php" target="_blank">info page</a>.</span>
+							</label>
+						</td>
+					</tr>
+				</table>
+				<input type="hidden" name="upcont" value="1" />';
+
+	// We need a normal continue button here!
+	$upcontext['continue'] = 1;
+}
+
+// Template for the database backup tool/
+function template_backup_database()
+{
+	global $upcontext, $modSettings, $upgradeurl, $disable_security, $settings, $support_js, $is_debug;
+
+	echo '
+			<h3>Please wait while a backup is created. For large forums this may take some time!</h3>';
+
+	echo '
+			<form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post">
+			<input type="hidden" name="backup_done" id="backup_done" value="0" />
+			<strong>Completed <span id="tab_done">', $upcontext['cur_table_num'], '</span> out of ', $upcontext['table_count'], ' tables.</strong>
+			<span id="debuginfo"></span>';
+
+	// Dont any tables so far?
+	if (!empty($upcontext['previous_tables']))
+		foreach ($upcontext['previous_tables'] as $table)
+			echo '
+			<br />Completed Table: &quot;', $table, '&quot;.';
+
+	echo '
+			<h3 id="current_tab_div">Current Table: &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>
+			<br /><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Backup Complete! Click Continue to Proceed.</span>';
+
+	// Continue please!
+	$upcontext['continue'] = $support_js ? 2 : 1;
+
+	// If javascript allows we want to do this using XML.
+	if ($support_js)
+	{
+		echo '
+		<script type="text/javascript"><!-- // --><![CDATA[
+			var lastTable = ', $upcontext['cur_table_num'], ';
+			function getNextTables()
+			{
+				getXMLDocument(\'', $upcontext['form_url'], '&xml&substep=\' + lastTable, onBackupUpdate);
+			}
+
+			// Got an update!
+			function onBackupUpdate(oXMLDoc)
+			{
+				var sCurrentTableName = "";
+				var iTableNum = 0;
+				var sCompletedTableName = getInnerHTML(document.getElementById(\'current_table\'));
+				for (var i = 0; i < oXMLDoc.getElementsByTagName("table")[0].childNodes.length; i++)
+					sCurrentTableName += oXMLDoc.getElementsByTagName("table")[0].childNodes[i].nodeValue;
+				iTableNum = oXMLDoc.getElementsByTagName("table")[0].getAttribute("num");
+
+				// Update the page.
+				setInnerHTML(document.getElementById(\'tab_done\'), iTableNum);
+				setInnerHTML(document.getElementById(\'current_table\'), sCurrentTableName);
+				lastTable = iTableNum;
+				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
+
+		// If debug flood the screen.
+		if ($is_debug)
+			echo '
+				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br />Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');';
+
+		echo '
+				// Get the next update...
+				if (iTableNum == ', $upcontext['table_count'], ')
+				{
+					document.getElementById(\'commess\').style.display = "";
+					document.getElementById(\'current_tab_div\').style.display = "none";
+					document.getElementById(\'contbutt\').disabled = 0;
+					document.getElementById(\'backup_done\').value = 1;
+				}
+				else
+					getNextTables();
+			}
+			getNextTables();
+		// ]]></script>';
+	}
+}
+
+function template_backup_xml()
+{
+	global $upcontext, $settings, $options, $txt;
+
+	echo '
+	<table num="', $upcontext['cur_table_num'], '">', $upcontext['cur_table_name'], '</table>';
+}
+
+// Here is the actual "make the changes" template!
+function template_database_changes()
+{
+	global $upcontext, $modSettings, $upgradeurl, $disable_security, $settings, $support_js, $is_debug, $timeLimitThreshold;
+
+	echo '
+		<h3>Executing database changes</h3>
+		<h4 style="font-style: italic;">Please be patient - this may take some time on large forums. The time elapsed increments from the server to show progress is being made!</h4>';
+
+	echo '
+		<form action="', $upcontext['form_url'], '&amp;filecount=', $upcontext['file_count'], '" name="upform" id="upform" method="post">
+		<input type="hidden" name="database_done" id="database_done" value="0" />';
+
+	// No javascript looks rubbish!
+	if (!$support_js)
+	{
+		foreach ($upcontext['actioned_items'] as $num => $item)
+		{
+			if ($num != 0)
+				echo ' Successful!';
+			echo '<br />' . $item;
+		}
+		if (!empty($upcontext['changes_complete']))
+			echo ' Successful!<br /><br /><span id="commess" style="font-weight: bold;">Database Updates Complete! Click Continue to Proceed.</span><br />';
+	}
+	else
+	{
+		// Tell them how many files we have in total.
+		if ($upcontext['file_count'] > 1)
+			echo '
+		<strong id="info1">Executing upgrade script <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>';
+
+		echo '
+		<h3 id="info2"><strong>Executing:</strong> &quot;<span id="cur_item_name">', $upcontext['current_item_name'], '</span>&quot; (<span id="item_num">', $upcontext['current_item_num'], '</span> of <span id="total_items"><span id="item_count">', $upcontext['total_items'], '</span>', $upcontext['file_count'] > 1 ? ' - of this script' : '', ')</span></h3>
+		<br /><span id="commess" style="font-weight: bold; display: ', !empty($upcontext['changes_complete']) || $upcontext['current_debug_item_num'] == $upcontext['debug_items'] ? 'inline' : 'none', ';">Database Updates Complete! Click Continue to Proceed.</span>';
+
+		if ($is_debug)
+		{
+			echo '
+			<div id="debug_section" style="height: 200px; overflow: auto;">
+			<span id="debuginfo"></span>
+			</div>';
+		}
+	}
+
+	// Place for the XML error message.
+	echo '
+		<div id="error_block" style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9; display: ', empty($upcontext['error_message']) ? 'none' : '', ';">
+			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
+			<strong style="text-decoration: underline;">Error!</strong><br />
+			<div style="padding-left: 6ex;" id="error_message">', isset($upcontext['error_message']) ? $upcontext['error_message'] : 'Unknown Error!', '</div>
+		</div>';
+
+	// We want to continue at some point!
+	$upcontext['continue'] = $support_js ? 2 : 1;
+
+	// If javascript allows we want to do this using XML.
+	if ($support_js)
+	{
+		echo '
+		<script type="text/javascript"><!-- // --><![CDATA[
+			var lastItem = ', $upcontext['current_debug_item_num'], ';
+			var sLastString = "', strtr($upcontext['current_debug_item_name'], array('"' => '&quot;')), '";
+			var iLastSubStepProgress = -1;
+			var curFile = ', $upcontext['cur_file_num'], ';
+			var totalItems = 0;
+			var prevFile = 0;
+			var retryCount = 0;
+			var testvar = 0;
+			var timeOutID = 0;
+			var getData = "";
+			var debugItems = ', $upcontext['debug_items'], ';
+			function getNextItem()
+			{
+				// We want to track this...
+				if (timeOutID)
+					clearTimeout(timeOutID);
+				timeOutID = window.setTimeout("retTimeout()", ', (10 * $timeLimitThreshold), '000);
+
+				getXMLDocument(\'', $upcontext['form_url'], '&xml&filecount=', $upcontext['file_count'], '&substep=\' + lastItem + getData, onItemUpdate);
+			}
+
+			// Got an update!
+			function onItemUpdate(oXMLDoc)
+			{
+				var sItemName = "";
+				var sDebugName = "";
+				var iItemNum = 0;
+				var iSubStepProgress = -1;
+				var iDebugNum = 0;
+				var bIsComplete = 0;
+				getData = "";
+
+				// We\'ve got something - so reset the timeout!
+				if (timeOutID)
+					clearTimeout(timeOutID);
+
+				// Assume no error at this time...
+				document.getElementById("error_block").style.display = "none";
+
+				// Are we getting some duff info?
+				if (!oXMLDoc.getElementsByTagName("item")[0])
+				{
+					// Too many errors?
+					if (retryCount > 15)
+					{
+						document.getElementById("error_block").style.display = "";
+						setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));';
+
+	if ($is_debug)
+		echo '
+						setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');';
+
+	echo '
+					}
+					else
+					{
+						retryCount++;
+						getNextItem();
+					}
+					return false;
+				}
+
+				// Never allow loops.
+				if (curFile == prevFile)
+				{
+					retryCount++;
+					if (retryCount > 10)
+					{
+						document.getElementById("error_block").style.display = "";
+						setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);';
+
+	if ($is_debug)
+		echo '
+						setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');';
+
+	echo '
+					}
+				}
+				retryCount = 0;
+
+				for (var i = 0; i < oXMLDoc.getElementsByTagName("item")[0].childNodes.length; i++)
+					sItemName += oXMLDoc.getElementsByTagName("item")[0].childNodes[i].nodeValue;
+				for (var i = 0; i < oXMLDoc.getElementsByTagName("debug")[0].childNodes.length; i++)
+					sDebugName += oXMLDoc.getElementsByTagName("debug")[0].childNodes[i].nodeValue;
+				for (var i = 0; i < oXMLDoc.getElementsByTagName("get").length; i++)
+				{
+					getData += "&" + oXMLDoc.getElementsByTagName("get")[i].getAttribute("key") + "=";
+					for (var j = 0; j < oXMLDoc.getElementsByTagName("get")[i].childNodes.length; j++)
+					{
+						getData += oXMLDoc.getElementsByTagName("get")[i].childNodes[j].nodeValue;
+					}
+				}
+
+				iItemNum = oXMLDoc.getElementsByTagName("item")[0].getAttribute("num");
+				iDebugNum = parseInt(oXMLDoc.getElementsByTagName("debug")[0].getAttribute("num"));
+				bIsComplete = parseInt(oXMLDoc.getElementsByTagName("debug")[0].getAttribute("complete"));
+				iSubStepProgress = parseFloat(oXMLDoc.getElementsByTagName("debug")[0].getAttribute("percent"));
+				sLastString = sDebugName + " (Item: " + iDebugNum + ")";
+
+				curFile = parseInt(oXMLDoc.getElementsByTagName("file")[0].getAttribute("num"));
+				debugItems = parseInt(oXMLDoc.getElementsByTagName("file")[0].getAttribute("debug_items"));
+				totalItems = parseInt(oXMLDoc.getElementsByTagName("file")[0].getAttribute("items"));
+
+				// If we have an error we haven\'t completed!
+				if (oXMLDoc.getElementsByTagName("error")[0] && bIsComplete)
+					iDebugNum = lastItem;
+
+				// Do we have the additional progress bar?
+				if (iSubStepProgress != -1)
+				{
+					document.getElementById("substep_bar_div").style.display = "";
+					document.getElementById("substep_bar_div2").style.display = "";
+					document.getElementById("substep_progress").style.width = iSubStepProgress + "%";
+					setInnerHTML(document.getElementById("substep_text"), iSubStepProgress + "%");
+					setInnerHTML(document.getElementById("substep_bar_div"), sDebugName.replace(/\./g, "") + ":");
+				}
+				else
+				{
+					document.getElementById("substep_bar_div").style.display = "none";
+					document.getElementById("substep_bar_div2").style.display = "none";
+				}
+
+				// Move onto the next item?
+				if (bIsComplete)
+					lastItem = iDebugNum;
+				else
+					lastItem = iDebugNum - 1;
+
+				// Are we finished?
+				if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ')
+				{';
+
+		if ($is_debug)
+			echo '
+					document.getElementById(\'debug_section\').style.display = "none";';
+
+		echo '
+
+					document.getElementById(\'commess\').style.display = "";
+					document.getElementById(\'contbutt\').disabled = 0;
+					document.getElementById(\'database_done\').value = 1;';
+
+		if ($upcontext['file_count'] > 1)
+			echo '
+					document.getElementById(\'info1\').style.display = "none";';
+
+		echo '
+					document.getElementById(\'info2\').style.display = "none";
+					updateStepProgress(100, 100, ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');
+					return true;
+				}
+				// Was it the last step in the file?
+				else if (bIsComplete && iDebugNum == -1)
+				{
+					lastItem = 0;
+					prevFile = curFile;';
+
+		if ($is_debug)
+			echo '
+					setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br /><span id="debuginfo"><\' + \'/span>\');';
+
+		echo '
+					getNextItem();
+					return true;
+				}';
+
+		// If debug scroll the screen.
+		if ($is_debug)
+			echo '
+				if (iLastSubStepProgress == -1)
+				{
+					// Give it consistent dots.
+					dots = sDebugName.match(/\./g);
+					numDots = dots ? dots.length : 0;
+					for (var i = numDots; i < 3; i++)
+						sDebugName += ".";
+					setOuterHTML(document.getElementById(\'debuginfo\'), sDebugName + \'<span id="debuginfo"><\' + \'/span>\');
+				}
+				iLastSubStepProgress = iSubStepProgress;
+
+				if (bIsComplete)
+					setOuterHTML(document.getElementById(\'debuginfo\'), \'done<br /><span id="debuginfo"><\' + \'/span>\');
+				else
+					setOuterHTML(document.getElementById(\'debuginfo\'), \'...<span id="debuginfo"><\' + \'/span>\');
+
+				if (document.getElementById(\'debug_section\').scrollHeight)
+					document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
+
+		echo '
+				// Update the page.
+				setInnerHTML(document.getElementById(\'item_num\'), iItemNum);
+				setInnerHTML(document.getElementById(\'cur_item_name\'), sItemName);';
+
+		if ($upcontext['file_count'] > 1)
+		{
+			echo '
+				setInnerHTML(document.getElementById(\'file_done\'), curFile);
+				setInnerHTML(document.getElementById(\'item_count\'), totalItems);';
+		}
+
+		echo '
+				// Is there an error?
+				if (oXMLDoc.getElementsByTagName("error")[0])
+				{
+					var sErrorMsg = "";
+					for (var i = 0; i < oXMLDoc.getElementsByTagName("error")[0].childNodes.length; i++)
+						sErrorMsg += oXMLDoc.getElementsByTagName("error")[0].childNodes[i].nodeValue;
+					document.getElementById("error_block").style.display = "";
+					setInnerHTML(document.getElementById("error_message"), sErrorMsg);
+					return false;
+				}
+
+				// Get the progress bar right.
+				barTotal = debugItems * ', $upcontext['file_count'], ';
+				barDone = (debugItems * (curFile - 1)) + lastItem;
+
+				updateStepProgress(barDone, barTotal, ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');
+
+				// Finally - update the time here as it shows the server is responding!
+				curTime = new Date();
+				iElapsed = (curTime.getTime() / 1000 - ', $upcontext['started'], ');
+				mins = parseInt(iElapsed / 60);
+				secs = parseInt(iElapsed - mins * 60);
+				setInnerHTML(document.getElementById("mins_elapsed"), mins);
+				setInnerHTML(document.getElementById("secs_elapsed"), secs);
+
+				getNextItem();
+				return true;
+			}
+
+			// What if we timeout?!
+			function retTimeout(attemptAgain)
+			{
+				// Oh noes...
+				if (!attemptAgain)
+				{
+					document.getElementById("error_block").style.display = "";
+					setInnerHTML(document.getElementById("error_message"), "Server has not responded for ', ($timeLimitThreshold * 10), ' seconds. It may be worth waiting a little longer or otherwise please click <a href=\"#\" onclick=\"retTimeout(true); return false;\">here<" + "/a> to try this step again");
+				}
+				else
+				{
+					document.getElementById("error_block").style.display = "none";
+					getNextItem();
+				}
+			}';
+
+		// Start things off assuming we've not errored.
+		if (empty($upcontext['error_message']))
+			echo '
+			getNextItem();';
+
+		echo '
+		// ]]></script>';
+	}
+	return;
+}
+
+function template_database_xml()
+{
+	global $upcontext, $settings, $options, $txt;
+
+	echo '
+	<file num="', $upcontext['cur_file_num'], '" items="', $upcontext['total_items'], '" debug_items="', $upcontext['debug_items'], '">', $upcontext['cur_file_name'], '</file>
+	<item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item>
+	<debug num="', $upcontext['current_debug_item_num'], '" percent="', isset($upcontext['substep_progress']) ? $upcontext['substep_progress'] : '-1', '" complete="', empty($upcontext['completed_step']) ? 0 : 1, '">', $upcontext['current_debug_item_name'], '</debug>';
+
+	if (!empty($upcontext['error_message']))
+		echo '
+	<error>', $upcontext['error_message'], '</error>';
+}
+
+function template_clean_mods()
+{
+	global $upcontext, $modSettings, $upgradeurl, $disable_security, $settings, $boarddir, $db_prefix, $boardurl;
+
+	$upcontext['chmod_in_form'] = true;
+
+	echo '
+	<h3>SMF has detected some packages which were installed but not fully removed prior to upgrade. We recommend you remove the following mods and reinstall upon completion of the upgrade.</h3>
+	<form action="', $upcontext['form_url'], '&amp;ssi=1" name="upform" id="upform" method="post">';
+
+	// In case it's required.
+	template_chmod();
+
+	echo '
+		<table width="90%" align="center" cellspacing="1" cellpadding="2" style="background-color: black;">
+			<tr style="background-color: #eeeeee;">
+				<td width="40%"><strong>Modification Name</strong></td>
+				<td width="10%" align="center"><strong>Version</strong></td>
+				<td width="15%"><strong>Files Affected</strong></td>
+				<td width="20%"><strong>Status</strong></td>
+				<td width="5%" align="center"><strong>Fix?</strong></td>
+			</tr>';
+
+	foreach ($upcontext['packages'] as $package)
+	{
+		echo '
+			<tr style="background-color: #cccccc;">
+				<td width="40%">', $package['name'], '</td>
+				<td width="10%">', $package['version'], '</td>
+				<td width="15%">', $package['file_count'], ' <span class="smalltext">[<a href="#" onclick="alert(\'The following files are affected by this modification:\\n\\n', strtr(implode('<br />', $package['files']), array('\\' => '\\\\', '<br />' => '\\n')), '\'); return false;">details</a>]</td>
+				<td width="20%"><span style="font-weight: bold; color: ', $package['color'], '">', $package['status'], '</span></td>
+				<td width="5%" align="center">
+					<input type="hidden" name="remove[', $package['id'], ']" value="0" />
+					<input type="checkbox" name="remove[', $package['id'], ']"', $package['color'] == 'green' ? ' disabled="disabled"' : '', ' class="input_check" />
+				</td>
+			</tr>';
+	}
+	echo '
+		</table>
+		<input type="hidden" name="cleandone" value="1" />';
+
+	// Files to make writable?
+	if (!empty($upcontext['writable_files']))
+		echo '
+		<input type="hidden" name="writable_files" value="', base64_encode(serialize($upcontext['writable_files'])), '" />';
+
+	// We'll want a continue button...
+	if (empty($upcontext['chmod']['files']))
+		$upcontext['continue'] = 1;
+}
+
+// Finished with the mods - let them know what we've done.
+function template_cleanup_done()
+{
+	global $upcontext, $modSettings, $upgradeurl, $disable_security, $settings, $boarddir, $db_prefix, $boardurl;
+
+	echo '
+	<h3>SMF has attempted to fix and reinstall mods as required. We recommend you visit the package manager upon completing upgrade to check the status of your modifications.</h3>
+	<form action="', $upcontext['form_url'], '&amp;ssi=1" name="upform" id="upform" method="post">
+		<table width="90%" align="center" cellspacing="1" cellpadding="2" style="background-color: black;">
+			<tr style="background-color: #eeeeee;">
+				<td width="100%"><strong>Actions Completed:</strong></td>
+			</tr>';
+
+	foreach ($upcontext['packages'] as $package)
+	{
+		echo '
+			<tr style="background-color: #cccccc;">
+				<td>', $package['name'], '... <span style="font-weight: bold; color: ', $package['color'], ';">', $package['result'], '</span></td>
+			</tr>';
+	}
+	echo '
+		</table>
+		<input type="hidden" name="cleandone2" value="1" />';
+
+	// We'll want a continue button...
+	$upcontext['continue'] = 1;
+}
+
+// Do they want to upgrade their templates?
+function template_upgrade_templates()
+{
+	global $upcontext, $modSettings, $upgradeurl, $disable_security, $settings, $boarddir, $db_prefix, $boardurl;
+
+	echo '
+	<h3>There have been numerous language and template changes since the previous version of SMF. On this step the upgrader can attempt to automatically make these changes in your templates to save you from doing so manually.</h3>
+	<form action="', $upcontext['form_url'], '&amp;ssi=1', $upcontext['is_test'] ? '' : ';forreal=1', '" name="upform" id="upform" method="post">';
+
+	// Any files need to be writable?
+	$upcontext['chmod_in_form'] = true;
+	template_chmod();
+
+	// Language/Template files need an update?
+	if ($upcontext['temp_progress'] == 0 && !$upcontext['is_test'] && (!empty($upcontext['languages']) || !empty($upcontext['themes'])))
+	{
+		echo '
+		The following template files will be updated to ensure they are compatible with this version of SMF. Note that this can only fix a limited number of compatibility issues and in general you should seek out the latest version of these themes/language files.
+		<table width="90%" align="center" cellspacing="1" cellpadding="2" style="background-color: black;">
+			<tr style="background-color: #eeeeee;">
+				<td width="80%"><strong>Area</strong></td>
+				<td width="20%" align="center"><strong>Changes Required</strong></td>
+			</tr>';
+
+		foreach ($upcontext['languages'] as $language)
+		{
+			echo '
+				<tr style="background-color: #cccccc;">
+					<td width="80%">
+						&quot;', $language['name'], '&quot; Language Pack
+						<div class="smalltext">(';
+
+			foreach ($language['files'] as $k => $file)
+				echo $file['name'], $k + 1 != count($language['files']) ? ', ' : ')';
+
+			echo '
+						</div>
+					</td>
+					<td width="20%" align="center">', $language['edit_count'] == 0 ? 1 : $language['edit_count'], '</td>
+				</tr>';
+		}
+
+		foreach ($upcontext['themes'] as $theme)
+		{
+			echo '
+				<tr style="background-color: #CCCCCC;">
+					<td width="80%">
+						&quot;', $theme['name'], '&quot; Theme
+						<div class="smalltext">(';
+
+			foreach ($theme['files'] as $k => $file)
+				echo $file['name'], $k + 1 != count($theme['files']) ? ', ' : ')';
+
+			echo '
+						</div>
+					</td>
+					<td width="20%" align="center">', $theme['edit_count'] == 0 ? 1 : $theme['edit_count'], '</td>
+				</tr>';
+		}
+
+		echo '
+		</table>';
+	}
+	else
+	{
+		$langFiles = 0;
+		$themeFiles = 0;
+		if (!empty($upcontext['languages']))
+			foreach ($upcontext['languages'] as $lang)
+				$langFiles += count($lang['files']);
+		if (!empty($upcontext['themes']))
+			foreach ($upcontext['themes'] as $theme)
+				$themeFiles += count($theme['files']);
+		echo sprintf('Found <strong>%d</strong> language files and <strong>%d</strong> templates requiring an update so far.', $langFiles, $themeFiles) . '<br />';
+
+		// What we're currently doing?
+		if (!empty($upcontext['current_message']))
+			echo '
+				', $upcontext['current_message'];
+	}
+
+	echo '
+		<input type="hidden" name="uptempdone" value="1" />';
+
+	if (!empty($upcontext['languages']))
+		echo '
+		<input type="hidden" name="languages" value="', base64_encode(serialize($upcontext['languages'])), '" />';
+	if (!empty($upcontext['themes']))
+		echo '
+		<input type="hidden" name="themes" value="', base64_encode(serialize($upcontext['themes'])), '" />';
+	if (!empty($upcontext['writable_files']))
+		echo '
+		<input type="hidden" name="writable_files" value="', base64_encode(serialize($upcontext['writable_files'])), '" />';
+
+	// Offer them the option to upgrade from YaBB SE?
+	if (!empty($upcontext['can_upgrade_yabbse']))
+		echo '
+		<br /><label for="conv"><input type="checkbox" name="conv" id="conv" value="1" class="input_check" /> Convert the existing YaBB SE template and set it as default.</label><br />';
+
+	// We'll want a continue button... assuming chmod is OK (Otherwise let them use connect!)
+	if (empty($upcontext['chmod']['files']) || $upcontext['is_test'])
+		$upcontext['continue'] = 1;
+}
+
+function template_upgrade_complete()
+{
+	global $upcontext, $modSettings, $upgradeurl, $disable_security, $settings, $boarddir, $db_prefix, $boardurl;
+
+	echo '
+	<h3>That wasn\'t so hard, was it?  Now you are ready to use <a href="', $boardurl, '/index.php">your installation of SMF</a>.  Hope you like it!</h3>
+	<form action="', $boardurl, '/index.php">';
+
+	if (!empty($upcontext['can_delete_script']))
+		echo '
+			<label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete(this);" class="input_check" /> Delete this upgrade.php and its data files now.</label> <em>(doesn\'t work on all servers.)</em>
+			<script type="text/javascript"><!-- // --><![CDATA[
+				function doTheDelete(theCheck)
+				{
+					var theImage = document.getElementById ? document.getElementById("delete_upgrader") : document.all.delete_upgrader;
+
+					theImage.src = "', $upgradeurl, '?delete=1&ts_" + (new Date().getTime());
+					theCheck.disabled = true;
+				}
+			// ]]></script>
+			<img src="', $boardurl, '/Themes/default/images/blank.gif" alt="" id="delete_upgrader" /><br />';
+
+	echo '<br />
+			If you had any problems with this upgrade, or have any problems using SMF, please don\'t hesitate to <a href="http://www.simplemachines.org/community/index.php">look to us for assistance</a>.<br />
+			<br />
+			Best of luck,<br />
+			Simple Machines';
+}
+
+?>

+ 139 - 0
other/upgrade_2-1_mysql.sql

@@ -0,0 +1,139 @@
+/* ATTENTION: You don't need to run or use this file!  The upgrade.php script does everything for you! */
+
+/******************************************************************************/
+--- Adding new settings...
+/******************************************************************************/
+
+---# Adding login history...
+CREATE TABLE IF NOT EXISTS {$db_prefix}member_logins (
+	id_login int(10) NOT NULL auto_increment,
+	id_member mediumint(8) NOT NULL,
+	time int(10) NOT NULL,
+	ip varchar(255) NOT NULL default '',
+	ip2 varchar(255) NOT NULL default '',
+	PRIMARY KEY id_login(id_login),
+	KEY id_member (id_member),
+	KEY time (time)
+) ENGINE=MyISAM{$db_collation};
+---#
+
+---# Moving the cookie name to the database...
+---{
+if (!isset($modSettings['cookie_name']))
+{
+	if (empty($cookiename))
+		$cookiename = 'SMFCookie11';
+
+	upgrade_query("
+		INSERT INTO {$db_prefix}settings
+			(variable, value)
+		VALUES
+			('cookie_name', '$cookiename')");
+}
+---}
+---#
+
+---# Copying the current package backup setting...
+---{
+if (!isset($modSettings['package_make_full_backups']) && isset($modSettings['package_make_backups']))
+	upgrade_query("
+		INSERT INTO {$db_prefix}settings
+			(variable, value)
+		VALUES
+			('package_make_full_backups', '" . $modSettings['package_make_backups'] . "')");
+---}
+---#
+
+/******************************************************************************/
+--- Updating legacy attachments...
+/******************************************************************************/
+
+---# Converting legacy attachments.
+---{
+$request = upgrade_query("
+	SELECT MAX(id_attach)
+	FROM {$db_prefix}attachments");
+list ($step_progress['total']) = $smcFunc['db_fetch_row']($request);
+$smcFunc['db_free_result']($request);
+
+$_GET['a'] = isset($_GET['a']) ? (int) $_GET['a'] : 0;
+$step_progress['name'] = 'Converting legacy attachments';
+$step_progress['current'] = $_GET['a'];
+
+// We may be using multiple attachment directories.
+if (!empty($modSettings['currentAttachmentUploadDir']) && !is_array($modSettings['attachmentUploadDir']))
+	$modSettings['attachmentUploadDir'] = unserialize($modSettings['attachmentUploadDir']);
+
+$is_done = false;
+while (!$is_done)
+{
+	nextSubStep($substep);
+
+	$request = upgrade_query("
+		SELECT id_attach, id_folder, filename, file_hash
+		FROM {$db_prefix}attachments
+		WHERE file_hash = ''
+		LIMIT $_GET[a], 100");
+
+	// Finished?
+	if ($smcFunc['db_num_rows']($request) == 0)
+		$is_done = true;
+
+	while ($row = $smcFunc['db_fetch_assoc']($request))
+	{
+		// The current folder.
+		$current_folder = !empty($modSettings['currentAttachmentUploadDir']) ? $modSettings['attachmentUploadDir'][$row['id_folder']] : $modSettings['attachmentUploadDir'];
+
+		// The old location of the file.
+		$old_location = getLegacyAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder']);
+
+		// The new file name.
+		$file_hash = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], true);
+
+		// And we try to move it.
+		rename($old_location, $current_folder . '/' . $row['id_attach'] . '_' . $file_hash);
+
+		// Only update thif if it was successful.
+		if (file_exists($current_folder . '/' . $row['id_attach'] . '_' . $file_hash) && !file_exists($old_location))
+			upgrade_query("
+				UPDATE {$db_prefix}attachments
+				SET file_hash = '$file_hash'
+				WHERE id_attach = $row[id_attach]");
+	}
+	$smcFunc['db_free_result']($request);
+
+	$_GET['a'] += 100;
+	$step_progress['current'] = $_GET['a'];
+}
+
+unset($_GET['a']);
+---}
+---#
+
+/******************************************************************************/
+--- Adding support for IPv6...
+/******************************************************************************/
+
+---# Adding new columns to ban items...
+ALTER TABLE {$db_prefix}ban_items
+ADD COLUMN ip_low5 smallint(255) unsigned NOT NULL DEFAULT '0',
+ADD COLUMN ip_high5 smallint(255) unsigned NOT NULL DEFAULT '0',
+ADD COLUMN ip_low6 smallint(255) unsigned NOT NULL DEFAULT '0',
+ADD COLUMN ip_high6 smallint(255) unsigned NOT NULL DEFAULT '0',
+ADD COLUMN ip_low7 smallint(255) unsigned NOT NULL DEFAULT '0',
+ADD COLUMN ip_high7 smallint(255) unsigned NOT NULL DEFAULT '0',
+ADD COLUMN ip_low8 smallint(255) unsigned NOT NULL DEFAULT '0',
+ADD COLUMN ip_high8 smallint(255) unsigned NOT NULL DEFAULT '0';
+---#
+
+---# Changing existing columns to ban items...
+ALTER TABLE {$db_prefix}ban_items
+CHANGE ip_low1 ip_low1 tinyint(3) unsigned NOT NULL DEFAULT '0',
+CHANGE ip_high1 ip_high1 tinyint(3) unsigned NOT NULL DEFAULT '0',
+CHANGE ip_low2 ip_low2 tinyint(3) unsigned NOT NULL DEFAULT '0',
+CHANGE ip_high2 ip_high2 tinyint(3) unsigned NOT NULL DEFAULT '0',
+CHANGE ip_low3 ip_low3 tinyint(3) unsigned NOT NULL DEFAULT '0',
+CHANGE ip_high3 ip_high3 tinyint(3) unsigned NOT NULL DEFAULT '0',
+CHANGE ip_low4 ip_low4 tinyint(3) unsigned NOT NULL DEFAULT '0',
+CHANGE ip_high4 ip_high4 tinyint(3) unsigned NOT NULL DEFAULT '0';
+---#

+ 143 - 0
other/upgrade_2-1_postgresql.sql

@@ -0,0 +1,143 @@
+/* ATTENTION: You don't need to run or use this file!  The upgrade.php script does everything for you! */
+
+/******************************************************************************/
+--- Adding new settings...
+/******************************************************************************/
+
+---# Creating login history sequence.
+CREATE SEQUENCE {$db_prefix}member_logins_seq;
+---#
+
+---# Creating login history table.
+CREATE TABLE {$db_prefix}member_logins (
+	id_login int(10) NOT NULL default nextval('{$db_prefix}member_logins_seq'),
+	id_member mediumint(8) NOT NULL,
+	time int(10) NOT NULL,
+	ip varchar(255) NOT NULL default '',
+	ip2 varchar(255) NOT NULL default '',
+	PRIMARY KEY id_login(id_login)
+	KEY id_member (id_member)
+	KEY time (time)
+);
+---#
+
+---# Moving the cookie name to the database...
+---{
+if (!isset($modSettings['cookie_name']))
+{
+	if (empty($cookiename))
+		$cookiename = 'SMFCookie11';
+
+	upgrade_query("
+		INSERT INTO {$db_prefix}settings
+			(variable, value)
+		VALUES
+			('cookie_name', '$cookiename')");
+}
+---}
+---#
+
+---# Copying the current package backup setting...
+---{
+if (!isset($modSettings['package_make_full_backups']) && isset($modSettings['package_make_backups']))
+	upgrade_query("
+		INSERT INTO {$db_prefix}settings
+			(variable, value)
+		VALUES
+			('package_make_full_backups', '" . $modSettings['package_make_backups'] . "')");
+---}
+---#
+
+/******************************************************************************/
+--- Updating legacy attachments...
+/******************************************************************************/
+
+---# Converting legacy attachments.
+---{
+$request = upgrade_query("
+	SELECT MAX(id_attach)
+	FROM {$db_prefix}attachments");
+list ($step_progress['total']) = $smcFunc['db_fetch_row']($request);
+$smcFunc['db_free_result']($request);
+
+$_GET['a'] = isset($_GET['a']) ? (int) $_GET['a'] : 0;
+$step_progress['name'] = 'Converting legacy attachments';
+$step_progress['current'] = $_GET['a'];
+
+// We may be using multiple attachment directories.
+if (!empty($modSettings['currentAttachmentUploadDir']) && !is_array($modSettings['attachmentUploadDir']))
+	$modSettings['attachmentUploadDir'] = unserialize($modSettings['attachmentUploadDir']);
+
+$is_done = false;
+while (!$is_done)
+{
+	nextSubStep($substep);
+
+	$request = upgrade_query("
+		SELECT id_attach, id_folder, filename, file_hash
+		FROM {$db_prefix}attachments
+		WHERE file_hash = ''
+		LIMIT $_GET[a], 100");
+
+	// Finished?
+	if ($smcFunc['db_num_rows']($request) == 0)
+		$is_done = true;
+
+	while ($row = $smcFunc['db_fetch_assoc']($request))
+	{
+		// The current folder.
+		$current_folder = !empty($modSettings['currentAttachmentUploadDir']) ? $modSettings['attachmentUploadDir'][$row['id_folder']] : $modSettings['attachmentUploadDir'];
+
+		// The old location of the file.
+		$old_location = getLegacyAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder']);
+
+		// The new file name.
+		$file_hash = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], true);
+
+		// And we try to move it.
+		rename($old_location, $current_folder . '/' . $row['id_attach'] . '_' . $file_hash);
+
+		// Only update thif if it was successful.
+		if (file_exists($current_folder . '/' . $row['id_attach'] . '_' . $file_hash) && !file_exists($old_location))
+			upgrade_query("
+				UPDATE {$db_prefix}attachments
+				SET file_hash = '$file_hash'
+				WHERE id_attach = $row[id_attach]");
+	}
+	$smcFunc['db_free_result']($request);
+
+	$_GET['a'] += 100;
+	$step_progress['current'] = $_GET['a'];
+}
+
+unset($_GET['a']);
+---}
+---#
+
+/******************************************************************************/
+--- Adding support for IPv6...
+/******************************************************************************/
+
+---# Adding new columns to ban items...
+ALTER TABLE {$db_prefix}ban_items
+ADD COLUMN ip_low5 smallint(255) unsigned NOT NULL DEFAULT '0',
+ADD COLUMN ip_high5 smallint(255) unsigned NOT NULL DEFAULT '0',
+ADD COLUMN ip_low6 smallint(255) unsigned NOT NULL DEFAULT '0',
+ADD COLUMN ip_high6 smallint(255) unsigned NOT NULL DEFAULT '0',
+ADD COLUMN ip_low7 smallint(255) unsigned NOT NULL DEFAULT '0',
+ADD COLUMN ip_high7 smallint(255) unsigned NOT NULL DEFAULT '0',
+ADD COLUMN ip_low8 smallint(255) unsigned NOT NULL DEFAULT '0',
+ADD COLUMN ip_high8 smallint(255) unsigned NOT NULL DEFAULT '0';
+---#
+
+---# Changing existing columns to ban items...
+ALTER TABLE {$db_prefix}ban_items
+CHANGE ip_low1 ip_low1 tinyint(3) unsigned NOT NULL DEFAULT '0',
+CHANGE ip_high1 ip_high1 tinyint(3) unsigned NOT NULL DEFAULT '0',
+CHANGE ip_low2 ip_low2 tinyint(3) unsigned NOT NULL DEFAULT '0',
+CHANGE ip_high2 ip_high2 tinyint(3) unsigned NOT NULL DEFAULT '0',
+CHANGE ip_low3 ip_low3 tinyint(3) unsigned NOT NULL DEFAULT '0',
+CHANGE ip_high3 ip_high3 tinyint(3) unsigned NOT NULL DEFAULT '0',
+CHANGE ip_low4 ip_low4 tinyint(3) unsigned NOT NULL DEFAULT '0',
+CHANGE ip_high4 ip_high4 tinyint(3) unsigned NOT NULL DEFAULT '0';
+---#

+ 139 - 0
other/upgrade_2-1_sqlite.sql

@@ -0,0 +1,139 @@
+/* ATTENTION: You don't need to run or use this file!  The upgrade.php script does everything for you! */
+
+/******************************************************************************/
+--- Adding new settings...
+/******************************************************************************/
+
+---# Adding login history...
+CREATE TABLE IF NOT EXISTS {$db_prefix}member_logins (
+	id_login integer NOT NULL auto_increment,
+	id_member integer NOT NULL,
+	time integer NOT NULL,
+	ip varchar(255) NOT NULL default '',
+	ip2 varchar(255) NOT NULL default '',
+	PRIMARY KEY id_login(id_login)
+	KEY id_member (id_member)
+	KEY time (time)
+);
+---#
+
+---# Moving the cookie name to the database...
+---{
+if (!isset($modSettings['cookie_name']))
+{
+	if (empty($cookiename))
+		$cookiename = 'SMFCookie11';
+
+	upgrade_query("
+		INSERT INTO {$db_prefix}settings
+			(variable, value)
+		VALUES
+			('cookie_name', '$cookiename')");
+}
+---}
+---#
+
+---# Copying the current package backup setting...
+---{
+if (!isset($modSettings['package_make_full_backups']) && isset($modSettings['package_make_backups']))
+	upgrade_query("
+		INSERT INTO {$db_prefix}settings
+			(variable, value)
+		VALUES
+			('package_make_full_backups', '" . $modSettings['package_make_backups'] . "')");
+---}
+---#
+
+/******************************************************************************/
+--- Updating legacy attachments...
+/******************************************************************************/
+
+---# Converting legacy attachments.
+---{
+$request = upgrade_query("
+	SELECT MAX(id_attach)
+	FROM {$db_prefix}attachments");
+list ($step_progress['total']) = $smcFunc['db_fetch_row']($request);
+$smcFunc['db_free_result']($request);
+
+$_GET['a'] = isset($_GET['a']) ? (int) $_GET['a'] : 0;
+$step_progress['name'] = 'Converting legacy attachments';
+$step_progress['current'] = $_GET['a'];
+
+// We may be using multiple attachment directories.
+if (!empty($modSettings['currentAttachmentUploadDir']) && !is_array($modSettings['attachmentUploadDir']))
+	$modSettings['attachmentUploadDir'] = unserialize($modSettings['attachmentUploadDir']);
+
+$is_done = false;
+while (!$is_done)
+{
+	nextSubStep($substep);
+
+	$request = upgrade_query("
+		SELECT id_attach, id_folder, filename, file_hash
+		FROM {$db_prefix}attachments
+		WHERE file_hash = ''
+		LIMIT $_GET[a], 100");
+
+	// Finished?
+	if ($smcFunc['db_num_rows']($request) == 0)
+		$is_done = true;
+
+	while ($row = $smcFunc['db_fetch_assoc']($request))
+	{
+		// The current folder.
+		$current_folder = !empty($modSettings['currentAttachmentUploadDir']) ? $modSettings['attachmentUploadDir'][$row['id_folder']] : $modSettings['attachmentUploadDir'];
+
+		// The old location of the file.
+		$old_location = getLegacyAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder']);
+
+		// The new file name.
+		$file_hash = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], true);
+
+		// And we try to move it.
+		rename($old_location, $current_folder . '/' . $row['id_attach'] . '_' . $file_hash);
+
+		// Only update thif if it was successful.
+		if (file_exists($current_folder . '/' . $row['id_attach'] . '_' . $file_hash) && !file_exists($old_location))
+			upgrade_query("
+				UPDATE {$db_prefix}attachments
+				SET file_hash = '$file_hash'
+				WHERE id_attach = $row[id_attach]");
+	}
+	$smcFunc['db_free_result']($request);
+
+	$_GET['a'] += 100;
+	$step_progress['current'] = $_GET['a'];
+}
+
+unset($_GET['a']);
+---}
+---#
+
+/******************************************************************************/
+--- Adding support for IPv6...
+/******************************************************************************/
+
+---# Adding new columns to ban items...
+ALTER TABLE {$db_prefix}ban_items
+ADD COLUMN ip_low5 smallint(255) unsigned NOT NULL DEFAULT '0',
+ADD COLUMN ip_high5 smallint(255) unsigned NOT NULL DEFAULT '0',
+ADD COLUMN ip_low6 smallint(255) unsigned NOT NULL DEFAULT '0',
+ADD COLUMN ip_high6 smallint(255) unsigned NOT NULL DEFAULT '0',
+ADD COLUMN ip_low7 smallint(255) unsigned NOT NULL DEFAULT '0',
+ADD COLUMN ip_high7 smallint(255) unsigned NOT NULL DEFAULT '0',
+ADD COLUMN ip_low8 smallint(255) unsigned NOT NULL DEFAULT '0',
+ADD COLUMN ip_high8 smallint(255) unsigned NOT NULL DEFAULT '0';
+---#
+
+---# Changing existing columns to ban items...
+ALTER TABLE {$db_prefix}ban_items
+CHANGE ip_low1 ip_low1 tinyint(3) unsigned NOT NULL DEFAULT '0',
+CHANGE ip_high1 ip_high1 tinyint(3) unsigned NOT NULL DEFAULT '0',
+CHANGE ip_low2 ip_low2 tinyint(3) unsigned NOT NULL DEFAULT '0',
+CHANGE ip_high2 ip_high2 tinyint(3) unsigned NOT NULL DEFAULT '0',
+CHANGE ip_low3 ip_low3 tinyint(3) unsigned NOT NULL DEFAULT '0',
+CHANGE ip_high3 ip_high3 tinyint(3) unsigned NOT NULL DEFAULT '0',
+CHANGE ip_low4 ip_low4 tinyint(3) unsigned NOT NULL DEFAULT '0',
+CHANGE ip_high4 ip_high4 tinyint(3) unsigned NOT NULL DEFAULT '0';
+---#