【php开源代码栏目提醒】:以下是网学会员为您推荐的php开源代码-dbinformer.php,希望本篇文章对您学习有所帮助。
<?php
/***************************************************************************
* dbinformer.php
* -------------------
* begin : Saturday, May 05, 2002
* copyright : (C) 2002 The phpBB Group
* email : n/a
*
* $Id: dbinformer.php,v 1.65 2002/05/04 12:15:00 Blade Exp $
*
* Coded by AL, Techie-Micheal, Blade, and Black Fluffy Lion.
* http://www.phpbb.com/phpBB/groupcp.php?g=7330
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
/* magic quotes, borrowed from install.php */
set_magic_quotes_runtime(0);
if (!get_magic_quotes_gpc())
{
if (is_array($HTTP_POST_VARS))
{
while (list($k, $v) = each($HTTP_POST_VARS))
{
if (is_array($HTTP_POST_VARS[$k]))
{
while (list($k2, $v2) = each($HTTP_POST_VARS[$k]))
{
$HTTP_POST_VARS[$k][$k2] = addslashes($v2);
}
@reset($HTTP_POST_VARS[$k]);
}
else
{
$HTTP_POST_VARS[$k] = addslashes($v);
}
}
@reset($HTTP_POST_VARS);
}
}
$all_connected = false;
$error = false;
$error_msg = '';
$select = false;
$connect = false;
function make_config($dbms, $dbhost, $dbname, $dbuser, $dbpasswd, $table_prefix)
{
$config_file = '<?php<br />' . "\n";
$config_file .= '<br />' . "\n";
$config_file .= '//<br />' . "\n";
$config_file .= '// phpBB 2.x auto-generated config file<br />' . "\n";
$config_file .= '// Do not change anything in this file!<br />' . "\n";
$config_file .= '//<br />' . "\n";
$config_file .= '<br />' . "\n";
$config_file .= '$dbms = \'' . $dbms . '\';<br /><br />' . "\n\n";
$config_file .= '$dbhost = \'' . $dbhost . '\';<br />' . "\n";
$config_file .= '$dbname = \'' . $dbname . '\';<br />' . "\n";
$config_file .= '$dbuser = \'' . $dbuser . '\';<br />' . "\n";
$config_file .= '$dbpasswd = \'' . $dbpasswd . '\';<br /><br />' . "\n\n";
$config_file .= '$table_prefix = \'' . $table_prefix . '\';<br /><br />' . "\n\n";
$config_file .= 'define(\'PHPBB_INSTALLED\', true);<br /><br />' . "\n\n";
$config_file .= '?>';
return $config_file;
}
function make_download($dbms, $dbhost, $dbname, $dbuser, $dbpasswd, $table_prefix)
{
$config_file = '<?php' . "\n\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\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;
}
/* 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',
'ms
sql' => '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;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD
HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html" />
<meta http-equ