Skip to content

HTTPS clone URL

Subversion checkout URL

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