1 <?php |
|
2 /*********************************************************************** |
|
3 |
|
4 Copyright (C) 2002-2005 Rickard Andersson (rickard@punbb.org) |
|
5 |
|
6 This file is part of PunBB. |
|
7 |
|
8 PunBB is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published |
|
10 by the Free Software Foundation; either version 2 of the License, |
|
11 or (at your option) any later version. |
|
12 |
|
13 PunBB is distributed in the hope that it will be useful, but |
|
14 WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 GNU General Public License for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with this program; if not, write to the Free Software |
|
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
|
21 MA 02111-1307 USA |
|
22 |
|
23 ************************************************************************/ |
|
24 |
|
25 |
|
26 // The PunBB version this script installs |
|
27 $punbb_version = '1.2.15'; |
|
28 |
|
29 |
|
30 define('PUN_ROOT', './'); |
|
31 if (file_exists(PUN_ROOT.'config.php')) |
|
32 exit('The file \'config.php\' already exists which would mean that PunBB is already installed. You should go <a href="index.php">here</a> instead.'); |
|
33 |
|
34 |
|
35 // Make sure we are running at least PHP 4.1.0 |
|
36 if (intval(str_replace('.', '', phpversion())) < 410) |
|
37 exit('You are running PHP version '.PHP_VERSION.'. PunBB requires at least PHP 4.1.0 to run properly. You must upgrade your PHP installation before you can continue.'); |
|
38 |
|
39 // Disable error reporting for uninitialized variables |
|
40 error_reporting(E_ALL); |
|
41 |
|
42 // Turn off PHP time limit |
|
43 @set_time_limit(0); |
|
44 |
|
45 |
|
46 if (!isset($_POST['form_sent'])) |
|
47 { |
|
48 // Determine available database extensions |
|
49 $dual_mysql = false; |
|
50 $db_extensions = array(); |
|
51 if (function_exists('mysqli_connect')) |
|
52 $db_extensions[] = array('mysqli', 'MySQL Improved'); |
|
53 if (function_exists('mysql_connect')) |
|
54 { |
|
55 $db_extensions[] = array('mysql', 'MySQL Standard'); |
|
56 |
|
57 if (count($db_extensions) > 1) |
|
58 $dual_mysql = true; |
|
59 } |
|
60 if (function_exists('sqlite_open')) |
|
61 $db_extensions[] = array('sqlite', 'SQLite'); |
|
62 if (function_exists('pg_connect')) |
|
63 $db_extensions[] = array('pgsql', 'PostgreSQL'); |
|
64 |
|
65 if (empty($db_extensions)) |
|
66 exit('This PHP environment does not have support for any of the databases that PunBB supports. PHP needs to have support for either MySQL, PostgreSQL or SQLite in order for PunBB to be installed.'); |
|
67 |
|
68 ?> |
|
69 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
|
70 |
|
71 <html> |
|
72 <head> |
|
73 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> |
|
74 <title>PunBB Installation</title> |
|
75 <link rel="stylesheet" type="text/css" href="style/Oxygen.css" /> |
|
76 <script type="text/javascript"> |
|
77 <!-- |
|
78 function process_form(the_form) |
|
79 { |
|
80 var element_names = new Object() |
|
81 element_names["req_db_type"] = "Database type" |
|
82 element_names["req_db_host"] = "Database server hostname" |
|
83 element_names["req_db_name"] = "Database name" |
|
84 element_names["db_prefix"] = "Table prefix" |
|
85 element_names["req_username"] = "Administrator username" |
|
86 element_names["req_password1"] = "Administrator password 1" |
|
87 element_names["req_password2"] = "Administrator password 2" |
|
88 element_names["req_email"] = "Administrator's e-mail" |
|
89 element_names["req_base_url"] = "Base URL" |
|
90 |
|
91 if (document.all || document.getElementById) |
|
92 { |
|
93 for (i = 0; i < the_form.length; ++i) |
|
94 { |
|
95 var elem = the_form.elements[i] |
|
96 if (elem.name && elem.name.substring(0, 4) == "req_") |
|
97 { |
|
98 if (elem.type && (elem.type=="text" || elem.type=="textarea" || elem.type=="password" || elem.type=="file") && elem.value=='') |
|
99 { |
|
100 alert("\"" + element_names[elem.name] + "\" is a required field in this form.") |
|
101 elem.focus() |
|
102 return false |
|
103 } |
|
104 } |
|
105 } |
|
106 } |
|
107 |
|
108 return true |
|
109 } |
|
110 // --> |
|
111 </script> |
|
112 </head> |
|
113 <body onload="document.getElementById('install').req_db_type.focus()"> |
|
114 |
|
115 <div id="puninstall" style="margin: auto 10% auto 10%"> |
|
116 <div class="pun"> |
|
117 |
|
118 <div class="block"> |
|
119 <h2><span>PunBB Installation</span></h2> |
|
120 <div class="box"> |
|
121 <div class="inbox"> |
|
122 <p>Welcome to PunBB installation! You are about to install PunBB. In order to install PunBB you must complete the form set out below. If you encounter any difficulties with the installation, please refer to the documentation.</p> |
|
123 </div> |
|
124 </div> |
|
125 </div> |
|
126 |
|
127 <div class="blockform"> |
|
128 <h2><span>Install PunBB 1.2</span></h2> |
|
129 <div class="box"> |
|
130 <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;}"> |
|
131 <div><input type="hidden" name="form_sent" value="1" /></div> |
|
132 <div class="inform"> |
|
133 <div class="forminfo"> |
|
134 <h3>Database setup</h3> |
|
135 <p>Please enter the requested information in order to setup your database for PunBB. You must know all the information asked for before proceeding with the installation.</p> |
|
136 </div> |
|
137 <fieldset> |
|
138 <legend>Select your database type</legend> |
|
139 <div class="infldset"> |
|
140 <p>PunBB 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> |
|
141 <?php if ($dual_mysql): ?> <p>PunBB 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> |
|
142 <?php endif; ?> <label><strong>Database type</strong> |
|
143 <br /><select name="req_db_type"> |
|
144 <?php |
|
145 |
|
146 foreach ($db_extensions as $db_type) |
|
147 echo "\t\t\t\t\t\t\t".'<option value="'.$db_type[0].'">'.$db_type[1].'</option>'."\n"; |
|
148 |
|
149 ?> |
|
150 </select> |
|
151 <br /></label> |
|
152 </div> |
|
153 </fieldset> |
|
154 </div> |
|
155 <div class="inform"> |
|
156 <fieldset> |
|
157 <legend>Enter your database server hostname</legend> |
|
158 <div class="infldset"> |
|
159 <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> |
|
160 <label><strong>Database server hostname</strong><br /><input type="text" name="req_db_host" value="localhost" size="50" maxlength="100" /><br /></label> |
|
161 </div> |
|
162 </fieldset> |
|
163 </div> |
|
164 <div class="inform"> |
|
165 <fieldset> |
|
166 <legend>Enter then name of your database</legend> |
|
167 <div class="infldset"> |
|
168 <p>The name of the database that PunBB 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, PunBB will attempt to create it.</p> |
|
169 <label for="req_db_name"><strong>Database name</strong><br /><input id="req_db_name" type="text" name="req_db_name" size="30" maxlength="50" /><br /></label> |
|
170 </div> |
|
171 </fieldset> |
|
172 </div> |
|
173 <div class="inform"> |
|
174 <fieldset> |
|
175 <legend>Enter your database username and password</legend> |
|
176 <div class="infldset"> |
|
177 <p>Enter the username and password with which you connect to the database. Ignore for SQLite.</p> |
|
178 <label class="conl">Database username<br /><input type="text" name="db_username" size="30" maxlength="50" /><br /></label> |
|
179 <label class="conl">Database password<br /><input type="text" name="db_password" size="30" maxlength="50" /><br /></label> |
|
180 <div class="clearer"></div> |
|
181 </div> |
|
182 </fieldset> |
|
183 </div> |
|
184 <div class="inform"> |
|
185 <fieldset> |
|
186 <legend>Enter database table prefix</legend> |
|
187 <div class="infldset"> |
|
188 <p>If you like you can specify a table prefix. This way you can run multiple copies of PunBB in the same database (example: foo_).</p> |
|
189 <label>Table prefix<br /><input id="db_prefix" type="text" name="db_prefix" size="20" maxlength="30" /><br /></label> |
|
190 </div> |
|
191 </fieldset> |
|
192 </div> |
|
193 <div class="inform"> |
|
194 <div class="forminfo"> |
|
195 <h3>Administration setup</h3> |
|
196 <p>Please enter the requested information in order to setup an administrator for your PunBB installation</p> |
|
197 </div> |
|
198 <fieldset> |
|
199 <legend>Enter Administrators username</legend> |
|
200 <div class="infldset"> |
|
201 <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> |
|
202 <label><strong>Administrator username</strong><br /><input type="text" name="req_username" size="25" maxlength="25" /><br /></label> |
|
203 </div> |
|
204 </fieldset> |
|
205 </div> |
|
206 <div class="inform"> |
|
207 <fieldset> |
|
208 <legend>Enter and confirm Administrator password</legend> |
|
209 <div class="infldset"> |
|
210 <p>Passwords can be between 4 and 16 characters long. Passwords are case sensitive.</p> |
|
211 <label class="conl"><strong>Password</strong><br /><input id="req_password1" type="text" name="req_password1" size="16" maxlength="16" /><br /></label> |
|
212 <label class="conl"><strong>Confirm password</strong><br /><input type="text" name="req_password2" size="16" maxlength="16" /><br /></label> |
|
213 <div class="clearer"></div> |
|
214 </div> |
|
215 </fieldset> |
|
216 </div> |
|
217 <div class="inform"> |
|
218 <fieldset> |
|
219 <legend>Enter Administrator's e-mail</legend> |
|
220 <div class="infldset"> |
|
221 <p>The e-mail address of the forum administrator.</p> |
|
222 <label for="req_email"><strong>Administrator's e-mail</strong><br /><input id="req_email" type="text" name="req_email" size="50" maxlength="50" /><br /></label> |
|
223 </div> |
|
224 </fieldset> |
|
225 </div> |
|
226 <div class="inform"> |
|
227 <fieldset> |
|
228 <legend>Enter the Base URL of your PunBB installation</legend> |
|
229 <div class="infldset"> |
|
230 <p>The URL (without trailing slash) of your PunBB forum (example: http://forum.myhost.com or http://myhost.com/~myuser). This <strong>must</strong> be correct or administrators and moderators will not be able to submit any forms. Please note that the preset value below is just an educated guess by PunBB.</p> |
|
231 <label><strong>Base URL</strong><br /><input type="text" name="req_base_url" value="http://<?php echo $_SERVER['SERVER_NAME'].str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME'])) ?>" size="60" maxlength="100" /><br /></label> |
|
232 </div> |
|
233 </fieldset> |
|
234 </div> |
|
235 <p><input type="submit" name="start" value="Start install" /></p> |
|
236 </form> |
|
237 </div> |
|
238 </div> |
|
239 |
|
240 </div> |
|
241 </div> |
|
242 |
|
243 </body> |
|
244 </html> |
|
245 <?php |
|
246 |
|
247 } |
|
248 else |
|
249 { |
|
250 // |
|
251 // Strip slashes only if magic_quotes_gpc is on. |
|
252 // |
|
253 function unescape($str) |
|
254 { |
|
255 return (get_magic_quotes_gpc() == 1) ? stripslashes($str) : $str; |
|
256 } |
|
257 |
|
258 |
|
259 // |
|
260 // Compute a hash of $str. |
|
261 // Uses sha1() if available. If not, SHA1 through mhash() if available. If not, fall back on md5(). |
|
262 // |
|
263 function pun_hash($str) |
|
264 { |
|
265 if (function_exists('sha1')) // Only in PHP 4.3.0+ |
|
266 return sha1($str); |
|
267 else if (function_exists('mhash')) // Only if Mhash library is loaded |
|
268 return bin2hex(mhash(MHASH_SHA1, $str)); |
|
269 else |
|
270 return md5($str); |
|
271 } |
|
272 |
|
273 |
|
274 // |
|
275 // A temporary replacement for the full error handler found in functions.php. |
|
276 // It's here because a function called error() must be callable in the database abstraction layer. |
|
277 // |
|
278 function error($message, $file = false, $line = false, $db_error = false) |
|
279 { |
|
280 if ($file !== false && $line !== false) |
|
281 echo '<strong style="color: A00000">An error occured on line '.$line.' in file '.$file.'.</strong><br /><br />'; |
|
282 else |
|
283 echo '<strong style="color: A00000">An error occured.</strong><br /><br />'; |
|
284 |
|
285 echo '<strong>PunBB reported:</strong> '.htmlspecialchars($message).'<br /><br />'; |
|
286 |
|
287 if ($db_error !== false) |
|
288 echo '<strong>Database reported:</strong> '.htmlspecialchars($db_error['error_msg']).(($db_error['error_no']) ? ' (Errno: '.$db_error['error_no'].')' : ''); |
|
289 |
|
290 exit; |
|
291 } |
|
292 |
|
293 |
|
294 $db_type = $_POST['req_db_type']; |
|
295 $db_host = trim($_POST['req_db_host']); |
|
296 $db_name = trim($_POST['req_db_name']); |
|
297 $db_username = unescape(trim($_POST['db_username'])); |
|
298 $db_password = unescape(trim($_POST['db_password'])); |
|
299 $db_prefix = trim($_POST['db_prefix']); |
|
300 $username = unescape(trim($_POST['req_username'])); |
|
301 $email = strtolower(trim($_POST['req_email'])); |
|
302 $password1 = unescape(trim($_POST['req_password1'])); |
|
303 $password2 = unescape(trim($_POST['req_password2'])); |
|
304 |
|
305 |
|
306 // Make sure base_url doesn't end with a slash |
|
307 if (substr($_POST['req_base_url'], -1) == '/') |
|
308 $base_url = substr($_POST['req_base_url'], 0, -1); |
|
309 else |
|
310 $base_url = $_POST['req_base_url']; |
|
311 |
|
312 |
|
313 // Validate username and passwords |
|
314 if (strlen($username) < 2) |
|
315 error('Usernames must be at least 2 characters long. Please go back and correct.'); |
|
316 if (strlen($password1) < 4) |
|
317 error('Passwords must be at least 4 characters long. Please go back and correct.'); |
|
318 if ($password1 != $password2) |
|
319 error('Passwords do not match. Please go back and correct.'); |
|
320 if (!strcasecmp($username, 'Guest')) |
|
321 error('The username guest is reserved. Please go back and correct.'); |
|
322 if (preg_match('/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/', $username)) |
|
323 error('Usernames may not be in the form of an IP address. Please go back and correct.'); |
|
324 if (preg_match('#\[b\]|\[/b\]|\[u\]|\[/u\]|\[i\]|\[/i\]|\[color|\[/color\]|\[quote\]|\[/quote\]|\[code\]|\[/code\]|\[img\]|\[/img\]|\[url|\[/url\]|\[email|\[/email\]#i', $username)) |
|
325 error('Usernames may not contain any of the text formatting tags (BBCode) that the forum uses. Please go back and correct.'); |
|
326 |
|
327 if (strlen($email) > 50 || !preg_match('/^(([^<>()[\]\\.,;:\s@"\']+(\.[^<>()[\]\\.,;:\s@"\']+)*)|("[^"\']+"))@((\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\])|(([a-zA-Z\d\-]+\.)+[a-zA-Z]{2,}))$/', $email)) |
|
328 error('The administrator e-mail address you entered is invalid. Please go back and correct.'); |
|
329 |
|
330 |
|
331 // Load the appropriate DB layer class |
|
332 switch ($db_type) |
|
333 { |
|
334 case 'mysql': |
|
335 require PUN_ROOT.'include/dblayer/mysql.php'; |
|
336 break; |
|
337 |
|
338 case 'mysqli': |
|
339 require PUN_ROOT.'include/dblayer/mysqli.php'; |
|
340 break; |
|
341 |
|
342 case 'pgsql': |
|
343 require PUN_ROOT.'include/dblayer/pgsql.php'; |
|
344 break; |
|
345 |
|
346 case 'sqlite': |
|
347 require PUN_ROOT.'include/dblayer/sqlite.php'; |
|
348 break; |
|
349 |
|
350 default: |
|
351 error('\''.$db_type.'\' is not a valid database type.'); |
|
352 } |
|
353 |
|
354 // Create the database object (and connect/select db) |
|
355 $pun_db = new DBLayer($db_host, $db_username, $db_password, $db_name, $db_prefix, false); |
|
356 |
|
357 |
|
358 // Do some DB type specific checks |
|
359 switch ($db_type) |
|
360 { |
|
361 case 'mysql': |
|
362 case 'mysqli': |
|
363 break; |
|
364 |
|
365 case 'pgsql': |
|
366 // Make sure we are running at least PHP 4.3.0 (needed only for PostgreSQL) |
|
367 if (version_compare(PHP_VERSION, '4.3.0', '<')) |
|
368 error('You are running PHP version '.PHP_VERSION.'. PunBB requires at least PHP 4.3.0 to run properly when using PostgreSQL. You must upgrade your PHP installation or use a different database before you can continue.'); |
|
369 break; |
|
370 |
|
371 case 'sqlite': |
|
372 if (strtolower($db_prefix) == 'sqlite_') |
|
373 error('The table prefix \'sqlite_\' is reserved for use by the SQLite engine. Please choose a different prefix.'); |
|
374 break; |
|
375 } |
|
376 |
|
377 |
|
378 // Make sure PunBB isn't already installed |
|
379 $result = $pun_db->query('SELECT 1 FROM '.$db_prefix.'users WHERE id=1'); |
|
380 if ($pun_db->num_rows($result)) |
|
381 error('A table called "'.$db_prefix.'users" is already present in the database "'.$db_name.'". This could mean that PunBB is already installed or that another piece of software is installed and is occupying one or more of the table names PunBB requires. If you want to install multiple copies of PunBB in the same database, you must choose a different table prefix.'); |
|
382 |
|
383 |
|
384 // Create all tables |
|
385 switch ($db_type) |
|
386 { |
|
387 case 'mysql': |
|
388 case 'mysqli': |
|
389 $sql = 'CREATE TABLE '.$db_prefix."bans ( |
|
390 id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
391 username VARCHAR(200), |
|
392 ip VARCHAR(255), |
|
393 email VARCHAR(50), |
|
394 message VARCHAR(255), |
|
395 expire INT(10) UNSIGNED, |
|
396 PRIMARY KEY (id) |
|
397 ) TYPE=MyISAM;"; |
|
398 break; |
|
399 |
|
400 case 'pgsql': |
|
401 $pun_db->start_transaction(); |
|
402 |
|
403 $sql = 'CREATE TABLE '.$db_prefix."bans ( |
|
404 id SERIAL, |
|
405 username VARCHAR(200), |
|
406 ip VARCHAR(255), |
|
407 email VARCHAR(50), |
|
408 message VARCHAR(255), |
|
409 expire INT, |
|
410 PRIMARY KEY (id) |
|
411 )"; |
|
412 break; |
|
413 |
|
414 case 'sqlite': |
|
415 $pun_db->start_transaction(); |
|
416 |
|
417 $sql = 'CREATE TABLE '.$db_prefix."bans ( |
|
418 id INTEGER NOT NULL, |
|
419 username VARCHAR(200), |
|
420 ip VARCHAR(255), |
|
421 email VARCHAR(50), |
|
422 message VARCHAR(255), |
|
423 expire INTEGER, |
|
424 PRIMARY KEY (id) |
|
425 )"; |
|
426 break; |
|
427 |
|
428 } |
|
429 |
|
430 $pun_db->query($sql) or error('Unable to create table '.$db_prefix.'bans. Please check your settings and try again.', __FILE__, __LINE__, $pun_db->error()); |
|
431 |
|
432 |
|
433 switch ($db_type) |
|
434 { |
|
435 case 'mysql': |
|
436 case 'mysqli': |
|
437 $sql = 'CREATE TABLE '.$db_prefix."categories ( |
|
438 id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
439 cat_name VARCHAR(80) NOT NULL DEFAULT 'New Category', |
|
440 disp_position INT(10) NOT NULL DEFAULT 0, |
|
441 PRIMARY KEY (id) |
|
442 ) TYPE=MyISAM;"; |
|
443 break; |
|
444 |
|
445 case 'pgsql': |
|
446 $sql = 'CREATE TABLE '.$db_prefix."categories ( |
|
447 id SERIAL, |
|
448 cat_name VARCHAR(80) NOT NULL DEFAULT 'New Category', |
|
449 disp_position INT NOT NULL DEFAULT 0, |
|
450 PRIMARY KEY (id) |
|
451 )"; |
|
452 break; |
|
453 |
|
454 case 'sqlite': |
|
455 $sql = 'CREATE TABLE '.$db_prefix."categories ( |
|
456 id INTEGER NOT NULL, |
|
457 cat_name VARCHAR(80) NOT NULL DEFAULT 'New Category', |
|
458 disp_position INTEGER NOT NULL DEFAULT 0, |
|
459 PRIMARY KEY (id) |
|
460 )"; |
|
461 break; |
|
462 } |
|
463 |
|
464 $pun_db->query($sql) or error('Unable to create table '.$db_prefix.'categories. Please check your settings and try again.', __FILE__, __LINE__, $pun_db->error()); |
|
465 |
|
466 |
|
467 |
|
468 switch ($db_type) |
|
469 { |
|
470 case 'mysql': |
|
471 case 'mysqli': |
|
472 $sql = 'CREATE TABLE '.$db_prefix."censoring ( |
|
473 id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
474 search_for VARCHAR(60) NOT NULL DEFAULT '', |
|
475 replace_with VARCHAR(60) NOT NULL DEFAULT '', |
|
476 PRIMARY KEY (id) |
|
477 ) TYPE=MyISAM;"; |
|
478 break; |
|
479 |
|
480 case 'pgsql': |
|
481 $sql = 'CREATE TABLE '.$db_prefix."censoring ( |
|
482 id SERIAL, |
|
483 search_for VARCHAR(60) NOT NULL DEFAULT '', |
|
484 replace_with VARCHAR(60) NOT NULL DEFAULT '', |
|
485 PRIMARY KEY (id) |
|
486 )"; |
|
487 break; |
|
488 |
|
489 case 'sqlite': |
|
490 $sql = 'CREATE TABLE '.$db_prefix."censoring ( |
|
491 id INTEGER NOT NULL, |
|
492 search_for VARCHAR(60) NOT NULL DEFAULT '', |
|
493 replace_with VARCHAR(60) NOT NULL DEFAULT '', |
|
494 PRIMARY KEY (id) |
|
495 )"; |
|
496 break; |
|
497 } |
|
498 |
|
499 $pun_db->query($sql) or error('Unable to create table '.$db_prefix.'censoring. Please check your settings and try again.', __FILE__, __LINE__, $pun_db->error()); |
|
500 |
|
501 |
|
502 |
|
503 switch ($db_type) |
|
504 { |
|
505 case 'mysql': |
|
506 case 'mysqli': |
|
507 $sql = 'CREATE TABLE '.$db_prefix."config ( |
|
508 conf_name VARCHAR(255) NOT NULL DEFAULT '', |
|
509 conf_value TEXT, |
|
510 PRIMARY KEY (conf_name) |
|
511 ) TYPE=MyISAM;"; |
|
512 break; |
|
513 |
|
514 case 'pgsql': |
|
515 $sql = 'CREATE TABLE '.$db_prefix."config ( |
|
516 conf_name VARCHAR(255) NOT NULL DEFAULT '', |
|
517 conf_value TEXT, |
|
518 PRIMARY KEY (conf_name) |
|
519 )"; |
|
520 break; |
|
521 |
|
522 case 'sqlite': |
|
523 $sql = 'CREATE TABLE '.$db_prefix."config ( |
|
524 conf_name VARCHAR(255) NOT NULL DEFAULT '', |
|
525 conf_value TEXT, |
|
526 PRIMARY KEY (conf_name) |
|
527 )"; |
|
528 break; |
|
529 } |
|
530 |
|
531 $pun_db->query($sql) or error('Unable to create table '.$db_prefix.'config. Please check your settings and try again.', __FILE__, __LINE__, $pun_db->error()); |
|
532 |
|
533 |
|
534 |
|
535 switch ($db_type) |
|
536 { |
|
537 case 'mysql': |
|
538 case 'mysqli': |
|
539 $sql = 'CREATE TABLE '.$db_prefix."forum_perms ( |
|
540 group_id INT(10) NOT NULL DEFAULT 0, |
|
541 forum_id INT(10) NOT NULL DEFAULT 0, |
|
542 read_forum TINYINT(1) NOT NULL DEFAULT 1, |
|
543 post_replies TINYINT(1) NOT NULL DEFAULT 1, |
|
544 post_topics TINYINT(1) NOT NULL DEFAULT 1, |
|
545 PRIMARY KEY (group_id, forum_id) |
|
546 ) TYPE=MyISAM;"; |
|
547 break; |
|
548 |
|
549 case 'pgsql': |
|
550 $sql = 'CREATE TABLE '.$db_prefix."forum_perms ( |
|
551 group_id INT NOT NULL DEFAULT 0, |
|
552 forum_id INT NOT NULL DEFAULT 0, |
|
553 read_forum SMALLINT NOT NULL DEFAULT 1, |
|
554 post_replies SMALLINT NOT NULL DEFAULT 1, |
|
555 post_topics SMALLINT NOT NULL DEFAULT 1, |
|
556 PRIMARY KEY (group_id, forum_id) |
|
557 )"; |
|
558 break; |
|
559 |
|
560 case 'sqlite': |
|
561 $sql = 'CREATE TABLE '.$db_prefix."forum_perms ( |
|
562 group_id INTEGER NOT NULL DEFAULT 0, |
|
563 forum_id INTEGER NOT NULL DEFAULT 0, |
|
564 read_forum INTEGER NOT NULL DEFAULT 1, |
|
565 post_replies INTEGER NOT NULL DEFAULT 1, |
|
566 post_topics INTEGER NOT NULL DEFAULT 1, |
|
567 PRIMARY KEY (group_id, forum_id) |
|
568 )"; |
|
569 break; |
|
570 } |
|
571 |
|
572 $pun_db->query($sql) or error('Unable to create table '.$db_prefix.'forum_perms. Please check your settings and try again.', __FILE__, __LINE__, $pun_db->error()); |
|
573 |
|
574 |
|
575 |
|
576 switch ($db_type) |
|
577 { |
|
578 case 'mysql': |
|
579 case 'mysqli': |
|
580 $sql = 'CREATE TABLE '.$db_prefix."forums ( |
|
581 id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
582 forum_name VARCHAR(80) NOT NULL DEFAULT 'New forum', |
|
583 forum_desc TEXT, |
|
584 redirect_url VARCHAR(100), |
|
585 moderators TEXT, |
|
586 num_topics MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT 0, |
|
587 num_posts MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT 0, |
|
588 last_post INT(10) UNSIGNED, |
|
589 last_post_id INT(10) UNSIGNED, |
|
590 last_poster VARCHAR(200), |
|
591 sort_by TINYINT(1) NOT NULL DEFAULT 0, |
|
592 disp_position INT(10) NOT NULL DEFAULT 0, |
|
593 cat_id INT(10) UNSIGNED NOT NULL DEFAULT 0, |
|
594 PRIMARY KEY (id) |
|
595 ) TYPE=MyISAM;"; |
|
596 break; |
|
597 |
|
598 case 'pgsql': |
|
599 $sql = 'CREATE TABLE '.$db_prefix."forums ( |
|
600 id SERIAL, |
|
601 forum_name VARCHAR(80) NOT NULL DEFAULT 'New forum', |
|
602 forum_desc TEXT, |
|
603 redirect_url VARCHAR(100), |
|
604 moderators TEXT, |
|
605 num_topics INT NOT NULL DEFAULT 0, |
|
606 num_posts INT NOT NULL DEFAULT 0, |
|
607 last_post INT, |
|
608 last_post_id INT, |
|
609 last_poster VARCHAR(200), |
|
610 sort_by SMALLINT NOT NULL DEFAULT 0, |
|
611 disp_position INT NOT NULL DEFAULT 0, |
|
612 cat_id INT NOT NULL DEFAULT 0, |
|
613 PRIMARY KEY (id) |
|
614 )"; |
|
615 break; |
|
616 |
|
617 case 'sqlite': |
|
618 $sql = 'CREATE TABLE '.$db_prefix."forums ( |
|
619 id INTEGER NOT NULL, |
|
620 forum_name VARCHAR(80) NOT NULL DEFAULT 'New forum', |
|
621 forum_desc TEXT, |
|
622 redirect_url VARCHAR(100), |
|
623 moderators TEXT, |
|
624 num_topics INTEGER NOT NULL DEFAULT 0, |
|
625 num_posts INTEGER NOT NULL DEFAULT 0, |
|
626 last_post INTEGER, |
|
627 last_post_id INTEGER, |
|
628 last_poster VARCHAR(200), |
|
629 sort_by INTEGER NOT NULL DEFAULT 0, |
|
630 disp_position INTEGER NOT NULL DEFAULT 0, |
|
631 cat_id INTEGER NOT NULL DEFAULT 0, |
|
632 PRIMARY KEY (id) |
|
633 )"; |
|
634 break; |
|
635 } |
|
636 |
|
637 $pun_db->query($sql) or error('Unable to create table '.$db_prefix.'forums. Please check your settings and try again.', __FILE__, __LINE__, $pun_db->error()); |
|
638 |
|
639 |
|
640 |
|
641 switch ($db_type) |
|
642 { |
|
643 case 'mysql': |
|
644 case 'mysqli': |
|
645 $sql = 'CREATE TABLE '.$db_prefix."groups ( |
|
646 g_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
647 g_title VARCHAR(50) NOT NULL DEFAULT '', |
|
648 g_user_title VARCHAR(50), |
|
649 g_read_board TINYINT(1) NOT NULL DEFAULT 1, |
|
650 g_post_replies TINYINT(1) NOT NULL DEFAULT 1, |
|
651 g_post_topics TINYINT(1) NOT NULL DEFAULT 1, |
|
652 g_post_polls TINYINT(1) NOT NULL DEFAULT 1, |
|
653 g_edit_posts TINYINT(1) NOT NULL DEFAULT 1, |
|
654 g_delete_posts TINYINT(1) NOT NULL DEFAULT 1, |
|
655 g_delete_topics TINYINT(1) NOT NULL DEFAULT 1, |
|
656 g_set_title TINYINT(1) NOT NULL DEFAULT 1, |
|
657 g_search TINYINT(1) NOT NULL DEFAULT 1, |
|
658 g_search_users TINYINT(1) NOT NULL DEFAULT 1, |
|
659 g_edit_subjects_interval SMALLINT(6) NOT NULL DEFAULT 300, |
|
660 g_post_flood SMALLINT(6) NOT NULL DEFAULT 30, |
|
661 g_search_flood SMALLINT(6) NOT NULL DEFAULT 30, |
|
662 PRIMARY KEY (g_id) |
|
663 ) TYPE=MyISAM;"; |
|
664 break; |
|
665 |
|
666 case 'pgsql': |
|
667 $sql = 'CREATE TABLE '.$db_prefix."groups ( |
|
668 g_id SERIAL, |
|
669 g_title VARCHAR(50) NOT NULL DEFAULT '', |
|
670 g_user_title VARCHAR(50), |
|
671 g_read_board SMALLINT NOT NULL DEFAULT 1, |
|
672 g_post_replies SMALLINT NOT NULL DEFAULT 1, |
|
673 g_post_topics SMALLINT NOT NULL DEFAULT 1, |
|
674 g_post_polls SMALLINT NOT NULL DEFAULT 1, |
|
675 g_edit_posts SMALLINT NOT NULL DEFAULT 1, |
|
676 g_delete_posts SMALLINT NOT NULL DEFAULT 1, |
|
677 g_delete_topics SMALLINT NOT NULL DEFAULT 1, |
|
678 g_set_title SMALLINT NOT NULL DEFAULT 1, |
|
679 g_search SMALLINT NOT NULL DEFAULT 1, |
|
680 g_search_users SMALLINT NOT NULL DEFAULT 1, |
|
681 g_edit_subjects_interval SMALLINT NOT NULL DEFAULT 300, |
|
682 g_post_flood SMALLINT NOT NULL DEFAULT 30, |
|
683 g_search_flood SMALLINT NOT NULL DEFAULT 30, |
|
684 PRIMARY KEY (g_id) |
|
685 )"; |
|
686 break; |
|
687 |
|
688 case 'sqlite': |
|
689 $sql = 'CREATE TABLE '.$db_prefix."groups ( |
|
690 g_id INTEGER NOT NULL, |
|
691 g_title VARCHAR(50) NOT NULL DEFAULT '', |
|
692 g_user_title VARCHAR(50), |
|
693 g_read_board INTEGER NOT NULL DEFAULT 1, |
|
694 g_post_replies INTEGER NOT NULL DEFAULT 1, |
|
695 g_post_topics INTEGER NOT NULL DEFAULT 1, |
|
696 g_post_polls INTEGER NOT NULL DEFAULT 1, |
|
697 g_edit_posts INTEGER NOT NULL DEFAULT 1, |
|
698 g_delete_posts INTEGER NOT NULL DEFAULT 1, |
|
699 g_delete_topics INTEGER NOT NULL DEFAULT 1, |
|
700 g_set_title INTEGER NOT NULL DEFAULT 1, |
|
701 g_search INTEGER NOT NULL DEFAULT 1, |
|
702 g_search_users INTEGER NOT NULL DEFAULT 1, |
|
703 g_edit_subjects_interval INTEGER NOT NULL DEFAULT 300, |
|
704 g_post_flood INTEGER NOT NULL DEFAULT 30, |
|
705 g_search_flood INTEGER NOT NULL DEFAULT 30, |
|
706 PRIMARY KEY (g_id) |
|
707 )"; |
|
708 break; |
|
709 } |
|
710 |
|
711 $pun_db->query($sql) or error('Unable to create table '.$db_prefix.'groups. Please check your settings and try again.', __FILE__, __LINE__, $pun_db->error()); |
|
712 |
|
713 |
|
714 |
|
715 switch ($db_type) |
|
716 { |
|
717 case 'mysql': |
|
718 case 'mysqli': |
|
719 $sql = 'CREATE TABLE '.$db_prefix."online ( |
|
720 user_id INT(10) UNSIGNED NOT NULL DEFAULT 1, |
|
721 ident VARCHAR(200) NOT NULL DEFAULT '', |
|
722 logged INT(10) UNSIGNED NOT NULL DEFAULT 0, |
|
723 idle TINYINT(1) NOT NULL DEFAULT 0 |
|
724 ) TYPE=HEAP;"; |
|
725 break; |
|
726 |
|
727 case 'pgsql': |
|
728 $sql = 'CREATE TABLE '.$db_prefix."online ( |
|
729 user_id INT NOT NULL DEFAULT 1, |
|
730 ident VARCHAR(200) NOT NULL DEFAULT '', |
|
731 logged INT NOT NULL DEFAULT 0, |
|
732 idle SMALLINT NOT NULL DEFAULT 0 |
|
733 )"; |
|
734 break; |
|
735 |
|
736 case 'sqlite': |
|
737 $sql = 'CREATE TABLE '.$db_prefix."online ( |
|
738 user_id INTEGER NOT NULL DEFAULT 1, |
|
739 ident VARCHAR(200) NOT NULL DEFAULT '', |
|
740 logged INTEGER NOT NULL DEFAULT 0, |
|
741 idle INTEGER NOT NULL DEFAULT 0 |
|
742 )"; |
|
743 break; |
|
744 } |
|
745 |
|
746 $pun_db->query($sql) or error('Unable to create table '.$db_prefix.'online. Please check your settings and try again.', __FILE__, __LINE__, $pun_db->error()); |
|
747 |
|
748 |
|
749 |
|
750 switch ($db_type) |
|
751 { |
|
752 case 'mysql': |
|
753 case 'mysqli': |
|
754 $sql = 'CREATE TABLE '.$db_prefix."posts ( |
|
755 id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
756 poster VARCHAR(200) NOT NULL DEFAULT '', |
|
757 poster_id INT(10) UNSIGNED NOT NULL DEFAULT 1, |
|
758 poster_ip VARCHAR(15), |
|
759 poster_email VARCHAR(50), |
|
760 message TEXT, |
|
761 hide_smilies TINYINT(1) NOT NULL DEFAULT 0, |
|
762 posted INT(10) UNSIGNED NOT NULL DEFAULT 0, |
|
763 edited INT(10) UNSIGNED, |
|
764 edited_by VARCHAR(200), |
|
765 topic_id INT(10) UNSIGNED NOT NULL DEFAULT 0, |
|
766 PRIMARY KEY (id) |
|
767 ) TYPE=MyISAM;"; |
|
768 break; |
|
769 |
|
770 case 'pgsql': |
|
771 $sql = 'CREATE TABLE '.$db_prefix."posts ( |
|
772 id SERIAL, |
|
773 poster VARCHAR(200) NOT NULL DEFAULT '', |
|
774 poster_id INT NOT NULL DEFAULT 1, |
|
775 poster_ip VARCHAR(15), |
|
776 poster_email VARCHAR(50), |
|
777 message TEXT, |
|
778 hide_smilies SMALLINT NOT NULL DEFAULT 0, |
|
779 posted INT NOT NULL DEFAULT 0, |
|
780 edited INT, |
|
781 edited_by VARCHAR(200), |
|
782 topic_id INT NOT NULL DEFAULT 0, |
|
783 PRIMARY KEY (id) |
|
784 )"; |
|
785 break; |
|
786 |
|
787 case 'sqlite': |
|
788 $sql = 'CREATE TABLE '.$db_prefix."posts ( |
|
789 id INTEGER NOT NULL, |
|
790 poster VARCHAR(200) NOT NULL DEFAULT '', |
|
791 poster_id INTEGER NOT NULL DEFAULT 1, |
|
792 poster_ip VARCHAR(15), |
|
793 poster_email VARCHAR(50), |
|
794 message TEXT, |
|
795 hide_smilies INTEGER NOT NULL DEFAULT 0, |
|
796 posted INTEGER NOT NULL DEFAULT 0, |
|
797 edited INTEGER, |
|
798 edited_by VARCHAR(200), |
|
799 topic_id INTEGER NOT NULL DEFAULT 0, |
|
800 PRIMARY KEY (id) |
|
801 )"; |
|
802 break; |
|
803 } |
|
804 |
|
805 $pun_db->query($sql) or error('Unable to create table '.$db_prefix.'posts. Please check your settings and try again.', __FILE__, __LINE__, $pun_db->error()); |
|
806 |
|
807 |
|
808 |
|
809 switch ($db_type) |
|
810 { |
|
811 case 'mysql': |
|
812 case 'mysqli': |
|
813 $sql = 'CREATE TABLE '.$db_prefix."ranks ( |
|
814 id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
815 rank VARCHAR(50) NOT NULL DEFAULT '', |
|
816 min_posts MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT 0, |
|
817 PRIMARY KEY (id) |
|
818 ) TYPE=MyISAM;"; |
|
819 break; |
|
820 |
|
821 case 'pgsql': |
|
822 $sql = 'CREATE TABLE '.$db_prefix."ranks ( |
|
823 id SERIAL, |
|
824 rank VARCHAR(50) NOT NULL DEFAULT '', |
|
825 min_posts INT NOT NULL DEFAULT 0, |
|
826 PRIMARY KEY (id) |
|
827 )"; |
|
828 break; |
|
829 |
|
830 case 'sqlite': |
|
831 $sql = 'CREATE TABLE '.$db_prefix."ranks ( |
|
832 id INTEGER NOT NULL, |
|
833 rank VARCHAR(50) NOT NULL DEFAULT '', |
|
834 min_posts INTEGER NOT NULL DEFAULT 0, |
|
835 PRIMARY KEY (id) |
|
836 )"; |
|
837 break; |
|
838 } |
|
839 |
|
840 $pun_db->query($sql) or error('Unable to create table '.$db_prefix.'titles. Please check your settings and try again.', __FILE__, __LINE__, $pun_db->error()); |
|
841 |
|
842 |
|
843 |
|
844 switch ($db_type) |
|
845 { |
|
846 case 'mysql': |
|
847 case 'mysqli': |
|
848 $sql = 'CREATE TABLE '.$db_prefix."reports ( |
|
849 id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
850 post_id INT(10) UNSIGNED NOT NULL DEFAULT 0, |
|
851 topic_id INT(10) UNSIGNED NOT NULL DEFAULT 0, |
|
852 forum_id INT(10) UNSIGNED NOT NULL DEFAULT 0, |
|
853 reported_by INT(10) UNSIGNED NOT NULL DEFAULT 0, |
|
854 created INT(10) UNSIGNED NOT NULL DEFAULT 0, |
|
855 message TEXT, |
|
856 zapped INT(10) UNSIGNED, |
|
857 zapped_by INT(10) UNSIGNED, |
|
858 PRIMARY KEY (id) |
|
859 ) TYPE=MyISAM;"; |
|
860 break; |
|
861 |
|
862 case 'pgsql': |
|
863 $sql = 'CREATE TABLE '.$db_prefix."reports ( |
|
864 id SERIAL, |
|
865 post_id INT NOT NULL DEFAULT 0, |
|
866 topic_id INT NOT NULL DEFAULT 0, |
|
867 forum_id INT NOT NULL DEFAULT 0, |
|
868 reported_by INT NOT NULL DEFAULT 0, |
|
869 created INT NOT NULL DEFAULT 0, |
|
870 message TEXT, |
|
871 zapped INT, |
|
872 zapped_by INT, |
|
873 PRIMARY KEY (id) |
|
874 )"; |
|
875 break; |
|
876 |
|
877 case 'sqlite': |
|
878 $sql = 'CREATE TABLE '.$db_prefix."reports ( |
|
879 id INTEGER NOT NULL, |
|
880 post_id INTEGER NOT NULL DEFAULT 0, |
|
881 topic_id INTEGER NOT NULL DEFAULT 0, |
|
882 forum_id INTEGER NOT NULL DEFAULT 0, |
|
883 reported_by INTEGER NOT NULL DEFAULT 0, |
|
884 created INTEGER NOT NULL DEFAULT 0, |
|
885 message TEXT, |
|
886 zapped INTEGER, |
|
887 zapped_by INTEGER, |
|
888 PRIMARY KEY (id) |
|
889 )"; |
|
890 break; |
|
891 } |
|
892 |
|
893 $pun_db->query($sql) or error('Unable to create table '.$db_prefix.'reports. Please check your settings and try again.', __FILE__, __LINE__, $pun_db->error()); |
|
894 |
|
895 |
|
896 |
|
897 switch ($db_type) |
|
898 { |
|
899 case 'mysql': |
|
900 case 'mysqli': |
|
901 $sql = 'CREATE TABLE '.$db_prefix."search_cache ( |
|
902 id INT(10) UNSIGNED NOT NULL DEFAULT 0, |
|
903 ident VARCHAR(200) NOT NULL DEFAULT '', |
|
904 search_data TEXT, |
|
905 PRIMARY KEY (id) |
|
906 ) TYPE=MyISAM;"; |
|
907 break; |
|
908 |
|
909 case 'pgsql': |
|
910 $sql = 'CREATE TABLE '.$db_prefix."search_cache ( |
|
911 id INT NOT NULL DEFAULT 0, |
|
912 ident VARCHAR(200) NOT NULL DEFAULT '', |
|
913 search_data TEXT, |
|
914 PRIMARY KEY (id) |
|
915 )"; |
|
916 break; |
|
917 |
|
918 case 'sqlite': |
|
919 $sql = 'CREATE TABLE '.$db_prefix."search_cache ( |
|
920 id INTEGER NOT NULL DEFAULT 0, |
|
921 ident VARCHAR(200) NOT NULL DEFAULT '', |
|
922 search_data TEXT, |
|
923 PRIMARY KEY (id) |
|
924 )"; |
|
925 break; |
|
926 } |
|
927 |
|
928 $pun_db->query($sql) or error('Unable to create table '.$db_prefix.'search_cache. Please check your settings and try again.', __FILE__, __LINE__, $pun_db->error()); |
|
929 |
|
930 |
|
931 |
|
932 switch ($db_type) |
|
933 { |
|
934 case 'mysql': |
|
935 case 'mysqli': |
|
936 $sql = 'CREATE TABLE '.$db_prefix."search_matches ( |
|
937 post_id INT(10) UNSIGNED NOT NULL DEFAULT 0, |
|
938 word_id MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT 0, |
|
939 subject_match TINYINT(1) NOT NULL DEFAULT 0 |
|
940 ) TYPE=MyISAM;"; |
|
941 break; |
|
942 |
|
943 case 'pgsql': |
|
944 $sql = 'CREATE TABLE '.$db_prefix."search_matches ( |
|
945 post_id INT NOT NULL DEFAULT 0, |
|
946 word_id INT NOT NULL DEFAULT 0, |
|
947 subject_match SMALLINT NOT NULL DEFAULT 0 |
|
948 )"; |
|
949 break; |
|
950 |
|
951 case 'sqlite': |
|
952 $sql = 'CREATE TABLE '.$db_prefix."search_matches ( |
|
953 post_id INTEGER NOT NULL DEFAULT 0, |
|
954 word_id INTEGER NOT NULL DEFAULT 0, |
|
955 subject_match INTEGER NOT NULL DEFAULT 0 |
|
956 )"; |
|
957 break; |
|
958 } |
|
959 |
|
960 $pun_db->query($sql) or error('Unable to create table '.$db_prefix.'search_matches. Please check your settings and try again.', __FILE__, __LINE__, $pun_db->error()); |
|
961 |
|
962 |
|
963 |
|
964 switch ($db_type) |
|
965 { |
|
966 case 'mysql': |
|
967 case 'mysqli': |
|
968 $sql = 'CREATE TABLE '.$db_prefix."search_words ( |
|
969 id MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
970 word VARCHAR(20) BINARY NOT NULL DEFAULT '', |
|
971 PRIMARY KEY (word), |
|
972 KEY ".$db_prefix."search_words_id_idx (id) |
|
973 ) TYPE=MyISAM;"; |
|
974 break; |
|
975 |
|
976 case 'pgsql': |
|
977 $sql = 'CREATE TABLE '.$db_prefix."search_words ( |
|
978 id SERIAL, |
|
979 word VARCHAR(20) NOT NULL DEFAULT '', |
|
980 PRIMARY KEY (word) |
|
981 )"; |
|
982 break; |
|
983 |
|
984 case 'sqlite': |
|
985 $sql = 'CREATE TABLE '.$db_prefix."search_words ( |
|
986 id INTEGER NOT NULL, |
|
987 word VARCHAR(20) NOT NULL DEFAULT '', |
|
988 PRIMARY KEY (id), |
|
989 UNIQUE (word) |
|
990 )"; |
|
991 break; |
|
992 } |
|
993 |
|
994 $pun_db->query($sql) or error('Unable to create table '.$db_prefix.'search_words. Please check your settings and try again.', __FILE__, __LINE__, $pun_db->error()); |
|
995 |
|
996 |
|
997 |
|
998 switch ($db_type) |
|
999 { |
|
1000 case 'mysql': |
|
1001 case 'mysqli': |
|
1002 $sql = 'CREATE TABLE '.$db_prefix."subscriptions ( |
|
1003 user_id INT(10) UNSIGNED NOT NULL DEFAULT 0, |
|
1004 topic_id INT(10) UNSIGNED NOT NULL DEFAULT 0, |
|
1005 PRIMARY KEY (user_id, topic_id) |
|
1006 ) TYPE=MyISAM;"; |
|
1007 break; |
|
1008 |
|
1009 case 'pgsql': |
|
1010 $sql = 'CREATE TABLE '.$db_prefix."subscriptions ( |
|
1011 user_id INT NOT NULL DEFAULT 0, |
|
1012 topic_id INT NOT NULL DEFAULT 0, |
|
1013 PRIMARY KEY (user_id, topic_id) |
|
1014 )"; |
|
1015 break; |
|
1016 |
|
1017 case 'sqlite': |
|
1018 $sql = 'CREATE TABLE '.$db_prefix."subscriptions ( |
|
1019 user_id INTEGER NOT NULL DEFAULT 0, |
|
1020 topic_id INTEGER NOT NULL DEFAULT 0, |
|
1021 PRIMARY KEY (user_id, topic_id) |
|
1022 )"; |
|
1023 break; |
|
1024 } |
|
1025 |
|
1026 $pun_db->query($sql) or error('Unable to create table '.$db_prefix.'subscriptions. Please check your settings and try again.', __FILE__, __LINE__, $pun_db->error()); |
|
1027 |
|
1028 |
|
1029 |
|
1030 switch ($db_type) |
|
1031 { |
|
1032 case 'mysql': |
|
1033 case 'mysqli': |
|
1034 $sql = 'CREATE TABLE '.$db_prefix."topics ( |
|
1035 id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
1036 poster VARCHAR(200) NOT NULL DEFAULT '', |
|
1037 subject VARCHAR(255) NOT NULL DEFAULT '', |
|
1038 posted INT(10) UNSIGNED NOT NULL DEFAULT 0, |
|
1039 last_post INT(10) UNSIGNED NOT NULL DEFAULT 0, |
|
1040 last_post_id INT(10) UNSIGNED NOT NULL DEFAULT 0, |
|
1041 last_poster VARCHAR(200), |
|
1042 num_views MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT 0, |
|
1043 num_replies MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT 0, |
|
1044 closed TINYINT(1) NOT NULL DEFAULT 0, |
|
1045 sticky TINYINT(1) NOT NULL DEFAULT 0, |
|
1046 moved_to INT(10) UNSIGNED, |
|
1047 forum_id INT(10) UNSIGNED NOT NULL DEFAULT 0, |
|
1048 PRIMARY KEY (id) |
|
1049 ) TYPE=MyISAM;"; |
|
1050 break; |
|
1051 |
|
1052 case 'pgsql': |
|
1053 $sql = 'CREATE TABLE '.$db_prefix."topics ( |
|
1054 id SERIAL, |
|
1055 poster VARCHAR(200) NOT NULL DEFAULT '', |
|
1056 subject VARCHAR(255) NOT NULL DEFAULT '', |
|
1057 posted INT NOT NULL DEFAULT 0, |
|
1058 last_post INT NOT NULL DEFAULT 0, |
|
1059 last_post_id INT NOT NULL DEFAULT 0, |
|
1060 last_poster VARCHAR(200), |
|
1061 num_views INT NOT NULL DEFAULT 0, |
|
1062 num_replies INT NOT NULL DEFAULT 0, |
|
1063 closed SMALLINT NOT NULL DEFAULT 0, |
|
1064 sticky SMALLINT NOT NULL DEFAULT 0, |
|
1065 moved_to INT, |
|
1066 forum_id INT NOT NULL DEFAULT 0, |
|
1067 PRIMARY KEY (id) |
|
1068 )"; |
|
1069 break; |
|
1070 |
|
1071 case 'sqlite': |
|
1072 $sql = 'CREATE TABLE '.$db_prefix."topics ( |
|
1073 id INTEGER NOT NULL, |
|
1074 poster VARCHAR(200) NOT NULL DEFAULT '', |
|
1075 subject VARCHAR(255) NOT NULL DEFAULT '', |
|
1076 posted INTEGER NOT NULL DEFAULT 0, |
|
1077 last_post INTEGER NOT NULL DEFAULT 0, |
|
1078 last_post_id INTEGER NOT NULL DEFAULT 0, |
|
1079 last_poster VARCHAR(200), |
|
1080 num_views INTEGER NOT NULL DEFAULT 0, |
|
1081 num_replies INTEGER NOT NULL DEFAULT 0, |
|
1082 closed INTEGER NOT NULL DEFAULT 0, |
|
1083 sticky INTEGER NOT NULL DEFAULT 0, |
|
1084 moved_to INTEGER, |
|
1085 forum_id INTEGER NOT NULL DEFAULT 0, |
|
1086 PRIMARY KEY (id) |
|
1087 )"; |
|
1088 break; |
|
1089 } |
|
1090 |
|
1091 $pun_db->query($sql) or error('Unable to create table '.$db_prefix.'topics. Please check your settings and try again.', __FILE__, __LINE__, $pun_db->error()); |
|
1092 |
|
1093 |
|
1094 |
|
1095 switch ($db_type) |
|
1096 { |
|
1097 case 'mysql': |
|
1098 case 'mysqli': |
|
1099 $sql = 'CREATE TABLE '.$db_prefix."users ( |
|
1100 id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
1101 group_id INT(10) UNSIGNED NOT NULL DEFAULT 4, |
|
1102 username VARCHAR(200) NOT NULL DEFAULT '', |
|
1103 password VARCHAR(40) NOT NULL DEFAULT '', |
|
1104 email VARCHAR(50) NOT NULL DEFAULT '', |
|
1105 title VARCHAR(50), |
|
1106 realname VARCHAR(40), |
|
1107 url VARCHAR(100), |
|
1108 jabber VARCHAR(75), |
|
1109 icq VARCHAR(12), |
|
1110 msn VARCHAR(50), |
|
1111 aim VARCHAR(30), |
|
1112 yahoo VARCHAR(30), |
|
1113 location VARCHAR(30), |
|
1114 use_avatar TINYINT(1) NOT NULL DEFAULT 0, |
|
1115 signature TEXT, |
|
1116 disp_topics TINYINT(3) UNSIGNED, |
|
1117 disp_posts TINYINT(3) UNSIGNED, |
|
1118 email_setting TINYINT(1) NOT NULL DEFAULT 1, |
|
1119 save_pass TINYINT(1) NOT NULL DEFAULT 1, |
|
1120 notify_with_post TINYINT(1) NOT NULL DEFAULT 0, |
|
1121 show_smilies TINYINT(1) NOT NULL DEFAULT 1, |
|
1122 show_img TINYINT(1) NOT NULL DEFAULT 1, |
|
1123 show_img_sig TINYINT(1) NOT NULL DEFAULT 1, |
|
1124 show_avatars TINYINT(1) NOT NULL DEFAULT 1, |
|
1125 show_sig TINYINT(1) NOT NULL DEFAULT 1, |
|
1126 timezone FLOAT NOT NULL DEFAULT 0, |
|
1127 language VARCHAR(25) NOT NULL DEFAULT 'English', |
|
1128 style VARCHAR(25) NOT NULL DEFAULT 'Oxygen', |
|
1129 num_posts INT(10) UNSIGNED NOT NULL DEFAULT 0, |
|
1130 last_post INT(10) UNSIGNED, |
|
1131 registered INT(10) UNSIGNED NOT NULL DEFAULT 0, |
|
1132 registration_ip VARCHAR(15) NOT NULL DEFAULT '0.0.0.0', |
|
1133 last_visit INT(10) UNSIGNED NOT NULL DEFAULT 0, |
|
1134 admin_note VARCHAR(30), |
|
1135 activate_string VARCHAR(50), |
|
1136 activate_key VARCHAR(8), |
|
1137 PRIMARY KEY (id) |
|
1138 ) TYPE=MyISAM;"; |
|
1139 break; |
|
1140 |
|
1141 case 'pgsql': |
|
1142 $sql = 'CREATE TABLE '.$db_prefix."users ( |
|
1143 id SERIAL, |
|
1144 group_id INT NOT NULL DEFAULT 4, |
|
1145 username VARCHAR(200) NOT NULL DEFAULT '', |
|
1146 password VARCHAR(40) NOT NULL DEFAULT '', |
|
1147 email VARCHAR(50) NOT NULL DEFAULT '', |
|
1148 title VARCHAR(50), |
|
1149 realname VARCHAR(40), |
|
1150 url VARCHAR(100), |
|
1151 jabber VARCHAR(75), |
|
1152 icq VARCHAR(12), |
|
1153 msn VARCHAR(50), |
|
1154 aim VARCHAR(30), |
|
1155 yahoo VARCHAR(30), |
|
1156 location VARCHAR(30), |
|
1157 use_avatar SMALLINT NOT NULL DEFAULT 0, |
|
1158 signature TEXT, |
|
1159 disp_topics SMALLINT, |
|
1160 disp_posts SMALLINT, |
|
1161 email_setting SMALLINT NOT NULL DEFAULT 1, |
|
1162 save_pass SMALLINT NOT NULL DEFAULT 1, |
|
1163 notify_with_post SMALLINT NOT NULL DEFAULT 0, |
|
1164 show_smilies SMALLINT NOT NULL DEFAULT 1, |
|
1165 show_img SMALLINT NOT NULL DEFAULT 1, |
|
1166 show_img_sig SMALLINT NOT NULL DEFAULT 1, |
|
1167 show_avatars SMALLINT NOT NULL DEFAULT 1, |
|
1168 show_sig SMALLINT NOT NULL DEFAULT 1, |
|
1169 timezone REAL NOT NULL DEFAULT 0, |
|
1170 language VARCHAR(25) NOT NULL DEFAULT 'English', |
|
1171 style VARCHAR(25) NOT NULL DEFAULT 'Oxygen', |
|
1172 num_posts INT NOT NULL DEFAULT 0, |
|
1173 last_post INT, |
|
1174 registered INT NOT NULL DEFAULT 0, |
|
1175 registration_ip VARCHAR(15) NOT NULL DEFAULT '0.0.0.0', |
|
1176 last_visit INT NOT NULL DEFAULT 0, |
|
1177 admin_note VARCHAR(30), |
|
1178 activate_string VARCHAR(50), |
|
1179 activate_key VARCHAR(8), |
|
1180 PRIMARY KEY (id) |
|
1181 )"; |
|
1182 break; |
|
1183 |
|
1184 case 'sqlite': |
|
1185 $sql = 'CREATE TABLE '.$db_prefix."users ( |
|
1186 id INTEGER NOT NULL, |
|
1187 group_id INTEGER NOT NULL DEFAULT 4, |
|
1188 username VARCHAR(200) NOT NULL DEFAULT '', |
|
1189 password VARCHAR(40) NOT NULL DEFAULT '', |
|
1190 email VARCHAR(50) NOT NULL DEFAULT '', |
|
1191 title VARCHAR(50), |
|
1192 realname VARCHAR(40), |
|
1193 url VARCHAR(100), |
|
1194 jabber VARCHAR(75), |
|
1195 icq VARCHAR(12), |
|
1196 msn VARCHAR(50), |
|
1197 aim VARCHAR(30), |
|
1198 yahoo VARCHAR(30), |
|
1199 location VARCHAR(30), |
|
1200 use_avatar INTEGER NOT NULL DEFAULT 0, |
|
1201 signature TEXT, |
|
1202 disp_topics INTEGER, |
|
1203 disp_posts INTEGER, |
|
1204 email_setting INTEGER NOT NULL DEFAULT 1, |
|
1205 save_pass INTEGER NOT NULL DEFAULT 1, |
|
1206 notify_with_post INTEGER NOT NULL DEFAULT 0, |
|
1207 show_smilies INTEGER NOT NULL DEFAULT 1, |
|
1208 show_img INTEGER NOT NULL DEFAULT 1, |
|
1209 show_img_sig INTEGER NOT NULL DEFAULT 1, |
|
1210 show_avatars INTEGER NOT NULL DEFAULT 1, |
|
1211 show_sig INTEGER NOT NULL DEFAULT 1, |
|
1212 timezone FLOAT NOT NULL DEFAULT 0, |
|
1213 language VARCHAR(25) NOT NULL DEFAULT 'English', |
|
1214 style VARCHAR(25) NOT NULL DEFAULT 'Oxygen', |
|
1215 num_posts INTEGER NOT NULL DEFAULT 0, |
|
1216 last_post INTEGER, |
|
1217 registered INTEGER NOT NULL DEFAULT 0, |
|
1218 registration_ip VARCHAR(15) NOT NULL DEFAULT '0.0.0.0', |
|
1219 last_visit INTEGER NOT NULL DEFAULT 0, |
|
1220 admin_note VARCHAR(30), |
|
1221 activate_string VARCHAR(50), |
|
1222 activate_key VARCHAR(8), |
|
1223 PRIMARY KEY (id) |
|
1224 )"; |
|
1225 break; |
|
1226 } |
|
1227 |
|
1228 $pun_db->query($sql) or error('Unable to create table '.$db_prefix.'users. Please check your settings and try again.', __FILE__, __LINE__, $pun_db->error()); |
|
1229 |
|
1230 |
|
1231 // Add some indexes |
|
1232 switch ($db_type) |
|
1233 { |
|
1234 case 'mysql': |
|
1235 case 'mysqli': |
|
1236 // We use MySQL's ALTER TABLE ... ADD INDEX syntax instead of CREATE INDEX to avoid problems with users lacking the INDEX privilege |
|
1237 $queries[] = 'ALTER TABLE '.$db_prefix.'online ADD UNIQUE INDEX '.$db_prefix.'online_user_id_ident_idx(user_id,ident)'; |
|
1238 $queries[] = 'ALTER TABLE '.$db_prefix.'online ADD INDEX '.$db_prefix.'online_user_id_idx(user_id)'; |
|
1239 $queries[] = 'ALTER TABLE '.$db_prefix.'posts ADD INDEX '.$db_prefix.'posts_topic_id_idx(topic_id)'; |
|
1240 $queries[] = 'ALTER TABLE '.$db_prefix.'posts ADD INDEX '.$db_prefix.'posts_multi_idx(poster_id, topic_id)'; |
|
1241 $queries[] = 'ALTER TABLE '.$db_prefix.'reports ADD INDEX '.$db_prefix.'reports_zapped_idx(zapped)'; |
|
1242 $queries[] = 'ALTER TABLE '.$db_prefix.'search_matches ADD INDEX '.$db_prefix.'search_matches_word_id_idx(word_id)'; |
|
1243 $queries[] = 'ALTER TABLE '.$db_prefix.'search_matches ADD INDEX '.$db_prefix.'search_matches_post_id_idx(post_id)'; |
|
1244 $queries[] = 'ALTER TABLE '.$db_prefix.'topics ADD INDEX '.$db_prefix.'topics_forum_id_idx(forum_id)'; |
|
1245 $queries[] = 'ALTER TABLE '.$db_prefix.'topics ADD INDEX '.$db_prefix.'topics_moved_to_idx(moved_to)'; |
|
1246 $queries[] = 'ALTER TABLE '.$db_prefix.'users ADD INDEX '.$db_prefix.'users_registered_idx(registered)'; |
|
1247 $queries[] = 'ALTER TABLE '.$db_prefix.'search_cache ADD INDEX '.$db_prefix.'search_cache_ident_idx(ident(8))'; |
|
1248 $queries[] = 'ALTER TABLE '.$db_prefix.'users ADD INDEX '.$db_prefix.'users_username_idx(username(8))'; |
|
1249 break; |
|
1250 |
|
1251 default: |
|
1252 $queries[] = 'CREATE INDEX '.$db_prefix.'online_user_id_idx ON '.$db_prefix.'online(user_id)'; |
|
1253 $queries[] = 'CREATE INDEX '.$db_prefix.'posts_topic_id_idx ON '.$db_prefix.'posts(topic_id)'; |
|
1254 $queries[] = 'CREATE INDEX '.$db_prefix.'posts_multi_idx ON '.$db_prefix.'posts(poster_id, topic_id)'; |
|
1255 $queries[] = 'CREATE INDEX '.$db_prefix.'reports_zapped_idx ON '.$db_prefix.'reports(zapped)'; |
|
1256 $queries[] = 'CREATE INDEX '.$db_prefix.'search_matches_word_id_idx ON '.$db_prefix.'search_matches(word_id)'; |
|
1257 $queries[] = 'CREATE INDEX '.$db_prefix.'search_matches_post_id_idx ON '.$db_prefix.'search_matches(post_id)'; |
|
1258 $queries[] = 'CREATE INDEX '.$db_prefix.'topics_forum_id_idx ON '.$db_prefix.'topics(forum_id)'; |
|
1259 $queries[] = 'CREATE INDEX '.$db_prefix.'topics_moved_to_idx ON '.$db_prefix.'topics(moved_to)'; |
|
1260 $queries[] = 'CREATE INDEX '.$db_prefix.'users_registered_idx ON '.$db_prefix.'users(registered)'; |
|
1261 $queries[] = 'CREATE INDEX '.$db_prefix.'users_username_idx ON '.$db_prefix.'users(username)'; |
|
1262 $queries[] = 'CREATE INDEX '.$db_prefix.'search_cache_ident_idx ON '.$db_prefix.'search_cache(ident)'; |
|
1263 $queries[] = 'CREATE INDEX '.$db_prefix.'search_words_id_idx ON '.$db_prefix.'search_words(id)'; |
|
1264 break; |
|
1265 } |
|
1266 |
|
1267 @reset($queries); |
|
1268 while (list(, $sql) = @each($queries)) |
|
1269 $pun_db->query($sql) or error('Unable to create indexes. Please check your configuration and try again.', __FILE__, __LINE__, $pun_db->error()); |
|
1270 |
|
1271 |
|
1272 |
|
1273 $now = time(); |
|
1274 |
|
1275 // Insert the four preset groups |
|
1276 $pun_db->query('INSERT INTO '.$pun_db->prefix."groups (g_title, g_user_title, g_read_board, g_post_replies, g_post_topics, g_post_polls, g_edit_posts, g_delete_posts, g_delete_topics, g_set_title, g_search, g_search_users, g_edit_subjects_interval, g_post_flood, g_search_flood) VALUES('Administrators', 'Administrator', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0)") or error('Unable to add group', __FILE__, __LINE__, $pun_db->error()); |
|
1277 $pun_db->query('INSERT INTO '.$pun_db->prefix."groups (g_title, g_user_title, g_read_board, g_post_replies, g_post_topics, g_post_polls, g_edit_posts, g_delete_posts, g_delete_topics, g_set_title, g_search, g_search_users, g_edit_subjects_interval, g_post_flood, g_search_flood) VALUES('Moderators', 'Moderator', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0)") or error('Unable to add group', __FILE__, __LINE__, $pun_db->error()); |
|
1278 $pun_db->query('INSERT INTO '.$pun_db->prefix."groups (g_title, g_user_title, g_read_board, g_post_replies, g_post_topics, g_post_polls, g_edit_posts, g_delete_posts, g_delete_topics, g_set_title, g_search, g_search_users, g_edit_subjects_interval, g_post_flood, g_search_flood) VALUES('Guest', NULL, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0)") or error('Unable to add group', __FILE__, __LINE__, $pun_db->error()); |
|
1279 $pun_db->query('INSERT INTO '.$pun_db->prefix."groups (g_title, g_user_title, g_read_board, g_post_replies, g_post_topics, g_post_polls, g_edit_posts, g_delete_posts, g_delete_topics, g_set_title, g_search, g_search_users, g_edit_subjects_interval, g_post_flood, g_search_flood) VALUES('Members', NULL, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 300, 60, 30)") or error('Unable to add group', __FILE__, __LINE__, $pun_db->error()); |
|
1280 |
|
1281 // Insert guest and first admin user |
|
1282 $pun_db->query('INSERT INTO '.$db_prefix."users (group_id, username, password, email) VALUES(3, 'Guest', 'Guest', 'Guest')") |
|
1283 or error('Unable to add guest user. Please check your configuration and try again.'); |
|
1284 |
|
1285 $pun_db->query('INSERT INTO '.$db_prefix."users (group_id, username, password, email, num_posts, last_post, registered, registration_ip, last_visit) VALUES(1, '".$pun_db->escape($username)."', '".pun_hash($password1)."', '$email', 1, ".$now.", ".$now.", '127.0.0.1', ".$now.')') |
|
1286 or error('Unable to add administrator user. Please check your configuration and try again.'); |
|
1287 |
|
1288 // Insert config data |
|
1289 $config = array( |
|
1290 'o_cur_version' => "'$punbb_version'", |
|
1291 'o_board_title' => "'My PunBB forum'", |
|
1292 'o_board_desc' => "'Unfortunately no one can be told what PunBB is - you have to see it for yourself.'", |
|
1293 'o_server_timezone' => "'0'", |
|
1294 'o_time_format' => "'H:i:s'", |
|
1295 'o_date_format' => "'Y-m-d'", |
|
1296 'o_timeout_visit' => "'600'", |
|
1297 'o_timeout_online' => "'300'", |
|
1298 'o_redirect_delay' => "'1'", |
|
1299 'o_show_version' => "'0'", |
|
1300 'o_show_user_info' => "'1'", |
|
1301 'o_show_post_count' => "'1'", |
|
1302 'o_smilies' => "'1'", |
|
1303 'o_smilies_sig' => "'1'", |
|
1304 'o_make_links' => "'1'", |
|
1305 'o_default_lang' => "'English'", |
|
1306 'o_default_style' => "'Oxygen'", |
|
1307 'o_default_user_group' => "'4'", |
|
1308 'o_topic_review' => "'15'", |
|
1309 'o_disp_topics_default' => "'30'", |
|
1310 'o_disp_posts_default' => "'25'", |
|
1311 'o_indent_num_spaces' => "'4'", |
|
1312 'o_quickpost' => "'1'", |
|
1313 'o_users_online' => "'1'", |
|
1314 'o_censoring' => "'0'", |
|
1315 'o_ranks' => "'1'", |
|
1316 'o_show_dot' => "'0'", |
|
1317 'o_quickjump' => "'1'", |
|
1318 'o_gzip' => "'0'", |
|
1319 'o_additional_navlinks' => "''", |
|
1320 'o_report_method' => "'0'", |
|
1321 'o_regs_report' => "'0'", |
|
1322 'o_mailing_list' => "'$email'", |
|
1323 'o_avatars' => "'1'", |
|
1324 'o_avatars_dir' => "'img/avatars'", |
|
1325 'o_avatars_width' => "'60'", |
|
1326 'o_avatars_height' => "'60'", |
|
1327 'o_avatars_size' => "'10240'", |
|
1328 'o_search_all_forums' => "'1'", |
|
1329 'o_base_url' => "'$base_url'", |
|
1330 'o_admin_email' => "'$email'", |
|
1331 'o_webmaster_email' => "'$email'", |
|
1332 'o_subscriptions' => "'1'", |
|
1333 'o_smtp_host' => "NULL", |
|
1334 'o_smtp_user' => "NULL", |
|
1335 'o_smtp_pass' => "NULL", |
|
1336 'o_regs_allow' => "'1'", |
|
1337 'o_regs_verify' => "'0'", |
|
1338 'o_announcement' => "'0'", |
|
1339 'o_announcement_message' => "'Enter your announcement here.'", |
|
1340 'o_rules' => "'0'", |
|
1341 'o_rules_message' => "'Enter your rules here.'", |
|
1342 'o_maintenance' => "'0'", |
|
1343 'o_maintenance_message' => "'The forums are temporarily down for maintenance. Please try again in a few minutes.<br />\\n<br />\\n/Administrator'", |
|
1344 'p_mod_edit_users' => "'1'", |
|
1345 'p_mod_rename_users' => "'0'", |
|
1346 'p_mod_change_passwords' => "'0'", |
|
1347 'p_mod_ban_users' => "'0'", |
|
1348 'p_message_bbcode' => "'1'", |
|
1349 'p_message_img_tag' => "'1'", |
|
1350 'p_message_all_caps' => "'1'", |
|
1351 'p_subject_all_caps' => "'1'", |
|
1352 'p_sig_all_caps' => "'1'", |
|
1353 'p_sig_bbcode' => "'1'", |
|
1354 'p_sig_img_tag' => "'0'", |
|
1355 'p_sig_length' => "'400'", |
|
1356 'p_sig_lines' => "'4'", |
|
1357 'p_allow_banned_email' => "'1'", |
|
1358 'p_allow_dupe_email' => "'0'", |
|
1359 'p_force_guest_email' => "'1'" |
|
1360 ); |
|
1361 |
|
1362 while (list($conf_name, $conf_value) = @each($config)) |
|
1363 { |
|
1364 $pun_db->query('INSERT INTO '.$db_prefix."config (conf_name, conf_value) VALUES('$conf_name', $conf_value)") |
|
1365 or error('Unable to insert into table '.$db_prefix.'config. Please check your configuration and try again.'); |
|
1366 } |
|
1367 |
|
1368 // Insert some other default data |
|
1369 $pun_db->query('INSERT INTO '.$db_prefix."categories (cat_name, disp_position) VALUES('Test category', 1)") |
|
1370 or error('Unable to insert into table '.$db_prefix.'categories. Please check your configuration and try again.'); |
|
1371 |
|
1372 $pun_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, '".$pun_db->escape($username)."', 1, 1)") |
|
1373 or error('Unable to insert into table '.$db_prefix.'forums. Please check your configuration and try again.'); |
|
1374 |
|
1375 $pun_db->query('INSERT INTO '.$db_prefix."topics (poster, subject, posted, last_post, last_post_id, last_poster, forum_id) VALUES('".$pun_db->escape($username)."', 'Test post', ".$now.", ".$now.", 1, '".$pun_db->escape($username)."', 1)") |
|
1376 or error('Unable to insert into table '.$db_prefix.'topics. Please check your configuration and try again.'); |
|
1377 |
|
1378 $pun_db->query('INSERT INTO '.$db_prefix."posts (poster, poster_id, poster_ip, message, posted, topic_id) VALUES('".$pun_db->escape($username)."', 2, '127.0.0.1', 'If you are looking at this (which I guess you are), the install of PunBB appears to have worked! Now log in and head over to the administration control panel to configure your forum.', ".$now.', 1)') |
|
1379 or error('Unable to insert into table '.$db_prefix.'posts. Please check your configuration and try again.'); |
|
1380 |
|
1381 $pun_db->query('INSERT INTO '.$db_prefix."ranks (rank, min_posts) VALUES('New member', 0)") |
|
1382 or error('Unable to insert into table '.$db_prefix.'ranks. Please check your configuration and try again.'); |
|
1383 |
|
1384 $pun_db->query('INSERT INTO '.$db_prefix."ranks (rank, min_posts) VALUES('Member', 10)") |
|
1385 or error('Unable to insert into table '.$db_prefix.'ranks. Please check your configuration and try again.'); |
|
1386 |
|
1387 |
|
1388 if ($db_type == 'pgsql' || $db_type == 'sqlite') |
|
1389 $pun_db->end_transaction(); |
|
1390 |
|
1391 |
|
1392 |
|
1393 $alerts = ''; |
|
1394 // Check if the cache directory is writable |
|
1395 if (!@is_writable('./cache/')) |
|
1396 $alerts .= '<p style="font-size: 1.1em"><span style="color: #C03000"><strong>The cache directory is currently not writable!</strong></span> In order for PunBB 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.</p>'; |
|
1397 |
|
1398 // Check if default avatar directory is writable |
|
1399 if (!@is_writable('./img/avatars/')) |
|
1400 $alerts .= '<p style="font-size: 1.1em"><span style="color: #C03000"><strong>The avatar directory is currently not writable!</strong></span> 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.</p>'; |
|
1401 |
|
1402 |
|
1403 /// Display config.php and give further instructions |
|
1404 $config = '<?php'."\n\n".'$db_type = \''.$db_type."';\n".'$db_host = \''.$db_host."';\n".'$db_name = \''.$db_name."';\n".'$db_username = \''.$db_username."';\n".'$db_password = \''.$db_password."';\n".'$db_prefix = \''.$db_prefix."';\n".'$p_connect = false;'."\n\n".'$cookie_name = '."'punbb_cookie';\n".'$cookie_domain = '."'';\n".'$cookie_path = '."'/';\n".'$cookie_secure = 0;'."\n".'$cookie_seed = \''.substr(md5(time()), -8)."';\n\ndefine('PUN', 1);"; |
|
1405 |
|
1406 |
|
1407 ?> |
|
1408 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
|
1409 |
|
1410 <html> |
|
1411 <head> |
|
1412 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> |
|
1413 <title>PunBB Installation</title> |
|
1414 <link rel="stylesheet" type="text/css" href="style/Oxygen.css" /> |
|
1415 </head> |
|
1416 <body> |
|
1417 |
|
1418 <div id="puninstall" style="margin: auto 10% auto 10%"> |
|
1419 <div class="pun"> |
|
1420 |
|
1421 <div class="blockform"> |
|
1422 <h2>Final instructions</h2> |
|
1423 <div class="box"> |
|
1424 <div class="fakeform"> |
|
1425 <div class="inform"> |
|
1426 <div class="forminfo"> |
|
1427 <p>To finalize the installation all you need to do is to <strong>copy and paste the text in the text box below into a file called config.php and then upload this file to the root directory of your PunBB installation</strong>. Make sure there are no linebreaks or spaces before <?php. You can later edit config.php if you reconfigure your setup (e.g. change the database password or ).</p> |
|
1428 <?php if ($alerts != ''): ?> <?php echo $alerts."\n" ?> |
|
1429 <?php endif; ?> </div> |
|
1430 <fieldset> |
|
1431 <legend>Copy contents to config.php</legend> |
|
1432 <div class="infldset"> |
|
1433 <textarea cols="80" rows="20"><?php echo htmlspecialchars($config) ?></textarea> |
|
1434 </div> |
|
1435 </fieldset> |
|
1436 </div> |
|
1437 <div class="inform"> |
|
1438 <div class="forminfo"> |
|
1439 <p>Once you have created config.php with the contents above, PunBB is installed!</p> |
|
1440 <p><a href="index.php">Go to forum index</a></p> |
|
1441 </div> |
|
1442 </div> |
|
1443 </div> |
|
1444 </div> |
|
1445 </div> |
|
1446 |
|
1447 </div> |
|
1448 </div> |
|
1449 |
|
1450 </body> |
|
1451 </html> |
|
1452 <?php |
|
1453 |
|
1454 } |
|