phpBB
Statistics
| Revision:

root / tags / release_2_0_2 / phpBB / install.php

History | View | Annotate | Download (32.8 kB)

1 1102 the_systech
<?php
2 1102 the_systech
/***************************************************************************
3 1771 psotfx
 *                                install.php
4 1102 the_systech
 *                            -------------------
5 1102 the_systech
 *   begin                : Tuesday, Sept 11, 2001
6 1102 the_systech
 *   copyright            : (C) 2001 The phpBB Group
7 1102 the_systech
 *   email                : supportphpbb.com
8 1102 the_systech
 *
9 1102 the_systech
 *   $Id$
10 1102 the_systech
 *
11 1102 the_systech
 ***************************************************************************/
12 1102 the_systech
13 1102 the_systech
/***************************************************************************
14 1102 the_systech
 *
15 1102 the_systech
 *   This program is free software; you can redistribute it and/or modify
16 1102 the_systech
 *   it under the terms of the GNU General Public License as published by
17 1102 the_systech
 *   the Free Software Foundation; either version 2 of the License, or
18 1102 the_systech
 *   (at your option) any later version.
19 1102 the_systech
 *
20 1102 the_systech
 ***************************************************************************/
21 1125 the_systech
22 1976 psotfx
error_reporting  (E_ERROR | E_WARNING | E_PARSE); // This will NOT report uninitialized variables
23 1976 psotfx
set_magic_quotes_runtime(0); // Disable magic_quotes_runtime
24 1976 psotfx
25 2305 psotfx
define('IN_PHPBB', true);
26 1144 psotfx
$phpbb_root_path='./';
27 1144 psotfx
include($phpbb_root_path.'extension.inc');
28 2637 the_systech
include($phpbb_root_path . 'includes/functions_selects.'.$phpEx);
29 1144 psotfx
30 1491 psotfx
$userdata = array();
31 1491 psotfx
$lang = array();
32 1491 psotfx
$reinstall = false;
33 1491 psotfx
34 1144 psotfx
if( !get_magic_quotes_gpc() )
35 1125 the_systech
{
36 1144 psotfx
        if( is_array($HTTP_GET_VARS) )
37 1125 the_systech
        {
38 1144 psotfx
                while( list($k, $v) = each($HTTP_GET_VARS) )
39 1144 psotfx
                {
40 1144 psotfx
                        if( is_array($HTTP_GET_VARS[$k]) )
41 1144 psotfx
                        {
42 1144 psotfx
                                while( list($k2, $v2) = each($HTTP_GET_VARS[$k]) )
43 1144 psotfx
                                {
44 1144 psotfx
                                        $HTTP_GET_VARS[$k][$k2] = addslashes($v2);
45 1144 psotfx
                                }
46 1144 psotfx
                                @reset($HTTP_GET_VARS[$k]);
47 1144 psotfx
                        }
48 1144 psotfx
                        else
49 1144 psotfx
                        {
50 1144 psotfx
                                $HTTP_GET_VARS[$k] = addslashes($v);
51 1144 psotfx
                        }
52 1144 psotfx
                }
53 1144 psotfx
                @reset($HTTP_GET_VARS);
54 1125 the_systech
        }
55 1125 the_systech
56 1144 psotfx
        if( is_array($HTTP_POST_VARS) )
57 1144 psotfx
        {
58 1144 psotfx
                while( list($k, $v) = each($HTTP_POST_VARS) )
59 1144 psotfx
                {
60 1144 psotfx
                        if( is_array($HTTP_POST_VARS[$k]) )
61 1144 psotfx
                        {
62 1144 psotfx
                                while( list($k2, $v2) = each($HTTP_POST_VARS[$k]) )
63 1144 psotfx
                                {
64 1144 psotfx
                                        $HTTP_POST_VARS[$k][$k2] = addslashes($v2);
65 1144 psotfx
                                }
66 1144 psotfx
                                @reset($HTTP_POST_VARS[$k]);
67 1144 psotfx
                        }
68 1144 psotfx
                        else
69 1144 psotfx
                        {
70 1144 psotfx
                                $HTTP_POST_VARS[$k] = addslashes($v);
71 1144 psotfx
                        }
72 1144 psotfx
                }
73 1144 psotfx
                @reset($HTTP_POST_VARS);
74 1144 psotfx
        }
75 1102 the_systech
76 1144 psotfx
        if( is_array($HTTP_COOKIE_VARS) )
77 1144 psotfx
        {
78 1144 psotfx
                while( list($k, $v) = each($HTTP_COOKIE_VARS) )
79 1144 psotfx
                {
80 1144 psotfx
                        if( is_array($HTTP_COOKIE_VARS[$k]) )
81 1144 psotfx
                        {
82 1144 psotfx
                                while( list($k2, $v2) = each($HTTP_COOKIE_VARS[$k]) )
83 1144 psotfx
                                {
84 1144 psotfx
                                        $HTTP_COOKIE_VARS[$k][$k2] = addslashes($v2);
85 1144 psotfx
                                }
86 1144 psotfx
                                @reset($HTTP_COOKIE_VARS[$k]);
87 1144 psotfx
                        }
88 1144 psotfx
                        else
89 1144 psotfx
                        {
90 1144 psotfx
                                $HTTP_COOKIE_VARS[$k] = addslashes($v);
91 1144 psotfx
                        }
92 1144 psotfx
                }
93 1144 psotfx
                @reset($HTTP_COOKIE_VARS);
94 1144 psotfx
        }
95 1144 psotfx
}
96 1125 the_systech
97 1125 the_systech
/***************************************************************************
98 1516 the_systech
 *                                Install Customization Section
99 1125 the_systech
 *
100 1516 the_systech
 *        This section can be modified to set up some basic default information
101 1125 the_systech
 *         used by the install script.  Specifically the default theme data
102 1516 the_systech
 *        and the default template.
103 1125 the_systech
 *
104 1125 the_systech
 **************************************************************************/
