source: branches/rsr.v5.1.dev/web/punbb/install.php @ 3

Last change on this file since 3 was 3, checked in by dj3c1t, 12 years ago

passage a Fluxbb 1.4.7

File size: 58.2 KB
Line 
1<?php
2
3/**
4 * Copyright (C) 2008-2011 FluxBB
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */
8
9// The FluxBB version this script installs
10define('FORUM_VERSION', '1.4.7');
11
12define('FORUM_DB_REVISION', 15);
13define('FORUM_SI_REVISION', 2);
14define('FORUM_PARSER_REVISION', 2);
15
16define('MIN_PHP_VERSION', '4.4.0');
17define('MIN_MYSQL_VERSION', '4.1.2');
18define('MIN_PGSQL_VERSION', '7.0.0');
19define('PUN_SEARCH_MIN_WORD', 3);
20define('PUN_SEARCH_MAX_WORD', 20);
21
22
23define('PUN_ROOT', dirname(__FILE__).'/');
24
25// Load the functions script
26require PUN_ROOT.'include/functions.php';
27
28// Load UTF-8 functions
29require PUN_ROOT.'include/utf8/utf8.php';
30
31// Strip out "bad" UTF-8 characters
32forum_remove_bad_characters();
33
34// Reverse the effect of register_globals
35forum_unregister_globals();
36
37// Disable error reporting for uninitialized variables
38error_reporting(E_ALL);
39
40// Force POSIX locale (to prevent functions such as strtolower() from messing up UTF-8 strings)
41setlocale(LC_CTYPE, 'C');
42
43// Turn off magic_quotes_runtime
44if (get_magic_quotes_runtime())
45        set_magic_quotes_runtime(0);
46
47// Strip slashes from GET/POST/COOKIE (if magic_quotes_gpc is enabled)
48if (get_magic_quotes_gpc())
49{
50        function stripslashes_array($array)
51        {
52                return is_array($array) ? array_map('stripslashes_array', $array) : stripslashes($array);
53        }
54
55        $_GET = stripslashes_array($_GET);
56        $_POST = stripslashes_array($_POST);
57        $_COOKIE = stripslashes_array($_COOKIE);
58        $_REQUEST = stripslashes_array($_REQUEST);
59}
60
61// Turn off PHP time limit
62@set_time_limit(0);
63
64
65// If we've been passed a default language, use it
66$install_lang = isset($_REQUEST['install_lang']) ? trim($_REQUEST['install_lang']) : 'English';
67
68// If such a language pack doesn't exist, or isn't up-to-date enough to translate this page, default to English
69if (!file_exists(PUN_ROOT.'lang/'.$install_lang.'/install.php'))
70        $install_lang = 'English';
71
72require PUN_ROOT.'lang/'.$install_lang.'/install.php';
73
74if (file_exists(PUN_ROOT.'config.php'))
75{
76        // Check to see whether FluxBB is already installed
77        include PUN_ROOT.'config.php';
78
79        // If we have the 1.3-legacy constant defined, define the proper 1.4 constant so we don't get an incorrect "need to install" message
80        if (defined('FORUM'))
81                define('PUN', FORUM);
82
83        // If PUN is defined, config.php is probably valid and thus the software is installed
84        if (defined('PUN'))
85                exit($lang_install['Already installed']);
86}
87
88// Define PUN because email.php requires it
89define('PUN', 1);
90
91// If the cache directory is not specified, we use the default setting
92if (!defined('FORUM_CACHE_DIR'))
93        define('FORUM_CACHE_DIR', PUN_ROOT.'cache/');
94
95// Make sure we are running at least MIN_PHP_VERSION
96if (!function_exists('version_compare') || version_compare(PHP_VERSION, MIN_PHP_VERSION, '<'))
97        exit(sprintf($lang_install['You are running error'], 'PHP', PHP_VERSION, FORUM_VERSION, MIN_PHP_VERSION));
98
99
100//
101// Generate output to be used for config.php
102//
103function generate_config_file()
104{
105        global $db_type, $db_host, $db_name, $db_username, $db_password, $db_prefix, $cookie_name, $cookie_seed;
106
107        return '<?php'."\n\n".'$db_type = \''.$db_type."';\n".'$db_host = \''.$db_host."';\n".'$db_name = \''.addslashes($db_name)."';\n".'$db_username = \''.addslashes($db_username)."';\n".'$db_password = \''.addslashes($db_password)."';\n".'$db_prefix = \''.addslashes($db_prefix)."';\n".'$p_connect = false;'."\n\n".'$cookie_name = '."'".$cookie_name."';\n".'$cookie_domain = '."'';\n".'$cookie_path = '."'/';\n".'$cookie_secure = 0;'."\n".'$cookie_seed = \''.random_key(16, false, true)."';\n\ndefine('PUN', 1);\n";
108}
109
110
111if (isset($_POST['generate_config']))
112{
113        header('Content-Type: text/x-delimtext; name="config.php"');
114        header('Content-disposition: attachment; filename=config.php');
115
116        $db_type = $_POST['db_type'];
117        $db_host = $_POST['db_host'];
118        $db_name = $_POST['db_name'];
119        $db_username = $_POST['db_username'];
120        $db_password = $_POST['db_password'];
121        $db_prefix = $_POST['db_prefix'];
122        $cookie_name = $_POST['cookie_name'];
123        $cookie_seed = $_POST['cookie_seed'];
124
125        echo generate_config_file();
126        exit;
127}
128
129
130if (!isset($_POST['form_sent']))
131{
132        // Make an educated guess regarding base_url
133        $base_url  = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://';  // protocol
134        $base_url .= preg_replace('%:(80|443)$%', '', $_SERVER['HTTP_HOST']);                                                   // host[:port]
135        $base_url .= str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME']));                                                  // path
136
137        if (substr($base_url, -1) == '/')
138                $base_url = substr($base_url, 0, -1);
139
140        $db_type = $db_name = $db_username = $db_prefix = $username = $email = '';
141        $db_host = 'localhost';
142        $title = $lang_install['My FluxBB Forum'];
143        $description = '<p><span>'.$lang_install['Description'].'</span></p>';
144        $default_lang = $install_lang;
145        $default_style = 'Air';
146}
147else
148{
149        $db_type = $_POST['req_db_type'];
150        $db_host = pun_trim($_POST['req_db_host']);
151        $db_name = pun_trim($_POST['req_db_name']);
152        $db_username = pun_trim($_POST['db_username']);
153        $db_password = pun_trim($_POST['db_password']);
154        $db_prefix = pun_trim($_POST['db_prefix']);
155        $username = pun_trim($_POST['req_username']);
156        $email = strtolower(pun_trim($_POST['req_email']));
157        $password1 = pun_trim($_POST['req_password1']);
158        $password2 = pun_trim($_POST['req_password2']);
159        $title = pun_trim($_POST['req_title']);
160        $description = pun_trim($_POST['desc']);
161        $base_url = pun_trim($_POST['req_base_url']);
162        $default_lang = pun_trim($_POST['req_default_lang']);
163        $default_style = pun_trim($_POST['req_default_style']);
164        $alerts = array();
165
166        // Make sure base_url doesn't end with a slash
167        if (substr($base_url, -1) == '/')
168                $base_url = substr($base_url, 0, -1);
169
170        // Validate username and passwords
171        if (pun_strlen($username) < 2)
172                $alerts[] = $lang_install['Username 1'];
173        else if (pun_strlen($username) > 25) // This usually doesn't happen since the form element only accepts 25 characters
174                $alerts[] = $lang_install['Username 2'];
175        else if (!strcasecmp($username, 'Guest'))
176                $alerts[] = $lang_install['Username 3'];
177        else if (preg_match('%[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}%', $username) || preg_match('%((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))%', $username))
178                $alerts[] = $lang_install['Username 4'];
179        else if ((strpos($username, '[') !== false || strpos($username, ']') !== false) && strpos($username, '\'') !== false && strpos($username, '"') !== false)
180                $alerts[] = $lang_install['Username 5'];
181        else if (preg_match('%(?:\[/?(?:b|u|i|h|colou?r|quote|code|img|url|email|list)\]|\[(?:code|quote|list)=)%i', $username))
182                $alerts[] = $lang_install['Username 6'];
183
184        if (pun_strlen($password1) < 4)
185                $alerts[] = $lang_install['Short password'];
186        else if ($password1 != $password2)
187                $alerts[] = $lang_install['Passwords not match'];
188
189        // Validate email
190        require PUN_ROOT.'include/email.php';
191
192        if (!is_valid_email($email))
193                $alerts[] = $lang_install['Wrong email'];
194
195        if ($title == '')
196                $alerts[] = $lang_install['No board title'];
197
198        $languages = forum_list_langs();
199        if (!in_array($default_lang, $languages))
200                $alerts[] = $lang_install['Error default language'];
201
202        $styles = forum_list_styles();
203        if (!in_array($default_style, $styles))
204                $alerts[] = $lang_install['Error default style'];
205}
206
207// Check if the cache directory is writable
208if (!@is_writable(FORUM_CACHE_DIR))
209        $alerts[] = sprintf($lang_install['Alert cache'], FORUM_CACHE_DIR);
210
211// Check if default avatar directory is writable
212if (!@is_writable(PUN_ROOT.'img/avatars/'))
213        $alerts[] = sprintf($lang_install['Alert avatar'], PUN_ROOT.'img/avatars/');
214
215if (!isset($_POST['form_sent']) || !empty($alerts))
216{
217        // Determine available database extensions
218        $dual_mysql = false;
219        $db_extensions = array();
220        $mysql_innodb = false;
221        if (function_exists('mysqli_connect'))
222        {
223                $db_extensions[] = array('mysqli', 'MySQL Improved');
224                $db_extensions[] = array('mysqli_innodb', 'MySQL Improved (InnoDB)');
225                $mysql_innodb = true;
226        }
227        if (function_exists('mysql_connect'))
228        {
229                $db_extensions[] = array('mysql', 'MySQL Standard');
230                $db_extensions[] = array('mysql_innodb', 'MySQL Standard (InnoDB)');
231                $mysql_innodb = true;
232
233                if (count($db_extensions) > 2)
234                        $dual_mysql = true;
235        }
236        if (function_exists('sqlite_open'))
237                $db_extensions[] = array('sqlite', 'SQLite');
238        if (function_exists('pg_connect'))
239                $db_extensions[] = array('pgsql', 'PostgreSQL');
240
241        if (empty($db_extensions))
242                error($lang_install['No DB extensions']);
243
244        // Fetch a list of installed languages
245        $languages = forum_list_langs();
246
247?>
248<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
249<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
250<head>
251<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
252<title><?php echo $lang_install['FluxBB Installation'] ?></title>
253<link rel="stylesheet" type="text/css" href="style/<?php echo $default_style ?>.css" />
254<script type="text/javascript">
255/* <![CDATA[ */
256function process_form(the_form)
257{
258        var element_names = {
259                "req_db_type": "<?php echo $lang_install['Database type'] ?>",
260                "req_db_host": "<?php echo $lang_install['Database server hostname'] ?>",
261                "req_db_name": "<?php echo $lang_install['Database name'] ?>",
262                "db_prefix": "<?php echo $lang_install['Table prefix'] ?>",
263                "req_username": "<?php echo $lang_install['Administrator username'] ?>",
264                "req_password1": "<?php echo $lang_install['Administrator password 1'] ?>",
265                "req_password2": "<?php echo $lang_install['Administrator password 2'] ?>",
266                "req_email": "<?php echo $lang_install['Administrator email'] ?>",
267                "req_title": "<?php echo $lang_install['Board title'] ?>",
268                "req_base_url": "<?php echo $lang_install['Base URL'] ?>"
269        };
270        if (document.all || document.getElementById)
271        {
272                for (var i = 0; i < the_form.length; ++i)
273                {
274                        var elem = the_form.elements[i];
275                        if (elem.name && (/^req_/.test(elem.name)))
276                        {
277                                if (!elem.value && elem.type && (/^(?:text(?:area)?|password|file)$/i.test(elem.type)))
278                                {
279                                        alert('"' + element_names[elem.name] + '" <?php echo $lang_install['Required field'] ?>');
280                                        elem.focus();
281                                        return false;
282                                }
283                        }
284                }
285        }
286        return true;
287}
288/* ]]> */
289</script>
290</head>
291<body onload="document.getElementById('install').req_db_type.focus();document.getElementById('install').start.disabled=false;" onunload="">
292
293<div id="puninstall" class="pun">
294<div class="top-box"><div><!-- Top Corners --></div></div>
295<div class="punwrap">
296
297<div id="brdheader" class="block">
298        <div class="box">
299                <div id="brdtitle" class="inbox">
300                        <h1><span><?php echo $lang_install['FluxBB Installation'] ?></span></h1>
301                        <div id="brddesc"><p><?php echo $lang_install['Install message'] ?></p><p><?php echo $lang_install['Welcome'] ?></p></div>
302                </div>
303        </div>
304</div>
305
306<div id="brdmain">
307<?php if (count($languages) > 1): ?><div class="blockform">
308        <h2><span><?php echo $lang_install['Choose install language'] ?></span></h2>
309        <div class="box">
310                <form id="install" method="post" action="install.php">
311                        <div class="inform">
312                                <fieldset>
313                                        <legend><?php echo $lang_install['Install language'] ?></legend>
314                                        <div class="infldset">
315                                                <p><?php echo $lang_install['Choose install language info'] ?></p>
316                                                <label><strong><?php echo $lang_install['Install language'] ?></strong>
317                                                <br /><select name="install_lang">
318<?php
319
320                foreach ($languages as $temp)
321                {
322                        if ($temp == $install_lang)
323                                echo "\t\t\t\t\t".'<option value="'.$temp.'" selected="selected">'.$temp.'</option>'."\n";
324                        else
325                                echo "\t\t\t\t\t".'<option value="'.$temp.'">'.$temp.'</option>'."\n";
326                }
327
328?>
329                                                </select>
330                                                <br /></label>
331                                        </div>
332                                </fieldset>
333                        </div>
334                        <p class="buttons"><input type="submit" name="start" value="<?php echo $lang_install['Change language'] ?>" /></p>
335                </form>
336        </div>
337</div>
338<?php endif; ?>
339
340<div class="blockform">
341        <h2><span><?php echo $lang_install['Install'] ?></span></h2>
342        <div class="box">
343                <form id="install" method="post" action="install.php" onsubmit="this.start.disabled=true;if(process_form(this)){return true;}else{this.start.disabled=false;return false;}">
344                <div><input type="hidden" name="form_sent" value="1" /><input type="hidden" name="install_lang" value="<?php echo pun_htmlspecialchars($install_lang) ?>" /></div>
345                        <div class="inform">
346<?php if (!empty($alerts)): ?>                          <div class="forminfo error-info">
347                                        <h3><?php echo $lang_install['Errors'] ?></h3>
348                                        <ul class="error-list">
349<?php
350
351foreach ($alerts as $cur_alert)
352        echo "\t\t\t\t\t\t".'<li><strong>'.$cur_alert.'</strong></li>'."\n";
353?>
354                                        </ul>
355                                </div>
356<?php endif; ?>                 </div>
357                        <div class="inform">
358                                <div class="forminfo">
359                                        <h3><?php echo $lang_install['Database setup'] ?></h3>
360                                        <p><?php echo $lang_install['Info 1'] ?></p>
361                                </div>
362                                <fieldset>
363                                <legend><?php echo $lang_install['Select database'] ?></legend>
364                                        <div class="infldset">
365                                                <p><?php echo $lang_install['Info 2'] ?></p>
366<?php if ($dual_mysql): ?>                                              <p><?php echo $lang_install['Dual MySQL'] ?></p>
367<?php endif; ?><?php if ($mysql_innodb): ?>                                             <p><?php echo $lang_install['InnoDB'] ?></p>
368<?php endif; ?>                                         <label class="required"><strong><?php echo $lang_install['Database type'] ?> <span><?php echo $lang_install['Required'] ?></span></strong>
369                                                <br /><select name="req_db_type">
370<?php
371
372        foreach ($db_extensions as $temp)
373        {
374                if ($temp[0] == $db_type)
375                        echo "\t\t\t\t\t\t\t".'<option value="'.$temp[0].'" selected="selected">'.$temp[1].'</option>'."\n";
376                else
377                        echo "\t\t\t\t\t\t\t".'<option value="'.$temp[0].'">'.$temp[1].'</option>'."\n";
378        }
379
380?>
381                                                </select>
382                                                <br /></label>
383                                        </div>
384                                </fieldset>
385                        </div>
386                        <div class="inform">
387                                <fieldset>
388                                        <legend><?php echo $lang_install['Database hostname'] ?></legend>
389                                        <div class="infldset">
390                                                <p><?php echo $lang_install['Info 3'] ?></p>
391                                                <label class="required"><strong><?php echo $lang_install['Database server hostname'] ?> <span><?php echo $lang_install['Required'] ?></span></strong><br /><input type="text" name="req_db_host" value="<?php echo pun_htmlspecialchars($db_host) ?>" size="50" /><br /></label>
392                                        </div>
393                                </fieldset>
394                        </div>
395                        <div class="inform">
396                                <fieldset>
397                                        <legend><?php echo $lang_install['Database enter name'] ?></legend>
398                                        <div class="infldset">
399                                                <p><?php echo $lang_install['Info 4'] ?></p>
400                                                <label class="required"><strong><?php echo $lang_install['Database name'] ?> <span><?php echo $lang_install['Required'] ?></span></strong><br /><input id="req_db_name" type="text" name="req_db_name" value="<?php echo pun_htmlspecialchars($db_name) ?>" size="30" /><br /></label>
401                                        </div>
402                                </fieldset>
403                        </div>
404                        <div class="inform">
405                                <fieldset>
406                                        <legend><?php echo $lang_install['Database enter informations'] ?></legend>
407                                        <div class="infldset">
408                                                <p><?php echo $lang_install['Info 5'] ?></p>
409                                                <label class="conl"><?php echo $lang_install['Database username'] ?><br /><input type="text" name="db_username" value="<?php echo pun_htmlspecialchars($db_username) ?>" size="30" /><br /></label>
410                                                <label class="conl"><?php echo $lang_install['Database password'] ?><br /><input type="password" name="db_password" size="30" /><br /></label>
411                                                <div class="clearer"></div>
412                                        </div>
413                                </fieldset>
414                        </div>
415                        <div class="inform">
416                                <fieldset>
417                                        <legend><?php echo $lang_install['Database enter prefix'] ?></legend>
418                                        <div class="infldset">
419                                                <p><?php echo $lang_install['Info 6'] ?></p>
420                                                <label><?php echo $lang_install['Table prefix'] ?><br /><input id="db_prefix" type="text" name="db_prefix" value="<?php echo pun_htmlspecialchars($db_prefix) ?>" size="20" maxlength="30" /><br /></label>
421                                        </div>
422                                </fieldset>
423                        </div>
424                        <div class="inform">
425                                <div class="forminfo">
426                                        <h3><?php echo $lang_install['Administration setup'] ?></h3>
427                                        <p><?php echo $lang_install['Info 7'] ?></p>
428                                </div>
429                                <fieldset>
430                                        <legend><?php echo $lang_install['Admin enter username'] ?></legend>
431                                        <div class="infldset">
432                                                <p><?php echo $lang_install['Info 8'] ?></p>
433                                                <label class="required"><strong><?php echo $lang_install['Administrator username'] ?> <span><?php echo $lang_install['Required'] ?></span></strong><br /><input type="text" name="req_username" value="<?php echo pun_htmlspecialchars($username) ?>" size="25" maxlength="25" /><br /></label>
434                                        </div>
435                                </fieldset>
436                        </div>
437                        <div class="inform">
438                                <fieldset>
439                                        <legend><?php echo $lang_install['Admin enter password'] ?></legend>
440                                        <div class="infldset">
441                                                <p><?php echo $lang_install['Info 9'] ?></p>
442                                                <label class="conl required"><strong><?php echo $lang_install['Password'] ?> <span><?php echo $lang_install['Required'] ?></span></strong><br /><input id="req_password1" type="password" name="req_password1" size="16" /><br /></label>
443                                                <label class="conl required"><strong><?php echo $lang_install['Confirm password'] ?> <span><?php echo $lang_install['Required'] ?></span></strong><br /><input type="password" name="req_password2" size="16" /><br /></label>
444                                                <div class="clearer"></div>
445                                        </div>
446                                </fieldset>
447                        </div>
448                        <div class="inform">
449                                <fieldset>
450                                        <legend><?php echo $lang_install['Admin enter email'] ?></legend>
451                                        <div class="infldset">
452                                                <p><?php echo $lang_install['Info 10'] ?></p>
453                                                <label class="required"><strong><?php echo $lang_install['Administrator email'] ?> <span><?php echo $lang_install['Required'] ?></span></strong><br /><input id="req_email" type="text" name="req_email" value="<?php echo pun_htmlspecialchars($email) ?>" size="50" maxlength="80" /><br /></label>
454                                        </div>
455                                </fieldset>
456                        </div>
457                        <div class="inform">
458                                <div class="forminfo">
459                                        <h3><?php echo $lang_install['Board setup'] ?></h3>
460                                        <p><?php echo $lang_install['Info 11'] ?></p>
461                                </div>
462                                <fieldset>
463                                        <legend><?php echo $lang_install['Enter board title'] ?></legend>
464                                        <div class="infldset">
465                                                <p><?php echo $lang_install['Info 12'] ?></p>
466                                                <label class="required"><strong><?php echo $lang_install['Board title'] ?> <span><?php echo $lang_install['Required'] ?></span></strong><br /><input id="req_title" type="text" name="req_title" value="<?php echo pun_htmlspecialchars($title) ?>" size="60" maxlength="255" /><br /></label>
467                                        </div>
468                                </fieldset>
469                        </div>
470                        <div class="inform">
471                                <fieldset>
472                                        <legend><?php echo $lang_install['Enter board description'] ?></legend>
473                                        <div class="infldset">
474                                                <p><?php echo $lang_install['Info 13'] ?></p>
475                                                <label><?php echo $lang_install['Board description'] ?><br /><input id="desc" type="text" name="desc" value="<?php echo pun_htmlspecialchars($description) ?>" size="60" maxlength="255" /><br /></label>
476                                        </div>
477                                </fieldset>
478                        </div>
479                        <div class="inform">
480                                <fieldset>
481                                        <legend><?php echo $lang_install['Enter base URL'] ?></legend>
482                                        <div class="infldset">
483                                                <p><?php echo $lang_install['Info 14'] ?></p>
484                                                <label class="required"><strong><?php echo $lang_install['Base URL'] ?> <span><?php echo $lang_install['Required'] ?></span></strong><br /><input id="req_base_url" type="text" name="req_base_url" value="<?php echo pun_htmlspecialchars($base_url) ?>" size="60" maxlength="100" /><br /></label>
485                                        </div>
486                                </fieldset>
487                        </div>
488                        <div class="inform">
489                                <fieldset>
490                                        <legend><?php echo $lang_install['Choose the default language'] ?></legend>
491                                        <div class="infldset">
492                                                <p><?php echo $lang_install['Info 15'] ?></p>
493                                                <label class="required"><strong><?php echo $lang_install['Default language'] ?> <span><?php echo $lang_install['Required'] ?></span></strong><br /><select id="req_default_lang" name="req_default_lang">
494<?php
495
496                $languages = forum_list_langs();
497                foreach ($languages as $temp)
498                {
499                        if ($temp == $default_lang)
500                                echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$temp.'" selected="selected">'.$temp.'</option>'."\n";
501                        else
502                                echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$temp.'">'.$temp.'</option>'."\n";
503                }
504
505?>
506                                                </select><br /></label>
507                                        </div>
508                                </fieldset>
509                        </div>
510                        <div class="inform">
511                                <fieldset>
512                                        <legend><?php echo $lang_install['Choose the default style'] ?></legend>
513                                        <div class="infldset">
514                                                <p><?php echo $lang_install['Info 16'] ?></p>
515                                                <label class="required"><strong><?php echo $lang_install['Default style'] ?> <span><?php echo $lang_install['Required'] ?></span></strong><br /><select id="req_default_style" name="req_default_style">
516<?php
517
518                $styles = forum_list_styles();
519                foreach ($styles as $temp)
520                {
521                        if ($temp == $default_style)
522                                echo "\t\t\t\t\t\t\t\t\t".'<option value="'.$temp.'" selected="selected">'.str_replace('_', ' ', $temp).'</option>'."\n";
523                        else
524                                echo "\t\t\t\t\t\t\t\t\t".'<option value="'.$temp.'">'.str_replace('_', ' ', $temp).'</option>'."\n";
525                }
526
527?>
528                                                </select><br /></label>
529                                        </div>
530                                </fieldset>
531                        </div>
532                        <p class="buttons"><input type="submit" name="start" value="<?php echo $lang_install['Start install'] ?>" /></p>
533                </form>
534        </div>
535</div>
536</div>
537
538</div>
539<div class="end-box"><div><!-- Bottom Corners --></div></div>
540</div>
541
542</body>
543</html>
544<?php
545
546}
547else
548{
549        // Load the appropriate DB layer class
550        switch ($db_type)
551        {
552                case 'mysql':
553                        require PUN_ROOT.'include/dblayer/mysql.php';
554                        break;
555
556                case 'mysql_innodb':
557                        require PUN_ROOT.'include/dblayer/mysql_innodb.php';
558                        break;
559
560                case 'mysqli':
561                        require PUN_ROOT.'include/dblayer/mysqli.php';
562                        break;
563
564                case 'mysqli_innodb':
565                        require PUN_ROOT.'include/dblayer/mysqli_innodb.php';
566                        break;
567
568                case 'pgsql':
569                        require PUN_ROOT.'include/dblayer/pgsql.php';
570                        break;
571
572                case 'sqlite':
573                        require PUN_ROOT.'include/dblayer/sqlite.php';
574                        break;
575
576                default:
577                        error(sprintf($lang_install['DB type not valid'], pun_htmlspecialchars($db_type)));
578        }
579
580        // Create the database object (and connect/select db)
581        $db = new DBLayer($db_host, $db_username, $db_password, $db_name, $db_prefix, false);
582
583        // Validate prefix
584        if (strlen($db_prefix) > 0 && (!preg_match('%^[a-zA-Z_][a-zA-Z0-9_]*$%', $db_prefix) || strlen($db_prefix) > 40))
585                error(sprintf($lang_install['Table prefix error'], $db->prefix));
586
587        // Do some DB type specific checks
588        switch ($db_type)
589        {
590                case 'mysql':
591                case 'mysqli':
592                case 'mysql_innodb':
593                case 'mysqli_innodb':
594                        $mysql_info = $db->get_version();
595                        if (version_compare($mysql_info['version'], MIN_MYSQL_VERSION, '<'))
596                                error(sprintf($lang_install['You are running error'], 'MySQL', $mysql_info['version'], FORUM_VERSION, MIN_MYSQL_VERSION));
597                        break;
598
599                case 'pgsql':
600                        $pgsql_info = $db->get_version();
601                        if (version_compare($pgsql_info['version'], MIN_PGSQL_VERSION, '<'))
602                                error(sprintf($lang_install['You are running error'], 'PostgreSQL', $pgsql_info['version'], FORUM_VERSION, MIN_PGSQL_VERSION));
603                        break;
604
605                case 'sqlite':
606                        if (strtolower($db_prefix) == 'sqlite_')
607                                error($lang_install['Prefix reserved']);
608                        break;
609        }
610
611
612        // Make sure FluxBB isn't already installed
613        $result = $db->query('SELECT 1 FROM '.$db_prefix.'users WHERE id=1');
614        if ($db->num_rows($result))
615                error(sprintf($lang_install['Existing table error'], $db_prefix, $db_name));
616
617        // Check if InnoDB is available
618        if ($db_type == 'mysql_innodb' || $db_type == 'mysqli_innodb')
619        {
620                $result = $db->query('SHOW VARIABLES LIKE \'have_innodb\'');
621                list (, $result) = $db->fetch_row($result);
622                if ((strtoupper($result) != 'YES'))
623                        error($lang_install['InnoDB off']);
624        }
625
626
627        // Start a transaction
628        $db->start_transaction();
629
630
631        // Create all tables
632        $schema = array(
633                'FIELDS'                => array(
634                        'id'                    => array(
635                                'datatype'              => 'SERIAL',
636                                'allow_null'    => false
637                        ),
638                        'username'              => array(
639                                'datatype'              => 'VARCHAR(200)',
640                                'allow_null'    => true
641                        ),
642                        'ip'                    => array(
643                                'datatype'              => 'VARCHAR(255)',
644                                'allow_null'    => true
645                        ),
646                        'email'                 => array(
647                                'datatype'              => 'VARCHAR(80)',
648                                'allow_null'    => true
649                        ),
650                        'message'               => array(
651                                'datatype'              => 'VARCHAR(255)',
652                                'allow_null'    => true
653                        ),
654                        'expire'                => array(
655                                'datatype'              => 'INT(10) UNSIGNED',
656                                'allow_null'    => true
657                        ),
658                        'ban_creator'   => array(
659                                'datatype'              => 'INT(10) UNSIGNED',
660                                'allow_null'    => false,
661                                'default'               => '0'
662                        )
663                ),
664                'PRIMARY KEY'   => array('id'),
665                'INDEXES'               => array(
666                        'username_idx'  => array('username')
667                )
668        );
669
670        if ($db_type == 'mysql' || $db_type == 'mysqli' || $db_type == 'mysql_innodb' || $db_type == 'mysqli_innodb')
671                $schema['INDEXES']['username_idx'] = array('username(25)');
672
673        $db->create_table('bans', $schema) or error('Unable to create bans table', __FILE__, __LINE__, $db->error());
674
675
676        $schema = array(
677                'FIELDS'                => array(
678                        'id'                    => array(
679                                'datatype'              => 'SERIAL',
680                                'allow_null'    => false
681                        ),
682                        'cat_name'              => array(
683                                'datatype'              => 'VARCHAR(80)',
684                                'allow_null'    => false,
685                                'default'               => '\'New Category\''
686                        ),
687                        'disp_position' => array(
688                                'datatype'              => 'INT(10)',
689                                'allow_null'    => false,
690                                'default'               => '0'
691                        )
692                ),
693                'PRIMARY KEY'   => array('id')
694        );
695
696        $db->create_table('categories', $schema) or error('Unable to create categories table', __FILE__, __LINE__, $db->error());
697
698
699        $schema = array(
700                'FIELDS'                => array(
701                        'id'                    => array(
702                                'datatype'              => 'SERIAL',
703                                'allow_null'    => false
704                        ),
705                        'search_for'    => array(
706                                'datatype'              => 'VARCHAR(60)',
707                                'allow_null'    => false,
708                                'default'               => '\'\''
709                        ),
710                        'replace_with'  => array(
711                                'datatype'              => 'VARCHAR(60)',
712                                'allow_null'    => false,
713                                'default'               => '\'\''
714                        )
715                ),
716                'PRIMARY KEY'   => array('id')
717        );
718
719        $db->create_table('censoring', $schema) or error('Unable to create censoring table', __FILE__, __LINE__, $db->error());
720
721
722        $schema = array(
723                'FIELDS'                => array(
724                        'conf_name'             => array(
725                                'datatype'              => 'VARCHAR(255)',
726                                'allow_null'    => false,
727                                'default'               => '\'\''
728                        ),
729                        'conf_value'    => array(
730                                'datatype'              => 'TEXT',
731                                'allow_null'    => true
732                        )
733                ),
734                'PRIMARY KEY'   => array('conf_name')
735        );
736
737        $db->create_table('config', $schema) or error('Unable to create config table', __FILE__, __LINE__, $db->error());
738
739
740        $schema = array(
741                'FIELDS'                => array(
742                        'group_id'              => array(
743                                'datatype'              => 'INT(10)',
744                                'allow_null'    => false,
745                                'default'               => '0'
746                        ),
747                        'forum_id'              => array(
748                                'datatype'              => 'INT(10)',
749                                'allow_null'    => false,
750                                'default'               => '0'
751                        ),
752                        'read_forum'    => array(
753                                'datatype'              => 'TINYINT(1)',
754                                'allow_null'    => false,
755                                'default'               => '1'
756                        ),
757                        'post_replies'  => array(
758                                'datatype'              => 'TINYINT(1)',
759                                'allow_null'    => false,
760                                'default'               => '1'
761                        ),
762                        'post_topics'   => array(
763                                'datatype'              => 'TINYINT(1)',
764                                'allow_null'    => false,
765                                'default'               => '1'
766                        )
767                ),
768                'PRIMARY KEY'   => array('group_id', 'forum_id')
769        );
770
771        $db->create_table('forum_perms', $schema) or error('Unable to create forum_perms table', __FILE__, __LINE__, $db->error());
772
773
774        $schema = array(
775                'FIELDS'                => array(
776                        'id'                    => array(
777                                'datatype'              => 'SERIAL',
778                                'allow_null'    => false
779                        ),
780                        'forum_name'    => array(
781                                'datatype'              => 'VARCHAR(80)',
782                                'allow_null'    => false,
783                                'default'               => '\'New forum\''
784                        ),
785                        'forum_desc'    => array(
786                                'datatype'              => 'TEXT',
787                                'allow_null'    => true
788                        ),
789                        'redirect_url'  => array(
790                                'datatype'              => 'VARCHAR(100)',
791                                'allow_null'    => true
792                        ),
793                        'moderators'    => array(
794                                'datatype'              => 'TEXT',
795                                'allow_null'    => true
796                        ),
797                        'num_topics'    => array(
798                                'datatype'              => 'MEDIUMINT(8) UNSIGNED',
799                                'allow_null'    => false,
800                                'default'               => '0'
801                        ),
802                        'num_posts'             => array(
803                                'datatype'              => 'MEDIUMINT(8) UNSIGNED',
804                                'allow_null'    => false,
805                                'default'               => '0'
806                        ),
807                        'last_post'             => array(
808                                'datatype'              => 'INT(10) UNSIGNED',
809                                'allow_null'    => true
810                        ),
811                        'last_post_id'  => array(
812                                'datatype'              => 'INT(10) UNSIGNED',
813                                'allow_null'    => true
814                        ),
815                        'last_poster'   => array(
816                                'datatype'              => 'VARCHAR(200)',
817                                'allow_null'    => true
818                        ),
819                        'sort_by'               => array(
820                                'datatype'              => 'TINYINT(1)',
821                                'allow_null'    => false,
822                                'default'               => '0'
823                        ),
824                        'disp_position' => array(
825                                'datatype'              => 'INT(10)',
826                                'allow_null'    => false,
827                                'default'               =>      '0'
828                        ),
829                        'cat_id'                => array(
830                                'datatype'              => 'INT(10) UNSIGNED',
831                                'allow_null'    => false,
832                                'default'               =>      '0'
833                        )
834                ),
835                'PRIMARY KEY'   => array('id')
836        );
837
838        $db->create_table('forums', $schema) or error('Unable to create forums table', __FILE__, __LINE__, $db->error());
839
840
841        $schema = array(
842                'FIELDS'                => array(
843                        'g_id'                                          => array(
844                                'datatype'              => 'SERIAL',
845                                'allow_null'    => false
846                        ),
847                        'g_title'                                       => array(
848                                'datatype'              => 'VARCHAR(50)',
849                                'allow_null'    => false,
850                                'default'               => '\'\''
851                        ),
852                        'g_user_title'                          => array(
853                                'datatype'              => 'VARCHAR(50)',
854                                'allow_null'    => true
855                        ),
856                        'g_moderator'                           => array(
857                                'datatype'              => 'TINYINT(1)',
858                                'allow_null'    => false,
859                                'default'               => '0'
860                        ),
861                        'g_mod_edit_users'                      => array(
862                                'datatype'              => 'TINYINT(1)',
863                                'allow_null'    => false,
864                                'default'               => '0'
865                        ),
866                        'g_mod_rename_users'            => array(
867                                'datatype'              => 'TINYINT(1)',
868                                'allow_null'    => false,
869                                'default'               => '0'
870                        ),
871                        'g_mod_change_passwords'        => array(
872                                'datatype'              => 'TINYINT(1)',
873                                'allow_null'    => false,
874                                'default'               => '0'
875                        ),
876                        'g_mod_ban_users'                       => array(
877                                'datatype'              => 'TINYINT(1)',
878                                'allow_null'    => false,
879                                'default'               => '0'
880                        ),
881                        'g_read_board'                          => array(
882                                'datatype'              => 'TINYINT(1)',
883                                'allow_null'    => false,
884                                'default'               => '1'
885                        ),
886                        'g_view_users'                          => array(
887                                'datatype'              => 'TINYINT(1)',
888                                'allow_null'    => false,
889                                'default'               => '1'
890                        ),
891                        'g_post_replies'                        => array(
892                                'datatype'              => 'TINYINT(1)',
893                                'allow_null'    => false,
894                                'default'               => '1'
895                        ),
896                        'g_post_topics'                         => array(
897                                'datatype'              => 'TINYINT(1)',
898                                'allow_null'    => false,
899                                'default'               => '1'
900                        ),
901                        'g_edit_posts'                          => array(
902                                'datatype'              => 'TINYINT(1)',
903                                'allow_null'    => false,
904                                'default'               => '1'
905                        ),
906                        'g_delete_posts'                        => array(
907                                'datatype'              => 'TINYINT(1)',
908                                'allow_null'    => false,
909                                'default'               => '1'
910                        ),
911                        'g_delete_topics'                       => array(
912                                'datatype'              => 'TINYINT(1)',
913                                'allow_null'    => false,
914                                'default'               => '1'
915                        ),
916                        'g_set_title'                           => array(
917                                'datatype'              => 'TINYINT(1)',
918                                'allow_null'    => false,
919                                'default'               => '1'
920                        ),
921                        'g_search'                                      => array(
922                                'datatype'              => 'TINYINT(1)',
923                                'allow_null'    => false,
924                                'default'               => '1'
925                        ),
926                        'g_search_users'                        => array(
927                                'datatype'              => 'TINYINT(1)',
928                                'allow_null'    => false,
929                                'default'               => '1'
930                        ),
931                        'g_send_email'                          => array(
932                                'datatype'              => 'TINYINT(1)',
933                                'allow_null'    => false,
934                                'default'               => '1'
935                        ),
936                        'g_post_flood'                          => array(
937                                'datatype'              => 'SMALLINT(6)',
938                                'allow_null'    => false,
939                                'default'               => '30'
940                        ),
941                        'g_search_flood'                        => array(
942                                'datatype'              => 'SMALLINT(6)',
943                                'allow_null'    => false,
944                                'default'               => '30'
945                        ),
946                        'g_email_flood'                         => array(
947                                'datatype'              => 'SMALLINT(6)',
948                                'allow_null'    => false,
949                                'default'               => '60'
950                        ),
951                        'g_report_flood'                        => array(
952                                'datatype'              => 'SMALLINT(6)',
953                                'allow_null'    => false,
954                                'default'               => '60'
955                        )
956                ),
957                'PRIMARY KEY'   => array('g_id')
958        );
959
960        $db->create_table('groups', $schema) or error('Unable to create groups table', __FILE__, __LINE__, $db->error());
961
962
963        $schema = array(
964                'FIELDS'                => array(
965                        'user_id'               => array(
966                                'datatype'              => 'INT(10) UNSIGNED',
967                                'allow_null'    => false,
968                                'default'               => '1'
969                        ),
970                        'ident'                 => array(
971                                'datatype'              => 'VARCHAR(200)',
972                                'allow_null'    => false,
973                                'default'               => '\'\''
974                        ),
975                        'logged'                => array(
976                                'datatype'              => 'INT(10) UNSIGNED',
977                                'allow_null'    => false,
978                                'default'               => '0'
979                        ),
980                        'idle'                  => array(
981                                'datatype'              => 'TINYINT(1)',
982                                'allow_null'    => false,
983                                'default'               => '0'
984                        ),
985                        'last_post'                     => array(
986                                'datatype'              => 'INT(10) UNSIGNED',
987                                'allow_null'    => true
988                        ),
989                        'last_search'           => array(
990                                'datatype'              => 'INT(10) UNSIGNED',
991                                'allow_null'    => true
992                        ),
993                ),
994                'UNIQUE KEYS'   => array(
995                        'user_id_ident_idx'     => array('user_id', 'ident')
996                ),
997                'INDEXES'               => array(
998                        'ident_idx'             => array('ident'),
999                        'logged_idx'    => array('logged')
1000                )
1001        );
1002
1003        if ($db_type == 'mysql' || $db_type == 'mysqli' || $db_type == 'mysql_innodb' || $db_type == 'mysqli_innodb')
1004        {
1005                $schema['UNIQUE KEYS']['user_id_ident_idx'] = array('user_id', 'ident(25)');
1006                $schema['INDEXES']['ident_idx'] = array('ident(25)');
1007        }
1008
1009        if ($db_type == 'mysql_innodb' || $db_type == 'mysqli_innodb')
1010                $schema['ENGINE'] = 'InnoDB';
1011
1012        $db->create_table('online', $schema) or error('Unable to create online table', __FILE__, __LINE__, $db->error());
1013
1014
1015        $schema = array(
1016                'FIELDS'                => array(
1017                        'id'                    => array(
1018                                'datatype'              => 'SERIAL',
1019                                'allow_null'    => false
1020                        ),
1021                        'poster'                => array(
1022                                'datatype'              => 'VARCHAR(200)',
1023                                'allow_null'    => false,
1024                                'default'               => '\'\''
1025                        ),
1026                        'poster_id'             => array(
1027                                'datatype'              => 'INT(10) UNSIGNED',
1028                                'allow_null'    => false,
1029                                'default'               => '1'
1030                        ),
1031                        'poster_ip'             => array(
1032                                'datatype'              => 'VARCHAR(39)',
1033                                'allow_null'    => true
1034                        ),
1035                        'poster_email'  => array(
1036                                'datatype'              => 'VARCHAR(80)',
1037                                'allow_null'    => true
1038                        ),
1039                        'message'               => array(
1040                                'datatype'              => 'MEDIUMTEXT',
1041                                'allow_null'    => true
1042                        ),
1043                        'hide_smilies'  => array(
1044                                'datatype'              => 'TINYINT(1)',
1045                                'allow_null'    => false,
1046                                'default'               => '0'
1047                        ),
1048                        'posted'                => array(
1049                                'datatype'              => 'INT(10) UNSIGNED',
1050                                'allow_null'    => false,
1051                                'default'               => '0'
1052                        ),
1053                        'edited'                => array(
1054                                'datatype'              => 'INT(10) UNSIGNED',
1055                                'allow_null'    => true
1056                        ),
1057                        'edited_by'             => array(
1058                                'datatype'              => 'VARCHAR(200)',
1059                                'allow_null'    => true
1060                        ),
1061                        'topic_id'              => array(
1062                                'datatype'              => 'INT(10) UNSIGNED',
1063                                'allow_null'    => false,
1064                                'default'               => '0'
1065                        )
1066                ),
1067                'PRIMARY KEY'   => array('id'),
1068                'INDEXES'               => array(
1069                        'topic_id_idx'  => array('topic_id'),
1070                        'multi_idx'             => array('poster_id', 'topic_id')
1071                )
1072        );
1073
1074        $db->create_table('posts', $schema) or error('Unable to create posts table', __FILE__, __LINE__, $db->error());
1075
1076
1077        $schema = array(
1078                'FIELDS'                => array(
1079                        'id'                    => array(
1080                                'datatype'              => 'SERIAL',
1081                                'allow_null'    => false
1082                        ),
1083                        'rank'                  => array(
1084                                'datatype'              => 'VARCHAR(50)',
1085                                'allow_null'    => false,
1086                                'default'               => '\'\''
1087                        ),
1088                        'min_posts'             => array(
1089                                'datatype'              => 'MEDIUMINT(8) UNSIGNED',
1090                                'allow_null'    => false,
1091                                'default'               => '0'
1092                        )
1093                ),
1094                'PRIMARY KEY'   => array('id')
1095        );
1096
1097        $db->create_table('ranks', $schema) or error('Unable to create ranks table', __FILE__, __LINE__, $db->error());
1098
1099
1100        $schema = array(
1101                'FIELDS'                => array(
1102                        'id'                    => array(
1103                                'datatype'              => 'SERIAL',
1104                                'allow_null'    => false
1105                        ),
1106                        'post_id'               => array(
1107                                'datatype'              => 'INT(10) UNSIGNED',
1108                                'allow_null'    => false,
1109                                'default'               => '0'
1110                        ),
1111                        'topic_id'              => array(
1112                                'datatype'              => 'INT(10) UNSIGNED',
1113                                'allow_null'    => false,
1114                                'default'               => '0'
1115                        ),
1116                        'forum_id'              => array(
1117                                'datatype'              => 'INT(10) UNSIGNED',
1118                                'allow_null'    => false,
1119                                'default'               => '0'
1120                        ),
1121                        'reported_by'   => array(
1122                                'datatype'              => 'INT(10) UNSIGNED',
1123                                'allow_null'    => false,
1124                                'default'               => '0'
1125                        ),
1126                        'created'               => array(
1127                                'datatype'              => 'INT(10) UNSIGNED',
1128                                'allow_null'    => false,
1129                                'default'               => '0'
1130                        ),
1131                        'message'               => array(
1132                                'datatype'              => 'TEXT',
1133                                'allow_null'    => true
1134                        ),
1135                        'zapped'                => array(
1136                                'datatype'              => 'INT(10) UNSIGNED',
1137                                'allow_null'    => true
1138                        ),
1139                        'zapped_by'             => array(
1140                                'datatype'              => 'INT(10) UNSIGNED',
1141                                'allow_null'    => true
1142                        )
1143                ),
1144                'PRIMARY KEY'   => array('id'),
1145                'INDEXES'               => array(
1146                        'zapped_idx'    => array('zapped')
1147                )
1148        );
1149
1150        $db->create_table('reports', $schema) or error('Unable to create reports table', __FILE__, __LINE__, $db->error());
1151
1152
1153        $schema = array(
1154                'FIELDS'                => array(
1155                        'id'                    => array(
1156                                'datatype'              => 'INT(10) UNSIGNED',
1157                                'allow_null'    => false,
1158                                'default'               => '0'
1159                        ),
1160                        'ident'                 => array(
1161                                'datatype'              => 'VARCHAR(200)',
1162                                'allow_null'    => false,
1163                                'default'               => '\'\''
1164                        ),
1165                        'search_data'   => array(
1166                                'datatype'              => 'MEDIUMTEXT',
1167                                'allow_null'    => true
1168                        )
1169                ),
1170                'PRIMARY KEY'   => array('id'),
1171                'INDEXES'               => array(
1172                        'ident_idx'     => array('ident')
1173                )
1174        );
1175
1176        if ($db_type == 'mysql' || $db_type == 'mysqli' || $db_type == 'mysql_innodb' || $db_type == 'mysqli_innodb')
1177                $schema['INDEXES']['ident_idx'] = array('ident(8)');
1178
1179        $db->create_table('search_cache', $schema) or error('Unable to create search_cache table', __FILE__, __LINE__, $db->error());
1180
1181
1182        $schema = array(
1183                'FIELDS'                => array(
1184                        'post_id'               => array(
1185                                'datatype'              => 'INT(10) UNSIGNED',
1186                                'allow_null'    => false,
1187                                'default'               => '0'
1188                        ),
1189                        'word_id'               => array(
1190                                'datatype'              => 'INT(10) UNSIGNED',
1191                                'allow_null'    => false,
1192                                'default'               => '0'
1193                        ),
1194                        'subject_match' => array(
1195                                'datatype'              => 'TINYINT(1)',
1196                                'allow_null'    => false,
1197                                'default'               => '0'
1198                        )
1199                ),
1200                'INDEXES'               => array(
1201                        'word_id_idx'   => array('word_id'),
1202                        'post_id_idx'   => array('post_id')
1203                )
1204        );
1205
1206        $db->create_table('search_matches', $schema) or error('Unable to create search_matches table', __FILE__, __LINE__, $db->error());
1207
1208
1209        $schema = array(
1210                'FIELDS'                => array(
1211                        'id'                    => array(
1212                                'datatype'              => 'SERIAL',
1213                                'allow_null'    => false
1214                        ),
1215                        'word'                  => array(
1216                                'datatype'              => 'VARCHAR(20)',
1217                                'allow_null'    => false,
1218                                'default'               => '\'\'',
1219                                'collation'             => 'bin'
1220                        )
1221                ),
1222                'PRIMARY KEY'   => array('word'),
1223                'INDEXES'               => array(
1224                        'id_idx'        => array('id')
1225                )
1226        );
1227
1228        if ($db_type == 'sqlite')
1229        {
1230                $schema['PRIMARY KEY'] = array('id');
1231                $schema['UNIQUE KEYS'] = array('word_idx'       => array('word'));
1232        }
1233
1234        $db->create_table('search_words', $schema) or error('Unable to create search_words table', __FILE__, __LINE__, $db->error());
1235
1236
1237        $schema = array(
1238                'FIELDS'                => array(
1239                        'user_id'               => array(
1240                                'datatype'              => 'INT(10) UNSIGNED',
1241                                'allow_null'    => false,
1242                                'default'               => '0'
1243                        ),
1244                        'topic_id'              => array(
1245                                'datatype'              => 'INT(10) UNSIGNED',
1246                                'allow_null'    => false,
1247                                'default'               => '0'
1248                        )
1249                ),
1250                'PRIMARY KEY'   => array('user_id', 'topic_id')
1251        );
1252
1253        $db->create_table('topic_subscriptions', $schema) or error('Unable to create topic subscriptions table', __FILE__, __LINE__, $db->error());
1254
1255
1256        $schema = array(
1257                'FIELDS'                => array(
1258                        'user_id'               => array(
1259                                'datatype'              => 'INT(10) UNSIGNED',
1260                                'allow_null'    => false,
1261                                'default'               => '0'
1262                        ),
1263                        'forum_id'              => array(
1264                                'datatype'              => 'INT(10) UNSIGNED',
1265                                'allow_null'    => false,
1266                                'default'               => '0'
1267                        )
1268                ),
1269                'PRIMARY KEY'   => array('user_id', 'forum_id')
1270        );
1271
1272        $db->create_table('forum_subscriptions', $schema) or error('Unable to create forum subscriptions table', __FILE__, __LINE__, $db->error());
1273
1274
1275        $schema = array(
1276                'FIELDS'                => array(
1277                        'id'                    => array(
1278                                'datatype'              => 'SERIAL',
1279                                'allow_null'    => false
1280                        ),
1281                        'poster'                => array(
1282                                'datatype'              => 'VARCHAR(200)',
1283                                'allow_null'    => false,
1284                                'default'               => '\'\''
1285                        ),
1286                        'subject'               => array(
1287                                'datatype'              => 'VARCHAR(255)',
1288                                'allow_null'    => false,
1289                                'default'               => '\'\''
1290                        ),
1291                        'posted'                => array(
1292                                'datatype'              => 'INT(10) UNSIGNED',
1293                                'allow_null'    => false,
1294                                'default'               => '0'
1295                        ),
1296                        'first_post_id' => array(
1297                                'datatype'              => 'INT(10) UNSIGNED',
1298                                'allow_null'    => false,
1299                                'default'               => '0'
1300                        ),
1301                        'last_post'             => array(
1302                                'datatype'              => 'INT(10) UNSIGNED',
1303                                'allow_null'    => false,
1304                                'default'               => '0'
1305                        ),
1306                        'last_post_id'  => array(
1307                                'datatype'              => 'INT(10) UNSIGNED',
1308                                'allow_null'    => false,
1309                                'default'               => '0'
1310                        ),
1311                        'last_poster'   => array(
1312                                'datatype'              => 'VARCHAR(200)',
1313                                'allow_null'    => true
1314                        ),
1315                        'num_views'             => array(
1316                                'datatype'              => 'MEDIUMINT(8) UNSIGNED',
1317                                'allow_null'    => false,
1318                                'default'               => '0'
1319                        ),
1320                        'num_replies'   => array(
1321                                'datatype'              => 'MEDIUMINT(8) UNSIGNED',
1322                                'allow_null'    => false,
1323                                'default'               => '0'
1324                        ),
1325                        'closed'                => array(
1326                                'datatype'              => 'TINYINT(1)',
1327                                'allow_null'    => false,
1328                                'default'               => '0'
1329                        ),
1330                        'sticky'                => array(
1331                                'datatype'              => 'TINYINT(1)',
1332                                'allow_null'    => false,
1333                                'default'               => '0'
1334                        ),
1335                        'moved_to'              => array(
1336                                'datatype'              => 'INT(10) UNSIGNED',
1337                                'allow_null'    => true
1338                        ),
1339                        'forum_id'              => array(
1340                                'datatype'              => 'INT(10) UNSIGNED',
1341                                'allow_null'    => false,
1342                                'default'               => '0'
1343                        )
1344                ),
1345                'PRIMARY KEY'   => array('id'),
1346                'INDEXES'               => array(
1347                        'forum_id_idx'          => array('forum_id'),
1348                        'moved_to_idx'          => array('moved_to'),
1349                        'last_post_idx'         => array('last_post'),
1350                        'first_post_id_idx'     => array('first_post_id')
1351                )
1352        );
1353
1354        $db->create_table('topics', $schema) or error('Unable to create topics table', __FILE__, __LINE__, $db->error());
1355
1356
1357        $schema = array(
1358                'FIELDS'                => array(
1359                        'id'                            => array(
1360                                'datatype'              => 'SERIAL',
1361                                'allow_null'    => false
1362                        ),
1363                        'group_id'                      => array(
1364                                'datatype'              => 'INT(10) UNSIGNED',
1365                                'allow_null'    => false,
1366                                'default'               => '3'
1367                        ),
1368                        'username'                      => array(
1369                                'datatype'              => 'VARCHAR(200)',
1370                                'allow_null'    => false,
1371                                'default'               => '\'\''
1372                        ),
1373                        'password'                      => array(
1374                                'datatype'              => 'VARCHAR(40)',
1375                                'allow_null'    => false,
1376                                'default'               => '\'\''
1377                        ),
1378                        'email'                         => array(
1379                                'datatype'              => 'VARCHAR(80)',
1380                                'allow_null'    => false,
1381                                'default'               => '\'\''
1382                        ),
1383                        'title'                         => array(
1384                                'datatype'              => 'VARCHAR(50)',
1385                                'allow_null'    => true
1386                        ),
1387                        'realname'                      => array(
1388                                'datatype'              => 'VARCHAR(40)',
1389                                'allow_null'    => true
1390                        ),
1391                        'url'                           => array(
1392                                'datatype'              => 'VARCHAR(100)',
1393                                'allow_null'    => true
1394                        ),
1395                        'jabber'                        => array(
1396                                'datatype'              => 'VARCHAR(80)',
1397                                'allow_null'    => true
1398                        ),
1399                        'icq'                           => array(
1400                                'datatype'              => 'VARCHAR(12)',
1401                                'allow_null'    => true
1402                        ),
1403                        'msn'                           => array(
1404                                'datatype'              => 'VARCHAR(80)',
1405                                'allow_null'    => true
1406                        ),
1407                        'aim'                           => array(
1408                                'datatype'              => 'VARCHAR(30)',
1409                                'allow_null'    => true
1410                        ),
1411                        'yahoo'                         => array(
1412                                'datatype'              => 'VARCHAR(30)',
1413                                'allow_null'    => true
1414                        ),
1415                        'location'                      => array(
1416                                'datatype'              => 'VARCHAR(30)',
1417                                'allow_null'    => true
1418                        ),
1419                        'signature'                     => array(
1420                                'datatype'              => 'TEXT',
1421                                'allow_null'    => true
1422                        ),
1423                        'disp_topics'           => array(
1424                                'datatype'              => 'TINYINT(3) UNSIGNED',
1425                                'allow_null'    => true
1426                        ),
1427                        'disp_posts'            => array(
1428                                'datatype'              => 'TINYINT(3) UNSIGNED',
1429                                'allow_null'    => true
1430                        ),
1431                        'email_setting'         => array(
1432                                'datatype'              => 'TINYINT(1)',
1433                                'allow_null'    => false,
1434                                'default'               => '1'
1435                        ),
1436                        'notify_with_post'      => array(
1437                                'datatype'              => 'TINYINT(1)',
1438                                'allow_null'    => false,
1439                                'default'               => '0'
1440                        ),
1441                        'auto_notify'           => array(
1442                                'datatype'              => 'TINYINT(1)',
1443                                'allow_null'    => false,
1444                                'default'               => '0'
1445                        ),
1446                        'show_smilies'          => array(
1447                                'datatype'              => 'TINYINT(1)',
1448                                'allow_null'    => false,
1449                                'default'               => '1'
1450                        ),
1451                        'show_img'                      => array(
1452                                'datatype'              => 'TINYINT(1)',
1453                                'allow_null'    => false,
1454                                'default'               => '1'
1455                        ),
1456                        'show_img_sig'          => array(
1457                                'datatype'              => 'TINYINT(1)',
1458                                'allow_null'    => false,
1459                                'default'               => '1'
1460                        ),
1461                        'show_avatars'          => array(
1462                                'datatype'              => 'TINYINT(1)',
1463                                'allow_null'    => false,
1464                                'default'               => '1'
1465                        ),
1466                        'show_sig'                      => array(
1467                                'datatype'              => 'TINYINT(1)',
1468                                'allow_null'    => false,
1469                                'default'               => '1'
1470                        ),
1471                        'timezone'                      => array(
1472                                'datatype'              => 'FLOAT',
1473                                'allow_null'    => false,
1474                                'default'               => '0'
1475                        ),
1476                        'dst'                           => array(
1477                                'datatype'              => 'TINYINT(1)',
1478                                'allow_null'    => false,
1479                                'default'               => '0'
1480                        ),
1481                        'time_format'           => array(
1482                                'datatype'              => 'TINYINT(1)',
1483                                'allow_null'    => false,
1484                                'default'               => '0'
1485                        ),
1486                        'date_format'           => array(
1487                                'datatype'              => 'TINYINT(1)',
1488                                'allow_null'    => false,
1489                                'default'               => '0'
1490                        ),
1491                        'language'                      => array(
1492                                'datatype'              => 'VARCHAR(25)',
1493                                'allow_null'    => false,
1494                                'default'               => '\''.$db->escape($default_lang).'\''
1495                        ),
1496                        'style'                         => array(
1497                                'datatype'              => 'VARCHAR(25)',
1498                                'allow_null'    => false,
1499                                'default'               => '\''.$db->escape($default_style).'\''
1500                        ),
1501                        'num_posts'                     => array(
1502                                'datatype'              => 'INT(10) UNSIGNED',
1503                                'allow_null'    => false,
1504                                'default'               => '0'
1505                        ),
1506                        'last_post'                     => array(
1507                                'datatype'              => 'INT(10) UNSIGNED',
1508                                'allow_null'    => true
1509                        ),
1510                        'last_search'           => array(
1511                                'datatype'              => 'INT(10) UNSIGNED',
1512                                'allow_null'    => true
1513                        ),
1514                        'last_email_sent'       => array(
1515                                'datatype'              => 'INT(10) UNSIGNED',
1516                                'allow_null'    => true
1517                        ),
1518                        'last_report_sent'      => array(
1519                                'datatype'              => 'INT(10) UNSIGNED',
1520                                'allow_null'    => true
1521                        ),
1522                        'registered'            => array(
1523                                'datatype'              => 'INT(10) UNSIGNED',
1524                                'allow_null'    => false,
1525                                'default'               => '0'
1526                        ),
1527                        'registration_ip'       => array(
1528                                'datatype'              => 'VARCHAR(39)',
1529                                'allow_null'    => false,
1530                                'default'               => '\'0.0.0.0\''
1531                        ),
1532                        'last_visit'            => array(
1533                                'datatype'              => 'INT(10) UNSIGNED',
1534                                'allow_null'    => false,
1535                                'default'               => '0'
1536                        ),
1537                        'admin_note'            => array(
1538                                'datatype'              => 'VARCHAR(30)',
1539                                'allow_null'    => true
1540                        ),
1541                        'activate_string'       => array(
1542                                'datatype'              => 'VARCHAR(80)',
1543                                'allow_null'    => true
1544                        ),
1545                        'activate_key'          => array(
1546                                'datatype'              => 'VARCHAR(8)',
1547                                'allow_null'    => true
1548                        ),
1549                ),
1550                'PRIMARY KEY'   => array('id'),
1551                'UNIQUE KEYS'   => array(
1552                        'username_idx'          => array('username')
1553                ),
1554                'INDEXES'               => array(
1555                        'registered_idx'        => array('registered')
1556                )
1557        );
1558
1559        if ($db_type == 'mysql' || $db_type == 'mysqli' || $db_type == 'mysql_innodb' || $db_type == 'mysqli_innodb')
1560                $schema['UNIQUE KEYS']['username_idx'] = array('username(25)');
1561
1562        $db->create_table('users', $schema) or error('Unable to create users table', __FILE__, __LINE__, $db->error());
1563
1564
1565        $now = time();
1566
1567        // Insert the four preset groups
1568        $db->query('INSERT INTO '.$db->prefix.'groups ('.($db_type != 'pgsql' ? 'g_id, ' : '').'g_title, g_user_title, g_moderator, g_mod_edit_users, g_mod_rename_users, g_mod_change_passwords, g_mod_ban_users, g_read_board, g_view_users, g_post_replies, g_post_topics, g_edit_posts, g_delete_posts, g_delete_topics, g_set_title, g_search, g_search_users, g_send_email, g_post_flood, g_search_flood, g_email_flood, g_report_flood) VALUES('.($db_type != 'pgsql' ? '1, ' : '').'\''.$db->escape($lang_install['Administrators']).'\', \''.$db->escape($lang_install['Administrator']).'\', 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0)') or error('Unable to add group', __FILE__, __LINE__, $db->error());
1569
1570        $db->query('INSERT INTO '.$db->prefix.'groups ('.($db_type != 'pgsql' ? 'g_id, ' : '').'g_title, g_user_title, g_moderator, g_mod_edit_users, g_mod_rename_users, g_mod_change_passwords, g_mod_ban_users, g_read_board, g_view_users, g_post_replies, g_post_topics, g_edit_posts, g_delete_posts, g_delete_topics, g_set_title, g_search, g_search_users, g_send_email, g_post_flood, g_search_flood, g_email_flood, g_report_flood) VALUES('.($db_type != 'pgsql' ? '2, ' : '').'\''.$db->escape($lang_install['Moderators']).'\', \''.$db->escape($lang_install['Moderator']).'\', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0)') or error('Unable to add group', __FILE__, __LINE__, $db->error());
1571
1572        $db->query('INSERT INTO '.$db->prefix.'groups ('.($db_type != 'pgsql' ? 'g_id, ' : '').'g_title, g_user_title, g_moderator, g_mod_edit_users, g_mod_rename_users, g_mod_change_passwords, g_mod_ban_users, g_read_board, g_view_users, g_post_replies, g_post_topics, g_edit_posts, g_delete_posts, g_delete_topics, g_set_title, g_search, g_search_users, g_send_email, g_post_flood, g_search_flood, g_email_flood, g_report_flood) VALUES('.($db_type != 'pgsql' ? '3, ' : '').'\''.$db->escape($lang_install['Guests']).'\', NULL, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 60, 30, 0, 0)') or error('Unable to add group', __FILE__, __LINE__, $db->error());
1573
1574        $db->query('INSERT INTO '.$db->prefix.'groups ('.($db_type != 'pgsql' ? 'g_id, ' : '').'g_title, g_user_title, g_moderator, g_mod_edit_users, g_mod_rename_users, g_mod_change_passwords, g_mod_ban_users, g_read_board, g_view_users, g_post_replies, g_post_topics, g_edit_posts, g_delete_posts, g_delete_topics, g_set_title, g_search, g_search_users, g_send_email, g_post_flood, g_search_flood, g_email_flood, g_report_flood) VALUES('.($db_type != 'pgsql' ? '4, ' : '').'\''.$db->escape($lang_install['Members']).'\', NULL, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 60, 30, 60, 60)') or error('Unable to add group', __FILE__, __LINE__, $db->error());
1575
1576        // Insert guest and first admin user
1577        $db->query('INSERT INTO '.$db_prefix.'users (group_id, username, password, email) VALUES(3, \''.$db->escape($lang_install['Guest']).'\', \''.$db->escape($lang_install['Guest']).'\', \''.$db->escape($lang_install['Guest']).'\')')
1578                or error('Unable to add guest user. Please check your configuration and try again', __FILE__, __LINE__, $db->error());
1579
1580        $db->query('INSERT INTO '.$db_prefix.'users (group_id, username, password, email, language, style, num_posts, last_post, registered, registration_ip, last_visit) VALUES(1, \''.$db->escape($username).'\', \''.pun_hash($password1).'\', \''.$email.'\', \''.$db->escape($default_lang).'\', \''.$db->escape($default_style).'\', 1, '.$now.', '.$now.', \''.get_remote_address().'\', '.$now.')')
1581                or error('Unable to add administrator user. Please check your configuration and try again', __FILE__, __LINE__, $db->error());
1582
1583        // Enable/disable avatars depending on file_uploads setting in PHP configuration
1584        $avatars = in_array(strtolower(@ini_get('file_uploads')), array('on', 'true', '1')) ? 1 : 0;
1585
1586        // Insert config data
1587        $config = array(
1588                'o_cur_version'                         => "'".FORUM_VERSION."'",
1589                'o_database_revision'           => "'".FORUM_DB_REVISION."'",
1590                'o_searchindex_revision'        => "'".FORUM_SI_REVISION."'",
1591                'o_parser_revision'                     => "'".FORUM_PARSER_REVISION."'",
1592                'o_board_title'                         => "'".$db->escape($title)."'",
1593                'o_board_desc'                          => "'".$db->escape($description)."'",
1594                'o_default_timezone'            => "'0'",
1595                'o_time_format'                         => "'H:i:s'",
1596                'o_date_format'                         => "'Y-m-d'",
1597                'o_timeout_visit'                       => "'1800'",
1598                'o_timeout_online'                      => "'300'",
1599                'o_redirect_delay'                      => "'1'",
1600                'o_show_version'                        => "'0'",
1601                'o_show_user_info'                      => "'1'",
1602                'o_show_post_count'                     => "'1'",
1603                'o_signatures'                          => "'1'",
1604                'o_smilies'                                     => "'1'",
1605                'o_smilies_sig'                         => "'1'",
1606                'o_make_links'                          => "'1'",
1607                'o_default_lang'                        => "'".$db->escape($default_lang)."'",
1608                'o_default_style'                       => "'".$db->escape($default_style)."'",
1609                'o_default_user_group'          => "'4'",
1610                'o_topic_review'                        => "'15'",
1611                'o_disp_topics_default'         => "'30'",
1612                'o_disp_posts_default'          => "'25'",
1613                'o_indent_num_spaces'           => "'4'",
1614                'o_quote_depth'                         => "'3'",
1615                'o_quickpost'                           => "'1'",
1616                'o_users_online'                        => "'1'",
1617                'o_censoring'                           => "'0'",
1618                'o_ranks'                                       => "'1'",
1619                'o_show_dot'                            => "'0'",
1620                'o_topic_views'                         => "'1'",
1621                'o_quickjump'                           => "'1'",
1622                'o_gzip'                                        => "'0'",
1623                'o_additional_navlinks'         => "''",
1624                'o_report_method'                       => "'0'",
1625                'o_regs_report'                         => "'0'",
1626                'o_default_email_setting'       => "'1'",
1627                'o_mailing_list'                        => "'".$email."'",
1628                'o_avatars'                                     => "'".$avatars."'",
1629                'o_avatars_dir'                         => "'img/avatars'",
1630                'o_avatars_width'                       => "'60'",
1631                'o_avatars_height'                      => "'60'",
1632                'o_avatars_size'                        => "'10240'",
1633                'o_search_all_forums'           => "'1'",
1634                'o_base_url'                            => "'".$db->escape($base_url)."'",
1635                'o_admin_email'                         => "'".$email."'",
1636                'o_webmaster_email'                     => "'".$email."'",
1637                'o_forum_subscriptions'         => "'1'",
1638                'o_topic_subscriptions'         => "'1'",
1639                'o_smtp_host'                           => "NULL",
1640                'o_smtp_user'                           => "NULL",
1641                'o_smtp_pass'                           => "NULL",
1642                'o_smtp_ssl'                            => "'0'",
1643                'o_regs_allow'                          => "'1'",
1644                'o_regs_verify'                         => "'0'",
1645                'o_announcement'                        => "'0'",
1646                'o_announcement_message'        => "'".$db->escape($lang_install['Announcement'])."'",
1647                'o_rules'                                       => "'0'",
1648                'o_rules_message'                       => "'".$db->escape($lang_install['Rules'])."'",
1649                'o_maintenance'                         => "'0'",
1650                'o_maintenance_message'         => "'".$db->escape($lang_install['Maintenance message'])."'",
1651                'o_default_dst'                         => "'0'",
1652                'o_feed_type'                           => "'2'",
1653                'o_feed_ttl'                            => "'0'",
1654                'p_message_bbcode'                      => "'1'",
1655                'p_message_img_tag'                     => "'1'",
1656                'p_message_all_caps'            => "'1'",
1657                'p_subject_all_caps'            => "'1'",
1658                'p_sig_all_caps'                        => "'1'",
1659                'p_sig_bbcode'                          => "'1'",
1660                'p_sig_img_tag'                         => "'0'",
1661                'p_sig_length'                          => "'400'",
1662                'p_sig_lines'                           => "'4'",
1663                'p_allow_banned_email'          => "'1'",
1664                'p_allow_dupe_email'            => "'0'",
1665                'p_force_guest_email'           => "'1'"
1666        );
1667
1668        foreach ($config as $conf_name => $conf_value)
1669        {
1670                $db->query('INSERT INTO '.$db_prefix."config (conf_name, conf_value) VALUES('$conf_name', $conf_value)")
1671                        or error('Unable to insert into table '.$db_prefix.'config. Please check your configuration and try again', __FILE__, __LINE__, $db->error());
1672        }
1673
1674        // Insert some other default data
1675        $subject = $lang_install['Test post'];
1676        $message = $lang_install['Message'];
1677
1678        $db->query('INSERT INTO '.$db_prefix.'ranks (rank, min_posts) VALUES(\''.$db->escape($lang_install['New member']).'\', 0)')
1679                or error('Unable to insert into table '.$db_prefix.'ranks. Please check your configuration and try again', __FILE__, __LINE__, $db->error());
1680
1681        $db->query('INSERT INTO '.$db_prefix.'ranks (rank, min_posts) VALUES(\''.$db->escape($lang_install['Member']).'\', 10)')
1682                or error('Unable to insert into table '.$db_prefix.'ranks. Please check your configuration and try again', __FILE__, __LINE__, $db->error());
1683
1684        $db->query('INSERT INTO '.$db_prefix.'categories (cat_name, disp_position) VALUES(\''.$db->escape($lang_install['Test category']).'\', 1)')
1685                or error('Unable to insert into table '.$db_prefix.'categories. Please check your configuration and try again', __FILE__, __LINE__, $db->error());
1686
1687        $db->query('INSERT INTO '.$db_prefix.'forums (forum_name, forum_desc, num_topics, num_posts, last_post, last_post_id, last_poster, disp_position, cat_id) VALUES(\''.$db->escape($lang_install['Test forum']).'\', \''.$db->escape($lang_install['This is just a test forum']).'\', 1, 1, '.$now.', 1, \''.$db->escape($username).'\', 1, 1)')
1688                or error('Unable to insert into table '.$db_prefix.'forums. Please check your configuration and try again', __FILE__, __LINE__, $db->error());
1689
1690        $db->query('INSERT INTO '.$db_prefix.'topics (poster, subject, posted, first_post_id, last_post, last_post_id, last_poster, forum_id) VALUES(\''.$db->escape($username).'\', \''.$db->escape($subject).'\', '.$now.', 1, '.$now.', 1, \''.$db->escape($username).'\', 1)')
1691                or error('Unable to insert into table '.$db_prefix.'topics. Please check your configuration and try again', __FILE__, __LINE__, $db->error());
1692
1693        $db->query('INSERT INTO '.$db_prefix.'posts (poster, poster_id, poster_ip, message, posted, topic_id) VALUES(\''.$db->escape($username).'\', 2, \''.get_remote_address().'\', \''.$db->escape($message).'\', '.$now.', 1)')
1694                or error('Unable to insert into table '.$db_prefix.'posts. Please check your configuration and try again', __FILE__, __LINE__, $db->error());
1695
1696        // Index the test post so searching for it works
1697        require PUN_ROOT.'include/search_idx.php';
1698        $pun_config['o_default_lang'] = $default_lang;
1699        update_search_index('post', 1, $message, $subject);
1700
1701        $db->end_transaction();
1702
1703
1704        $alerts = array();
1705
1706        // Check if we disabled uploading avatars because file_uploads was disabled
1707        if ($avatars == '0')
1708                $alerts[] = $lang_install['Alert upload'];
1709
1710        // Add some random bytes at the end of the cookie name to prevent collisions
1711        $cookie_name = 'pun_cookie_'.random_key(6, false, true);
1712
1713        // Generate the config.php file data
1714        $config = generate_config_file();
1715
1716        // Attempt to write config.php and serve it up for download if writing fails
1717        $written = false;
1718        if (is_writable(PUN_ROOT))
1719        {
1720                $fh = @fopen(PUN_ROOT.'config.php', 'wb');
1721                if ($fh)
1722                {
1723                        fwrite($fh, $config);
1724                        fclose($fh);
1725
1726                        $written = true;
1727                }
1728        }
1729
1730
1731?>
1732<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
1733
1734<html>
1735<head>
1736<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
1737<title><?php echo $lang_install['FluxBB Installation'] ?></title>
1738<link rel="stylesheet" type="text/css" href="style/<?php echo $default_style ?>.css" />
1739</head>
1740<body>
1741
1742<div id="puninstall" class="pun">
1743<div class="top-box"><div><!-- Top Corners --></div></div>
1744<div class="punwrap">
1745
1746<div id="brdheader" class="block">
1747        <div class="box">
1748                <div id="brdtitle" class="inbox">
1749                        <h1><span><?php echo $lang_install['FluxBB Installation'] ?></span></h1>
1750                        <div id="brddesc"><p><?php echo $lang_install['FluxBB has been installed'] ?></p></div>
1751                </div>
1752        </div>
1753</div>
1754
1755<div id="brdmain">
1756
1757<div class="blockform">
1758        <h2><span><?php echo $lang_install['Final instructions'] ?></span></h2>
1759        <div class="box">
1760<?php
1761
1762if (!$written)
1763{
1764
1765?>
1766                <form method="post" action="install.php">
1767                        <div class="inform">
1768                                <div class="forminfo">
1769                                        <p><?php echo $lang_install['Info 17'] ?></p>
1770                                        <p><?php echo $lang_install['Info 18'] ?></p>
1771                                </div>
1772                                <input type="hidden" name="generate_config" value="1" />
1773                                <input type="hidden" name="db_type" value="<?php echo $db_type; ?>" />
1774                                <input type="hidden" name="db_host" value="<?php echo $db_host; ?>" />
1775                                <input type="hidden" name="db_name" value="<?php echo pun_htmlspecialchars($db_name); ?>" />
1776                                <input type="hidden" name="db_username" value="<?php echo pun_htmlspecialchars($db_username); ?>" />
1777                                <input type="hidden" name="db_password" value="<?php echo pun_htmlspecialchars($db_password); ?>" />
1778                                <input type="hidden" name="db_prefix" value="<?php echo pun_htmlspecialchars($db_prefix); ?>" />
1779                                <input type="hidden" name="cookie_name" value="<?php echo pun_htmlspecialchars($cookie_name); ?>" />
1780                                <input type="hidden" name="cookie_seed" value="<?php echo pun_htmlspecialchars($cookie_seed); ?>" />
1781
1782<?php if (!empty($alerts)): ?>                          <div class="forminfo error-info">
1783                                        <ul class="error-list">
1784<?php
1785
1786foreach ($alerts as $cur_alert)
1787        echo "\t\t\t\t\t".'<li>'.$cur_alert.'</li>'."\n";
1788?>
1789                                        </ul>
1790                                </div>
1791<?php endif; ?>                 </div>
1792                        <p class="buttons"><input type="submit" value="<?php echo $lang_install['Download config.php file'] ?>" /></p>
1793                </form>
1794
1795<?php
1796
1797}
1798else
1799{
1800
1801?>
1802                <div class="fakeform">
1803                        <div class="inform">
1804                                <div class="forminfo">
1805                                        <p><?php echo $lang_install['FluxBB fully installed'] ?></p>
1806                                </div>
1807                        </div>
1808                </div>
1809<?php
1810
1811}
1812
1813?>
1814        </div>
1815</div>
1816
1817</div>
1818
1819</div>
1820<div class="end-box"><div><!-- Bottom Corners --></div></div>
1821</div>
1822
1823</body>
1824</html>
1825<?php
1826
1827}
Note: See TracBrowser for help on using the repository browser.