diff --git a/phpBB/install/install.php b/phpBB/install/install.php
index 1270ecf2f2..bc8cf254c4 100644
--- a/phpBB/install/install.php
+++ b/phpBB/install/install.php
@@ -251,19 +251,7 @@ else if (isset($_POST['install']))
}
}
- // Include the DB layer
- include($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
-
- // Instantiate it and set return on error true
- $db = new sql_db();
- $db->sql_return_on_error(true);
-
- // Try and connect ...
- if (is_array($db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false)))
- {
- $db_error = $db->sql_error();
- $error['db'][] = $lang['INST_ERR_DB_CONNECT'] . ' ' . (($db_error['message']) ? $db_error['message'] : $lang['INST_ERR_DB_NO_ERROR']);
- }
+ connect_check_db(false, $error, $dbms, $table_prefix, $dbhost, $dbuser, $dbpasswd, $dbname, $dbport);
// No errors so lets do the twist
if (sizeof($error))
@@ -576,24 +564,7 @@ if ($stage == 1)
}
}
- // Include the DB layer
- include_once($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
-
- // Instantiate it and set return on error true
- $db = new sql_db();
- $db->sql_return_on_error(true);
-
- // Try and connect ...
- if (is_array($db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false)))
- {
- $db_error = $db->sql_error();
- $error['db'][] = $lang['INST_ERR_DB_CONNECT'] . ' ' . (($db_error['message']) ? $db_error['message'] : $lang['INST_ERR_DB_NO_ERROR']);
- }
-
- if (!sizeof($error['db']))
- {
- $error['db'][] = $lang['INSTALL_DB_CONNECT'];
- }
+ connect_check_db(true, $error, $dbms, $table_prefix, $dbhost, $dbuser, $dbpasswd, $dbname, $dbport);
}
@@ -686,11 +657,11 @@ if ($stage == 1)
-
:
+
:
-
:
+
:
@@ -1055,15 +1026,13 @@ if ($stage == 3)
@dl($available_dbms[$dbms]['MODULE'] . ".$prefix");
}
-
// Load the appropriate database class if not already loaded
- include_once($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
+ include($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
// Instantiate the database
$db = new sql_db();
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false);
-
// We ship the Access schema complete, we don't need to create tables nor
// populate it (at this time ... this may change). So we skip this section
if ($dbms != 'msaccess')
@@ -1071,7 +1040,6 @@ if ($stage == 3)
// NOTE: trigger_error does not work here.
$db->return_on_error = true;
- $ignore_tables = array();
// Ok we have the db info go ahead and read in the relevant schema
// and work on building the table
@@ -1093,22 +1061,12 @@ if ($stage == 3)
$sql = trim($sql);
if (!$db->sql_query($sql))
{
- // TODO
- //
- // This is a fudgy way of dealing with attempts at installing to a DB
- // which already contains the relevant tables. Next thing to do is
- // to quit back to stage 1 and inform the user that this table extension
- // is already in use
- $ignore_tables[] = preg_replace('#^CREATE TABLE ([a-z_]+?) .*$#is', '\1', $sql);
-
$error = $db->sql_error();
- die($error['message']);
+ inst_db_error($error['message'], $sql, __LINE__, __FILE__);
}
}
unset($sql_query);
- $ignore_tables = str_replace('\\|', '|', preg_quote(implode('|', $ignore_tables), '#'));
-
// Ok tables have been built, let's fill in the basic information
$sql_query = fread(fopen('schemas/schema_data.sql', 'r'), filesize('schemas/schema_data.sql'));
@@ -1133,15 +1091,10 @@ if ($stage == 3)
foreach ($sql_query as $sql)
{
$sql = trim(str_replace('|', ';', $sql));
- if ($ignore_tables != '' && preg_match('#' . $ignore_tables . '#', $sql))
- {
- continue;
- }
-
if (!$db->sql_query($sql))
{
$error = $db->sql_error();
- die($error['message']);
+ inst_db_error($error['message'], $sql, __LINE__, __FILE__);
}
}
unset($sql_query);
@@ -1171,9 +1124,13 @@ if ($stage == 3)
WHERE config_name = 'script_path'",
'UPDATE ' . $table_prefix . "config
- SET config_value = '" . $db->sql_escape($board_email) . "'
+ SET config_value = '" . $db->sql_escape($board_email1) . "'
WHERE config_name = 'board_email'",
+ 'UPDATE ' . $table_prefix . "config
+ SET config_value = '" . $db->sql_escape($board_email1) . "'
+ WHERE config_name = 'board_contact'",
+
'UPDATE ' . $table_prefix . "config
SET config_value = '" . $db->sql_escape($server_name) . "'
WHERE config_name = 'cookie_domain'",
@@ -1215,15 +1172,11 @@ if ($stage == 3)
foreach ($sql_ary as $sql)
{
$sql = trim(str_replace('|', ';', $sql));
- if ($ignore_tables != '' && preg_match('#' . $ignore_tables . '#i', $sql))
- {
- continue;
- }
if (!$db->sql_query($sql))
{
$error = $db->sql_error();
- die($error['message']);
+ inst_db_error($error['message'], $sql, __LINE__, __FILE__);
}
}
@@ -1264,6 +1217,8 @@ if ($stage == 4)
sql_close();
+
inst_page_footer();
exit;
@@ -1326,16 +1281,42 @@ td.cat { background-image: url('../adm/images/cellpic1.gif') }
}
-// Output page -> footer
-function inst_page_footer()
+function inst_db_error($error, $sql, $line, $file)
{
- global $lang;
+ global $lang, $db;
+
+ inst_page_header();
?>
-