root/trunk/install.php

Revision 307, 26.8 kB (checked in by hannes, 3 years ago)

untested attempt at replacing member status with group based functionality

Line 
1 <?php
2
3 /**
4  * Package: Spam Board 5
5  * File: install.php
6  * Description: script to initialize a new board
7  *
8  * Copyright (C) 2007, 2008, 2009 Hannes Schueller
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU Affero General Public License as
12  * published by the Free Software Foundation, version 3 of the
13  * License.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Affero General Public License for more details.
19  *
20  * You should have received a copy of the GNU Affero General Public License
21  * along with this program (see LICENCE). If not,
22  * see <http://www.gnu.org/licenses/>.
23  **/
24
25 // number of the page which actually writes all the settings
26 $commitpage = 9;
27 $overviewpage = $commitpage - 1;
28
29 // global settings template (has a few defaults)
30 require_once('includes/config/settings.tmpl');
31
32 // import version number
33 require_once('includes/config/version.php');
34
35 // get formatting class
36 require_once('classes/misc/Format.php');
37 // initialize formatting object
38 $F = new Format();
39
40 // language file
41 require('includes/lang/' . $SETTINGS['language'] . '.php');
42
43 // input validation
44 require_once('includes/input.php');
45
46 // start output in order to set correct character encoding
47 header('Content-Type: text/html; charset=' . $SETTINGS['encoding']);
48
49 // default page
50 if (!isset($INPUT['page']) || $INPUT['page'] == '') {
51     $INPUT['page'] = 1;
52 }
53
54 // check if the user wants to start over
55 if (isset($INPUT['submit']) && $INPUT['submit'] == $LANG['Start_Over']) {
56     $INPUT['page'] = 1;
57     $SETUPDATA = Array();
58 } else {
59     $SETUPDATA = $_POST['SETUPDATA'];
60 }
61
62 // define next page number
63 $nextpage = $INPUT['page'] + 1;
64
65 // since this is important, define the order in which the password hashes should be suggested
66 $hashes_default = Array();
67 $hashes_default[0] = 'sha512';
68 $hashes_default[1] = 'ripemd320';
69 $hashes_default[2] = 'sha384';
70 $hashes_default[3] = 'ripemd256';
71 $hashes_default[4] = 'sha256';
72 $hashes_default[5] = 'ripemd160';
73 $hashes_default[6] = 'ripemd128';
74 $hashes_default[7] = 'sha1';
75 // available
76 $hashes = hash_algos();
77 for ($i = 7; $i <= 0; $i--) {
78     if (in_array($hashes_default[$i], $hashes)) {
79         // use this hash as default
80         $SETTINGS['hash'] = $hashes_default[$i];
81     }
82 }
83
84 // unlike all the other pages, this installer is a little simpler and prints output directly
85 print('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
86 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
87     <head>
88         <title>' . $LANG['Spam_Board_Installer'] . '</title>
89     </head>
90     <body>
91         <h1>' . $LANG['Spam_Board_Installer'] . '</h1>
92         <h2>' . $LANG['Page'] . ' ' . $INPUT['page'] . ' / ' . $commitpage . '</h2>
93         <form action="install.php" method="post">
94             <input type="hidden" name="page" value="' . $nextpage . '" />
95 ');
96
97 switch ($INPUT['page']) {
98     case $commitpage:
99         /* commit */
100         $ok = 1;
101         // set file permissions
102         if ($SETUPDATA['set_permissions'] == 1) {
103             if (@chmod('attachments', 0755)) {
104                 if (@chmod('db', 0700)) {
105                     if (@chmod('sessions', 0700)) {
106                         if (@chmod('images/avatars', 0755)) {
107                             if (@chmod('includes/config', 0700)) {
108                                 if (@chmod('includes/wrappers', 0700)) {
109                                     $ok = 1;
110                                 } else { $ok = 0; }
111                             } else { $ok = 0; }
112                         } else { $ok = 0; }
113                     } else { $ok = 0; }
114                 } else { $ok = 0; }
115             } else { $ok = 0; }
116             if ($ok == 1) {
117                 print($LANG['installer_permissions_success'] . '<br /><br />');
118             } else {
119                 print($LANG['error_installer_permissions']);
120             }
121         }
122         if ($ok == 1) {
123             // set up Apache URL rewriting
124             if ($SETUPDATA['url_rewriting'] == 1) {
125                 // create .htaccess
126                 if ($handle = @fopen('.htaccess', 'w')) {
127                     if (@fwrite($handle, "RewriteEngine On\n\nRewriteBase " . $SETUPDATA['webpath'] . "\n\nRewriteRule ^index\.php$ index.php [L]\nRewriteRule ^install\.php$ install.php [L]\nRewriteRule ^([a-z]+)\.php$ index.php?show=$1&%{QUERY_STRING} [L]\n\nOptions -Indexes\n")) {
128                         // set chmod
129                         @chmod('.htaccess', 0644);
130                     } else { $ok = 0; }
131                 } else { $ok = 0; }
132                 // create admin/.htaccess
133                 if ($handle = @fopen('admin/.htaccess', 'w')) {
134                     if (@fwrite($handle, "RewriteEngine On\n\nRewriteBase " . $SETUPDATA['webpath'] . "admin/\n\nRewriteRule ^index\.php$ index.php [L]\nRewriteRule ^([a-z]+)\.php$ index.php?show=$1&%{QUERY_STRING} [L]\n\nOptions -Indexes\n")) {
135                         // set chmod
136                         @chmod('admin/.htaccess', 0644);
137                     } else { $ok = 0; }
138                 } else { $ok = 0; }
139                 if ($ok == 1) {
140                     print($LANG['installer_rewriting_success'] . '<br /><br />');
141                 } else {
142                     print($LANG['error_installer_rewriting'] . '<br /><br />');
143                 }
144             }
145             if ($ok == 1) {
146                 /* write settings.php */
147                 // open settings file for write access
148                 if ($file = @fopen('includes/config/settings.php', 'w')) {
149                     // write settings
150                     fwrite($file, "<?php\n\n");
151                     fwrite($file, "/**\n * Package: Spam Board 5\n * File: includes/config/settings.php\n * Description: global board settings (usually modified through admin panel)\n **/\n\n");
152                     fwrite($file, "\$SETTINGS['maintainancemode'] = " . $SETTINGS['maintainancemode'] . "; // put the board into maintainance mode (1/0); only admins can use it then\n");
153                     fwrite($file, "\$SETTINGS['sqltype'] = '" . $SETUPDATA['sqltype'] . "'; // type of SQL database (e.g. SQLite)\n");
154                     fwrite($file, "\$SETTINGS['sqlhost'] = '" . $SETUPDATA['sqlhost'] . "'; // hostname for the SQL database (usually localhost)\n");
155                     fwrite($file, "\$SETTINGS['sqluser'] = '" . $SETUPDATA['sqluser'] . "'; // username for SQL\n");
156                     fwrite($file, "\$SETTINGS['sqlpassword'] = '" . $SETUPDATA['sqlpassword'] . "'; // password for SQL\n");
157                     fwrite($file, "\$SETTINGS['dbname'] = '" . $SETUPDATA['sqldatabase'] . "'; // name of the SQL database\n");
158                     fwrite($file, "\$SETTINGS['dbtableprefix'] = '" . $SETUPDATA['sqltableprefix'] . "'; // prefix of all the database tables\n");
159                     fwrite($file, "\$SETTINGS['fspath'] = '" . $SETUPDATA['fspath'] . "'; // full file system path to the forum root\n");
160                     fwrite($file, "\$SETTINGS['webpath'] = '" . $SETUPDATA['webpath'] . "'; // path to the forum from domain's root\n");
161                     fwrite($file, "\$SETTINGS['cookiepath'] = '" . $SETUPDATA['cookiepath'] . "'; // path of the cookies\n");
162                     fwrite($file, "\$SETTINGS['forumname'] = '" . $SETUPDATA['forumname'] . "'; // displayed in browser's title and used for outgoing e-mail\n");
163                     fwrite($file, "\$SETTINGS['slogan'] = '" . $SETUPDATA['slogan'] . "'; // displayed in browser's title\n");
164                     fwrite($file, "\$SETTINGS['forumlogo'] = '" . $SETUPDATA['forumlogo'] . "'; // has to be placed in the images directory\n");
165                     fwrite($file, "\$SETTINGS['sitename'] = '" . $SETUPDATA['sitename'] . "'; // name of the site the forum should link back to\n");
166                     fwrite($file, "\$SETTINGS['siteurl'] = '" . $SETUPDATA['siteurl'] . "'; // URL of the site the forum should link back to\n");
167                     fwrite($file, "\$SETTINGS['forumadmin'] = '" . $SETUPDATA['forumadmin'] . "'; // The admin's name. This'll be used to 'sign' all outgoing e-mail.\n");
168                     fwrite($file, "\$SETTINGS['forumadminemail'] = '" . $SETUPDATA['forumadminemail'] . "'; // e-mail address for outgoing mail\n");
169                     fwrite($file, "\$SETTINGS['topicsperpage'] = " . $SETTINGS['topicsperpage'] . "; // number of topics displayed per page\n");
170                     fwrite($file, "\$SETTINGS['postsperpage'] = " . $SETTINGS['postsperpage'] . "; // number of posts displayed per page\n");
171                     fwrite($file, "\$SETTINGS['maxavatarsize'] = " . $SETTINGS['maxavatarsize'] . "; // max. avatar width & height in pixels\n");
172                     fwrite($file, "\$SETTINGS['guestemail'] = " . $SETTINGS['guestemail'] . "; // show e-mail address field on post form for guests (1) or not (0)\n");
173                     fwrite($file, "\$SETTINGS['severalaccountspermail'] = " . $SETTINGS['severalaccountspermail'] . "; // allow registering more than one account per e-mail address (1/0)\n");
174                     fwrite($file, "\$SETTINGS['polls'] = " . $SETTINGS['polls'] . "; // polls on (1) or off (0)\n");
175                     fwrite($file, "\$SETTINGS['floodcontrol'] = " . $SETTINGS['floodcontrol'] . "; // number of seconds someone has to wait between two posts\n");
176                     fwrite($file, "\$SETTINGS['floodcontrol_search'] = " . $SETTINGS['floodcontrol_search'] . "; // number of seconds someone has to wait between two searches\n");
177                     fwrite($file, "\$SETTINGS['loginattempts'] = " . $SETTINGS['loginattempts'] . "; // number of failed login attempts by a user after which the board will try to lock him or her out for good (set to 0 to disable)\n");
178                     fwrite($file, "\$SETTINGS['maxuploadsize'] = " . $SETTINGS['maxuploadsize'] . "; // maximum file size of attachments in bytes\n");
179                     fwrite($file, "\$SETTINGS['uploadextensions'] = '" . $SETTINGS['uploadextensions'] . "'; // allowed file extensions for attachments (seperated by commas)\n");
180                     fwrite($file, "\$SETTINGS['ip_logging'] = " . $SETTINGS['ip_logging'] . "; // log IP address of every post (1) or not (0)\n");
181                     fwrite($file, "\$SETTINGS['language'] = '" . $SETTINGS['language'] . "'; // default board language\n");
182                     fwrite($file, "\$SETTINGS['url_rewriting'] = " . $SETUPDATA['url_rewriting'] . "; // URL rewriting through mod_rewrite (1) or not (0)\n");
183                     fwrite($file, "\$SETTINGS['timezone'] = '" . $SETTINGS['timezone'] . "'; // time offset compared to UTC\n");
184                     fwrite($file, "\$SETTINGS['encoding'] = '" . $SETTINGS['encoding'] . "'; // character encoding\n");
185                     fwrite($file, "\$SETTINGS['defaultstyle'] = '" . $SETTINGS['defaultstyle'] . "'; // default stylesheet of the board\n");
186                     fwrite($file, "\$SETTINGS['expire'] = " . $SETTINGS['expire'] . "; // cookie expiration in days\n");
187                     fwrite($file, "\$SETTINGS['debug'] = " . $SETTINGS['debug'] . "; // debug mode (0: off, 1: on, 2: admins only)\n");
188                     fwrite($file, "\$SETTINGS['warnings'] = " . $SETTINGS['warnings'] . "; // show warnings (0: off, 1: on)\n");
189                     fwrite($file, "\$SETTINGS['hash'] = '" . $SETUPDATA['hash'] . "'; // hash algorithm used for the passwords\n");
190                     fwrite($file, "\$SETTINGS['authcodes'] = " . $SETTINGS['authcodes'] . "; // 0: none, 1: random character / number combinations, 2: math questions\n");
191                     fwrite($file, '?>');
192                     // close file
193                     @fclose($file);
194                     // set chmod
195                     @chmod('includes/config/settings.php', 0600);
196                     // include new settings again
197                     require('includes/config/settings.php');
198                 } else { $ok = 0; }
199                 /* initialize crypto module */
200                 require('classes/misc/Password.php');
201                 $key = new Password();
202                 $key->generate(512);
203                 $padding = new Password();
204                 $padding->generate(512);
205                 // read template
206                 if ($template = @file_get_contents('includes/config/crypt.tmpl')) {
207                     // write into crypt.php
208                     if ($file = @fopen('includes/config/crypt.php', 'w')) {
209                         // write settings
210                         if (@fwrite($file, str_replace(Array('%key%', '%padding%'), Array($key->get(), $padding->get()), $template))) {
211                             @fclose($file);
212                             // set permissions
213                             @chmod('includes/config/crypt.php', 0600);
214                             // get new crypto settings
215                             require('includes/config/crypt.php');
216                         } else { $ok = 0; }
217                     } else { $ok = 0; }
218                 } else { $ok = 0; }
219                 /* copy other template files to their actual names */
220                 if (@copy('includes/config/bans.tmpl', 'includes/config/bans.php')) {
221                     @chmod('includes/config/bans.php', 0600);
222                 } else { $ok = 0; }
223                 if (@copy('includes/config/memberstages.tmpl', 'includes/config/memberstages.php')) {
224                     @chmod('includes/config/memberstages.php', 0600);
225                 } else { $ok = 0; }
226                 if ($ok == 1) {
227                     print($LANG['installer_config_success'] . '<br /><br />');
228                 } else {
229                     print($LANG['error_installer_config']);
230                 }
231                 // set permissions for version.php
232                 @chmod('includes/config/version.php', 0600);
233                 // set permissions for bots.php
234                 @chmod('includes/config/bots.php', 0600);
235                 if ($ok == 1) {
236                     /* set up database */
237                     require('classes/misc/Connection.php');
238                     // create database file if needed
239                     if ($SETTINGS['sqltype'] == 'sqlite' && !is_file('db/' . $SETTINGS['dbname'])) {
240                         @touch('db/' . $SETTINGS['dbname']);
241                     }
242                     // open SQL connection
243                     if ($C = new Connection()) {
244                         // get table structure
245                         if ($db = @file_get_contents('db/' . $SETTINGS['sqltype'] . '.sql')) {
246                             // one SQL query at a time
247                             $db = explode(';', $db);
248                             foreach ($db as $query) {
249                                 $C->query(str_replace('%prefix%', $SETTINGS['dbtableprefix'], $query));
250                             }
251                             // finally, fill in default data
252                             if ($db = @file_get_contents('db/data.sql')) {
253                                 // one SQL query at a time
254                                 $db = explode(';', $db);
255                                 foreach ($db as $query) {
256                                     $C->query(str_replace('%prefix%', $SETTINGS['dbtableprefix'], $query));
257                                 }
258                             }
259                             // write the admin account
260                             $q = $C->prepare('INSERT INTO ' . $SETTINGS['dbtableprefix'] . 'members (membername, memberemail, memberavatar, memberpassword, registered) VALUES (:name, :email, :avatar, :password, :registered)');
261                             $_t = new DateTime('now', new DateTimeZone('UTC'));
262                             $q->bindParam(':name', $SETUPDATA['forumadmin'], PDO::PARAM_STR);
263                             $q->bindParam(':email', $SETUPDATA['forumadminemail'], PDO::PARAM_STR);
264                             $q->bindValue(':avatar', 'images/spacer.gif', PDO::PARAM_STR);
265                             $q->bindValue(':password', '*', PDO::PARAM_STR);
266                             $q->bindParam(':registered', $_t->format('Y-m-d H:i:s'), PDO::PARAM_STR, 19);
267                             $q->execute();
268                             // get id of admin
269                             $q = $C->prepare('SELECT MAX(memberid) AS id FROM ' . $SETTINGS['dbtableprefix'] . 'members');
270                             $q->execute();
271                             $row = $q->fetchObject();
272                             $q->closeCursor();
273                             // set actual password
274                             require('classes/misc/Member.php');
275                             Member::setPassword($row->id, $SETUPDATA['adminpassword']);
276                             // set group membership 'Admin'
277                             $q = $C->prepare('SELECT id FROM ' . $SETTINGS['dbtableprefix'] . 'usergroups WHERE name = :admin');
278                             $q->bindValue(':admin', 'Admin', PDO::PARAM_STR);
279                             $q->execute();
280                             $row2 = $q->fetchObject();
281                             $q->closeCursor();
282                             $q = $C->prepare('INSERT INTO ' . $SETTINGS['dbtableprefix'] . 'groupmemberships (member, usergroup) VALUES (:member, :group)');
283                             $q->bindParam(':member', $row->id, PDO::PARAM_INT, 12);
284                             $q->bindParam(':group', $row2->id, PDO::PARAM_INT, 12);
285                             $q->execute();
286                             // set group membership 'Member'
287                             $q = $C->prepare('SELECT id FROM ' . $SETTINGS['dbtableprefix'] . 'usergroups WHERE name = :member');
288                             $q->bindValue(':member', 'Member', PDO::PARAM_STR);
289                             $q->execute();
290                             $row2 = $q->fetchObject();
291                             $q->closeCursor();
292                             $q = $C->prepare('INSERT INTO ' . $SETTINGS['dbtableprefix'] . 'groupmemberships (member, usergroup) VALUES (:member, :group)');
293                             $q->bindParam(':member', $row->id, PDO::PARAM_INT, 12);
294                             $q->bindParam(':group', $row2->id, PDO::PARAM_INT, 12);
295                             $q->execute();
296                             // permissions
297                             if ($SETUPDATA['sqltype'] == 'sqlite') {
298                                 @chmod('db/' . $SETUPDATA['sqldatabase'], 0600);
299                             }
300
301                         } else { $ok = 0; }
302                     } else { $ok = 0; }
303                     if ($ok == 1) {
304                         print($LANG['installer_database_success'] . '<br /><br />');
305                         /* try securing sessions and db directories */
306                         if (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== FALSE) {
307                             // Apache -> .htaccess
308                             if ($file = @fopen('sessions/.htaccess', 'w')) {
309                                 // write settings
310                                 if (@fwrite($file, 'deny from all')) {
311                                     @fclose($file);
312                                     // set permissions
313                                     @chmod('sessions/.htaccess', 0644);
314                                 }
315                             }
316                             @copy('sessions/.htaccess', 'db/.htaccess');
317                             @copy('sessions/.htaccess', 'classes/.htaccess');
318                             @copy('sessions/.htaccess', 'admin/classes/.htaccess');
319                             @copy('sessions/.htaccess', 'includes/.htaccess');
320                             // exception: allow
321                             if ($file = @fopen('includes/styles/.htaccess', 'w')) {
322                                 // write settings
323                                 if (@fwrite($file, 'allow from all')) {
324                                     @fclose($file);
325                                     // set permissions
326                                     @chmod('includes/styles/.htaccess', 0644);
327                                 }
328                             }
329                             @copy('includes/styles/.htaccess', 'includes/js/.htaccess');
330                         } else {
331                             // other webservers...
332                         }
333                     } else {
334                         print($LANG['error_installer_database'] . '<br /><br />');
335                     }
336                 }
337             }
338         }
339         if ($ok == 1) {
340             /* test whether db and settings directories are accessable via HTTP */
341             $fp = @fsockopen($_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $errno, $errstr, 30);
342             if ($fp !== FALSE) {
343                 // db
344                 $req = 'GET ' . $SETTINGS['webpath'] . "db/spamboard.sql HTTP/1.1\r\n";
345                 $req .= 'Host: ' . $_SERVER['SERVER_NAME'] . "\r\n";
346                 $req .= "Connection: Close\r\n\r\n";
347                 fwrite($fp, $req);
348                 $reply = '';
349                 while (!feof($fp)) {
350                     $reply .= fgets($fp, 128);
351                 }
352                 fclose($fp);
353                 if (strpos($reply, '403 Forbidden') === FALSE) {
354                     // db accessable via HTTP -> bad
355                     $ok = -1;
356                 }
357             } else {
358                 $ok = -1;
359             }
360             $fp = @fsockopen($_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $errno, $errstr, 30);
361             if ($fp !== FALSE) {
362                 // sessions
363                 @touch('sessions/test.file');
364                 $req = 'GET ' . $SETTINGS['webpath'] . "sessions/test.file HTTP/1.1\r\n";
365                 $req .= 'Host: ' . $_SERVER['SERVER_NAME'] . "\r\n";
366                 $req .= "Connection: Close\r\n\r\n";
367                 fwrite($fp, $req);
368                 $reply = '';
369                 while (!feof($fp)) {
370                     $reply .= fgets($fp, 128);
371                 }
372                 fclose($fp);
373                 if (strpos($reply, '403 Forbidden') === FALSE) {
374                     // db accessable via HTTP -> bad
375                     $ok = -1;
376                 }
377                 @unlink('sessions/test.file');
378             } else {
379                 $ok = -1;
380             }
381             if ($ok == -1) {
382                 // message about securing db and settings directories
383                 print($LANG['installer_warning_insecure_directories'] . '<br /><br />');
384                 // this won't make the overall installation fail
385                 $ok = 1;
386             }
387             /* clean up */
388             if ($ok == 1) {
389                 // remove settings.tmpl
390                 if (@unlink('includes/config/settings.tmpl')) {
391                 } else { $ok = 2; }
392                 // remove crypt.tmpl
393                 if (@unlink('includes/config/crypt.tmpl')) {
394                 } else { $ok = 2; }
395                 // remove bans.tmpl
396                 if (@unlink('includes/config/bans.tmpl')) {
397                 } else { $ok = 2; }
398                 // remove memberstages.tmpl
399                 if (@unlink('includes/config/memberstages.tmpl')) {
400                 } else { $ok = 2; }
401             } else {
402                 // something went wrong, so remove everything from the database again
403                 if ($db = @file_get_contents('db/clean.sql')) {
404                     // one SQL query at a time
405                     $db = explode(';', $db);
406                     foreach ($db as $query) {
407                         @$C->query(str_replace('%prefix%', $SETTINGS['dbtableprefix'], $query));
408                     }
409                 }
410             }
411             /* everything done */
412             if ($ok >= 1) {
413                 if ($ok == 2) {
414                     print($LANG['installer_warning_cleanup_failed'] . '<br /><br />');
415                 }
416                 if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
417                     $_s = 's';
418                 } else { $_s = ''; }
419                 print(str_replace('%boardurl%', 'http' . $_s . '://' . $_SERVER['HTTP_HOST'] . $SETTINGS['webpath'] , $LANG['installer_overall_success']));
420             }
421         }
422     break;
423     case $overviewpage:
424         /* show overview */
425         // get setting from previous page
426         $SETUPDATA['forumadmin'] = $_POST['forumadmin'];
427         $SETUPDATA['forumadminemail'] = $_POST['forumadminemail'];
428         $SETUPDATA['adminpassword'] = $_POST['adminpassword'];
429         $SETUPDATA['hash'] = $_POST['hash'];
430         // retain previously set data
431         foreach ($SETUPDATA as $key=>$val) {
432             print('        <input type="hidden" name="SETUPDATA[' . $key . ']" value="' . $val . "\" />\n");
433         }
434         // show the data
435         print('
436         <div>
437             ' . $LANG['installer_overview'] . '
438         </div><br />
439         <table border="0" align="center">
440         ');
441         foreach ($SETUPDATA as $key=>$val) {
442             print('
443             <tr>
444                 <td><b>' . $key . '</b></td>
445                 <td>');
446             if (strpos($key, 'password') === FALSE) {
447                 print($val);
448             } else {
449                 print('*****');
450             }
451             print('</td>
452             </tr>
453             ');
454         }
455         print('
456         </table>
457         ');
458     break;
459     case '7':
460         /* admin account */
461         // get setting from previous page
462         $SETUPDATA['forumname'] = $_POST['forumname'];
463         $SETUPDATA['slogan'] = $_POST['slogan'];
464         $SETUPDATA['forumlogo'] = $_POST['forumlogo'];
465         $SETUPDATA['sitename'] = $_POST['sitename'];
466         $SETUPDATA['siteurl'] = $_POST['siteurl'];
467         // retain previously set data
468         foreach ($SETUPDATA as $key=>$val) {
469             print('        <input type="hidden" name="SETUPDATA[' . $key . ']" value="' . $val . "\" />\n");
470         }
471         // new data
472         print('
473         <div>
474             ' . $LANG['installer_admin_account'] . '
475         </div><br />
476         <table border="0" align="center">
477             <tr>
478                 <td><b>' . $LANG['Board_Admin'] . ':</b></td>
479                 <td><input size="40" type="text" name="forumadmin" /></td>
480             </tr>
481             <tr>
482                 <td><b>' . $LANG['Admin_e-mail'] . ':</b></td>
483                 <td><input size="40" type="text" name="forumadminemail" /></td>
484             </tr>
485             <tr>
486                 <td><b>' . $LANG['Password'] . ':</b></td>
487                 <td><input size="40" type="password" name="adminpassword" /></td>
488             </tr>
489             <tr>
490                 <td><b>' . $LANG['Hash_Algorithm'] . ':</b></td>
491                 <td>
492                     <select name="hash">
493         ');
494         foreach ($hashes as $_hash) {
495             print('<option value="' . $_hash . '"');
496             if ($SETTINGS['hash'] == $_hash) {
497                 print(' selected="selected"');
498             }
499             print('>' . $_hash . '</option>');
500         }
501         print('
502                     </select>
503                 </td>
504             </tr>
505         </table>
506         ');
507     break;
508     case '6':
509         /* board identification */
510         // get setting from previous page
511         $SETUPDATA['fspath'] = $_POST['fspath'];
512         $SETUPDATA['webpath'] = $_POST['webpath'];
513         $SETUPDATA['cookiepath'] = $_POST['cookiepath'];
514         // retain previously set data
515         foreach ($SETUPDATA as $key=>$val) {
516             print('        <input type="hidden" name="SETUPDATA[' . $key . ']" value="' . $val . "\" />\n");
517         }
518         // new data
519         print('
520         <div>
521             ' . $LANG['installer_board'] . '
522         </div><br />
523         <table border="0" align="center">
524             <tr>
525                 <td><b>' . $LANG['Board_Name'] . ':</b></td>
526                 <td><input size="40" type="text" name="forumname" value="' . $SETTINGS['forumname'] . '" /></td>
527             </tr>
528             <tr>
529                 <td><b>' . $LANG['Board_Slogan'] . ':</b></td>
530                 <td><input size="40" type="text" name="slogan" value="' . $SETTINGS['slogan'] . '" /></td>
531             </tr>
532             <tr>
533                 <td><b>' . $LANG['Board_Logo'] . ':</b></td>
534                 <td><input size="40" type="text" name="forumlogo" value="' . $SETTINGS['forumlogo'] . '" /></td>
535             </tr>
536             <tr>
537                 <td><b>' . $LANG['Site_Name'] . ':</b></td>
538                 <td><input size="40" type="text" name="sitename" value="' . $SETTINGS['sitename'] . '" /></td>
539             </tr>
540             <tr>
541                 <td><b>' . $LANG['Site_URL'] . ':</b></td>
542                 <td><input size="40" type="text" name="siteurl" value="' . $SETTINGS['siteurl'] . '" /></td>
543             </tr>
544         </table>
545         ');
546     break;
547     case '5':
548         /* pathes */
549         // get setting from previous page
550         $SETUPDATA['sqltype'] = $_POST['sqltype'];
551         $SETUPDATA['sqlhost'] = $_POST['sqlhost'];
552         $SETUPDATA['sqluser'] = $_POST['sqluser'];
553         $SETUPDATA['sqlpassword'] = $_POST['sqlpassword'];
554         $SETUPDATA['sqldatabase'] = $_POST['sqldatabase'];
555         $SETUPDATA['sqltableprefix'] = $_POST['sqltableprefix'];
556         // retain previously set data
557         foreach ($SETUPDATA as $key=>$val) {
558             print('        <input type="hidden" name="SETUPDATA[' . $key . ']" value="' . $val . "\" />\n");
559         }
560         // new data
561         print('
562         <div>
563             ' . $LANG['installer_pathes'] . '
564         </div><br />
565         ');
566         $_fspath = substr($_SERVER['SCRIPT_FILENAME'], 0, strrpos($_SERVER['SCRIPT_FILENAME'], '/')) . '/';
567         $_webpath = substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], '/')) . '/';
568         print('
569         <table border="0" align="center">
570             <tr>
571                 <td><b>' . $LANG['Filesystem_Path'] . ':</b></td>
572                 <td><input size="40" type="text" name="fspath" value="' . $_fspath . '" /></td>
573             </tr>
574             <tr>
575                 <td><b>' . $LANG['Webserver_Path'] . ':</b></td>
576                 <td><input size="40" type="text" name="webpath" value="' . $_webpath . '" /></td>
577             </tr>
578             <tr>
579                 <td><b>' . $LANG['Cookie_Path'] . ':</b></td>
580                 <td><input size="40" type="text" name="cookiepath" value="' . $_webpath . '" /></td>
581             </tr>
582         </table>
583         ');
584     break;
585     case '4':
586         /* database setup */
587         // get setting from previous page
588         if (isset($_POST['set_permissions']) && $_POST['set_permissions'] == 1) {
589             $SETUPDATA['set_permissions'] = 1;
590         } else {
591             $SETUPDATA['set_permissions'] = 0;
592         }
593         // retain previously set data
594         foreach ($SETUPDATA as $key=>$val) {
595             print('        <input type="hidden" name="SETUPDATA[' . $key . ']" value="' . $val . "\" />\n");
596         }
597         // new data
598         print('
599         <div>
600             ' . $LANG['installer_database'] . '
601         </div><br />
602         <table border="0" align="center">
603             <tr>
604                 <td><b>' . $LANG['SQL_Database_Type'] . ':</b></td>
605                 <td>
606                     <select name="sqltype">
607                         <option value="sqlite">SQLite</option>
608                         <option value="mysql">MySQL</option>
609                         <option value="postgresql">PostgreSQL</option>
610                     </select>
611                 </td>
612             </tr>
613             <tr>
614                 <td><b>' . $LANG['SQL_Hostname'] . ':</b></td>
615                 <td><input type="text" name="sqlhost" value="' . $SETTINGS['sqlhost'] . '" /></td>
616             </tr>
617             <tr>
618                 <td><b>' . $LANG['SQL_Username'] . ':</b></td>
619                 <td><input type="text" name="sqluser" /></td>
620             </tr>
621             <tr>
622                 <td><b>' . $LANG['SQL_Password'] . ':</b></td>
623                 <td><input type="password" name="sqlpassword" /></td>
624             </tr>
625             <tr>
626                 <td><b>' . $LANG['SQL_Database'] . ':</b></td>
627                 <td><input type="text" name="sqldatabase" /></td>
628             </tr>
629             <tr>
630                 <td><b>' . $LANG['SQL_Database_Table_Prefix'] . ':</b></td>
631                 <td><input type="text" name="sqltableprefix" value="' . $SETTINGS['dbtableprefix'] . '" /></td>
632             </tr>
633         </table>
634         ');
635     break;
636     case '3':
637         /* UNIX permissions */
638         // get setting from previous page
639         if (isset($_POST['url_rewriting']) && $_POST['url_rewriting'] == 1) {
640             $SETUPDATA['url_rewriting'] = 1;
641         } else {
642             $SETUPDATA['url_rewriting'] = 0;
643         }
644         // retain previously set data
645         foreach ($SETUPDATA as $key=>$val) {
646             print('        <input type="hidden" name="SETUPDATA[' . $key . ']" value="' . $val . "\" />\n");
647         }
648         // new data
649         print('
650         <div>
651             ' . $LANG['installer_permissions'] . '
652         </div><br />
653         <div align="center">
654             <b>' . $LANG['Set_Permissions'] . '</b>
655             <input type="checkbox" name="set_permissions" value="1" />
656         </div>
657         ');
658     break;
659     case '2':
660         /* Apache mod_rewrite */
661         print('
662         <div>
663             ' . $LANG['installer_rewrite'] . '
664         </div><br />
665         <div align="center">
666             <b>' . $LANG['URL_Rewriting'] . '</b>
667             <input type="checkbox" name="url_rewriting" value="1" />
668         </div>
669         ');
670     break;
671     case '1':
672         // pre-install form
673         print('
674         <div>
675             ' . $LANG['installer_intro'] . '
676         </div>
677         ');
678     break;
679 }
680
681 if ($INPUT['page'] < $commitpage) {
682     print('
683         <br />
684         <div align="center">
685             <input type="submit" name="submit" value="' . $LANG['Start_Over'] . '" />
686             <input type="submit" name="submit" value="' . $LANG['Next_Page'] . '" />
687         </div>
688     ');
689 }
690 print('
691         </form>
692     </body>
693 </html>
694 ');
695
696 // close database connection
697 $C = NULL;
698
699 // destroy global formatting object
700 unset($F);
701
702 ?>
Note: See TracBrowser for help on using the browser.