' . "\n"; $config_file .= '
' . "\n"; $config_file .= '//
' . "\n"; $config_file .= '// phpBB 2.x auto-generated config file
' . "\n"; $config_file .= '// Do not change anything in this file!
' . "\n"; $config_file .= '//
' . "\n"; $config_file .= '
' . "\n"; $config_file .= '$dbms = \'' . $dbms . '\';

' . "\n\n"; $config_file .= '$dbhost = \'' . $dbhost . '\';
' . "\n"; $config_file .= '$dbname = \'' . $dbname . '\';
' . "\n"; $config_file .= '$dbuser = \'' . $dbuser . '\';
' . "\n"; $config_file .= '$dbpasswd = \'' . $dbpasswd . '\';

' . "\n\n"; $config_file .= '$table_prefix = \'' . $table_prefix . '\';

' . "\n\n"; $config_file .= 'define(\'PHPBB_INSTALLED\', true);

' . "\n\n"; $config_file .= '?>'; return $config_file; } function make_download($dbms, $dbhost, $dbname, $dbuser, $dbpasswd, $table_prefix) { $config_file = ''; return $config_file; } /* make all the vars safe to display in form inputs and on the user's screen. Borrowed from usercp_register.php */ $check_var_list = array('dbms' => 'dbms', 'dbhost' => 'dbhost', 'dbname' => 'dbname', 'dbuser' => 'dbuser', 'dbpasswd' => 'dbpasswd', 'table_prefix' => 'table_prefix'); while (list($var, $param) = each($check_var_list)) { if (!empty($HTTP_POST_VARS[$param])) { $$var = stripslashes(htmlspecialchars(strip_tags($HTTP_POST_VARS[$param]))); } } $available_dbms = array( 'mysql' => 'MySQL 3.x', 'mysql4' => 'MySQL 4.x', 'postgres' => 'PostgreSQL 7.x', 'mssql' => 'MS SQL Server 7/2000', 'msaccess' => 'MS Access [ ODBC ]', 'mssql-odbc' => 'MS SQL Server [ OBDC ]', ); if (isset($HTTP_POST_VARS['download_config']) && $HTTP_POST_VARS['download_config'] == true && isset($HTTP_POST_VARS['submit_download_config']) && $HTTP_POST_VARS['submit_download_config'] == 'Download') { /* borrowed from install.php */ header('Content-Type: text/x-delimtext; name="config.php"'); header('Content-disposition: attachment; filename=config.php'); echo make_download($dbms, $dbhost, $dbname, $dbuser, $dbpasswd, $table_prefix); return; } ?> phpBB :: dbinformer.php
phpBB2 : Creating Communities dbinformer.php

Database Configuration
Database type:
Database Server Hostname / DSN:
Your Database Name:
Database Username:
Database Password:
Chosen Prefix:
Generate a config file: />
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: ' . htmlspecialchars($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 '
  • ' . htmlspecialchars($table[0]) . '

  • '; } else { echo '
  • ' . htmlspecialchars($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 '
'; echo make_config($dbms, $dbhost, $dbname, $dbuser, $dbpasswd, $table_prefix); echo '
'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '

'; } } /* close the connection */ if ($all_connected == true) { $db['close']; } } } /* And they all lived happily ever after... The End */ ?>
Return to top
© Copyright 2002 The phpBB Group