105 1144 psotfx
106 1125 the_systech
$default_language = 'english';
107 1144 psotfx
$default_template = 'subSilver';
108 1491 psotfx
109 1144 psotfx
$available_dbms = array(
110 1491 psotfx
        "mysql" => array(
111 1491 psotfx
                "LABEL" => "MySQL 3.x",
112 1491 psotfx
                "SCHEMA" => "mysql",
113 1491 psotfx
                "DELIM" => ";",
114 1491 psotfx
                "DELIM_BASIC" => ";",
115 1491 psotfx
                "COMMENTS" => "remove_remarks"
116 1144 psotfx
        ),
117 1491 psotfx
        "mysql4" => array(
118 1491 psotfx
                "LABEL" => "MySQL 4.x",
119 1491 psotfx
                "SCHEMA" => "mysql",
120 1491 psotfx
                "DELIM" => ";",
121 1491 psotfx
                "DELIM_BASIC" => ";",
122 1491 psotfx
                "COMMENTS" => "remove_remarks"
123 1491 psotfx
        ),
124 1491 psotfx
        "postgres" => array(
125 1144 psotfx
                "LABEL" => "PostgreSQL 7.x",
126 1491 psotfx
                "SCHEMA" => "postgres",
127 1491 psotfx
                "DELIM" => ";",
128 1491 psotfx
                "DELIM_BASIC" => ";",
129 1491 psotfx
                "COMMENTS" => "remove_comments"
130 1144 psotfx
        ),
131 1491 psotfx
        "mssql" => array(
132 1144 psotfx
                "LABEL" => "MS SQL Server 7/2000",
133 1491 psotfx
                "SCHEMA" => "mssql",
134 1491 psotfx
                "DELIM" => "GO",
135 1491 psotfx
                "DELIM_BASIC" => ";",
136 1491 psotfx
                "COMMENTS" => "remove_comments"
137 1144 psotfx
        ),
138 1491 psotfx
        "msaccess" => array(
139 1395 psotfx
                "LABEL" => "MS Access [ ODBC ]",
140 1491 psotfx
                "SCHEMA" => "",
141 1491 psotfx
                "DELIM" => "",
142 1491 psotfx
                "DELIM_BASIC" => ";",
143 1491 psotfx
                "COMMENTS" => ""
144 1491 psotfx
        ),
145 1491 psotfx
        "mssql-odbc" =>        array(
146 1491 psotfx
                "LABEL" => "MS SQL Server [ ODBC ]",
147 1491 psotfx
                "SCHEMA" => "mssql",
148 1491 psotfx
                "DELIM" => "GO",
149 1491 psotfx
                "DELIM_BASIC" => ";",
150 1491 psotfx
                "COMMENTS" => "remove_comments"
151 1144 psotfx
        )
152 1125 the_systech
);
153 1144 psotfx
154 1231 the_systech
//
155 1491 psotfx
// drop table schema
156 1491 psotfx
//
157 1491 psotfx
$sql_array = array();
158 1491 psotfx
159 1491 psotfx
$sql_array['drop_schema'][] = "DROP TABLE phpbb_auth_access";
160 1491 psotfx
$sql_array['drop_schema'][] = "DROP TABLE phpbb_banlist";
161 1491 psotfx
$sql_array['drop_schema'][] = "DROP TABLE phpbb_categories";
162 1491 psotfx
$sql_array['drop_schema'][] = "DROP TABLE phpbb_config";
163 1491 psotfx
$sql_array['drop_schema'][] = "DROP TABLE phpbb_disallow";
164 1491 psotfx
$sql_array['drop_schema'][] = "DROP TABLE phpbb_forum_prune";
165 1491 psotfx
$sql_array['drop_schema'][] = "DROP TABLE phpbb_forums";
166 1491 psotfx
$sql_array['drop_schema'][] = "DROP TABLE phpbb_groups";
167 1491 psotfx
$sql_array['drop_schema'][] = "DROP TABLE phpbb_posts";
168 1491 psotfx
$sql_array['drop_schema'][] = "DROP TABLE phpbb_posts_text";
169 1491 psotfx
$sql_array['drop_schema'][] = "DROP TABLE phpbb_privmsgs";
170 1491 psotfx
$sql_array['drop_schema'][] = "DROP TABLE phpbb_privmsgs_text";
171 1491 psotfx
$sql_array['drop_schema'][] = "DROP TABLE phpbb_ranks";
172 1491 psotfx
$sql_array['drop_schema'][] = "DROP TABLE phpbb_search_results";
173 1491 psotfx
$sql_array['drop_schema'][] = "DROP TABLE phpbb_search_wordlist";
174 1491 psotfx
$sql_array['drop_schema'][] = "DROP TABLE phpbb_search_wordmatch";
175 1491 psotfx
$sql_array['drop_schema'][] = "DROP TABLE phpbb_sessions";
176 1491 psotfx
$sql_array['drop_schema'][] = "DROP TABLE phpbb_smilies";
177 1491 psotfx
$sql_array['drop_schema'][] = "DROP TABLE phpbb_themes";
178 1491 psotfx
$sql_array['drop_schema'][] = "DROP TABLE phpbb_themes_name";
179 1491 psotfx
$sql_array['drop_schema'][] = "DROP TABLE phpbb_topics";
180 1491 psotfx
$sql_array['drop_schema'][] = "DROP TABLE phpbb_topics_watch";
181 1491 psotfx
$sql_array['drop_schema'][] = "DROP TABLE phpbb_user_group";
182 1491 psotfx
$sql_array['drop_schema'][] = "DROP TABLE phpbb_users";
183 1491 psotfx
$sql_array['drop_schema'][] = "DROP TABLE phpbb_vote_desc";
184 1491 psotfx
$sql_array['drop_schema'][] = "DROP TABLE phpbb_vote_results";
185 1491 psotfx
$sql_array['drop_schema'][] = "DROP TABLE phpbb_vote_voters";
186 1491 psotfx
$sql_array['drop_schema'][] = "DROP TABLE phpbb_words";
187 1491 psotfx
188 1491 psotfx
//
189 1231 the_systech
// Uncomment the following line to completely disable the ftp option...
190 1231 the_systech
//
191 1231 the_systech
// define('NO_FTP', true);
192 1231 the_systech
193 1125 the_systech
/***************************************************************************
194 1125 the_systech
*
195 1125 the_systech
*                                                End Install Customization Section
196 1125 the_systech
*
197 1125 the_systech
***************************************************************************/
198 1125 the_systech
199 1125 the_systech
//
200 1144 psotfx
// Obtain various vars
201 1125 the_systech
//
202 1491 psotfx
$confirm = ( isset($HTTP_POST_VARS['confirm']) ) ? true : false;
203 1491 psotfx
$cancel = ( isset($HTTP_POST_VARS['cancel']) ) ? true : false;
204 1491 psotfx
205 1144 psotfx
if( isset($HTTP_POST_VARS['install_step']) || isset($HTTP_GET_VARS['install_step']) )
206 1125 the_systech
{
207 1144 psotfx
        $install_step = ( isset($HTTP_POST_VARS['install_step']) ) ? $HTTP_POST_VARS['install_step'] : $HTTP_GET_VARS['install_step'];
208 1125 the_systech
}
209 1144 psotfx
else
210 1144 psotfx
{
211 1144 psotfx
        $install_step = "";
212 1144 psotfx
}
213 1125 the_systech
214 1491 psotfx
$upgrade = ( !empty($HTTP_POST_VARS['upgrade']) ) ? $HTTP_POST_VARS['upgrade']: '';
215 1516 the_systech
$upgrade_now = ( !empty($HTTP_POST_VARS['upgrade_now']) ) ? $HTTP_POST_VARS['upgrade_now']:'';
216 1516 the_systech
217 1144 psotfx
$dbms = isset($HTTP_POST_VARS['dbms']) ? $HTTP_POST_VARS['dbms'] : "";
218 1144 psotfx
$language = ( !empty($HTTP_POST_VARS['language']) ) ? $HTTP_POST_VARS['language'] : $default_language;
219 1125 the_systech
220 1144 psotfx
$dbhost = ( !empty($HTTP_POST_VARS['dbhost']) ) ? $HTTP_POST_VARS['dbhost'] : "";
221 1144 psotfx
$dbuser = ( !empty($HTTP_POST_VARS['dbuser']) ) ? $HTTP_POST_VARS['dbuser'] : "";
222 1144 psotfx
$dbpasswd = ( !empty($HTTP_POST_VARS['dbpasswd']) ) ? $HTTP_POST_VARS['dbpasswd'] : "";
223 1144 psotfx
$dbname = ( !empty($HTTP_POST_VARS['dbname']) ) ? $HTTP_POST_VARS['dbname'] : "";
224 1144 psotfx
225 1491 psotfx
$table_prefix = ( !empty($HTTP_POST_VARS['prefix']) ) ? $HTTP_POST_VARS['prefix'] : "";
226 1491 psotfx
227 1600 psotfx
$admin_name = ( !empty($HTTP_POST_VARS['admin_name']) ) ? $HTTP_POST_VARS['admin_name'] : "";
228 1144 psotfx
$admin_pass1 = ( !empty($HTTP_POST_VARS['admin_pass1']) ) ? $HTTP_POST_VARS['admin_pass1'] : "";
229 1144 psotfx
$admin_pass2 = ( !empty($HTTP_POST_VARS['admin_pass2']) ) ? $HTTP_POST_VARS['admin_pass2'] : "";
230 1144 psotfx
231 1231 the_systech
$ftp_path = ( !empty($HTTP_POST_VARS['ftp_path']) ) ? $HTTP_POST_VARS['ftp_path'] : "";
232 1231 the_systech
$ftp_user = ( !empty($HTTP_POST_VARS['ftp_user']) ) ? $HTTP_POST_VARS['ftp_user'] : "";
233 1231 the_systech
$ftp_pass = ( !empty($HTTP_POST_VARS['ftp_pass']) ) ? $HTTP_POST_VARS['ftp_pass'] : "";
234 1144 psotfx
235 2363 the_systech
$server_name = ( !empty($HTTP_POST_VARS['server_name']) ) ? $HTTP_POST_VARS['server_name'] : "";
236 2363 the_systech
$server_port = ( !empty($HTTP_POST_VARS['server_port']) ) ? $HTTP_POST_VARS['server_port'] : "";
237 2363 the_systech
$board_email = ( !empty($HTTP_POST_VARS['board_email']) ) ? $HTTP_POST_VARS['board_email'] : "";
238 2363 the_systech
$script_path = ( !empty($HTTP_POST_VARS['script_path']) ) ? $HTTP_POST_VARS['script_path'] : "";
239 2363 the_systech
240 1491 psotfx
if( @file_exists('config.'.$phpEx) )
241 1282 the_systech
{
242 1491 psotfx
        include('config.'.$phpEx);
243 1282 the_systech
}
244 1282 the_systech
245 1491 psotfx
if( !defined("PHPBB_INSTALLED") )
246 1491 psotfx
{
247 1491 psotfx
        include($phpbb_root_path.'includes/sql_parse.'.$phpEx);
248 1491 psotfx
        include($phpbb_root_path.'includes/constants.'.$phpEx);
249 1491 psotfx
        include($phpbb_root_path.'includes/template.'.$phpEx);
250 1491 psotfx
        include($phpbb_root_path.'includes/functions.'.$phpEx);
251 1491 psotfx
        include($phpbb_root_path.'includes/sessions.'.$phpEx);
252 1144 psotfx
253 1491 psotfx
        //
254 1491 psotfx
        // Import language file, setup template ...
255 1491 psotfx
        //
256 1491 psotfx
        include($phpbb_root_path.'language/lang_' . $language . '/lang_main.'.$phpEx);
257 1491 psotfx
        include($phpbb_root_path.'language/lang_' . $language . '/lang_admin.'.$phpEx);
258 1144 psotfx
259 1491 psotfx
        $template = new Template($phpbb_root_path . "templates/" . $default_template);
260 1144 psotfx
261 1516 the_systech
        //
262 1516 the_systech
        // Ok for the time being I'm commenting this out whilst I'm working on
263 1516 the_systech
        // better integration of the install with upgrade as per Bart's request
264 1516 the_systech
        // JLH
265 1516 the_systech
        //
266 1516 the_systech
267 1491 psotfx
        if( $upgrade == 1 )
268 1491 psotfx
        {
269 1516 the_systech
                // require('upgrade.'.$phpEx);
270 1491 psotfx
                $install_step = 1;
271 1491 psotfx
        }
272 1516 the_systech
273 1102 the_systech
        //
274 1491 psotfx
        // Load default template for install
275 1491 psotfx
        //
276 1491 psotfx
        $template->set_filenames(array(
277 1491 psotfx
                "body" => "install.tpl")
278 1491 psotfx
        );
279 1491 psotfx
280 1102 the_systech
        $template->assign_vars(array(
281 1491 psotfx
                "L_INSTALLATION" => $lang['Welcome_install'])
282 1102 the_systech
        );
283 1491 psotfx
}
284 1491 psotfx
else
285 1491 psotfx
{
286 1491 psotfx
        define("IN_ADMIN", 1);
287 1144 psotfx
288 1491 psotfx
        include($phpbb_root_path.'common.'.$phpEx);
289 1491 psotfx
        include($phpbb_root_path.'includes/sql_parse.'.$phpEx);
290 1491 psotfx
291 1491 psotfx
        //
292 1491 psotfx
        // Set page ID for session management
293 1491 psotfx
        //
294 1491 psotfx
        $userdata = session_pagestart($user_ip, PAGE_INDEX, $session_length);
295 1491 psotfx
        init_userprefs($userdata);
296 1491 psotfx
        //
297 1491 psotfx
        // End session management
298 1491 psotfx
        //
299 1491 psotfx
300 1491 psotfx
        if( $userdata['user_level'] == ADMIN && !$cancel && $dbms != 'msaccess' )
301 1491 psotfx
        {
302 1491 psotfx
                if( !$confirm )
303 1491 psotfx
                {
304 1491 psotfx
                        //
305 1491 psotfx
                        // Sorry this has already been installed can't do anything more with it
306 1491 psotfx
                        //
307 1491 psotfx
                        include($phpbb_root_path . 'includes/page_header.'.$phpEx);
308 1491 psotfx
309 1491 psotfx
                        $template->set_filenames(array(
310 1491 psotfx
                                "confirm" => "confirm_body.tpl")
311 1491 psotfx
                        );
312 1491 psotfx
313 1491 psotfx
                        $template->assign_vars(array(
314 1491 psotfx
                                "MESSAGE_TITLE" => $lang['Admin_config'],
315 1491 psotfx
                                "MESSAGE_TEXT" => $lang['Re_install'],
316 1491 psotfx
317 1491 psotfx
                                "L_YES" => $lang['Yes'],
318 1491 psotfx
                                "L_NO" => $lang['No'],
319 1491 psotfx
320 1491 psotfx
                                "S_CONFIRM_ACTION" => append_sid("install.$phpEx"),
321 1491 psotfx
                                "S_HIDDEN_FIELDS" => $hidden_fields)
322 1491 psotfx
                        );
323 1491 psotfx
324 1491 psotfx
                        $template->pparse("confirm");
325 1491 psotfx
326 1491 psotfx
                        include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
327 1491 psotfx
                }
328 1491 psotfx
329 1491 psotfx
                include($phpbb_root_path.'language/lang_' . $language . '/lang_main.'.$phpEx);
330 1491 psotfx
                include($phpbb_root_path.'language/lang_' . $language . '/lang_admin.'.$phpEx);
331 1491 psotfx
332 1491 psotfx
                $template = new Template($phpbb_root_path . "templates/" . $default_template);
333 1491 psotfx
334 1491 psotfx
                $template->set_filenames(array(
335 1491 psotfx
                        "body" => "install.tpl")
336 1491 psotfx
                );
337 1491 psotfx
338 1491 psotfx
                $template->assign_vars(array(
339 1491 psotfx
                        "L_INSTALLATION" => $lang['Welcome_install'])
340 1491 psotfx
                );
341 1491 psotfx
342 1491 psotfx
                $reinstall = true;
343 1491 psotfx
        }
344 1491 psotfx
        else
345 1491 psotfx
        {
346 1491 psotfx
                header("Location: " . append_sid("index.$phpEx", true));
347 2575 psotfx
                exit;
348 1491 psotfx
        }
349 1102 the_systech
}
350 1491 psotfx
351 1491 psotfx
//
352 1491 psotfx
//
353 1491 psotfx
//
354 1516 the_systech
if( !empty($HTTP_POST_VARS['send_file']) && $HTTP_POST_VARS['send_file'] == 1  && !defined("PHPBB_INSTALLED") && empty($HTTP_POST_VARS['upgrade_now']) )
355 1102 the_systech
{
356 1984 psotfx
        header("Content-Type: text/x-delimtext; name=\"config.$phpEx\"");
357 1984 psotfx
        header("Content-disposition: attachment; filename=config.$phpEx");
358 1144 psotfx
359 1253 thefinn
        //
360 1253 thefinn
        // We need to stripslashes no matter what the setting of magic_quotes_gpc is
361 1253 thefinn
        // because we add slahes at the top if its off, and they are added automaticlly
362 1253 thefinn
        // if it is on.
363 1253 thefinn
        //
364 1253 thefinn
        $HTTP_POST_VARS['config_data'] = stripslashes($HTTP_POST_VARS['config_data']);
365 1144 psotfx
366 1144 psotfx
        echo $HTTP_POST_VARS['config_data'];
367 1144 psotfx
368 1144 psotfx
        exit;
369 1144 psotfx
}
370 1491 psotfx
else if( !empty($HTTP_POST_VARS['send_file']) && $HTTP_POST_VARS['send_file'] == 2 && !defined("PHPBB_INSTALLED")  )
371 1231 the_systech
{
372 1231 the_systech
        //
373 1231 the_systech
        // Ok we couldn't write the config file so let's try ftping it.
374 1231 the_systech
        //
375 1253 thefinn
376 1253 thefinn
        $HTTP_POST_VARS['config_data'] = stripslashes($HTTP_POST_VARS['config_data']);
377 1253 thefinn
378 1491 psotfx
        $s_hidden_fields = '<input type="hidden" name="config_data" value="' . htmlspecialchars($HTTP_POST_VARS['config_data']) . '" />';
379 1231 the_systech
        $s_hidden_fields .= '<input type="hidden" name="ftp_file" value="1" />';
380 1491 psotfx
381 1516 the_systech
        if( $upgrade == 1 )
382 1516 the_systech
        {
383 1516 the_systech
                $s_hidden_fields .= '<input type="hidden" name="upgrade" value="1" />';
384 1516 the_systech
        }
385 1662 psotfx
386 1662 psotfx
        $template->assign_block_vars("switch_ftp_file", array());
387 1662 psotfx
        $template->assign_block_vars("switch_common_install", array());
388 1662 psotfx
389 1231 the_systech
        $template->assign_vars(array(
390 1491 psotfx
                "L_INSTRUCTION_TEXT" => $lang['ftp_instructs'],
391 1491 psotfx
                "L_FTP_INFO" => $lang['ftp_info'],
392 1491 psotfx
                "L_FTP_PATH" => $lang['ftp_path'],
393 1491 psotfx
                "L_FTP_PASS" => $lang['ftp_password'],
394 1491 psotfx
                "L_FTP_USER" => $lang['ftp_username'],
395 1491 psotfx
                "L_SUBMIT" => $lang['Transfer_config'],
396 1491 psotfx
397 1491 psotfx
                "S_HIDDEN_FIELDS" => $s_hidden_fields,
398 1491 psotfx
                "S_FORM_ACTION" => "install.$phpEx")
399 1231 the_systech
        );
400 1491 psotfx
401 1231 the_systech
        $template->pparse("body");
402 1491 psotfx
403 1231 the_systech
        exit;
404 1491 psotfx
405 1231 the_systech
}
406 1491 psotfx
else if( !empty($HTTP_POST_VARS['ftp_file']) && !defined("PHPBB_INSTALLED")  )
407 1231 the_systech
{
408 1231 the_systech
        //
409 1231 the_systech
        // Here we'll actually send the file...
410 1231 the_systech
        //
411 1252 thefinn
        $HTTP_POST_VARS['config_data'] = stripslashes($HTTP_POST_VARS['config_data']);
412 1252 thefinn
413 1491 psotfx
        $conn_id = @ftp_connect('localhost');
414 1491 psotfx
        $login_result = @ftp_login($conn_id, "$ftp_user", "$ftp_pass");
415 1491 psotfx
416 1491 psotfx
        if( !$conn_id || !$login_result )
417 1231 the_systech
        {
418 1231 the_systech
                //
419 1231 the_systech
                // Error couldn't get connected... Go back to option to send file...
420 1231 the_systech
                //
421 1705 the_systech
                $s_hidden_fields = '<input type="hidden" name="config_data" value="' . htmlspecialchars($HTTP_POST_VARS['config_data']) . '" />';
422 1231 the_systech
                $s_hidden_fields .= '<input type="hidden" name="send_file" value="1" />';
423 1516 the_systech
                if( $upgrade == 1 )
424 1516 the_systech
                {
425 1516 the_systech
                        $s_hidden_fields .= '<input type="hidden" name="upgrade" value="1" />';
426 1516 the_systech
                        $s_hidden_fields .= '<input type="hidden" name="dbms" value="'.$dmbs.'" />';
427 2352 the_systech
                        $s_hidden_fields .= '<input type="hidden" name="prefix" value="'.$table_prefix.'" />';
428 1516 the_systech
                        $s_hidden_fields .= '<input type="hidden" name="dbhost" value="'.$dbhost.'" />';
429 1516 the_systech
                        $s_hidden_fields .= '<input type="hidden" name="dbname" value="'.$dbname.'" />';
430 1516 the_systech
                        $s_hidden_fields .= '<input type="hidden" name="dbuser" value="'.$dbuser.'" />';
431 1516 the_systech
                        $s_hidden_fields .= '<input type="hidden" name="dbpasswd" value="'.$dbpasswd.'" />';
432 1516 the_systech
                        $s_hidden_fields .= '<input type="hidden" name="install_step" value="1" />';
433 1516 the_systech
                        $s_hidden_fields .= '<input type="hidden" name="admin_pass1" value="1" />';
434 1516 the_systech
                        $s_hidden_fields .= '<input type="hidden" name="admin_pass2" value="1" />';
435 2363 the_systech
                        $s_hidden_fields .= '<input type="hidden" name="server_port" value="'.$server_port.'" />';
436 2363 the_systech
                        $s_hidden_fields .= '<input type="hidden" name="server_name" value="'.$server_name.'" />';
437 2363 the_systech
                        $s_hidden_fields .= '<input type="hidden" name="script_path" value="'.$script_path.'" />';
438 2363 the_systech
                        $s_hidden_fields .= '<input type="hidden" name="board_email" value="'.$board_email.'" />';
439 1516 the_systech
                        $template->assign_block_vars("switch_upgrade_install", array());
440 1516 the_systech
                        $template->assign_vars(array(
441 1516 the_systech
                                "L_UPGRADE_INST" => $lang['continue_upgrade'],
442 1516 the_systech
                                "L_UPGRADE_SUBMIT" => $lang['upgrade_submit'])
443 1516 the_systech
                        );
444 1516 the_systech
                }
445 1236 the_systech
                $template->assign_block_vars("switch_common_install", array());
446 1516 the_systech
447 1231 the_systech
                $template->assign_vars(array(
448 1231 the_systech
                        "L_INSTRUCTION_TEXT" => $lang['NoFTP_config'],
449 1231 the_systech
                        "L_SUBMIT" => $lang['Download_config'],
450 1491 psotfx
451 1231 the_systech
                        "S_HIDDEN_FIELDS" => $s_hidden_fields,
452 1231 the_systech
                        "S_FORM_ACTION" => "install.$phpEx")
453 1231 the_systech
                );
454 1491 psotfx
455 1231 the_systech
                $template->pparse('body');
456 1491 psotfx
457 1491 psotfx
                exit;
458 1231 the_systech
        }
459 1231 the_systech
        else
460 1231 the_systech
        {
461 1231 the_systech
                //
462 1231 the_systech
                // Write out a temp file...
463 1231 the_systech
                //
464 1491 psotfx
                $tmpfname = @tempnam('/tmp', 'cfg');
465 1491 psotfx
466 1231 the_systech
                @unlink($tmpfname); // unlink for safety on php4.0.3+
467 1491 psotfx
468 1231 the_systech
                $fp = @fopen($tmpfname, 'w');
469 1491 psotfx
470 1231 the_systech
                @fwrite($fp, $HTTP_POST_VARS['config_data']);
471 1491 psotfx
472 1231 the_systech
                @fclose($fp);
473 1491 psotfx
474 1231 the_systech
                //
475 1231 the_systech
                // Now ftp it across.
476 1231 the_systech
                //
477 1231 the_systech
                @ftp_chdir($conn_id, $ftp_dir);
478 1491 psotfx
479 1984 psotfx
                $res = ftp_put($conn_id, 'config.'.$phpEx, $tmpfname, FTP_ASCII);
480 1491 psotfx
481 1231 the_systech
                @ftp_quit($conn_id);
482 1491 psotfx
483 1231 the_systech
                unlink($tmpfname);
484 1516 the_systech
                if( $upgrade == 1 )
485 1516 the_systech
                {
486 1516 the_systech
                        require('upgrade.'.$phpEx);
487 1516 the_systech
                        exit;
488 1516 the_systech
                }
489 1231 the_systech
                //
490 1231 the_systech
                // Ok we are basically done with the install process let's go on
491 1231 the_systech
                // and let the user configure their board now.
492 1491 psotfx
                //
493 1231 the_systech
                // We are going to do this by calling the admin_board.php from the
494 1231 the_systech
                // normal board admin section.
495 1231 the_systech
                //
496 1231 the_systech
                $s_hidden_fields = '<input type="hidden" name="username" value="' . $admin_name . '" />';
497 1231 the_systech
                $s_hidden_fields .= '<input type="hidden" name="password" value="' . $admin_pass1 . '" />';
498 2284 the_systech
                $s_hidden_fields .= '<input type="hidden" name="redirect" value="admin/index.php" />';
499 1491 psotfx
                $s_hidden_fields .= '<input type="hidden" name="submit" value="' . $lang['Login'] . '" />';
500 1491 psotfx
501 1236 the_systech
                $template->assign_block_vars("switch_common_install", array());
502 1491 psotfx
503 1231 the_systech
                $template->assign_vars(array(
504 1231 the_systech
                        "L_INSTRUCTION_TEXT" => $lang['Inst_Step_2'],
505 1231 the_systech
                        "L_SUBMIT" => $lang['Finish_Install'],
506 1231 the_systech
507 1231 the_systech
                        "S_HIDDEN_FIELDS" => $s_hidden_fields,
508 1231 the_systech
                        "S_FORM_ACTION" => "login.$phpEx")
509 1231 the_systech
                );
510 1231 the_systech
511 1231 the_systech
                $template->pparse('body');
512 1491 psotfx
513 1231 the_systech
                exit();
514 1231 the_systech
        }
515 1231 the_systech
}
516 2278 the_systech
else if( ( empty($install_step) || $admin_pass1 != $admin_pass2 || empty($admin_pass1) || $dbhost == "" )  && !defined("PHPBB_INSTALLED") )
517 2363 the_systech
{        //
518 1144 psotfx
        // Ok we haven't installed before so lets work our way through the various
519 1144 psotfx
        // steps of the install process.  This could turn out to be quite a lengty
520 1144 psotfx
        // process.
521 1144 psotfx
        //
522 1144 psotfx
523 1144 psotfx
        //
524 1102 the_systech
        // Step 0 gather the pertinant info for database setup...
525 1102 the_systech
        // Namely dbms, dbhost, dbname, dbuser, and dbpasswd.
526 1102 the_systech
        //
527 2363 the_systech
528 2363 the_systech
        //
529 2363 the_systech
        // Guess at some basic info used for install..
530 2363 the_systech
        //
531 2363 the_systech
532 2363 the_systech
        if ( !empty($HTTP_SERVER_VARS['SERVER_NAME']) || !empty($HTTP_ENV_VARS['SERVER_NAME']) )
533 2363 the_systech
        {
534 2363 the_systech
                $server_name = ( !empty($HTTP_SERVER_VARS['SERVER_NAME']) ) ? $HTTP_SERVER_VARS['SERVER_NAME'] : $HTTP_ENV_VARS['SERVER_NAME'];
535 2363 the_systech
        }
536 2363 the_systech
        else if ( !empty($HTTP_SERVER_VARS['HTTP_HOST']) || !empty($HTTP_ENV_VARS['HTTP_HOST']) )
537 2363 the_systech
        {
538 2363 the_systech
                $server_name = ( !empty($HTTP_SERVER_VARS['HTTP_HOST']) ) ? $HTTP_SERVER_VARS['HTTP_HOST'] : $HTTP_ENV_VARS['HTTP_HOST'];
539 2363 the_systech
        }
540 2363 the_systech
        else
541 2363 the_systech
        {
542 2363 the_systech
                $server_name = '';
543 2363 the_systech
        }
544 2363 the_systech
        if ( !empty($HTTP_SERVER_VARS['SERVER_PORT']) || !empty($HTTP_ENV_VARS['SERVER_PORT']) )
545 2363 the_systech
        {
546 2363 the_systech
                $server_port = ( !empty($HTTP_SERVER_VARS['SERVER_PORT']) ) ? $HTTP_SERVER_VARS['SERVER_PORT'] : $HTTP_ENV_VARS['SERVER_PORT'];
547 2363 the_systech
        }
548 2363 the_systech
        else
549 2363 the_systech
        {
550 2363 the_systech
                $server_port = '80';
551 2363 the_systech
        }
552 2363 the_systech
        $script_path = preg_replace('/install\.'.$phpEx.'/i', '', $HTTP_SERVER_VARS['PHP_SELF']);
553 2363 the_systech
554 1144 psotfx
        $instruction_text = $lang['Inst_Step_0'];
555 1144 psotfx
556 2312 dougk_ff7
        if( (($HTTP_POST_VARS['admin_pass1'] != $HTTP_POST_VARS['admin_pass2']) && $install_step != '0') || (empty($HTTP_POST_VARS['admin_pass1']) && !empty($dbhost)))
557 1107 the_systech
        {
558 1144 psotfx
                $instruction_text = $lang['Password_mismatch'] . '<br />' . $instruction_text;
559 1107 the_systech
        }
560 1144 psotfx
561 1144 psotfx
        $lang_options = language_select($language, 'language');
562 1144 psotfx
563 1518 the_systech
        $dbms_options = '<select name="dbms" onchange="if(document.install_form.upgrade.options[upgrade.selectedIndex].value == 1) { document.install_form.dbms.selectedIndex=0}">';
564 1491 psotfx
        while( list($dbms_name, $details) = @each($available_dbms) )
565 1102 the_systech
        {
566 1491 psotfx
                $selected = ( $dbms_name == $dbms ) ? "selected=\"selected\"" : "";
567 1491 psotfx
                $dbms_options .= '<option value="' . $dbms_name . '">' . $details['LABEL'] . '</option>';
568 1102 the_systech
        }
569 1144 psotfx
        $dbms_options .= '</select>';
570 1144 psotfx
571 1282 the_systech
        $upgrade_option = '<select name="upgrade"';
572 1518 the_systech
        $upgrade_option .= 'onchange="if( this.options[this.selectedIndex].value == 1 ) { document.install_form.dbms.selectedIndex=0; }">';
573 1491 psotfx
        $upgrade_option .= '<option value="0">' . $lang['Install'] . '</option>';
574 1491 psotfx
        $upgrade_option .= '<option value="1">' . $lang['Upgrade'] . '</option></select>';
575 1282 the_systech
576 1144 psotfx
        $s_hidden_fields = '<input type="hidden" name="install_step" value="1" />';
577 1144 psotfx
578 1236 the_systech
        $template->assign_block_vars("switch_stage_one_install", array());
579 1236 the_systech
        $template->assign_block_vars("switch_common_install", array());
580 1144 psotfx
581 1144 psotfx
        $template->assign_vars(array(
582 1144 psotfx
                "L_INSTRUCTION_TEXT" => $instruction_text,
583 1144 psotfx
                "L_INITIAL_CONFIGURATION" => $lang['Initial_config'],
584 1144 psotfx
                "L_DATABASE_CONFIGURATION" => $lang['DB_config'],
585 1144 psotfx
                "L_ADMIN_CONFIGURATION" => $lang['Admin_config'],
586 1144 psotfx
                "L_LANGUAGE" => $lang['Default_lang'],
587 1144 psotfx
                "L_DBMS" => $lang['dbms'],
588 1144 psotfx
                "L_DB_HOST" => $lang['DB_Host'],
589 1144 psotfx
                "L_DB_NAME" => $lang['DB_Name'],
590 1676 psotfx
                "L_DB_USER" => $lang['DB_Username'],
591 1676 psotfx
                "L_DB_PASSWORD" => $lang['DB_Password'],
592 1144 psotfx
                "L_DB_PREFIX" => $lang['Table_Prefix'],
593 1282 the_systech
                "L_UPGRADE" => $lang['Install_Method'],
594 1676 psotfx
                "L_ADMIN_USERNAME" => $lang['Admin_Username'],
595 1676 psotfx
                "L_ADMIN_PASSWORD" => $lang['Admin_Password'],
596 1676 psotfx
                "L_ADMIN_CONFIRM_PASSWORD" => $lang['Admin_Password_confirm'],
597 1144 psotfx
                "L_SUBMIT" => $lang['Start_Install'],
598 2363 the_systech
                "L_ADMIN_EMAIL" => $lang['Admin_email'],
599 2363 the_systech
                "L_SERVER_NAME" => $lang['Server_name'],
600 2363 the_systech
                "L_SERVER_PORT" => $lang['Server_port'],
601 2363 the_systech
                "L_SCRIPT_PATH" => $lang['Script_path'],
602 2363 the_systech
603 2363 the_systech
                "SCRIPT_PATH" => $script_path,
604 2363 the_systech
                "SERVER_PORT" => $server_port,
605 2363 the_systech
                "SERVER_NAME" => $server_name,
606 1491 psotfx
                "DB_PREFIX" => ( !empty($table_prefix) ) ? $table_prefix : "phpbb_",
607 1144 psotfx
                "DB_HOST" => ( $dbhost != "" ) ? $dbhost : "",
608 1144 psotfx
                "DB_USER" => ( $dbuser != "" ) ? $dbuser : "",
609 1144 psotfx
                "DB_PASSWD" => ( $dbpasswd != "" ) ? $dbpasswd : "",
610 1600 psotfx
                "ADMIN_USERNAME" => ( $admin_name != "" ) ? $admin_name : "",
611 1144 psotfx
612 1144 psotfx
                "S_LANG_SELECT" => $lang_options,
613 1144 psotfx
                "S_DBMS_SELECT" => $dbms_options,
614 1282 the_systech
                "S_HIDDEN_FIELDS" => $s_hidden_fields,
615 1282 the_systech
                "S_UPGRADE_SELECT" => $upgrade_option,
616 1144 psotfx
                "S_FORM_ACTION" => "install.$phpEx")
617 1102 the_systech
        );
618 1144 psotfx
619 1102 the_systech
        $template->pparse("body");
620 1144 psotfx
621 1491 psotfx
        exit;
622 1102 the_systech
}
623 1144 psotfx
else
624 1102 the_systech
{
625 1144 psotfx
        //
626 1491 psotfx
        // Go ahead and create the DB, then populate it
627 1144 psotfx
        //
628 1491 psotfx
        // MS Access is slightly different in that a pre-built, pre-
629 1491 psotfx
        // populated DB is supplied, all we need do here is update
630 1491 psotfx
        // the relevant entries
631 1491 psotfx
        //
632 1491 psotfx
        if( $reinstall )
633 1144 psotfx
        {
634 1491 psotfx
                $sql_query = preg_replace('/phpbb_/', $table_prefix, $sql_array['drop_schema']);
635 1491 psotfx
                $sql_count = count($sql_query);
636 1491 psotfx
637 1491 psotfx
                for($i = 0; $i < $sql_count; $i++)
638 1491 psotfx
                {
639 1491 psotfx
                        $result = $db->sql_query($sql_query[$i]);
640 1491 psotfx
                        if( !$result )
641 1491 psotfx
                        {
642 1491 psotfx
                                $error = $db->sql_error();
643 1491 psotfx
644 1491 psotfx
                                $template->assign_block_vars("switch_error_install", array());
645 1491 psotfx
646 1491 psotfx
                                $template->assign_vars(array(
647 1491 psotfx
                                        "L_ERROR_TITLE" => $lang['Installer_Error'],
648 1491 psotfx
                                        "L_ERROR" => $lang['Install_db_error'] . '<br /><br />' . $error)
649 1491 psotfx
                                );
650 1491 psotfx
651 1491 psotfx
                                $template->pparse('body');
652 1491 psotfx
653 1491 psotfx
                                exit;
654 1491 psotfx
                        }
655 1491 psotfx
                }
656 1491 psotfx
657 1491 psotfx
                $admin_name = $userdata['username'];
658 1491 psotfx
                $admin_pass1 = $userdata['user_password'];
659 1491 psotfx
                $language = $userdata['user_lang'];
660 1491 psotfx
        }
661 1516 the_systech
        else if( isset($dbms) )
662 1491 psotfx
        {
663 2012 the_systech
                switch( $dbms )
664 2012 the_systech
                {
665 2012 the_systech
                        case 'msaccess':
666 2012 the_systech
                        case 'mssql-odbc':
667 2012 the_systech
                                $check_exts = 'odbc';
668 2012 the_systech
                                $check_other = 'odbc';
669 2012 the_systech
                                break;
670 2012 the_systech
                        case 'mssql':
671 2012 the_systech
                                $check_exts = 'mssql';
672 2012 the_systech
                                $check_other = 'sybase';
673 2012 the_systech
                                break;
674 2012 the_systech
                        case 'mysql':
675 2012 the_systech
                        case 'mysql4':
676 2012 the_systech
                                $check_exts = 'mysql';
677 2012 the_systech
                                $check_other = 'mysql';
678 2012 the_systech
                                break;
679 2012 the_systech
                        case 'postgres':
680 2012 the_systech
                                $check_exts = 'pgsql';
681 2012 the_systech
                                $check_other = 'pgsql';
682 2012 the_systech
                                break;
683 2012 the_systech
                }
684 2012 the_systech
                if( !extension_loaded( $check_exts ) && !extension_loaded( $check_other ) )
685 2012 the_systech
                {
686 2012 the_systech
                        $template->assign_block_vars("switch_error_install", array());
687 2012 the_systech
688 2012 the_systech
                        $template->assign_vars(array(
689 2012 the_systech
                                "L_ERROR_TITLE" => $lang['Installer_Error'],
690 2012 the_systech
                                "L_ERROR" => $lang['Install_No_Ext'])
691 2012 the_systech
                        );
692 2012 the_systech
                        $template->pparse('body');
693 2012 the_systech
                        exit;
694 2012 the_systech
                }
695 1144 psotfx
                include($phpbb_root_path.'includes/db.'.$phpEx);
696 1144 psotfx
        }
697 1102 the_systech
698 1491 psotfx
        $dbms_schema = 'db/schemas/' . $available_dbms[$dbms]['SCHEMA'] . '_schema.sql';
699 1491 psotfx
        $dbms_basic = 'db/schemas/' . $available_dbms[$dbms]['SCHEMA'] . '_basic.sql';
700 1144 psotfx
701 1491 psotfx
        $remove_remarks = $available_dbms[$dbms]['COMMENTS'];;
702 1491 psotfx
        $delimiter = $available_dbms[$dbms]['DELIM'];
703 1491 psotfx
        $delimiter_basic = $available_dbms[$dbms]['DELIM_BASIC'];
704 1144 psotfx
705 1491 psotfx
        if( $install_step == 1 || $reinstall )
706 1144 psotfx
        {
707 1491 psotfx
                if( $upgrade != 1 )
708 1163 the_systech
                {
709 1491 psotfx
                        if( $dbms != 'msaccess' )
710 1102 the_systech
                        {
711 1491 psotfx
                                //
712 1491 psotfx
                                // Ok we have the db info go ahead and read in the relevant schema
713 1491 psotfx
                                // and work on building the table.. probably ought to provide some
714 1491 psotfx
                                // kind of feedback to the user as we are working here in order
715 1491 psotfx
                                // to let them know we are actually doing something.
716 1491 psotfx
                                //
717 1491 psotfx
                                $sql_query = @fread(@fopen($dbms_schema, 'r'), @filesize($dbms_schema));
718 1491 psotfx
                                $sql_query = preg_replace('/phpbb_/', $table_prefix, $sql_query);
719 1491 psotfx
720 1491 psotfx
                                $sql_query = $remove_remarks($sql_query);
721 1491 psotfx
                                $sql_query = split_sql_file($sql_query, $delimiter);
722 1491 psotfx
723 1491 psotfx
                                $sql_count = count($sql_query);
724 1491 psotfx
725 1491 psotfx
                                for($i = 0; $i < $sql_count; $i++)
726 1144 psotfx
                                {
727 1491 psotfx
                                        $result = $db->sql_query($sql_query[$i]);
728 1491 psotfx
                                        if( !$result )
729 1491 psotfx
                                        {
730 1491 psotfx
                                                $error = $db->sql_error();
731 1491 psotfx
732 1491 psotfx
                                                $template->assign_block_vars("switch_error_install", array());
733 1395 psotfx
734 1491 psotfx
                                                $template->assign_vars(array(
735 1491 psotfx
                                                        "L_ERROR_TITLE" => $lang['Installer_Error'],
736 1491 psotfx
                                                        "L_ERROR" => $lang['Install_db_error'] . '<br />' . $error['message'])
737 1491 psotfx
                                                );
738 1491 psotfx
739 1491 psotfx
                                                $template->pparse('body');
740 1491 psotfx
741 1491 psotfx
                                                exit;
742 1491 psotfx
                                        }
743 1144 psotfx
                                }
744 1491 psotfx
745 1491 psotfx
                                //
746 1491 psotfx
                                // Ok tables have been built, let's fill in the basic information
747 1491 psotfx
                                //
748 1491 psotfx
                                $sql_query = @fread(@fopen($dbms_basic, 'r'), @filesize($dbms_basic));
749 1491 psotfx
                                $sql_query = preg_replace('/phpbb_/', $table_prefix, $sql_query);
750 1491 psotfx
751 1491 psotfx
                                $sql_query = $remove_remarks($sql_query);
752 1491 psotfx
                                $sql_query = split_sql_file($sql_query, $delimiter_basic);
753 1491 psotfx
754 1163 the_systech
                                $sql_count = count($sql_query);
755 1491 psotfx
756 1491 psotfx
                                for($i = 0; $i < $sql_count; $i++)
757 1144 psotfx
                                {
758 1491 psotfx
                                        $result = $db->sql_query($sql_query[$i]);
759 1491 psotfx
                                        if( !$result )
760 1491 psotfx
                                        {
761 1491 psotfx
                                                $error = $db->sql_error();
762 1491 psotfx
763 1491 psotfx
                                                $template->assign_block_vars("switch_error_install", array());
764 1491 psotfx
765 1491 psotfx
                                                $template->assign_vars(array(
766 1491 psotfx
                                                        "L_ERROR_TITLE" => $lang['Installer_Error'],
767 1491 psotfx
                                                        "L_ERROR" => $lang['Install_db_error'] . "<br />" . $error["message"])
768 1491 psotfx
                                                );
769 1491 psotfx
770 1491 psotfx
                                                $template->pparse('body');
771 1491 psotfx
772 1491 psotfx
                                                exit;
773 1491 psotfx
                                        }
774 1144 psotfx
                                }
775 1102 the_systech
                        }
776 1491 psotfx
777 1102 the_systech
                        //
778 1144 psotfx
                        // Ok at this point they have entered their admin password, let's go
779 1144 psotfx
                        // ahead and create the admin account with some basic default information
780 1144 psotfx
                        // that they can customize later, and write out the config file.  After
781 1144 psotfx
                        // this we are going to pass them over to the admin_forum.php script
782 1144 psotfx
                        // to set up their forum defaults.
783 1102 the_systech
                        //
784 1163 the_systech
                        $error = "";
785 1491 psotfx
786 1163 the_systech
                        //
787 1163 the_systech
                        // Update the default admin user with their information.
788 1163 the_systech
                        //
789 1163 the_systech
                        $sql = "INSERT INTO " . $table_prefix . "config (config_name, config_value)
790 1163 the_systech
                                VALUES ('board_startdate', " . time() . ")";
791 1163 the_systech
                        $result = $db->sql_query($sql);
792 1163 the_systech
                        if( !$result )
793 1102 the_systech
                        {
794 1491 psotfx
                                $error .= "Could not insert board_startdate :: " . $sql . " :: " . __LINE__ . " :: " . __FILE__ . "<br /><br />";
795 1163 the_systech
                        }
796 1144 psotfx
797 1163 the_systech
                        $sql = "INSERT INTO " . $table_prefix . "config (config_name, config_value)
798 1662 psotfx
                                VALUES ('default_lang', '" . str_replace("\'", "''", $language) . "')";
799 1163 the_systech
                        $result = $db->sql_query($sql);
800 1163 the_systech
                        if( !$result )
801 1163 the_systech
                        {
802 1491 psotfx
                                $error .= "Could not insert default_lang :: " . $sql . " :: " . __LINE__ . " :: " . __FILE__ . "<br /><br />";
803 1163 the_systech
                        }
804 2363 the_systech
                        $sql = "UPDATE " . $table_prefix . "config
805 2363 the_systech
                                SET config_value = '" . $server_name . "'
806 2363 the_systech
                                WHERE config_name = 'server_name'";
807 2363 the_systech
                        $result = $db->sql_query($sql);
808 2363 the_systech
                        if( !$result )
809 2363 the_systech
                        {
810 2363 the_systech
                                $error .= "Could not update Board info :: " . $sql . " :: " . __LINE__ . " :: " . __FILE__ . "<br /><br />";
811 2363 the_systech
                        }
812 2363 the_systech
                        $sql = "UPDATE " . $table_prefix . "config
813 2363 the_systech
                                SET config_value = '" . $server_port . "'
814 2363 the_systech
                                WHERE config_name = 'server_port'";
815 2363 the_systech
                        $result = $db->sql_query($sql);
816 2363 the_systech
                        if( !$result )
817 2363 the_systech
                        {
818 2363 the_systech
                                $error .= "Could not update Board info :: " . $sql . " :: " . __LINE__ . " :: " . __FILE__ . "<br /><br />";
819 2363 the_systech
                        }
820 2363 the_systech
                        $sql = "UPDATE " . $table_prefix . "config
821 2371 the_systech
                                SET config_value = '" . $script_path . "'
822 2371 the_systech
                                WHERE config_name = 'script_path'";
823 2363 the_systech
                        $result = $db->sql_query($sql);
824 2363 the_systech
                        if( !$result )
825 2363 the_systech
                        {
826 2363 the_systech
                                $error .= "Could not update Board info :: " . $sql . " :: " . __LINE__ . " :: " . __FILE__ . "<br /><br />";
827 2363 the_systech
                        }
828 2363 the_systech
                        $sql = "UPDATE " . $table_prefix . "config
829 2363 the_systech
                                SET config_value = '" . $board_email . "'
830 2363 the_systech
                                WHERE config_name = 'board_email'";
831 2363 the_systech
                        $result = $db->sql_query($sql);
832 2363 the_systech
                        if( !$result )
833 2363 the_systech
                        {
834 2363 the_systech
                                $error .= "Could not update Board info :: " . $sql . " :: " . __LINE__ . " :: " . __FILE__ . "<br /><br />";
835 2363 the_systech
                        }
836 2363 the_systech
                        $sql = "UPDATE " . $table_prefix . "config
837 2363 the_systech
                                SET config_value = '" . $server_name . "'
838 2363 the_systech
                                WHERE config_name = 'cookie_domain'";
839 2363 the_systech
                        $result = $db->sql_query($sql);
840 2363 the_systech
                        if( !$result )
841 2363 the_systech
                        {
842 2363 the_systech
                                $error .= "Could not update Board info :: " . $sql . " :: " . __LINE__ . " :: " . __FILE__ . "<br /><br />";
843 2363 the_systech
                        }
844 2363 the_systech
845 1144 psotfx
846 1491 psotfx
                        $admin_pass_md5 = ( $confirm && $userdata['user_level'] == ADMIN ) ? $admin_pass1 : md5($admin_pass1);
847 1491 psotfx
848 1163 the_systech
                        $sql = "UPDATE " . $table_prefix . "users
849 2363 the_systech
                                SET username = '" . str_replace("\'", "''", $admin_name) . "', user_password='" . str_replace("\'", "''", $admin_pass_md5) . "', user_lang = '" . str_replace("\'", "''", $language) . "', user_email='" . str_replace("\'", "''", $board_email) . "'
850 1163 the_systech
                                WHERE username = 'Admin'";
851 1163 the_systech
                        $result = $db->sql_query($sql);
852 1163 the_systech
                        if( !$result )
853 1163 the_systech
                        {
854 1491 psotfx
                                $error .= "Could not update admin info :: " . $sql . " :: " . __LINE__ . " :: " . __FILE__ . "<br /><br />";
855 1163 the_systech
                        }
856 1144 psotfx
857 1163 the_systech
                        $sql = "UPDATE " . $table_prefix . "users
858 1163 the_systech
                                SET user_regdate = " . time();
859 1163 the_systech
                        $result = $db->sql_query($sql);
860 1163 the_systech
                        if( !$result )
861 1163 the_systech
                        {
862 1491 psotfx
                                $error .= "Could not update user_regdate :: " . $sql . " :: " . __LINE__ . " :: " . __FILE__ . "<br /><br />";
863 1102 the_systech
                        }
864 1163 the_systech
865 1491 psotfx
                        //
866 1491 psotfx
                        // Change session table to HEAP if MySQL version matches
867 1491 psotfx
                        //
868 1491 psotfx
                        if( preg_match("/^mysql/", $dbms) )
869 1491 psotfx
                        {
870 1491 psotfx
                                $sql = "SELECT VERSION() AS mysql_version";
871 1491 psotfx
                                if($result = $db->sql_query($sql))
872 1491 psotfx
                                {
873 1491 psotfx
                                        $row = $db->sql_fetchrow($result);
874 1491 psotfx
                                        $version = $row['mysql_version'];
875 1491 psotfx
876 1771 psotfx
                                        if( preg_match("/^(3\.23)|(4\.)/", $version) )
877 1491 psotfx
                                        {
878 1491 psotfx
                                                $sql = "ALTER TABLE " . $table_prefix . "sessions
879 2723 psotfx
                                                        TYPE=HEAP MAX_ROWS=500";
880 1772 thefinn
                                                $db->sql_query($sql);
881 1491 psotfx
                                        }
882 1491 psotfx
                                }
883 1491 psotfx
                        }
884 1491 psotfx
885 1163 the_systech
                        if( $error != "" )
886 1125 the_systech
                        {
887 1491 psotfx
                                $template->assign_block_vars("switch_error_install", array());
888 1144 psotfx
889 1163 the_systech
                                $template->assign_vars(array(
890 1163 the_systech
                                        "L_ERROR_TITLE" => $lang['Installer_Error'],
891 1163 the_systech
                                        "L_ERROR" => $lang['Install_db_error'] . '<br /><br />' . $error)
892 1163 the_systech
                                );
893 1144 psotfx
894 1163 the_systech
                                $template->pparse('body');
895 1491 psotfx
896 1163 the_systech
                                exit;
897 1163 the_systech
                        }
898 1163 the_systech
                }
899 1144 psotfx
900 1771 psotfx
                if( !$reinstall && !$upgrade_now )
901 1163 the_systech
                {
902 1491 psotfx
                        $template->assign_block_vars("switch_common_install", array());
903 1491 psotfx
904 1163 the_systech
                        //
905 1491 psotfx
                        // Write out the config file.
906 1163 the_systech
                        //
907 1491 psotfx
                        $config_data = '<?php'."\n\n";
908 1491 psotfx
                        $config_data .= "//\n// phpBB 2.x auto-generated config file\n// Do not change anything in this file!\n//\n\n";
909 2619 dougk_ff7
                        $config_data .= '$dbms = \'' . $dbms . '\';' . "\n\n";
910 2619 dougk_ff7
                        $config_data .= '$dbhost = \'' . $dbhost . '\';' . "\n";
911 2619 dougk_ff7
                        $config_data .= '$dbname = \'' . $dbname . '\';' . "\n";
912 2619 dougk_ff7
                        $config_data .= '$dbuser = \'' . $dbuser . '\';' . "\n";
913 2619 dougk_ff7
                        $config_data .= '$dbpasswd = \'' . $dbpasswd . '\';' . "\n\n";
914 2619 dougk_ff7
                        $config_data .= '$table_prefix = \'' . $table_prefix . '\';' . "\n\n";
915 1491 psotfx
                        $config_data .= 'define(\'PHPBB_INSTALLED\', true);'."\n\n";
916 1491 psotfx
                        $config_data .= '?' . '>'; // Done this to prevent highlighting editors getting confused!
917 1491 psotfx
918 1491 psotfx
                        @umask(0111);
919 1491 psotfx
                        $no_open = FALSE;
920 1491 psotfx
921 1984 psotfx
                        $fp = @fopen('config.'.$phpEx, 'w');
922 1491 psotfx
                        if( !$fp )
923 1231 the_systech
                        {
924 1491 psotfx
                                //
925 1491 psotfx
                                // Unable to open the file writeable do something here as an attempt
926 1491 psotfx
                                // to get around that...
927 1491 psotfx
                                //
928 1491 psotfx
                                $s_hidden_fields = '<input type="hidden" name="config_data" value="' . htmlspecialchars($config_data) . '" />';
929 1491 psotfx
930 1491 psotfx
                                if( extension_loaded('ftp') && !defined('NO_FTP') )
931 1491 psotfx
                                {
932 1491 psotfx
                                        $template->assign_block_vars('switch_ftp_option', array());
933 1491 psotfx
934 1491 psotfx
                                        $lang['Unwriteable_config'] .= '<p>' . $lang['ftp_option'] . '</p>';
935 1491 psotfx
936 1491 psotfx
                                        $template->assign_vars(array(
937 1491 psotfx
                                                "L_CHOOSE_FTP" => $lang['ftp_choose'],
938 1491 psotfx
                                                "L_ATTEMPT_FTP" => $lang['Attempt_ftp'],
939 1491 psotfx
                                                "L_SEND_FILE" => $lang['Send_file'])
940 1491 psotfx
                                        );
941 1491 psotfx
                                }
942 1491 psotfx
                                else
943 1491 psotfx
                                {
944 1491 psotfx
                                        $s_hidden_fields .= '<input type="hidden" name="send_file" value="1" />';
945 1491 psotfx
                                }
946 1516 the_systech
                                if( $upgrade == 1 )
947 1516 the_systech
                                {
948 1516 the_systech
                                        $s_hidden_fields .= '<input type="hidden" name="upgrade" value="1" />';
949 1516 the_systech
                                        $s_hidden_fields .= '<input type="hidden" name="dbms" value="'.$dbms.'" />';
950 2352 the_systech
                                        $s_hidden_fields .= '<input type="hidden" name="prefix" value="'.$table_prefix.'" />';
951 1516 the_systech
                                        $s_hidden_fields .= '<input type="hidden" name="dbhost" value="'.$dbhost.'" />';
952 1516 the_systech
                                        $s_hidden_fields .= '<input type="hidden" name="dbname" value="'.$dbname.'" />';
953 1516 the_systech
                                        $s_hidden_fields .= '<input type="hidden" name="dbuser" value="'.$dbuser.'" />';
954 1516 the_systech
                                        $s_hidden_fields .= '<input type="hidden" name="dbpasswd" value="'.$dbpasswd.'" />';
955 1516 the_systech
                                        $s_hidden_fields .= '<input type="hidden" name="install_step" value="1" />';
956 1516 the_systech
                                        $s_hidden_fields .= '<input type="hidden" name="admin_pass1" value="1" />';
957 1516 the_systech
                                        $s_hidden_fields .= '<input type="hidden" name="admin_pass2" value="1" />';
958 2363 the_systech
                                        $s_hidden_fields .= '<input type="hidden" name="server_port" value="'.$server_port.'" />';
959 2363 the_systech
                                        $s_hidden_fields .= '<input type="hidden" name="server_name" value="'.$server_name.'" />';
960 2363 the_systech
                                        $s_hidden_fields .= '<input type="hidden" name="script_path" value="'.$script_path.'" />';
961 2363 the_systech
                                        $s_hidden_fields .= '<input type="hidden" name="board_email" value="'.$board_email.'" />';
962 1491 psotfx
963 1516 the_systech
                                        $template->assign_block_vars("switch_upgrade_install", array());
964 1516 the_systech
                                        $template->assign_vars(array(
965 1516 the_systech
                                                "L_UPGRADE_INST" => $lang['continue_upgrade'],
966 1516 the_systech
                                                "L_UPGRADE_SUBMIT" => $lang['upgrade_submit'])
967 1516 the_systech
                                        );
968 1516 the_systech
                                }
969 1516 the_systech
970 1231 the_systech
                                $template->assign_vars(array(
971 1491 psotfx
                                        "L_INSTRUCTION_TEXT" => $lang['Unwriteable_config'],
972 1491 psotfx
                                        "L_SUBMIT" => $lang['Download_config'],
973 1491 psotfx
974 1491 psotfx
                                        "S_HIDDEN_FIELDS" => $s_hidden_fields,
975 1491 psotfx
                                        "S_FORM_ACTION" => "install.$phpEx")
976 1231 the_systech
                                );
977 1491 psotfx
978 1491 psotfx
                                $template->pparse('body');
979 1491 psotfx
980 1491 psotfx
                                exit;
981 1231 the_systech
                        }
982 1144 psotfx
983 1491 psotfx
                        $result = @fputs($fp, $config_data, strlen($config_data));
984 1144 psotfx
985 1491 psotfx
                        @fclose($fp);
986 1516 the_systech
                        $upgrade_now = $lang['upgrade_submit'];
987 1163 the_systech
                }
988 1491 psotfx
                else
989 1491 psotfx
                {
990 1491 psotfx
                        $template->assign_block_vars("switch_common_install", array());
991 1491 psotfx
                }
992 1144 psotfx
993 1516 the_systech
                //
994 1516 the_systech
                // First off let's check and see if we are supposed to be doing an upgrade.
995 1163 the_systech
                //
996 1516 the_systech
                if ( $upgrade == 1 && $upgrade_now == $lang['upgrade_submit'] )
997 1516 the_systech
                {
998 1648 the_systech
                        define('INSTALLING', true);
999 1516 the_systech
                        require('upgrade.'.$phpEx);
1000 1516 the_systech
                        exit;
1001 1516 the_systech
                }
1002 1516 the_systech
                //
1003 1163 the_systech
                // Ok we are basically done with the install process let's go on
1004 1163 the_systech
                // and let the user configure their board now.
1005 1491 psotfx
                //
1006 1163 the_systech
                // We are going to do this by calling the admin_board.php from the
1007 1163 the_systech
                // normal board admin section.
1008 1163 the_systech
                //
1009 1491 psotfx
                if( !$reinstall )
1010 1163 the_systech
                {
1011 1491 psotfx
                        $s_hidden_fields = '<input type="hidden" name="username" value="' . $admin_name . '" />';
1012 1491 psotfx
                        $s_hidden_fields .= '<input type="hidden" name="password" value="' . $admin_pass1 . '" />';
1013 2396 the_systech
                        $s_hidden_fields .= '<input type="hidden" name="redirect" value="admin/index.php" />';
1014 1491 psotfx
                        $s_hidden_fields .= '<input type="hidden" name="login" value="true" />';
1015 1163 the_systech
                }
1016 1491 psotfx
                else
1017 1491 psotfx
                {
1018 1491 psotfx
                        $s_hidden_fields = "";
1019 1491 psotfx
                }
1020 1144 psotfx
1021 1163 the_systech
                $template->assign_vars(array(
1022 1163 the_systech
                        "L_INSTRUCTION_TEXT" => $lang['Inst_Step_2'],
1023 1163 the_systech
                        "L_SUBMIT" => $lang['Finish_Install'],
1024 1144 psotfx
1025 1163 the_systech
                        "S_HIDDEN_FIELDS" => $s_hidden_fields,
1026 1491 psotfx
                        "S_FORM_ACTION" => ( $reinstall ) ? append_sid("login.$phpEx") : "login.$phpEx")
1027 1163 the_systech
                );
1028 1163 the_systech
1029 1163 the_systech
                $template->pparse('body');
1030 1491 psotfx
1031 1491 psotfx
                exit;
1032 1144 psotfx
        }
1033 1102 the_systech
}
1034 1491 psotfx
1035 1705 the_systech
?>