diff --git a/phpBB/install/install.php b/phpBB/install/install.php
index afb74c219a..f3598dc8cf 100644
--- a/phpBB/install/install.php
+++ b/phpBB/install/install.php
@@ -19,11 +19,13 @@
*
***************************************************************************/
-error_reporting (E_ERROR | E_WARNING | E_PARSE); // This will NOT report uninitialized variables
+//error_reporting (E_ERROR | E_WARNING | E_PARSE); // This will NOT report uninitialized variables
+error_reporting (E_ERROR | E_WARNING | E_PARSE | E_WARNING); // This will NOT report uninitialized variables
set_magic_quotes_runtime(0); // Disable magic_quotes_runtime
-if ( !get_magic_quotes_gpc() )
+if (!get_magic_quotes_gpc())
{
+ $_REQUEST = slash_input_data($_REQUEST);
$_GET = slash_input_data($_GET);
$_POST = slash_input_data($_POST);
}
@@ -34,44 +36,23 @@ require($phpbb_root_path . 'extension.inc');
require($phpbb_root_path . 'includes/functions.'.$phpEx);
-/***************************************************************************
- * Install Customization Section
- *
- * This section can be modified to set up some basic default information
- * used by the install script. Specifically the default theme data
- * and the default template.
- *
- **************************************************************************/
+// Set some vars
+define('ANONYMOUS', 1);
+define('ACL_DENY', 0);
+define('ACL_ALLOW', 1);
+define('ACL_INHERIT', 2);
+
$default_language = 'en';
-
-if ( isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) )
-{
- $accept_lang_ary = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
- foreach ( $accept_lang_ary as $accept_lang )
- {
- // Set correct format ... guess full xx_YY form
- $accept_lang = substr($accept_lang, 0, 2) . '_' . strtoupper(substr($accept_lang, 3, 2));
- if ( file_exists($phpbb_root_path . 'language/' . $accept_lang) )
- {
- $default_language = $accept_lang;
- break;
- }
- else
- {
- // No match on xx_YY so try xx
- $accept_lang = substr($accept_lang, 0, 2);
- if ( file_exists($phpbb_root_path . 'language/' . $accept_lang) )
- {
- $default_language = $accept_lang;
- break;
- }
- }
- }
-}
-
$default_template = 'subSilver';
$available_dbms = array(
+ 'firebird' => array(
+ 'LABEL' => 'FireBird',
+ 'SCHEMA' => 'firebird',
+ 'DELIM' => ';',
+ 'DELIM_BASIC' => ';',
+ 'COMMENTS' => 'remove_remarks'
+ ),
'mysql' => array(
'LABEL' => 'MySQL 3.x',
'SCHEMA' => 'mysql',
@@ -86,13 +67,6 @@ $available_dbms = array(
'DELIM_BASIC' => ';',
'COMMENTS' => 'remove_remarks'
),
- 'postgres' => array(
- 'LABEL' => 'PostgreSQL 7.x',
- 'SCHEMA' => 'postgres',
- 'DELIM' => ';',
- 'DELIM_BASIC' => ';',
- 'COMMENTS' => 'remove_comments'
- ),
'mssql' => array(
'LABEL' => 'MS SQL Server 7/2000',
'SCHEMA' => 'mssql',
@@ -113,103 +87,113 @@ $available_dbms = array(
'DELIM' => 'GO',
'DELIM_BASIC' => ';',
'COMMENTS' => 'remove_comments'
- )
+ ),
+ 'postgres' => array(
+ 'LABEL' => 'PostgreSQL 7.x',
+ 'SCHEMA' => 'postgres',
+ 'DELIM' => ';',
+ 'DELIM_BASIC' => ';',
+ 'COMMENTS' => 'remove_comments'
+ ),
);
-//
-// Uncomment the following line to completely disable the ftp option...
-//
-// define('NO_FTP', true);
-
-/***************************************************************************
-*
-* End Install Customization Section
-*
-***************************************************************************/
-
-//
-// Try opening config file
-//
-if ( @file_exists('../config.'.$phpEx) )
+// Try and load an appropriate language
+if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE']))
{
- include('../config.'.$phpEx);
-}
-
-//
-// Obtain various vars
-//
-$confirm = ( isset($_POST['confirm']) ) ? true : false;
-$cancel = ( isset($_POST['cancel']) ) ? true : false;
-
-if ( isset($_POST['install_step']) || isset($_GET['install_step']) )
-{
- $install_step = ( isset($_POST['install_step']) ) ? $_POST['install_step'] : $_GET['install_step'];
-}
-else
-{
- $install_step = '';
-}
-
-$upgrade = ( !empty($_POST['upgrade']) ) ? $_POST['upgrade']: '';
-$upgrade_now = ( !empty($_POST['upgrade_now']) ) ? $_POST['upgrade_now']:'';
-
-$dbms = isset($_POST['dbms']) ? $_POST['dbms'] : '';
-$language = ( !empty($_POST['language']) ) ? $_POST['language'] : $default_language;
-
-$dbhost = ( !empty($_POST['dbhost']) ) ? $_POST['dbhost'] : '';
-$dbuser = ( !empty($_POST['dbuser']) ) ? $_POST['dbuser'] : '';
-$dbpasswd = ( !empty($_POST['dbpasswd']) ) ? $_POST['dbpasswd'] : '';
-$dbname = ( !empty($_POST['dbname']) ) ? $_POST['dbname'] : '';
-
-$table_prefix = ( !empty($_POST['prefix']) ) ? $_POST['prefix'] : '';
-
-$admin_name = ( !empty($_POST['admin_name']) ) ? $_POST['admin_name'] : '';
-$admin_pass1 = ( !empty($_POST['admin_pass1']) ) ? $_POST['admin_pass1'] : '';
-$admin_pass2 = ( !empty($_POST['admin_pass2']) ) ? $_POST['admin_pass2'] : '';
-
-$ftp_path = ( !empty($_POST['ftp_path']) ) ? $_POST['ftp_path'] : '';
-$ftp_user = ( !empty($_POST['ftp_user']) ) ? $_POST['ftp_user'] : '';
-$ftp_pass = ( !empty($_POST['ftp_pass']) ) ? $_POST['ftp_pass'] : '';
-
-$server_name = ( !empty($_POST['server_name']) ) ? $_POST['server_name'] : '';
-$server_port = ( !empty($_POST['server_port']) ) ? $_POST['server_port'] : '';
-$board_email = ( !empty($_POST['board_email']) ) ? $_POST['board_email'] : '';
-$script_path = ( !empty($_POST['script_path']) ) ? $_POST['script_path'] : '';
-
-//
-// Do we install/upgrade/update or quit back to index?
-//
-if ( !defined('PHPBB_INSTALLED') )
-{
- include($phpbb_root_path . 'includes/session.'.$phpEx);
- include($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
-
- // Import language file, setup template ...
- include($phpbb_root_path . 'language/' . $language . '/lang_main.'.$phpEx);
- include($phpbb_root_path . 'language/' . $language . '/lang_admin.'.$phpEx);
-
- if ( $upgrade == 1 )
+ $accept_lang_ary = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
+ foreach ($accept_lang_ary as $accept_lang)
{
- require('upgrade.'.$phpEx);
- $install_step = 1;
+ // Set correct format ... guess full xx_YY form
+ $accept_lang = substr($accept_lang, 0, 2) . '_' . strtoupper(substr($accept_lang, 3, 2));
+ if (file_exists($phpbb_root_path . 'language/' . $accept_lang))
+ {
+ $default_language = $accept_lang;
+ break;
+ }
+ else
+ {
+ // No match on xx_YY so try xx
+ $accept_lang = substr($accept_lang, 0, 2);
+ if (file_exists($phpbb_root_path . 'language/' . $accept_lang))
+ {
+ $default_language = $accept_lang;
+ break;
+ }
+ }
}
}
-else
+
+// Obtain various vars
+$confirm = (isset($_POST['confirm'])) ? true : false;
+$cancel = (isset($_POST['cancel'])) ? true : false;
+$install_step = (isset($_REQUEST['install_step'])) ? $_REQUEST['install_step'] : '';
+$upgrade = (!empty($_POST['upgrade'])) ? $_POST['upgrade']: '';
+$upgrade_now = (!empty($_POST['upgrade_now'])) ? $_POST['upgrade_now']:'';
+
+$language = (!empty($_POST['language'])) ? htmlspecialchars($_POST['language']) : $default_language;
+$dbms = isset($_POST['dbms']) ? $_POST['dbms'] : '';
+$dbhost = (!empty($_POST['dbhost'])) ? $_POST['dbhost'] : '';
+$dbuser = (!empty($_POST['dbuser'])) ? $_POST['dbuser'] : '';
+$dbpasswd = (!empty($_POST['dbpasswd'])) ? $_POST['dbpasswd'] : '';
+$dbname = (!empty($_POST['dbname'])) ? $_POST['dbname'] : '';
+$table_prefix = (!empty($_POST['prefix'])) ? $_POST['prefix'] : '';
+
+$admin_name = (!empty($_POST['admin_name'])) ? htmlspecialchars($_POST['admin_name']) : '';
+$admin_pass1 = (!empty($_POST['admin_pass1'])) ? htmlspecialchars($_POST['admin_pass1']) : '';
+$admin_pass2 = (!empty($_POST['admin_pass2'])) ? htmlspecialchars($_POST['admin_pass2']) : '';
+$board_email1 = (!empty($_POST['board_email1'])) ? htmlspecialchars($_POST['board_email1']) : '';
+$board_email2 = (!empty($_POST['board_email2'])) ? htmlspecialchars($_POST['board_email2']) : '';
+
+$server_name = (!empty($_POST['server_name'])) ? htmlspecialchars($_POST['server_name']) : '';
+$server_port = (!empty($_POST['server_port'])) ? htmlspecialchars($_POST['server_port']) : '';
+$script_path = (!empty($_POST['script_path'])) ? htmlspecialchars($_POST['script_path']) : '';
+
+$ftp_path = (!empty($_POST['ftp_path'])) ? $_POST['ftp_path'] : '';
+$ftp_user = (!empty($_POST['ftp_user'])) ? $_POST['ftp_user'] : '';
+$ftp_pass = (!empty($_POST['ftp_pass'])) ? $_POST['ftp_pass'] : '';
+
+
+// Try opening config file
+if (@file_exists('../config.'.$phpEx))
{
- header("Location: ../index.$phpEx");
- exit;
+// include('../config.'.$phpEx);
}
-//
-// What shall we do?
-//
-if ( !empty($_POST['send_file']) && $_POST['send_file'] == 1 && !defined("PHPBB_INSTALLED") && empty($_POST['upgrade_now']) )
+
+// Do we install/upgrade/update or quit back to index?
+if (defined('PHPBB_INSTALLED'))
+{
+// redirect("../index.$phpEx");
+}
+
+// Include essential scripts
+include($phpbb_root_path . 'includes/session.'.$phpEx);
+include($phpbb_root_path . 'includes/acm/cache_file.'.$phpEx);
+include($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
+
+// Import language file, setup template ...
+include($phpbb_root_path . 'language/' . $language . '/lang_main.'.$phpEx);
+include($phpbb_root_path . 'language/' . $language . '/lang_admin.'.$phpEx);
+
+// If we're upgrading include that script
+if ($upgrade)
+{
+ require('upgrade.' . $phpEx);
+ $install_step = 1;
+}
+
+// Instantiate classes for future use
+$user = new user();
+$auth = new auth();
+$cache = new acm();
+
+
+// What shall we do?
+if (!empty($_POST['send_file']) && $_POST['send_file'] == 1 && !defined('PHPBB_INSTALLED') && empty($_POST['upgrade_now']))
{
- //
// We need to stripslashes no matter what the setting of magic_quotes_gpc is
// because we add slahes at the top if its off, and they are added automaticlly
// if it is on.
- //
$_POST['config_data'] = stripslashes($_POST['config_data']);
header("Content-Type: text/x-delimtext; name=\"config.$phpEx\"");
@@ -218,192 +202,187 @@ if ( !empty($_POST['send_file']) && $_POST['send_file'] == 1 && !defined("PHPBB
exit;
}
-else if ( !empty($_POST['send_file']) && $_POST['send_file'] == 2 && !defined("PHPBB_INSTALLED") )
+else if (!empty($_POST['send_file']) && $_POST['send_file'] == 2 && !defined("PHPBB_INSTALLED"))
{
- //
// Ok we couldn't write the config file so let's try ftping it.
- //
-
$_POST['config_data'] = stripslashes($_POST['config_data']);
$s_hidden_fields = '';
$s_hidden_fields .= '';
- if ( $upgrade == 1 )
+ if ($upgrade == 1)
{
$s_hidden_fields .= '';
}
- $template->assign_block_vars("switch_ftp_file", array());
- $template->assign_block_vars("switch_common_install", array());
+ page_header($lang['ftp_instructs']);
- $template->assign_vars(array(
- "L_INSTRUCTION_TEXT" => $lang['ftp_instructs'],
- "L_FTP_INFO" => $lang['ftp_info'],
- "L_FTP_PATH" => $lang['ftp_path'],
- "L_FTP_PASS" => $lang['ftp_password'],
- "L_FTP_USER" => $lang['ftp_username'],
- "L_SUBMIT" => $lang['Transfer_config'],
-
- "S_HIDDEN_FIELDS" => $s_hidden_fields,
- "S_FORM_ACTION" => "install.$phpEx")
- );
-
- $template->pparse("body");
+?>
+
+ |
+
+
+ |
+ |
+
+
+ |
+ |
+
+
+ |
+ |
+
+';
$s_hidden_fields .= '';
page_header($lang['NoFTP_config'], "install.$phpEx");
- if ( $upgrade == 1 )
+ if ($upgrade)
{
$s_hidden_fields .= '';
- $s_hidden_fields .= '';
- $s_hidden_fields .= '';
- $s_hidden_fields .= '';
- $s_hidden_fields .= '';
- $s_hidden_fields .= '';
- $s_hidden_fields .= '';
+ $s_hidden_fields .= '';
+ $s_hidden_fields .= '';
+ $s_hidden_fields .= '';
+ $s_hidden_fields .= '';
+ $s_hidden_fields .= '';
+ $s_hidden_fields .= '';
$s_hidden_fields .= '';
$s_hidden_fields .= '';
$s_hidden_fields .= '';
- $s_hidden_fields .= '';
- $s_hidden_fields .= '';
- $s_hidden_fields .= '';
- $s_hidden_fields .= '';
+ $s_hidden_fields .= '';
+ $s_hidden_fields .= '';
+ $s_hidden_fields .= '';
+ $s_hidden_fields .= '';
+ $s_hidden_fields .= '';
- $template->assign_block_vars("switch_upgrade_install", array());
- $template->assign_vars(array(
- "L_UPGRADE_INST" => $lang['continue_upgrade'],
- "L_UPGRADE_SUBMIT" => $lang['upgrade_submit'])
- );
+ page_upgrade_form();
+ }
+ else
+ {
+ page_common_form($s_hidden_fields, $lang['Download_config']);
}
page_footer($lang['Download_config'], $s_hidden_fields);
-
exit;
}
else
{
- //
// Write out a temp file...
- //
$tmpfname = @tempnam('/tmp', 'cfg');
-
- @unlink($tmpfname); // unlink for safety on php4.0.3+
+ @unlink($tmpfname);
$fp = @fopen($tmpfname, 'w');
-
@fwrite($fp, $_POST['config_data']);
-
@fclose($fp);
- //
// Now ftp it across.
- //
@ftp_chdir($conn_id, $ftp_dir);
-
- $res = ftp_put($conn_id, '../config.'.$phpEx, $tmpfname, FTP_ASCII);
-
+ $res = @ftp_put($conn_id, 'config.' . $phpEx, $tmpfname, FTP_ASCII);
@ftp_quit($conn_id);
unlink($tmpfname);
- if( $upgrade == 1 )
+ if ($upgrade)
{
require('upgrade.'.$phpEx);
exit;
}
- //
- // Ok we are basically done with the install process let's go on and let the user
- // configure their board now. We are going to do this by calling the admin_board.php
- // from the normal board admin section.
- //
- $s_hidden_fields = '';
- $s_hidden_fields .= '';
- $s_hidden_fields .= '';
- $s_hidden_fields .= '';
+ $sql = "SELECT *
+ FROM {$table_prefix}config";
+ $result = $db->sql_query($sql);
- page_header($lang['Inst_Step_2'], "../login.$phpEx");
+ $config = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $config[$row['config_name']] = $row['config_value'];
+ }
+ $db->sql_freeresult($result);
+
+ // Log user in
+ $auth->login($admin_name, $admin_pass1);
+
+ page_header($lang['Inst_Step_2'], "../adm/index.$phpEx$SID");
page_footer($lang['Finish_Install'], $s_hidden_fields);
-
- exit();
+ exit;
}
-
}
-else if ( ( empty($install_step) || $admin_pass1 != $admin_pass2 || empty($admin_pass1) || $dbhost == '' ) && !defined("PHPBB_INSTALLED") )
+else if ((empty($install_step) || $admin_pass1 != $admin_pass2 || $board_email1 != $board_email2 || empty($admin_pass1) || $dbhost == '') && !defined("PHPBB_INSTALLED"))
{
- //
// Ok we haven't installed before so lets work our way through the various
// steps of the install process. This could turn out to be quite a lengty
// process.
- //
+
// Step 0 gather the pertinant info for database setup...
// Namely dbms, dbhost, dbname, dbuser, and dbpasswd.
- //
- //
// Guess at some basic info used for install..
- //
- if ( !empty($_SERVER['SERVER_NAME']) || !empty($_ENV['SERVER_NAME']) )
+ if (!empty($_SERVER['SERVER_NAME']) || !empty($_ENV['SERVER_NAME']))
{
- $server_name = ( !empty($_SERVER['SERVER_NAME']) ) ? $_SERVER['SERVER_NAME'] : $_ENV['SERVER_NAME'];
+ $server_name = (!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : $_ENV['SERVER_NAME'];
}
- else if ( !empty($_SERVER['HTTP_HOST']) || !empty($_ENV['HTTP_HOST']) )
+ else if (!empty($_SERVER['HTTP_HOST']) || !empty($_ENV['HTTP_HOST']))
{
- $server_name = ( !empty($_SERVER['HTTP_HOST']) ) ? $_SERVER['HTTP_HOST'] : $_ENV['HTTP_HOST'];
+ $server_name = (!empty($_SERVER['HTTP_HOST'])) ? $_SERVER['HTTP_HOST'] : $_ENV['HTTP_HOST'];
}
else
{
$server_name = '';
}
- if ( !empty($_SERVER['SERVER_PORT']) || !empty($_ENV['SERVER_PORT']) )
+ if (!empty($_SERVER['SERVER_PORT']) || !empty($_ENV['SERVER_PORT']))
{
- $server_port = ( !empty($_SERVER['SERVER_PORT']) ) ? $_SERVER['SERVER_PORT'] : $_ENV['SERVER_PORT'];
+ $server_port = (!empty($_SERVER['SERVER_PORT'])) ? $_SERVER['SERVER_PORT'] : $_ENV['SERVER_PORT'];
}
else
{
$server_port = '80';
}
- $script_path = preg_replace('/install\/install\.'.$phpEx.'/i', '', $_SERVER['PHP_SELF']);
+ $script_path = preg_replace('#install\/install\.'.$phpEx.'#i', '', $_SERVER['PHP_SELF']);
- //
- //
- //
+ // Generate installation form
$instruction_text = $lang['Inst_Step_0'];
-/*
- if ( (($_POST['admin_pass1'] != $_POST['admin_pass2']) && $install_step != '0') || ( empty($_POST['admin_pass1']) && !empty($dbhost)) )
+
+ if (!empty($install_step))
{
- $instruction_text = $lang['Password_mismatch'] . '
' . $instruction_text;
+ if ((($_POST['admin_pass1'] != $_POST['admin_pass2'])) ||
+ (empty($_POST['admin_pass1']) || empty($dbhost)) && $_POST['cur_lang'] == $language)
+ {
+ $error = $lang['Password_mismatch'];
+ }
+
+ if ((($_POST['board_email1'] != $_POST['board_email2'])) ||
+ (empty($_POST['board_email1']) || empty($dbhost)) && $_POST['cur_lang'] == $language)
+ {
+ $error = $lang['INSTALL_EMAIL_MISMATCH'];
+ }
}
-*/
+
$lang_options = language_select($language, 'language', '../language');
- foreach( $available_dbms as $dbms_name => $details )
+ foreach($available_dbms as $dbms_name => $details)
{
- $selected = ( $dbms_name == $dbms ) ? ' selected="selected' : '';
+ $selected = ($dbms_name == $dbms) ? ' selected="selected' : '';
$dbms_options .= '';
}
@@ -421,42 +400,54 @@ else if ( ( empty($install_step) || $admin_pass1 != $admin_pass2 || empty($admin
: |
- |
+ |
: |
- |
+ |
: |
- |
+ |
|
: |
- |
+ |
: |
- |
+ |
: |
- |
+ |
: |
- |
+ |
: |
- |
+ |
|
+
+
+ |
+
+
: |
|
@@ -471,19 +462,23 @@ else if ( ( empty($install_step) || $admin_pass1 != $admin_pass2 || empty($admin
: |
- |
+ |
- : |
- |
+ : |
+ |
+
+ : |
+ |
+
: |
- |
+ |
: |
- |
+ |
assign_block_vars("switch_error_install", array());
-
- $template->assign_vars(array(
- "L_ERROR_TITLE" => $lang['Installer_Error'],
- "L_ERROR" => $lang['Install_No_Ext'])
- );
- $template->pparse('body'); */
-
- // Try to load the Extensions
- $loaded_extension = FALSE;
-
- if ( (!@ini_get('safe_mode')) && (@ini_get('enable_dl')) )
+ if (!@extension_loaded($check_exts))
{
- $suffix = ( (defined('PHP_OS')) && (eregi('win', PHP_OS)) ) ? '.dll' : '.so';
-
- if (!@extension_loaded($check_exts))
+ if (!@dl($check_exts . $suffix))
{
- if (@dl($check_exts . $suffix))
+ $loaded_extension = FALSE;
+ }
+ else
+ {
+ $load_extensions .= ($load_extensions == '') ? $check_exts . $suffix : ',' . $check_exts . $suffix;
+ }
+ }
+
+ foreach ($check_other as $extension)
+ {
+ if (!@extension_loaded($extension))
+ {
+ if (!@dl($extension . $suffix))
+ {
+ $loaded_extension = FALSE;
+ break;
+ }
+ else if ($loaded_extension)
{
$load_extensions .= ($load_extensions == '') ? $check_exts . $suffix : ',' . $check_exts . $suffix;
- $loaded_extension = TRUE;
}
}
-
- if (!$loaded_extension)
- {
- if (!@extension_loaded($check_other))
- {
- if (@dl($check_other . $suffix))
- {
- $load_extensions .= ($load_extensions == '') ? $check_other . $suffix : ',' . $check_other . $suffix;
- $loaded_extension = TRUE;
- }
- }
- }
-
- }
-
- if (!$loaded_extension)
- {
- die("Error during installation: no $check_exts extension");
}
}
- include($phpbb_root_path . 'db/' . $dbms . '.' . $phpEx);
-
- $db = new sql_db($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false);
- }
-
- // Add another Extension Checks here if you want, please do not specify the suffix
- $check_extensions = array();
- $suffix = ( (defined('PHP_OS')) && (eregi('win', PHP_OS)) ) ? '.dll' : '.so';
-
- foreach ($check_extensions as $extension)
- {
- if (!@extension_loaded($extension))
+ if (!$loaded_extension)
{
- if ( (!@ini_get('safe_mode')) && (@ini_get('enable_dl')) )
- {
- if (@dl($extension . $suffix))
- {
- $load_extensions .= ($load_extensions == '') ? $extension . $suffix : ',' . $extension . $suffix;
- }
- }
+ page_header($lang['Install'], '');
+ page_error($lang['Installer_Error'], $lang['INSTALL_EXT_FAILED']);
+ page_footer();
+ exit;
}
}
-
+
+ // Load the appropriate database class
+ include($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
+
+ // Instantiate the database
+ $db = new sql_db($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false);
+
+ // Load the appropriate schema and basic data
$dbms_schema = 'schemas/' . $available_dbms[$dbms]['SCHEMA'] . '_schema.sql';
$dbms_basic = 'schemas/' . $available_dbms[$dbms]['SCHEMA'] . '_basic.sql';
+ // How should we treat this schema?
$remove_remarks = $available_dbms[$dbms]['COMMENTS'];;
$delimiter = $available_dbms[$dbms]['DELIM'];
$delimiter_basic = $available_dbms[$dbms]['DELIM_BASIC'];
- if ( $install_step == 1 || $reinstall )
+ if ($install_step == 1 || $reinstall)
{
- if ( $upgrade != 1 )
+ if ($upgrade != 1)
{
- if ( $dbms != 'msaccess' )
+ if ($dbms != 'msaccess')
{
-
- //
+ // NOTE: trigger_error does not work here.
+ $db->return_on_error = true;
+
// Ok we have the db info go ahead and read in the relevant schema
// and work on building the table.. probably ought to provide some
// kind of feedback to the user as we are working here in order
// to let them know we are actually doing something.
- //
$sql_query = @fread(@fopen($dbms_schema, 'r'), @filesize($dbms_schema));
- $sql_query = preg_replace('/phpbb_/is', $table_prefix, $sql_query);
+ $sql_query = preg_replace('#phpbb_#is', $table_prefix, $sql_query);
$sql_query = $remove_remarks($sql_query);
$sql_query = split_sql_file($sql_query, $delimiter);
-
$sql_count = count($sql_query);
- // NOTE: trigger_error does not work here.
- $db->return_on_error = true;
- for($i = 0; $i < $sql_count; $i++)
+ foreach ($sql_query as $sql)
{
- if (!$db->sql_query($sql_query[$i]))
+ if (!$db->sql_query($sql))
{
- $error = $db->sql_error($sql_query[$i]);
- echo "
ERROR: " . $error['message'] . "
";
+ $error = $db->sql_error();
+ page_header($lang['Install'], '');
+ page_error($lang['Installer_Error'], $lang['Install_db_error'] . '
' . $error['message']);
+ page_footer();
+ exit;
}
}
- //
// Ok tables have been built, let's fill in the basic information
- //
$sql_query = @fread(@fopen($dbms_basic, 'r'), @filesize($dbms_basic));
- $sql_query = preg_replace('/phpbb_/', $table_prefix, $sql_query);
+ $sql_query = preg_replace('#phpbb_#', $table_prefix, $sql_query);
$sql_query = $remove_remarks($sql_query);
$sql_query = split_sql_file($sql_query, $delimiter_basic);
-
$sql_count = count($sql_query);
- for($i = 0; $i < $sql_count; $i++)
+ foreach ($sql_query as $sql)
{
- $db->sql_query($sql_query[$i]);
+ if (!$db->sql_query($sql))
+ {
+ $error = $db->sql_error();
+ page_header($lang['Install'], '');
+ page_error($lang['Installer_Error'], $lang['Install_db_error'] . '
' . $error['message']);
+ page_footer();
+ exit;
+ }
}
}
- //
- // Ok at this point they have entered their admin password, let's go
- // ahead and create the admin account with some basic default information
- // that they can customize later, and write out the config file. After
- // this we are going to pass them over to the admin_forum.php script
- // to set up their forum defaults.
- //
- $admin_pass_md5 = ( $confirm && $userdata['user_level'] == ADMIN ) ? $admin_pass1 : md5($admin_pass1);
- $error = '';
-
- //
- // Update the default admin user with their information.
- //
- $sql = "INSERT INTO " . $table_prefix . "config (config_name, config_value)
- VALUES ('board_startdate', " . time() . ")";
- $db->sql_query($sql);
-
- $sql = "INSERT INTO " . $table_prefix . "config (config_name, config_value)
- VALUES ('default_lang', '" . str_replace("\'", "''", $language) . "')";
- $db->sql_query($sql);
-
- $sql = "UPDATE " . $table_prefix . "config
- SET config_value = '" . $server_name . "'
- WHERE config_name = 'server_name'";
- $db->sql_query($sql);
-
- $sql = "UPDATE " . $table_prefix . "config
- SET config_value = '" . $server_port . "'
- WHERE config_name = 'server_port'";
- $db->sql_query($sql);
-
- $sql = "UPDATE " . $table_prefix . "config
- SET config_value = '" . $script_path . "'
- WHERE config_name = 'script_path'";
- $db->sql_query($sql);
-
- $sql = "UPDATE " . $table_prefix . "config
- SET config_value = '" . $board_email . "'
- WHERE config_name = 'board_email'";
- $db->sql_query($sql);
-
- $sql = "UPDATE " . $table_prefix . "config
- SET config_value = '" . $server_name . "'
- WHERE config_name = 'cookie_domain'";
- $db->sql_query($sql);
-
- $sql = "UPDATE " . $table_prefix . "config
- SET config_value = '" . $admin_name . "'
- WHERE config_name = 'newest_username'";
- $db->sql_query($sql);
-
- $sql = "UPDATE " . $table_prefix . "users
- SET username = '" . str_replace("\'", "''", $admin_name) . "', user_password='" . str_replace("\'", "''", $admin_pass_md5) . "', user_lang = '" . str_replace("\'", "''", $language) . "', user_email='" . str_replace("\'", "''", $board_email) . "'
- WHERE username = 'Admin'";
- $db->sql_query($sql);
-
- $sql = "UPDATE " . $table_prefix . "moderator_cache
- SET username = '" . $admin_name . "'
- WHERE username = 'Admin'";
- $db->sql_query($sql);
-
- $sql = "UPDATE " . $table_prefix . "forums
- SET forum_last_poster_name = '" . $admin_name . "'
- WHERE forum_last_poster_name = 'Admin'";
- $db->sql_query($sql);
-
- $sql = "UPDATE " . $table_prefix . "topics
- SET topic_first_poster_name = '" . $admin_name . "', topic_last_poster_name = '" . $admin_name . "'
+ // Set default config and post data
+ $sql_ary = array(
+ "INSERT INTO " . $table_prefix . "config (config_name, config_value)
+ VALUES ('board_startdate', " . time() . ")",
+ "INSERT INTO " . $table_prefix . "config (config_name, config_value)
+ VALUES ('default_lang', '" . $db->sql_escape($language) . "')",
+ "UPDATE " . $table_prefix . "config
+ SET config_value = '" . $db->sql_escape($server_name) . "'
+ WHERE config_name = 'server_name'",
+ "UPDATE " . $table_prefix . "config
+ SET config_value = '" . $db->sql_escape($server_port) . "'
+ WHERE config_name = 'server_port'",
+ "UPDATE " . $table_prefix . "config
+ SET config_value = '" . $db->sql_escape($script_path) . "'
+ WHERE config_name = 'script_path'",
+ "UPDATE " . $table_prefix . "config
+ SET config_value = '" . $db->sql_escape($board_email) . "'
+ WHERE config_name = 'board_email'",
+ "UPDATE " . $table_prefix . "config
+ SET config_value = '" . $db->sql_escape($server_name) . "'
+ WHERE config_name = 'cookie_domain'",
+ "UPDATE " . $table_prefix . "config
+ SET config_value = '" . $db->sql_escape($admin_name) . "'
+ WHERE config_name = 'newest_username'",
+ "UPDATE " . $table_prefix . "users
+ SET username = '" . $db->sql_escape($admin_name) . "', user_password='" . $db->sql_escape(md5($admin_pass1)) . "', user_lang = '" . $db->sql_escape($language) . "', user_email='" . $db->sql_escape($board_email) . "'
+ WHERE username = 'Admin'",
+ "UPDATE " . $table_prefix . "moderator_cache
+ SET username = '" . $db->sql_escape($admin_name) . "'
+ WHERE username = 'Admin'",
+ "UPDATE " . $table_prefix . "forums
+ SET forum_last_poster_name = '" . $db->sql_escape($admin_name) . "'
+ WHERE forum_last_poster_name = 'Admin'",
+ "UPDATE " . $table_prefix . "topics
+ SET topic_first_poster_name = '" . $db->sql_escape($admin_name) . "', topic_last_poster_name = '" . $db->sql_escape($admin_name) . "'
WHERE topic_first_poster_name = 'Admin'
- OR topic_last_poster_name = 'Admin'";
- $db->sql_query($sql);
+ OR topic_last_poster_name = 'Admin'",
+ "UPDATE " . $table_prefix . "users
+ SET user_regdate = " . time()
+ );
- $sql = "UPDATE " . $table_prefix . "users
- SET user_regdate = " . time();
- $db->sql_query($sql);
-
-/* if ( $error != '' )
+ foreach ($sql_ary as $sql)
{
- $template->assign_block_vars("switch_error_install", array());
-
- $template->assign_vars(array(
- "L_ERROR_TITLE" => $lang['Installer_Error'],
- "L_ERROR" => $lang['Install_db_error'] . '
' . $error)
- );
-
- $template->pparse('body');
-
- exit;
- }*/
+ if (!$db->sql_query($sql))
+ {
+ $error = $db->sql_error();
+ page_header($lang['Install'], '');
+ page_error($lang['Installer_Error'], $lang['Install_db_error'] . '
' . $error['message']);
+ page_footer();
+ exit;
+ }
+ }
}
- if ( !$reinstall && !$upgrade_now )
+ if (!$upgrade_now)
{
-// $template->assign_block_vars("switch_common_install", array());
-
- //
// Write out the config file.
- //
- $config_data = ''; // Done this to prevent highlighting editors getting confused!
@umask(0111);
$no_open = FALSE;
- if ( !($fp = fopen('../config.'.$phpEx, 'w')) )
+ if (!($fp = @fopen('../config.'.$phpEx, 'w')))
{
- //
// Unable to open the file writeable do something here as an attempt
// to get around that...
- //
$s_hidden_fields = '';
- if ( extension_loaded('ftp') && !defined('NO_FTP') )
+ if (extension_loaded('ftp') && !defined('NO_FTP'))
{
- $template->assign_block_vars('switch_ftp_option', array());
-
- $lang['Unwriteable_config'] .= '' . $lang['ftp_option'] . '
';
-
- $template->assign_vars(array(
- "L_CHOOSE_FTP" => $lang['ftp_choose'],
- "L_ATTEMPT_FTP" => $lang['Attempt_ftp'],
- "L_SEND_FILE" => $lang['Send_file'])
- );
+ page_header($lang['Unwriteable_config'] . '' . $lang['ftp_option'] . '
');
+?>
+
+ |
+
+
+ |
+ |
+
+
+ |
+ |
+
+';
}
- if ( $upgrade == 1 )
+ if ($upgrade == 1)
{
$s_hidden_fields .= '';
$s_hidden_fields .= '';
@@ -808,24 +760,14 @@ else
$s_hidden_fields .= '';
$s_hidden_fields .= '';
- $template->assign_block_vars("switch_upgrade_install", array());
- $template->assign_vars(array(
- "L_UPGRADE_INST" => $lang['continue_upgrade'],
- "L_UPGRADE_SUBMIT" => $lang['upgrade_submit'])
- );
+ page_upgrade_form();
+ }
+ else
+ {
+ page_common_form($s_hidden_fields, $lang['Download_config']);
}
- /*$template->assign_vars(array(
- "L_INSTRUCTION_TEXT" => $lang['Unwriteable_config'],
- "L_SUBMIT" => $lang['Download_config'],
-
- "S_HIDDEN_FIELDS" => $s_hidden_fields,
- "S_FORM_ACTION" => "install.$phpEx")
- );
-
- $template->pparse('body');
- */
-
+ page_footer();
exit;
}
@@ -834,42 +776,35 @@ else
@fclose($fp);
$upgrade_now = $lang['upgrade_submit'];
}
- else
- {
-// $template->assign_block_vars("switch_common_install", array());
- }
- //
// First off let's check and see if we are supposed to be doing an upgrade.
- //
- if ( $upgrade == 1 && $upgrade_now == $lang['upgrade_submit'] )
+ if ($upgrade && $upgrade_now == $lang['upgrade_submit'])
{
define('INSTALLING', true);
require('upgrade.'.$phpEx);
exit;
}
- //
- // Ok we are basically done with the install process let's go on
- // and let the user configure their board now.
- //
- // We are going to do this by calling the admin_board.php from the
- // normal board admin section.
- //
- if ( !$reinstall )
- {
- $s_hidden_fields = '';
- $s_hidden_fields .= '';
- $s_hidden_fields .= '';
- $s_hidden_fields .= '';
- }
- else
- {
- $s_hidden_fields = '';
- }
- page_header($lang['Inst_Step_2'], "../login.$phpEx");
+ // Load the basic configuration data
+ define('SESSIONS_TABLE', $table_prefix . 'sessions');
+ define('USERS_TABLE', $table_prefix . 'users');
+
+ $sql = "SELECT *
+ FROM {$table_prefix}config";
+ $result = $db->sql_query($sql);
+
+ $config = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $config[$row['config_name']] = $row['config_value'];
+ }
+ $db->sql_freeresult($result);
+
+ // Log user in
+ $auth->login($admin_name, $admin_pass1);
+
+ page_header($lang['Inst_Step_2'], "../adm/index.$phpEx$SID");
page_footer($lang['Finish_Install'], $s_hidden_fields);
-
exit;
}
}
@@ -878,11 +813,11 @@ else
// to prevent someone trying to break out of a SQL statement.
function slash_input_data(&$data)
{
- if ( is_array($data) )
+ if (is_array($data))
{
- foreach ( $data as $k => $v )
+ foreach ($data as $k => $v)
{
- $data[$k] = ( is_array($v) ) ? slash_input_data($v) : addslashes($v);
+ $data[$k] = (is_array($v)) ? slash_input_data($v) : addslashes($v);
}
}
return $data;
@@ -935,11 +870,11 @@ function page_footer($l_submit, $s_hidden_fields)
?>
- |
+ |
-
+
@@ -949,4 +884,44 @@ function page_footer($l_submit, $s_hidden_fields)
}
+function page_common_form($hidden, $submit)
+{
+
+?>
+
+ |
+
+
+
+ |
+
+
+ |
+
+
+
+ |
+
+
+ |
+
+
\ No newline at end of file