-
- $dbms_ary)
- {
- if (!extension_loaded($dbms_ary['MODULE']))
- {
- if (!can_load_dll($dbms_ary['MODULE']))
- {
- continue;
- }
- }
-
- $available_dbms_temp[$type] = $dbms_ary;
- }
-
- $available_dbms = &$available_dbms_temp;
-
- // Here we guess at some server information, however we only
- // do this if no "errors" exist ... if they do then the user
- // has relady set the info and we can bypass it
- if (!sizeof($error))
- {
- if (!empty($_SERVER['SERVER_NAME']) || !empty($_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']))
- {
- $server_name = (!empty($_SERVER['HTTP_HOST'])) ? $_SERVER['HTTP_HOST'] : $_ENV['HTTP_HOST'];
- }
- else
- {
- $server_name = '';
- }
-
- if (!empty($_SERVER['SERVER_PORT']) || !empty($_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']);
- }
-
- // Generate list of available DB's
- $dbms_options = '';
- foreach ($available_dbms as $dbms_name => $details)
- {
- $selected = ($dbms_name == $dbms) ? ' selected="selected"' : '';
- $dbms_options .= '';
- }
-
- $s_hidden_fields = '';
- $s_hidden_fields .= ($img_imagick) ? '' : '';;
-
- inst_page_header();
-
-?>
-
-
-
-
-
-
-
-
-
-
-
-
', $error['admin']); ?>
-
-
-
-
:
-
-
-
-
:
-
-
-
-
:
-
-
-
-
:
-
-
-
-
:
-
-
-
-
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
', $error['db']); ?>
-
-
-
-
:
-
-
-
-
:
-
-
-
-
:
-
-
-
-
:
-
-
-
-
:
-
-
-
-
:
-
-
-
-
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
', $error['server']); ?>
-
-
-
-
:
-
-
-
-
:
-
-
-
-
:
-
-
-
-
-
-
-
-'; // Done this to prevent highlighting editors getting confused!
-
- // Attempt to write out the config directly ...
- if (filesize($phpbb_root_path . 'config.' . $phpEx) == 0 && is_writeable($phpbb_root_path . 'config.' . $phpEx))
- {
- // Lets jump to the DB setup stage ... if nothing goes wrong below
- $stage = 3;
-
- if (!($fp = @fopen($phpbb_root_path . 'config.'.$phpEx, 'w')))
- {
- // Something went wrong ... so let's try another method
- $stage = 2;
- }
-
- if (!(@fwrite($fp, $config_data)))
- {
- // Something went wrong ... so let's try another method
- $stage = 2;
- }
-
- @fclose($fp);
- }
-
- // We couldn't write it directly so we'll give the user three alternatives
- if ($stage == 2)
- {
- $ignore_ftp = false;
-
- // User is trying to upload via FTP ... so let's process it
- if (isset($_POST['sendftp']))
- {
- if (($conn_id = @ftp_connect('localhost')))
- {
- if (@ftp_login($conn_id, $ftp_user, $ftp_pass))
- {
- // Write out a temp file ... if safe mode is on we'll write it to our
- // local cache/tmp directory
- $tmp_path = (!@ini_get('safe_mode')) ? false : $phpbb_root_path . 'cache/tmp';
- $filename = tempnam($tmp_path, unique_id() . 'cfg');
-
- $fp = @fopen($filename, 'w');
- @fwrite($fp, $config_data);
- @fclose($fp);
-
- if (@ftp_chdir($conn_id, $ftp_dir))
- {
- // So far, so good so now we'll try and upload the file. If it
- // works we'll jump to stage 3, else we'll fall back again
- if (@ftp_put($conn_id, 'config.' . $phpEx, $filename, FTP_ASCII))
- {
- $stage = 3;
- }
- else
- {
- // Since we couldn't put the file something is fundamentally wrong, e.g.
- // the file is owned by a different user, etc. We'll give up trying
- // FTP at this point
- $ignore_ftp = true;
- }
- }
- else
- {
- $error['ftp'][] = $lang['INST_ERR_FTP_PATH'];
- }
-
- // Remove the temporary file now
- @unlink($filename);
- }
- else
- {
- $error['ftp'][] = $lang['INST_ERR_FTP_LOGIN'];
- }
- @ftp_quit($conn_id);
- }
- }
- else if (isset($_POST['dlftp']))
- {
- // The user requested a download, so send the relevant headers
- // and dump out the data
- header("Content-Type: text/x-delimtext; name=\"config.$phpEx\"");
- header("Content-disposition: attachment; filename=config.$phpEx");
- echo $config_data;
- exit;
- }
-
- // Here we give the users up to three options to complete the setup
- // of config.php, FTP, download and a retry and direct writing
- if ($stage == 2)
- {
- inst_page_header();
-
-?>
-
-
-
-';
- $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 .= '';
-
- // Can we ftp? If we can then let's offer that option on top of download
- // We first see if the relevant extension is loaded and then whether a server is
- // listening on the ftp port
- if (extension_loaded('ftp') && ($fsock = @fsockopen('localhost', 21, $errno, $errstr, 1)) && !$ignore_ftp)
- {
- @fclose($fsock);
-
-?>
-
-
-
-
-
-
-
-
-
-
-
-
', $error['ftp']); ?>
-
-
-
-
:
-
-
-
-
:
-
-
-
-
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-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')
- {
- // 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
- $dbms_schema = 'schemas/' . $available_dbms[$dbms]['SCHEMA'] . '_schema.sql';
-
- // How should we treat this schema?
- $remove_remarks = $available_dbms[$dbms]['COMMENTS'];
- $delimiter = $available_dbms[$dbms]['DELIM'];
-
- $sql_query = @fread(@fopen($dbms_schema, 'r'), @filesize($dbms_schema));
- $sql_query = preg_replace('#phpbb_#i', $table_prefix, $sql_query);
-
- $remove_remarks($sql_query);
-
- $sql_query = split_sql_file($sql_query, $delimiter);
-
- foreach ($sql_query as $sql)
- {
- //$sql = trim(str_replace('|', ';', $sql));
- if (!$db->sql_query($sql))
- {
- $error = $db->sql_error();
- inst_db_error($error['message'], $sql, __LINE__, __FILE__);
- }
- }
- unset($sql_query);
-
- // 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'));
-
- // Deal with any special comments, used at present for mssql set identity switching
- switch ($dbms)
- {
- case 'mssql':
- case 'mssql_odbc':
- $sql_query = preg_replace('#\# MSSQL IDENTITY (phpbb_[a-z_]+) (ON|OFF) \##s', 'SET IDENTITY_INSERT \1 \2', $sql_query);
- break;
-
- case 'postgres':
- $sql_query = preg_replace('#\# POSTGRES (BEGIN|COMMIT) \##s', '\1; ', $sql_query);
- // Some versions of PGSQL don't like remarks, lets remove them.
- remove_remarks($sql_query);
- break;
-
- case 'firebird':
- $sql_query = str_replace('module_name', '"module_name"', $sql_query);
- break;
-
- case 'oracle':
- remove_remarks($sql_query);
- break;
-
- default:
- //$sql_query = preg_replace('#\# MSSQL IDENTITY (phpbb_[a-z_]+) (ON|OFF) \##s', '', $sql_query);
- }
-
- $sql_query = preg_replace('#phpbb_#i', $table_prefix, $sql_query);
-
- remove_remarks($sql_query);
- $sql_query = split_sql_file($sql_query, ';');
-
- foreach ($sql_query as $sql)
- {
- //$sql = trim(str_replace('|', ';', $sql));
- if (!$db->sql_query($sql))
- {
- $error = $db->sql_error();
- inst_db_error($error['message'], $sql, __LINE__, __FILE__);
- }
- }
- unset($sql_query);
- }
-
-
- $current_time = time();
-
- // Set default config and post data, this applies to all DB's including Access
- $sql_ary = array(
- 'INSERT INTO ' . $table_prefix . "config (config_name, config_value)
- VALUES ('board_startdate', $current_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($img_imagick) . "'
- WHERE config_name = 'img_imagick'",
-
- '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_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'",
-
- '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_email1) . "'
- 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'",
-
- 'UPDATE ' . $table_prefix . "users
- SET user_regdate = $current_time",
-
- 'UPDATE ' . $table_prefix . "posts
- SET post_time = $current_time",
-
- 'UPDATE ' . $table_prefix . "topics
- SET topic_time = $current_time, topic_last_post_time = $current_time",
-
- 'UPDATE ' . $table_prefix . "forums
- SET forum_last_post_time = $current_time",
- );
-
- foreach ($sql_ary as $sql)
- {
- $sql = trim(str_replace('|', ';', $sql));
-
- if (!$db->sql_query($sql))
- {
- $error = $db->sql_error();
- inst_db_error($error['message'], $sql, __LINE__, __FILE__);
- }
- }
-
- $stage = 4;
-}
-
-// Install completed ... log the user in ... we're done
-if ($stage == 4)
-{
- // Load the basic configuration data
- define('SESSIONS_TABLE', $table_prefix . 'sessions');
- define('BOTS_TABLE', $table_prefix . 'bots');
- define('USERS_TABLE', $table_prefix . 'users');
- define('GROUPS_TABLE', $table_prefix . 'groups');
- define('BANLIST_TABLE', $table_prefix . 'banlist');
- define('CONFIG_TABLE', $table_prefix . 'config');
- define('USER_NORMAL', 0);
- define('USER_INACTIVE', 1);
- define('USER_IGNORE', 2);
- define('USER_FOUNDER', 3);
- define('LOGIN_SUCCESS', 3);
-
-
- $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);
-
- $user->session_begin();
- $auth->login($admin_name, $admin_pass1);
-
- inst_page_header();
-
-?>
-
-
-
-
-