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