]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - configurator.php
The configurator is finished, please test it out. Creates the file 'settings.php...
[SourceForge/phpwiki.git] / configurator.php
1 <?php printf("<?xml version=\"1.0\" encoding=\"%s\"?>\n", 'iso-8859-1'); ?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml">
5 <head>
6 <!-- $Id: configurator.php,v 1.5 2002-03-26 22:29:06 carstenklapp Exp $ -->
7 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
8 <title>Configuration tool for PhpWiki 1.3.x</title>
9 </head>
10 <body>
11
12 <h1>Configuration tool for PhpWiki 1.3.x</h1>
13
14 <?php
15 //define('DEBUG', 1);
16 /**
17  * The Configurator is a php script to aid in the configuration of PhpWiki.
18  * Parts of this file are based on PHPWeather's configurator.php file.
19  * http://sourceforge.net/projects/phpweather/
20  *
21  *
22  * TO CHANGE THE CONFIGURATION OF YOUR PHPWIKI, DO *NOT* MODIFY THIS FILE!
23  * more instructions go here
24  *
25  * 
26  * An index.php will be generated for you which you can also modify later if you wish.
27  */
28
29
30 //////////////////////////////
31 // begin configuration options
32
33
34 /**
35  * Notes for the description parameter of $property:
36  *
37  * - Descriptive text will be changed into comments (preceeded by //)
38  *   for the final output to index.php.
39  *
40  * - Only a limited set of html is allowed: pre, dl dt dd; it will be
41  *   stripped from the final output.
42  *
43  * - Line breaks and spacing will be preserved for the final output.
44  *
45  * - Double line breaks are automatically converted to paragraphs
46  *   for the html version of the descriptive text.
47  *
48  * - Double-quotes and dollar signs in the descriptive text must be
49  *   escaped: \" and \$. Instead of escaping double-quotes you can use 
50  *   single (') quotes for the enclosing quotes. 
51  *
52  * - Special characters like < and > must use html entities,
53  *   they will be converted back to characters for the final output.
54  */
55
56 $SEPARATOR = "///////////////////////////////////////////////////////////////////";
57
58 $copyright = '
59 Copyright 1999, 2000, 2001, 2002 $ThePhpWikiProgrammingTeam = array(
60 "Steve Wainstead", "Clifford A. Adams", "Lawrence Akka", 
61 "Scott R. Anderson", "Jon Åslund", "Neil Brown", "Jeff Dairiki",
62 "Stéphane Gourichon", "Jan Hidders", "Arno Hollosi", "John Jorgensen",
63 "Antti Kaihola", "Jeremie Kass", "Carsten Klapp", "Marco Milanesi",
64 "Grant Morgan", "Jan Nieuwenhuizen", "Aredridel Niothke", 
65 "Pablo Roca Rozas", "Sandino Araico Sánchez", "Joel Uckelman", 
66 "Reini Urban", "Tim Voght");
67
68 This file is part of PhpWiki.
69
70 PhpWiki is free software; you can redistribute it and/or modify
71 it under the terms of the GNU General Public License as published by
72 the Free Software Foundation; either version 2 of the License, or
73 (at your option) any later version.
74
75 PhpWiki is distributed in the hope that it will be useful,
76 but WITHOUT ANY WARRANTY; without even the implied warranty of
77 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
78 GNU General Public License for more details.
79
80 You should have received a copy of the GNU General Public License
81 along with PhpWiki; if not, write to the Free Software
82 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
83 ';
84
85
86
87 $preamble = "
88   This is the starting file for PhpWiki. All this file does is set
89   configuration options, and at the end of the file it includes() the
90   file lib/main.php, where the real action begins.
91
92   This file is divided into six parts: Parts Zero, One, Two, Three,
93   Four and Five. Each one has different configuration settings you can
94   change; in all cases the default should work on your system,
95   however, we recommend you tailor things to your particular setting.
96 ";
97
98
99
100 $properties["Part Zero"] =
101 new part('_part0', false, "
102 Part Zero: If PHP needs help in finding where you installed the
103 rest of the PhpWiki code, you can set the include_path here.");
104
105
106
107 $properties["PHP include_path"] =
108 new _ini_set('include_path', "\$include_path", "
109 NOTE: phpwiki uses the PEAR library of php code for SQL database
110 access. Your PHP is probably already configured to set
111 include_path so that PHP can find the pear code. If not (or if you
112 change include_path here) make sure you include the path to the
113 PEAR code in include_path. (To find the PEAR code on your system,
114 search for a file named 'PEAR.php'. Some common locations are:
115 <pre>
116   Unixish systems:
117     /usr/share/php
118     /usr/local/share/php
119   Mac OS X:
120     /System/Library/PHP
121 </pre>
122 The above examples are already included by PhpWiki. You shouldn't
123 have to change this unless you see a WikiFatalError:
124 <pre>
125     lib/FileFinder.php:82: Fatal[256]: DB.php: file not found
126 </pre>
127 Define the include path for this wiki: pear plus the phpwiki path
128 <pre>
129 $include_path = '.:/Apache/php/pear:/prog/php/phpwiki';
130 </pre>
131 Windows needs ';' as path delimiter. cygwin, mac and unix ':'
132 <pre>
133 if (substr(PHP_OS,0,3) == 'WIN') {
134     $include_path = implode(';',explode(':',$include_path));
135 } elseif (substr(PHP_OS,0,6) == 'CYGWIN') {
136     $include_path = '.:/usr/local/lib/php/pear:/usr/src/php/phpwiki';
137 } else {
138     ;
139 }</pre>");
140
141
142
143 $properties["Part Null"] =
144 new part('_partnullheader', "", "
145 Part Null: Don't touch this!");
146
147
148
149 $properties["Part Null Settings"] =
150 new unchangeable_variable('_partnullsettings', "
151 define ('PHPWIKI_VERSION', '1.3.3-jeffs-hacks');
152 require \"lib/prepend.php\";
153 rcs_id('\$Id: configurator.php,v 1.5 2002-03-26 22:29:06 carstenklapp Exp $');", "");
154
155
156
157 $properties["Part One"] =
158 new part('_partone', $SEPARATOR."\n", "
159
160 Part One:
161 Authentication and security settings:
162 ");
163
164
165
166 $properties["Wiki Name"] =
167 new _define('WIKI_NAME', ''/*'PhpWiki'*/, "
168 The name of your wiki.
169 This is used to generate a keywords meta tag in the HTML templates,
170 in bookmark titles for any bookmarks made to pages in your wiki,
171 and during RSS generation for the title of the RSS channel.");
172
173
174
175 $properties["Reverse DNS"] =
176 new boolean_define('ENABLE_REVERSE_DNS',
177                     array('true'  => "perform additional reverse dns lookups",
178                           'false' => "just record the address as given by the httpd server"), "
179 If set, we will perform reverse dns lookups to try to convert the
180 users IP number to a host name, even if the http server didn't do
181 it for us.");
182
183
184
185 $properties["Admin Username"] =
186 new _define('ADMIN_USER', "", "
187 Username and password of administrator.
188 Set these to your preferences. For heaven's sake
189 pick a good password!");
190 $properties["Admin Password"] =
191 new _define_password('ADMIN_PASSWD', "", "");
192
193
194
195 $properties["ZIPdump Authentication"] =
196 new boolean_define('ZIPDUMP_AUTH', 
197                     array('false' => "everyone may download zip dumps",
198                           'true'  => "only admin may download zip dumps"), "
199 If true, only the admin user can make zip dumps, else zip dumps
200 require no authentication.");
201
202
203
204 $properties["Strict Mailable Pagedumps"] =
205 new boolean_define('STRICT_MAILABLE_PAGEDUMPS', 
206                     array('false' => "binary",
207                           'true'  => "quoted-printable"), "
208 If you define this to true, (MIME-type) page-dumps (either zip dumps,
209 or \"dumps to directory\" will be encoded using the quoted-printable
210 encoding.  If you're actually thinking of mailing the raw page dumps,
211 then this might be useful, since (among other things,) it ensures
212 that all lines in the message body are under 80 characters in length.
213
214 Also, setting this will cause a few additional mail headers
215 to be generated, so that the resulting dumps are valid
216 RFC 2822 e-mail messages.
217
218 Probably, you can just leave this set to false, in which case you get
219 raw ('binary' content-encoding) page dumps.");
220
221
222
223 $properties["HTML Dump Filename Suffix"] =
224 new _variable('HTML_DUMP_SUFFIX', ".html", "
225 Here you can change the filename suffix used for XHTML page dumps.
226 If you don't want any suffix just comment this out.");
227
228
229
230 $properties["Maximum Upload Size"] =
231 new numeric_define('MAX_UPLOAD_SIZE', "16 * 1024 * 1024", "
232 The maximum file upload size.");
233
234
235
236 $properties["Minor Edit Timeout"] =
237 new numeric_define('MINOR_EDIT_TIMEOUT', "7 * 24 * 3600", "
238 If the last edit is older than MINOR_EDIT_TIMEOUT seconds, the
239 default state for the \"minor edit\" checkbox on the edit page form
240 will be off.");
241
242
243
244 $properties["Disabled Actions"] =
245 new array_variable('DisabledActions', array(), "
246 Actions listed in this array will not be allowed. Actions are:
247 browse, diff, dumphtml, dumpserial, edit, loadfile, lock, remove, 
248 unlock, upload, viewsource, zip, ziphtml");
249
250
251
252 $properties["Access Log"] =
253 new _define('ACCESS_LOG', "", "
254 PhpWiki can generate an access_log (in \"NCSA combined log\" format)
255 for you. If you want one, define this to the name of the log file,
256 such as /tmp/wiki_access_log.");
257
258
259
260 $properties["Strict Login"] =
261 new boolean_define('ALLOW_BOGO_LOGIN',
262                     array('true'  => "Users may Sign In with any WikiWord",
263                           'false' => "Only admin may Sign In"), "
264 If ALLOW_BOGO_LOGIN is true, users are allowed to login (with
265 any/no password) using any userid which: 1) is not the ADMIN_USER,
266 2) is a valid WikiWord (matches \$WikiNameRegexp.)");
267
268
269
270 $properties["Require Sign In Before Editing"] =
271 new boolean_define('REQUIRE_SIGNIN_BEFORE_EDIT',
272                     array('false' => "Do not require Sign In",
273                           'true'  => "Require Sign In"), "
274 If set, then if an anonymous user attempts to edit a page he will
275 be required to sign in.  (If ALLOW_BOGO_LOGIN is true, of course,
276 no password is required, but the user must still sign in under
277 some sort of BogoUserId.)");
278
279
280
281 $properties["Path for PHP Session Support"] =
282 new _ini_set('session.save_path', 'some_other_directory', "
283 The login code now uses PHP's session support. Usually, the default
284 configuration of PHP is to store the session state information in
285 /tmp. That probably will work fine, but fails e.g. on clustered
286 servers where each server has their own distinct /tmp (this is the
287 case on SourceForge's project web server.) You can specify an
288 alternate directory in which to store state information like so
289 (whatever user your httpd runs as must have read/write permission
290 in this directory):");
291
292
293
294 $properties["Disable PHP Transparent Session ID"] =
295 new unchangeable_variable('session.use_trans_sid', "@ini_set('session.use_trans_sid', 0);", "
296 If your php was compiled with --enable-trans-sid it tries to
297 add a PHPSESSID query argument to all URL strings when cookie
298 support isn't detected in the client browser.  For reasons
299 which aren't entirely clear (PHP bug) this screws up the URLs
300 generated by PhpWiki.  Therefore, transparent session ids
301 should be disabled.  This next line does that.
302
303 (At the present time, you will not be able to log-in to PhpWiki,
304 or set any user preferences, unless your browser supports cookies.)");
305
306
307
308 ///////// database selection
309
310
311
312 $properties["Part Two"] =
313 new part('_parttwo', $SEPARATOR."\n", "
314
315 Part Two:
316 Database Selection
317 ");
318
319
320 $properties["Database Type"] =
321 new _variable_selection("DBParams|dbtype",
322               array('dba'   => "dba DBM",
323                     'SQL'   => "SQL PEAR",
324                     'ADODB' => "SQL ADODB"), "
325 Select the database type:");
326
327
328 $properties["Filename / Table name Prefix"] =
329 new _variable_commented("DBParams|prefix", "phpwiki_", "
330 Used by all DB types:
331
332 prefix for filenames or table names
333
334 currently you MUST EDIT THE SQL file too (in the schemas/
335 directory because we aren't doing on the fly sql generation
336 during the installation.:");
337
338
339
340 $properties["SQL dsn Setup"] =
341 new part('_sqldsnstuff', "
342 ", "
343 For SQL based backends, specify the database as a DSN
344 The most general form of a DSN looks like:
345 <pre>
346   phptype(dbsyntax)://username:password@protocol+hostspec/database
347 </pre>
348 For a MySQL database, the following should work:
349 <pre>
350    mysql://user:password@host/databasename
351 </pre>
352 <dl><dd>FIXME:</dd> <dt>My version Pear::DB seems to be broken enough that there
353         is no way to connect to a mysql server over a socket right now.</dt></dl>
354 <pre>'dsn' => 'mysql://guest@:/var/lib/mysql/mysql.sock/test',
355 'dsn' => 'mysql://guest@localhost/test',
356 'dsn' => 'pgsql://localhost/test',</pre>");
357
358
359
360 $properties["SQL Type"] =
361 new _variable_selection('dsn_sqltype',
362               array('mysql' => "MySQL",
363                     'pgsql' => "PostgreSQL"), "
364 SQL DB types");
365
366
367
368 $properties["SQL User"] =
369 new _variable('dsn_sqluser', "wikiuser", "
370 SQL User Id:");
371
372
373
374 $properties["SQL Password"] =
375 new _variable('dsn_sqlpass', "", "
376 SQL Password:");
377
378
379
380 $properties["SQL Database Host"] =
381 new _variable('dsn_sqlhostorsock', "localhost", "
382 SQL Database Hostname:");
383
384
385
386 $properties["SQL Database Name"] =
387 new _variable('dsn_sqldbname', "phpwiki", "
388 SQL Database Name:");
389
390
391 $properties["SQL dsn"] =
392 new unchangeable_variable("DBParams['dsn']", "\$DBParams['dsn'] = \"\$dsn_sqltype://\$dsn_sqluser:\$dsn_sqlpass@\$dsn_sqlhostorsock/\$dsn_sqldbname\";", "
393 ");
394
395
396
397 $properties["dba directory"] =
398 new _variable("DBParams|directory", "/tmp", "
399 dba directory:");
400
401
402 $properties["dba handler"] =
403 new _variable_selection('DBParams|dba_handler',
404               array('gdbm' => "Gdbm - GNU database manager",
405                     'db2'  => "DB2 - Sleepycat Software's DB2",
406                     'db3'  => "DB3 - Sleepycat Software's DB3"), "
407 Use 'gdbm', 'db2', or db3 depending on your database:");
408
409
410
411 $properties["dba timeout"] =
412 new _variable("DBParams|timeout", "20", "
413 Recommended values are 20 or 5.");
414
415
416
417 ///////////////////
418
419
420
421 $properties["Page Revisions"] =
422 new part('_parttworevisions', "
423 ", "
424
425 The next section controls how many old revisions of each page are
426 kept in the database.
427
428 There are two basic classes of revisions: major and minor. Which
429 class a revision belongs in is determined by whether the author
430 checked the \"this is a minor revision\" checkbox when they saved the
431 page.
432  
433 There is, additionally, a third class of revisions: author
434 revisions. The most recent non-mergable revision from each distinct
435 author is and author revision.
436
437 The expiry parameters for each of those three classes of revisions
438 can be adjusted seperately. For each class there are five
439 parameters (usually, only two or three of the five are actually
440 set) which control how long those revisions are kept in the
441 database.
442 <dl>
443    <dt>max_keep:</dt> <dd>If set, this specifies an absolute maximum for the
444             number of archived revisions of that class. This is
445             meant to be used as a safety cap when a non-zero
446             min_age is specified. It should be set relatively high,
447             and it's purpose is to prevent malicious or accidental
448             database overflow due to someone causing an
449             unreasonable number of edits in a short period of time.</dd>
450
451   <dt>min_age:</dt>  <dd>Revisions younger than this (based upon the supplanted
452             date) will be kept unless max_keep is exceeded. The age
453             should be specified in days. It should be a
454             non-negative, real number,</dd>
455
456   <dt>min_keep:</dt> <dd>At least this many revisions will be kept.</dd>
457
458   <dt>keep:</dt>     <dd>No more than this many revisions will be kept.</dd>
459
460   <dt>max_age:</dt>  <dd>No revision older than this age will be kept.</dd>
461 </dl>
462 Supplanted date: Revisions are timestamped at the instant that they
463 cease being the current revision. Revision age is computed using
464 this timestamp, not the edit time of the page.
465
466 Merging: When a minor revision is deleted, if the preceding
467 revision is by the same author, the minor revision is merged with
468 the preceding revision before it is deleted. Essentially: this
469 replaces the content (and supplanted timestamp) of the previous
470 revision with the content after the merged minor edit, the rest of
471 the page metadata for the preceding version (summary, mtime, ...)
472 is not changed.
473 ");
474
475
476 // For now the expiration parameters are statically inserted as
477 // an unchangeable property. You'll have to edit the resulting
478 // config file if you really want to change these from the default.
479
480 $properties["Expiration Parameters for Major Edits"] =
481 new unchangeable_variable('Expiration_Parameters_for_Major_Edits',
482 "\$ExpireParams['major'] = array('max_age' => 32,
483                                'keep'    => 8);", "
484 Keep up to 8 major edits, but keep them no longer than a month.");
485
486
487
488 $properties["Expiration Parameters for Minor Edits"] =
489 new unchangeable_variable('Expiration_Parameters_for_Minor_Edits',
490 "\$ExpireParams['minor'] = array('max_age' => 7,
491                                'keep'    => 4);", "
492 Keep up to 4 minor edits, but keep them no longer than a week.");
493
494
495
496 $properties["Expiration Parameters by Author"] =
497 new unchangeable_variable('Expiration_Parameters_by_Author',
498 "\$ExpireParams['author'] = array('max_age'  => 365,
499                                 'keep'     => 8,
500                                 'min_age'  => 7,
501                                 'max_keep' => 20);", "
502 Keep the latest contributions of the last 8 authors up to a year.
503 Additionally, (in the case of a particularly active page) try to
504 keep the latest contributions of all authors in the last week (even
505 if there are more than eight of them,) but in no case keep more
506 than twenty unique author revisions.");
507
508
509
510
511 $properties["Part Three"] =
512 new part('_partthree', $SEPARATOR."\n", "
513
514 Part Three:
515 Page appearance and layout
516 ");
517
518
519
520 $properties["Theme"] =
521 new _define_selection('THEME',
522               array('default'  => "default",
523                     'Hawaiian' => "Hawaiian",
524                     'MacOSX'   => "MacOSX",
525                     'Portland' => "Portland",
526                     'Sidebar'  => "Sidebar",
527                     'SpaceWiki' => "SpaceWiki"), "
528 THEME
529
530 Most of the page appearance is controlled by files in the theme
531 subdirectory.
532
533 There are a number of pre-defined themes shipped with PhpWiki.
534 Or you may create your own (e.g. by copying and then modifying one of
535 stock themes.)
536
537 Pick one.
538 <pre>
539 define('THEME', 'default');
540 define('THEME', 'Hawaiian');
541 define('THEME', 'MacOSX');
542 define('THEME', 'Portland');
543 define('THEME', 'Sidebar');
544 define('THEME', 'SpaceWiki');</pre>");
545
546
547
548
549 $properties["Character Set"] =
550 new _define('CHARSET', 'iso-8859-1', "
551 Select a valid charset name to be inserted into the xml/html pages, 
552 and to reference links to the stylesheets (css). For more info see: 
553 http://www.iana.org/assignments/character-sets. Note that PhpWiki 
554 has been extensively tested only with the latin1 (iso-8859-1) 
555 character set.
556
557 If you change the default from iso-8859-1 PhpWiki may not work 
558 properly and it will require code modifications. However, character 
559 sets similar to iso-8859-1 may work with little or no modification 
560 depending on your setup. The database must also support the same 
561 charset, and of course the same is true for the web browser. (Some 
562 work is in progress hopefully to allow more flexibility in this 
563 area in the future).");
564
565
566
567 $properties["Language"] =
568 new _variable_selection('LANG',
569               array('C'  => "English",
570                     'nl' => "Nederlands",
571                     'es' => "Español",
572                     'fr' => "Français",
573                     'de' => "Deutsch",
574                     'sv' => "Svenska",
575                     'it' => "Italiano",
576                     ''   => "none"), "
577 Select your language/locale - default language is \"C\" for English.
578 Other languages available:<pre>
579 English \"C\"  (English    - HomePage)
580 Dutch   \"nl\" (Nederlands - ThuisPagina)
581 Spanish \"es\" (Español    - PáginaPrincipal)
582 French  \"fr\" (Français   - Accueil)
583 German  \"de\" (Deutsch    - StartSeite)
584 Swedish \"sv\" (Svenska    - Framsida)
585 Italian \"it\" (Italiano   - PaginaPrincipale)
586 </pre>
587 If you set \$LANG to the empty string, your systems default language
588 (as determined by the applicable environment variables) will be
589 used.
590
591 Note that on some systems, apprently using these short forms for
592 the locale won't work. On my home system 'LANG=de' won't result in
593 german pages. Somehow the system must recognize the locale as a
594 valid locale before gettext() will work, i.e., use 'de_DE', 'nl_NL'.");
595
596
597
598 $properties["Wiki Page Source"] =
599 new _define('WIKI_PGSRC', 'pgsrc', "
600 WIKI_PGSRC -- specifies the source for the initial page contents of
601 the Wiki. The setting of WIKI_PGSRC only has effect when the wiki is
602 accessed for the first time (or after clearing the database.)
603 WIKI_PGSRC can either name a directory or a zip file. In either case
604 WIKI_PGSRC is scanned for files -- one file per page.
605 <pre>
606 define('WIKI_PGSRC', 'pgsrc'); // Default (old) behavior.
607 define('WIKI_PGSRC', 'wiki.zip'); // New style.
608 define('WIKI_PGSRC', '../../../Logs/Hamwiki/hamwiki-20010830.zip'); // New style.
609 </pre>");
610
611
612
613 $properties["Default Wiki Page Source"] =
614 new _define('DEFAULT_WIKI_PGSRC', 'pgsrc', "
615 DEFAULT_WIKI_PGSRC is only used when the language is *not* the
616 default (English) and when reading from a directory: in that case
617 some English pages are inserted into the wiki as well.
618 DEFAULT_WIKI_PGSRC defines where the English pages reside.
619
620 FIXME: is this really needed?
621 ");
622
623
624
625 $properties["Generic Pages"] =
626 new array_variable('GenericPages', array('ReleaseNotes', 'SteveWainstead', 'TestPage'), "
627 These are the pages which will get loaded from DEFAULT_WIKI_PGSRC.      
628
629 FIXME: is this really needed?  Can't we just copy these pages into
630 the localized pgsrc?
631 ");
632
633
634
635
636 $properties["Part Four"] =
637 new part('_partfour', $SEPARATOR."\n", "
638
639 Part Four:
640 Mark-up options.
641 ");
642
643
644
645 $properties["Allowed Protocols"] =
646 new list_variable('AllowedProtocols', 'http|https|mailto|ftp|news|nntp|ssh|gopher', "
647 allowed protocols for links - be careful not to allow \"javascript:\"
648 URL of these types will be automatically linked.
649 within a named link [name|uri] one more protocol is defined: phpwiki");
650
651
652
653 $properties["Inline Images"] =
654 new list_variable('InlineImages', 'png|jpg|gif', "
655 URLs ending with the following extension should be inlined as images");
656
657
658
659 $properties["WikiName Regexp"] =
660 new _variable('WikiNameRegexp', "(?<![[:alnum:]])(?:[[:upper:]][[:lower:]]+){2,}(?![[:alnum:]])", "
661 Perl regexp for WikiNames (\"bumpy words\")
662 (?&lt;!..) & (?!...) used instead of '\b' because \b matches '_' as well");
663
664
665
666 $properties["InterWiki Map File"] =
667 new _define('INTERWIKI_MAP_FILE', 'lib/interwiki.map', "
668 InterWiki linking -- wiki-style links to other wikis on the web
669
670 The map will be taken from a page name InterWikiMap.
671 If that page is not found (or is not locked), or map
672 data can not be found in it, then the file specified
673 by INTERWIKI_MAP_FILE (if any) will be used.");
674
675
676
677 $properties["Part Five"] =
678 new part('_partfive', $SEPARATOR."\n", "
679
680 Part Five:
681 URL options -- you can probably skip this section.
682 ");
683
684
685
686 $properties["Server Name"] =
687 new _define_commented('SERVER_NAME', 'some.host.com', "
688 Canonical name and httpd port of the server on which this PhpWiki
689 resides.");
690
691
692
693 $properties["Server Port"] =
694 new numeric_define_commented('SERVER_PORT', 80, "");
695
696
697 $properties["Script Name"] =
698 new _define_commented('SCRIPT_NAME', '/some/where/index.php', "
699 Relative URL (from the server root) of the PhpWiki script.");
700
701
702
703 $properties["Data Path"] =
704 new _define_commented('DATA_PATH', '/some/where/phpwiki', "
705 URL of the PhpWiki install directory.  (You only need to set this
706 if you've moved index.php out of the install directory.)  This can
707 be either a relative URL (from the directory where the top-level
708 PhpWiki script is) or an absolute one.");
709
710
711
712 $properties["PhpWiki Install Directory"] =
713 new _define_commented('PHPWIKI_DIR', '/htdocs/some/where/phpwiki', "
714 Path to the PhpWiki install directory.  This is the local
715 filesystem counterpart to DATA_PATH.  (If you have to set
716 DATA_PATH, your probably have to set this as well.)  This can be
717 either an absolute path, or a relative path interpreted from the
718 directory where the top-level PhpWiki script (normally index.php)
719 resides.");
720
721
722
723 $properties["Use PATH_INFO"] =
724 new boolean_define_commented('USE_PATH_INFO', 
725                     array('false' => 'do not use PATH_INFO',
726                           'true'  => 'use PATH_INFO'), "
727 Define to 'true' to use PATH_INFO to pass the pagenames.
728 e.g. http://www.some.where/index.php/HomePage instead
729 of http://www.some.where/index.php?pagename=HomePage
730 FIXME: more docs (maybe in README).");
731
732
733
734 $properties["Virtual Path"] =
735 new _define_commented('VIRTUAL_PATH', '/SomeWiki', "
736 VIRTUAL_PATH is the canonical URL path under which your your wiki
737 appears. Normally this is the same as dirname(SCRIPT_NAME), however
738 using, e.g. apaches mod_actions (or mod_rewrite), you can make it
739 something different.
740
741 If you do this, you should set VIRTUAL_PATH here.
742
743 E.g. your phpwiki might be installed at at /scripts/phpwiki/index.php,
744 but you've made it accessible through eg. /wiki/HomePage.
745
746 One way to do this is to create a directory named 'wiki' in your
747 server root. The directory contains only one file: an .htaccess
748 file which reads something like:
749 <pre>
750     Action x-phpwiki-page /scripts/phpwiki/index.php
751     SetHandler x-phpwiki-page
752     DirectoryIndex /scripts/phpwiki/index.php
753 </pre>
754 In that case you should set VIRTUAL_PATH to '/wiki'.
755
756 (VIRTUAL_PATH is only used if USE_PATH_INFO is true.)
757 ");
758
759
760
761 $end = "
762
763 $SEPARATOR
764 // Okay... fire up the code:
765 $SEPARATOR
766
767 include \"lib/main.php\";
768
769 // (c-file-style: \"gnu\")
770 // Local Variables:
771 // mode: php
772 // tab-width: 8
773 // c-basic-offset: 4
774 // c-hanging-comment-ender-p: nil
775 // indent-tabs-mode: nil
776 // End:   
777 ?>
778 ";
779
780
781
782 // end of configuration options
783 ///////////////////////////////
784 // begin class definitions
785
786 /**
787  * A basic index.php configuration line in the form of a variable.
788  *
789  * Produces a string in the form "$name = value;"
790  * e.g.:
791  * $WikiNameRegexp = "value";
792  */
793 class _variable {
794
795     var $config_item_name;
796     var $default_value;
797     var $description;
798
799     function _variable($config_item_name, $default_value, $description) {
800         $this->config_item_name = $config_item_name;
801         $this->description = $description;
802         $this->default_value = $default_value;
803     }
804
805     function _config_format($value) {
806         $v = $this->get_config_item_name();
807         // handle arrays: a|b --> a['b']
808         if (strpos($v, '|')) {
809             list($a, $b) = explode('|', $v);
810             $v = sprintf("%s['%s']", $a, $b);
811         }
812         return sprintf("\$%s = \"%s\";", $v, $value);
813     }
814     function get_config_item_name() {
815         return $this->config_item_name;
816     }
817
818     function _get_description() {
819         return $this->description;
820     }
821
822     function _get_config_line($posted_value) {
823         return "\n" . $this->_config_format($posted_value);
824     }
825     function get_config($posted_value) {
826         $d = stripHtml($this->_get_description());
827         $d = str_replace("\n", "\n// ", $d) . $this->_get_config_line($posted_value) ."\n";
828         return $d;
829     }
830
831     function get_instructions($title) {
832         $i = "<p><b><h3>" . $title . "</h3></b></p>\n    " . nl2p($this->_get_description()) . "\n";
833         return "<tr>\n<td>\n" . $i . "</td>\n";
834     }
835
836     function get_html() {
837         return "<input type=\"text\" size=\"50\" name=\"" . $this->get_config_item_name() . "\" value=\"" . $this->default_value . "\">";
838     }
839 }
840
841 class unchangeable_variable
842 extends _variable {
843     function _config_format($value) {
844         return "";
845     }
846     function get_html() {
847         return "";
848     }
849     function _get_config_line($posted_value) {
850         if ($this->description)
851             $n = "\n";
852         return "${n}".$this->default_value;
853     }
854     function get_instructions($title) {
855         $i = "<p><b><h3>" . $title . "</h3></b></p>\n    " . nl2p($this->_get_description()) . "\n";
856         $i = $i ."<em>Not editable.</em><br />\n<pre>" . $this->default_value."</pre>";
857         return "<tr>\n<td colspan=\"2\">\n" .$i ."</td></tr>\n";
858     }
859
860 }
861
862 class _variable_selection
863 extends _variable {
864     function get_html() {
865         $output = '<select name="' . $this->get_config_item_name() . "\">\n";
866         /* The first option is the default */
867         while(list($option, $label) = each($this->default_value)) {
868             $output .= "  <option value=\"$option\">$label</option>\n";
869         }
870         $output .= "    </select>\n  </td>\n";
871         return $output;
872     }
873 }
874
875
876 class _define
877 extends _variable {
878     function _config_format($value) {
879         return sprintf("define('%s', '%s');", $this->get_config_item_name(), $value);
880     }
881     function _get_config_line($posted_value) {
882         if ($this->description)
883             $n = "\n";
884         if ($posted_value == '')
885             return "${n}//" . $this->_config_format("");
886         else
887             return "${n}" . $this->_config_format($posted_value);
888     }
889 }
890
891 class _define_commented
892 extends _define {
893     function _get_config_line($posted_value) {
894         if ($this->description)
895             $n = "\n";
896         if ($posted_value == $this->default_value)
897             return "${n}//" . $this->_config_format($posted_value);
898         else if ($posted_value == '')
899             return "${n}//" . $this->_config_format("");
900         else
901             return "${n}" . $this->_config_format($posted_value);
902     }
903 }
904 class _variable_commented
905 extends _variable {
906     function _get_config_line($posted_value) {
907         if ($this->description)
908             $n = "\n";
909         if ($posted_value == $this->default_value)
910             return "${n}//" . $this->_config_format($posted_value);
911         else if ($posted_value == '')
912             return "${n}//" . $this->_config_format("");
913         else
914             return "${n}" . $this->_config_format($posted_value);
915     }
916 }
917
918 class numeric_define_commented
919 extends _define {
920     function _config_format($value) {
921         return sprintf("define('%s', %s);", $this->get_config_item_name(), $value);
922     }
923     function _get_config_line($posted_value) {
924         if ($this->description)
925             $n = "\n";
926         if ($posted_value == $this->default_value)
927             return "${n}//" . $this->_config_format($posted_value);
928         else if ($posted_value == '')
929             return "${n}//" . $this->_config_format('0');
930         else
931             return "${n}" . $this->_config_format($posted_value);
932     }
933 }
934
935 class _define_selection
936 extends _variable_selection {
937     function _config_format($value) {
938         return sprintf("define('%s', '%s');", $this->get_config_item_name(), $value);
939     }
940     function _get_config_line($posted_value) {
941         return _define::_get_config_line($posted_value);
942     }
943     function get_html() {
944         return _variable_selection::get_html();
945     }
946 }
947
948 class _define_password
949 extends _define {
950     function _get_config_line($posted_value) {
951         if ($this->description)
952             $n = "\n";
953         if ($posted_value == '') {
954             $p = "${n}//" . $this->_config_format("");
955             $p = $p . "\n// If you used the passencrypt.php utility to encode the password";
956             $p = $p . "\n// then uncomment this line:";
957             $p = $p . "\n//define('ENCRYPTED_PASSWD', true);";
958             return $p;
959         } else {
960             if (function_exists('crypt')) {
961                 $salt_length = max(CRYPT_SALT_LENGTH,
962                                     2 * CRYPT_STD_DES,
963                                     9 * CRYPT_EXT_DES,
964                                    12 * CRYPT_MD5,
965                                    16 * CRYPT_BLOWFISH);
966                 // generate an encrypted password
967                 $crypt_pass = crypt($posted_value, rand_ascii($salt_length));
968                 $p = "${n}" . $this->_config_format($crypt_pass);
969                 $p = $p . "\n// If you used the passencrypt.php utility to encode the password";
970                 $p = $p . "\n// then uncomment this line:";
971                 return $p . "\ndefine('ENCRYPTED_PASSWD', true);";
972             } else {
973                 $p = "${n}" . $this->_config_format($posted_value);
974                 $p = $p . "\n// If you used the passencrypt.php utility to encode the password";
975                 $p = $p . "\n// then uncomment this line:";
976                 $p = $p . "\n//define('ENCRYPTED_PASSWD', true);";
977                 $p = $p . "\n// Encrypted passwords cannot be used:";
978                 $p = $p . "\n// 'function crypt()' not available in this version of php";
979                 return $p;
980             }
981         }
982     }
983     function get_html() {
984         return _variable_password::get_html();
985     }
986 }
987
988 class _variable_password
989 extends _variable {
990     function get_html() {
991         return "<input type=\"password\" name=\"" . $this->get_config_item_name() . "\" value=\"" . $this->default_value . "\">";
992     }
993 }
994
995 class numeric_define
996 extends _define {
997     function _config_format($value) {
998         return sprintf("define('%s', %s);", $this->get_config_item_name(), $value);
999     }
1000     function _get_config_line($posted_value) {
1001         if ($this->description)
1002             $n = "\n";
1003         if ($posted_value == '')
1004             return "${n}//" . $this->_config_format('0');
1005         else
1006             return "${n}" . $this->_config_format($posted_value);
1007     }
1008 }
1009
1010 class list_variable
1011 extends _variable {
1012     function _get_config_line($posted_value) {
1013         // split the phrase by any number of commas or space characters,
1014         // which include " ", \r, \t, \n and \f
1015         $list_values = preg_split("/[\s,]+/", $posted_value, -1, PREG_SPLIT_NO_EMPTY);
1016         $list_values = join("|", $list_values);
1017         return _variable::_get_config_line($list_values);
1018     }
1019     function get_html() {
1020         $list_values = explode("|", $this->default_value);
1021         $rows = max(3, count($list_values) +1);
1022         $list_values = join("\n", $list_values);
1023         $ta = "<textarea cols=\"18\" rows=\"". $rows ."\" name=\"".$this->get_config_item_name()."\">";
1024         $ta .= $list_values . "</textarea>";
1025         return $ta;
1026     }
1027 }
1028
1029 class array_variable
1030 extends _variable {
1031     function _config_format($value) {
1032         return sprintf("\$%s = array(%s);", $this->get_config_item_name(), $value);
1033     }
1034     function _get_config_line($posted_value) {
1035         // split the phrase by any number of commas or space characters,
1036         // which include " ", \r, \t, \n and \f
1037         $list_values = preg_split("/[\s,]+/", $posted_value, -1, PREG_SPLIT_NO_EMPTY);
1038         if (!empty($list_values)) {
1039             $list_values = "'".join("', '", $list_values)."'";
1040             return "\n" . $this->_config_format($list_values);
1041         } else
1042             return "\n//" . $this->_config_format('');
1043     }
1044     function get_html() {
1045         $list_values = join("\n", $this->default_value);
1046         $rows = max(3, count($this->default_value) +1);
1047         $ta = "<textarea cols=\"18\" rows=\"". $rows ."\" name=\"".$this->get_config_item_name()."\">";
1048         $ta .= $list_values . "</textarea>";
1049         return $ta;
1050     }
1051
1052 }
1053
1054 class _ini_set
1055 extends _variable {
1056     function _config_format($value) {
1057         return sprintf("ini_set('%s', '%s');", $this->get_config_item_name(), $value);
1058     }
1059     function _get_config_line($posted_value) {
1060         if ($posted_value && ! $posted_value == $this->default_value)
1061             return "\n" . $this->_config_format($posted_value);
1062         else
1063             return "\n//" . $this->_config_format($this->default_value);
1064     }
1065 }
1066
1067 class boolean_define
1068 extends _define {
1069     function _config_format($value) {
1070         return sprintf("define('%s', %s);", $this->get_config_item_name(), $value);
1071     }
1072     function _get_config_line($posted_value) {
1073         if ($this->description)
1074             $n = "\n";
1075         return "${n}" . $this->_config_format($posted_value);
1076     }
1077     function get_html() {
1078         $output = '<select name="' . $this->get_config_item_name() . "\">\n";
1079         /* The first option is the default */
1080         list($option, $label) = each($this->default_value);
1081         $output .= "  <option value=\"$option\" selected>$label</option>\n";
1082         /* There can only be two options */
1083         list($option, $label) = each($this->default_value);
1084         $output .= "  <option value=\"$option\">$label</option>\n";
1085         $output .= "</select>\n  </td>\n";
1086         return $output;
1087     }
1088 }
1089
1090 class boolean_define_commented
1091 extends boolean_define {
1092     function _get_config_line($posted_value) {
1093         if ($this->description)
1094             $n = "\n";
1095         list($default_value, $label) = each($this->default_value);
1096         if ($posted_value == $default_value)
1097             return "${n}//" . $this->_config_format($posted_value);
1098         else if ($posted_value == '')
1099             return "${n}//" . $this->_config_format('false');
1100         else
1101             return "${n}" . $this->_config_format($posted_value);
1102     }
1103 }
1104
1105
1106 class part
1107 extends _variable {
1108     function get_config($posted_value) {
1109         $d = stripHtml($this->_get_description());
1110         global $SEPARATOR;
1111         return "\n".$SEPARATOR . str_replace("\n", "\n// ", $d) ."\n$this->default_value";
1112     }
1113     function get_instructions($title) {
1114         $i = "<p><b><h2>" . $title . "</h2></b></p>\n    " . nl2p($this->_get_description()) ."\n";
1115         return "<tr>\n<td colspan=\"2\" bgcolor=\"#eee\">\n" .$i ."</td></tr>\n";
1116     }
1117     function get_html() {
1118         return "";
1119     }
1120 }
1121
1122 // html utility functions
1123 function nl2p($text) {
1124     return "<p>" . str_replace("\n\n", "</p>\n<p>", $text) . "</p>";
1125 }
1126
1127 function stripHtml($text) {
1128         $d = str_replace("<pre>", "", $text);
1129         $d = str_replace("</pre>", "", $d);
1130         $d = str_replace("<dl>", "", $d);
1131         $d = str_replace("</dl>", "", $d);
1132         $d = str_replace("<dt>", "", $d);
1133         $d = str_replace("</dt>", "", $d);
1134         $d = str_replace("<dd>", "", $d);
1135         $d = str_replace("</dd>", "", $d);
1136         //restore html entities into characters
1137         // http://www.php.net/manual/en/function.htmlentities.php
1138         $trans = get_html_translation_table (HTML_ENTITIES);
1139         $trans = array_flip ($trans);
1140         $d = strtr($d, $trans);
1141         return $d;
1142 }
1143
1144 /**
1145  * Seed the random number generator.
1146  *
1147  * better_srand() ensures the randomizer is seeded only once.
1148  * 
1149  * How random do you want it? See:
1150  * http://www.php.net/manual/en/function.srand.php
1151  * http://www.php.net/manual/en/function.mt-srand.php
1152  */
1153 function better_srand($seed = '') {
1154     static $wascalled = FALSE;
1155     if (!$wascalled) {
1156         $seed = $seed === '' ? (double) microtime() * 1000000 : $seed;
1157         srand($seed);
1158         $wascalled = TRUE;
1159         //trigger_error("new random seed", E_USER_NOTICE); //debugging
1160     }
1161 }
1162
1163 function rand_ascii($length = 1) {
1164     better_srand();
1165    //srand((double) microtime() * 1000000);
1166    $s = "";
1167    for ($i = 1; $i <= $length; $i++) {
1168        $s .= chr(rand(40, 126)); // return only typeable 7 bit ascii
1169    }
1170    return $s;
1171 }
1172
1173 // debugging
1174 function printArray($a) {
1175     echo "<hr />\n<pre>\n";
1176     print_r($a);
1177     echo "\n</pre>\n<hr />\n";
1178 }
1179
1180 // end of class definitions
1181 /////////////////////////////
1182 // begin auto generation code
1183
1184 if ($action == 'make_config') {
1185
1186     $timestamp = date ('dS of F, Y H:i:s');
1187
1188     $config = "<?php
1189 /* This is a local configuration file for PhpWiki.
1190  * It was automatically generated by the configurator script
1191  * on the $timestamp.
1192  */
1193
1194 /*$copyright*/
1195
1196 /////////////////////////////////////////////////////////////////////
1197 /*$preamble*/
1198 ";
1199
1200     $posted = $GLOBALS['HTTP_POST_VARS'];
1201
1202     if (defined('DEBUG'))
1203         printArray($GLOBALS['HTTP_POST_VARS']);
1204
1205     foreach($properties as $option_name => $a) {
1206         $posted_value = $posted[$a->config_item_name];
1207         $config .= $properties[$option_name]->get_config($posted_value);
1208     }
1209
1210     if (defined('DEBUG')) {
1211         $diemsg = "The configurator.php is provided for testing purposes only.\nYou can't use this file with your PhpWiki server yet!!";
1212         $config .= "\ndie(\"$diemsg\");\n";
1213     }
1214     $config .= $end;
1215
1216     /* We first check if the config-file exists. */
1217     if (file_exists('settings.php')) {
1218         /* We make a backup copy of the file */
1219         $new_filename = 'settings.' . time() . '.php';
1220         if (@copy('settings.php', $new_filename)) {
1221             $fp = @fopen('settings.php', 'w');
1222         }
1223     } else {
1224         $fp = @fopen('settings.php', 'w');
1225     }
1226
1227     if ($fp) {
1228         fputs($fp, $config);
1229         fclose($fp);
1230         echo "<p>The configuration was written to <code><b>settings.php</b></code>.</p>\n";
1231         if ($new_filename) {
1232             echo "<p>A backup was made to <code><b>$new_filename</b></code>.</p>\n";
1233         }
1234         echo "<p><strong>You must rename or copy this</strong> <code><b>settings.php</b></code> <strong>file to</strong> <code><b>index.php</b></code>.</p>\n";
1235     } else {
1236         echo "<p>A configuration file could <b>not</b> be written. You should copy the above configuration to a file, and manually save it as <code><b>index.php</b></code>.</p>\n";
1237     }
1238
1239     echo "<hr />\n<p>Here's the configuration file based on your answers:</p>\n<pre>\n";
1240     echo htmlentities($config);
1241     echo "</pre>\n<hr />\n";
1242
1243     echo "<p>To make any corrections, <a href=\"configurator.php\">edit the settings again</a>.</p>\n";
1244
1245 } else {
1246     /* No action has been specified - we make a form. */
1247
1248     echo '
1249     <form action="configurator.php" method="post">
1250     <table border="1" cellpadding="4" cellspacing="0">
1251     <input type="hidden" name="action" value="make_config">
1252     ';
1253
1254     while(list($property, $obj) = each($properties)) {
1255         echo $obj->get_instructions($property);
1256         if ($h = $obj->get_html()) {
1257             if (defined('DEBUG'))
1258                 $h = get_class($obj) . "<br />\n" . $h;
1259             echo "<td>".$h."</td>\n";
1260         }
1261     }
1262
1263     echo '
1264         </table>
1265         <p><input type="submit" value="Make config-file"> <input type="reset" value="Clear"></p>
1266         </form>
1267         ';
1268
1269 }
1270 ?>
1271 </body>
1272 </html>