Please enter your data. ';
}
else
{
/* dbal added by Techie-Micheal [and then obliterated by BFL]. weeeeeee! */
switch ($dbms)
{
case 'mysql':
if (function_exists(@mysql_connect))
{
$db = array(
'choice' => 'MySQL 3.x',
'connect' => @mysql_connect($dbhost, $dbuser, $dbpasswd),
'select' => @mysql_select_db($dbname),
'error' => @mysql_error(),
'list' => @mysql_list_tables($dbname),
'fetch' => @mysql_fetch_row,
'close' => @mysql_close()
);
}
else
{
$error = true;
$error_msg = 'You do not have the needed functions available for ' . $available_dbms[$dbms] . '.';
}
break;
case 'mysql4':
if (function_exists(@mysql_connect))
{
$db = array(
'choice' => 'MySQL 4.x',
'connect' => @mysql_connect($dbhost, $dbuser, $dbpasswd),
'select' => @mysql_select_db($dbname),
'error' => @mysql_error(),
'list' => @mysql_list_tables($dbname),
'fetch' => @mysql_fetch_row,
'close' => @mysql_close()
);
}
else
{
$error = true;
$error_msg = 'You do not have the needed functions available for ' . $available_dbms[$dbms] . '.';
}
break;
case 'msaccess':
if (function_exists(@odbc_connect))
{
$db = array(
'choice' => 'MS Access [ ODBC ]',
'connect' => @odbc_connect($dbhost, $dbuser, $dbpasswd),
'select' => 'na',
'error' => @odbc_errormsg(),
'list' => 'na', /* odbc_tables() */
'fetch' => 'na', /* odbc_fetch_row(), odbc_result_all() */
'close' => @odbc_close()
);
}
else
{
$error = true;
$error_msg = 'You do not have the needed functions available for ' . $available_dbms[$dbms] . '.';
}
break;
case 'postgres':
if (function_exists(@pg_connect))
{
$db = array(
'choice' => 'PostgreSQL 7.x',
'connect' => @pg_connect('host=' . $dbhost . ' user=' . $dbuser . ' dbname=' . $dbname . ' password=' . $dbpasswd),
'select' => 'na',
'error' => @pg_last_error(),
'list' => @pg_exec("SELECT relname FROM pg_class WHERE relkind = 'r' AND relname NOT LIKE 'pg\_%'"), /* provided by SuGa */
'fetch' => @pg_fetch_row,
'close' => @pg_close()
);
}
else
{
$error = true;
$error_msg = 'You do not have the needed functions available for ' . $available_dbms[$dbms] . '.';
}
break;
case 'mssql':
if (function_exists(@mssql_connect))
{
$db = array(
'choice' => 'MS SQL Server 7/2000',
'connect' => @mssql_connect($dbhost, $dbuser, $dbpasswd),
'select' => @mssql_select_db($dbname),
'error' => @mssql_get_last_message(),
'list' => 'na',
'fetch' => 'na', /* mssql_fetch_row() */
'close' => @mssql_close()
);
}
else
{
$error = true;
$error_msg = 'You do not have the needed functions available for ' . $available_dbms[$dbms] . '.';
}
break;
case 'mssql-odbc':
if (function_exists(@odbc_connect))
{
$db = array(
'choice' => 'MS SQL Server [ ODBC ]',
'connect' => @odbc_connect($dbhost, $dbuser, $dbpasswd),
'select' => 'na',
'error' => @odbc_errormsg(),
'list' => 'na', /* odbc_tables() */
'fetch' => 'na', /* odbc_fetch_row(), odbc_result_all() */
'close' => @odbc_close()
);
}
else
{
$error = true;
$error_msg = 'You do not have the needed functions available for ' . $available_dbms[$dbms] . '.';
}
break;
default:
$error = true;
$error_msg = 'Unrecognised DBMS.';
break;
}
if ($error == true && $error_msg != '')
{
echo ' ERROR: ' . $error_msg . ' ';
}
else
{
echo 'What you entered';
echo 'Database Type: ' . $db['choice'] . ' ';
echo 'Database Server Hostname / DSN: ' . $dbhost . ' ';
echo 'Your Database Name: ' . $dbname . ' ';
echo 'Database Username: ' . $dbuser . ' ';
echo 'Database Password: ' . $dbpasswd . ' ';
echo 'Connection to database';
if (!$db['connect'])
{
echo 'You have not established a connection to ' . $db['choice'] . '. ';
echo 'ERROR: ' . $db['error'] . '
';
}
else
{
echo 'You have established a connection to ' . $db['choice'] . '.
';
$connect = true;
}
if ($dbms == 'msaccess' || $dbms == 'postgres' || $dbms == 'mssql-odbc')
{
/* for dbmses which have no db select function */
$select = true;
}
else
{
if (!$db['select'])
{
echo 'Your database was not found. ';
echo 'ERROR: ' . $db['error'] . ' ';
}
else
{
echo 'Your database was found. ';
$select = true;
}
}
if ($connect == true && $select == true)
{
echo 'Tables in database';
if ($dbms == 'mysql' || $dbms == 'mysql4' || $dbms == 'postgres')
{
echo 'Tables with the table prefix you specified are in bold.';
echo '';
while ($table = $db['fetch']($db['list']))
{
/* Highlight tables with the table_prefix specified */
if (preg_match("/^$HTTP_POST_VARS[table_prefix]/i", $table[0]))
{
echo '- ' . $table[0] . '
';
}
else
{
echo '- ' . $table[0] . '
';
}
}
echo ' ';
}
else
{
echo 'Sorry, this feature isn\'t available with ' . $db['choice'] . '.';
}
/* defined a var which is only there if successfully connected to the database and the database is found */
$all_connected = true;
}
/* Create a config file if checked and if the connection went OK */
if (isset($HTTP_POST_VARS['generate_config']) && $HTTP_POST_VARS['generate_config'] == true)
{
echo 'Config file';
if ($all_connected != true)
{
echo 'The database has not been successfully connected to so no config file has been generated. ';
}
else
{
echo 'Either copy the 19 lines below and save them as config.php or click on the Download button below. Then upload the file to your phpBB2 root directory (phpBB2/ by default). Make sure that there is nothing (this includes blank spaces) after the ?>.
';
/* Create our config file */
echo ' |