]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - configurator.php
more configurator updates (pear cache missing)
[SourceForge/phpwiki.git] / configurator.php
1 <?php 
2 // $Id: configurator.php,v 1.26 2005-02-16 15:11:00 rurban Exp $
3 /**
4  * Starts automatically the first time by IniConfig("config/config.ini") 
5  * if it doesn't exist.
6  *
7  * 1.3.11 TODO:
8  * fix SQL quotes, AUTH_ORDER quotes and file forward slashes
9  * read config-default.ini
10  * read config-dist.ini into sections, comments, and optional/required settings
11  *
12  * 1.3.9 Todo: 
13  * validate input (fix javascript, add POST checks)
14  * start this automatically the first time
15  * fix include_path
16  * eval index-user.php or index.php to get the actual settings.
17  * ask to store it in index.php or index-user.php
18  * 
19  * A file config/config.ini will be generated.
20  *
21  * NOTE: If you have a starterscript outside PHOWIKI_DIR but no 
22  * config/config.ini yet (very unlikely!), you must define DATA_PATH in the 
23  * starterscript, otherwise the webpath to configurator is unknown, and 
24  * subsequent requests will fail. (Save INI)
25  */
26
27 if (!defined('ENABLE_FILE_OUTPUT')) define('ENABLE_FILE_OUTPUT', true);
28
29 global $HTTP_SERVER_VARS;
30 if (empty($configurator))
31     $configurator = "configurator.php";
32 if (!strstr($HTTP_SERVER_VARS["SCRIPT_NAME"], $configurator) and defined('DATA_PATH'))
33     $configurator = DATA_PATH . "/" . $configurator;
34 $scriptname = str_replace('configurator.php', 'index.php', $HTTP_SERVER_VARS["SCRIPT_NAME"]);
35
36 $tdwidth = 700;
37 $config_file = (substr(PHP_OS,0,3) == 'WIN') ? 'config\\config.ini' : 'config/config.ini';
38 $fs_config_file = dirname(__FILE__) . (substr(PHP_OS,0,3) == 'WIN' ? '\\' : '/') . $config_file;
39 if (isset($HTTP_POST_VARS['create']))  header('Location: '.$configurator.'?create=1#create');
40 printf("<?xml version=\"1.0\" encoding=\"%s\"?>\n", 'iso-8859-1'); 
41 ?>
42 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
43   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
44 <html xmlns="http://www.w3.org/1999/xhtml">
45 <head>
46 <!-- $Id: configurator.php,v 1.26 2005-02-16 15:11:00 rurban Exp $ -->
47 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
48 <title>Configuration tool for PhpWiki <?php echo $config_file ?></title>
49 <style type="text/css" media="screen">
50 <!--
51 /* TABLE { border: thin solid black } */
52 body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 80%; }
53 pre { font-size: 120%; }
54 td { border: thin solid black }
55 tr { border: none }
56 tr.hidden { border: none; display: none; }
57 td.part { background-color: #eeeeee; color: inherit; }
58 td.instructions { background-color: #ffffee; width: <?php echo $tdwidth ?>px; color: inherit; }
59 td.unchangeable-variable-top   { border-bottom: none; background-color: #ffffee; color:inherit; }
60 td.unchangeable-variable-left  { border-top: none; background-color: #ffffee; color:inherit; }
61 -->
62 </style>
63 <script language="JavaScript" type="text/javascript">
64 <!--
65 function update(accepted, error, value, output) {
66   if (accepted) {
67     document.getElementById(output).innerHTML = "<font color=\"green\">Input accepted.</font>";
68   } else {
69     while ((index = error.indexOf("%s")) > -1) {
70       error = error.substring(0, index) + value + error.substring(index+2);
71     }
72     document.getElementById(output).innerHTML = "<font color=\"red\">" + error + "</font>";
73   }
74 }
75
76 function validate(error, value, output, field) {
77   update(field.value == value, error, field.value, output);
78 }
79
80 function validate_ereg(error, ereg, output, field) {
81   regex = new RegExp(ereg);
82   update(regex.test(field.value), error, field.value, output);
83 }
84
85 function validate_range(error, low, high, empty_ok, output, field) {
86   update((empty_ok == 1 && field.value == "") ||
87          (field.value >= low && field.value <= high),
88          error, field.value, output);
89 }
90
91 function toggle_group(id) {
92   var text = document.getElementById(id + "_text");
93   var do_hide = false;
94   if (text.innerHTML == "Hide options.") {
95     do_hide = true;
96     text.innerHTML = "Show options.";
97   } else {
98     text.innerHTML = "Hide options.";
99   }
100
101   var rows = document.getElementsByTagName('tr');
102   var i = 0;
103   for (i = 0; i < rows.length; i++) {
104     var tr = rows[i];
105     if (tr.className == 'header' && tr.id == id) {
106       i++;
107       break;
108     }
109   }
110   for (; i < rows.length; i++) {
111     var tr = rows[i];
112     if (tr.className == 'header')
113       break;
114     tr.className = do_hide ? 'hidden': 'nonhidden';
115   }
116 }
117
118 function do_init() {
119   // Hide all groups.  We do this via JavaScript to avoid
120   // hiding the groups if JavaScript is not supported...
121   var rows = document.getElementsByTagName('tr');
122   for (var i = 0; i < rows.length; i++) {
123     var tr = rows[i];
124     if (tr.className == 'header')
125       toggle_group(tr.id);
126   }
127
128   // Select text in textarea upon focus
129   var area = document.getElementById('config-output');
130   if (area) {
131     listener = { handleEvent: function (e) { area.select(); } };
132     area.addEventListener('focus', listener, false);
133   }
134 }
135   
136 -->
137 </script>
138 </head>
139 <body onload="do_init();">
140
141       <h1>Configuration for PhpWiki <?php echo $config_file ?></h1>
142
143 <?php
144 //define('DEBUG', 1);
145 /**
146  * The Configurator is a php script to aid in the configuration of PhpWiki.
147  * Parts of this file were based on PHPWeather's configurator.php file.
148  *   http://sourceforge.net/projects/phpweather/
149  *
150  * TO CHANGE THE CONFIGURATION OF YOUR PHPWIKI, DO *NOT* MODIFY THIS FILE!
151  * more instructions go here
152  *
153  * Todo: 
154  *   * fix include_path
155  *   * eval config.ini to get the actual settings.
156  */
157
158 //////////////////////////////
159 // begin configuration options
160
161 /**
162  * Notes for the description parameter of $property:
163  *
164  * - Descriptive text will be changed into comments (preceeded by ; )
165  *   for the final output to config.ini.
166  *
167  * - Only a limited set of html is allowed: pre, dl dt dd; it will be
168  *   stripped from the final output.
169  *
170  * - Line breaks and spacing will be preserved for the final output.
171  *
172  * - Double line breaks are automatically converted to paragraphs
173  *   for the html version of the descriptive text.
174  *
175  * - Double-quotes and dollar signs in the descriptive text must be
176  *   escaped: \" and \$. Instead of escaping double-quotes you can use 
177  *   single (') quotes for the enclosing quotes. 
178  *
179  * - Special characters like < and > must use html entities,
180  *   they will be converted back to characters for the final output.
181  */
182
183 $SEPARATOR = ";=========================================================================";
184
185 $preamble = "
186 ; This is the main configuration file for PhpWiki in INI-style format.
187 ; Note that certain characters are used as comment char and therefore 
188 ; these entries must be in double-quotes. Such as \":\", \";\", \",\" and \"|\"
189 ; Take special care for DBAUTH_ sql statements. (Part 3a)
190 ;
191 ; This file is divided into several parts: Each one has different configuration 
192 ; settings you can change; in all cases the default should work on your system,
193 ; however, we recommend you tailor things to your particular setting.
194 ";
195
196 $properties["Part Zero"] =
197 new part('_part0', $SEPARATOR."\n", "
198 Part Zero: (optional)
199 Latest Development and Tricky Options");
200
201 if (substr(PHP_OS,0,3) == 'WIN') {
202     $include_path = dirname(__FILE__) . ';' . ini_get('include_path');
203     if (strchr(ini_get('include_path'),'/'))
204         $include_path = strtr($include_path,'\\','/');
205 } else {
206     $include_path = dirname(__FILE__) . ':' . ini_get('include_path');
207 }
208
209 $properties["PHP include_path"] =
210     new _define('INCLUDE_PATH', ini_get('include_path'), "
211 If PHP needs help in finding where you installed the rest of the PhpWiki
212 code, you can set the include_path here.
213
214 Override the PHP include path so that it can find some needed additional libraries.
215 You shouldn't need to do this unless your system include_path esp. your 
216 system pear libs are broken or oudated. The PHPWIKI_DIR is automatically 
217 put to the front and the local lib/pear path is automatically added to the end.
218 But if you define it, be sure to include either the system pear path or 
219 the phpwiki/lib/pear path to override your Pear_DB.
220 Note that on Windows-based servers, you should use ; rather than :
221 as the path separator.");
222
223 // TODO: convert this a checkbox row as in tests/unit/test.pgp
224 $properties["DEBUG"] =
225 new _define_optional('DEBUG', '0', "
226 Set DEBUG to 1 to view the XHTML and CSS validator icons, page
227 processing timer, and possibly other debugging messages at the
228 bottom of each page. 65 for a more verbose level with AUTH hints. 
229 See lib/config.php for all supported values.");
230
231 $properties["ENABLE_USER_NEW"] =
232 new boolean_define_commented_optional
233 ('ENABLE_USER_NEW', 
234  array('true'  => "Enabled",
235        'false' => "Disabled."), "
236 Enable the new method of handling WikiUser Authetincation and Preferences. 
237 It's best to leave it on, and only disable it if you have problems with it.
238 Servers with memory-limit problems might want to turn it off. It costs ~300KB
239 Default: true");
240
241 $properties["ENABLE_PAGEPERM"] =
242 new boolean_define_commented_optional
243 ('ENABLE_PAGEPERM', 
244  array('true'  => "Enabled",
245        'false' => "Disabled."), "
246 Use access control lists (as in Solaris and Windows NTFS) per page and group, 
247 not per user for the whole wiki.
248
249 I suspect ACL page permissions to degrade speed by 10%. 
250 GROUP_METHOD=WIKIPAGE is slowest. (See Part 3a)
251 Default: true");
252
253 $properties["ENABLE_EDIT_TOOLBAR"] =
254 new boolean_define_commented_optional
255 ('ENABLE_EDIT_TOOLBAR', 
256  array('true'  => "Enabled",
257        'false' => "Disabled."), "
258 Graphical buttons on edit. Default: true.
259 Reportedly broken on MacOSX Safari");
260
261 $properties["JS_SEARCHREPLACE"] =
262 new boolean_define_commented_optional
263 ('JS_SEARCHREPLACE', 
264  array('true'  => "Enabled",
265        'false' => "Disabled"), "
266 Adds two additional buttons in EDIT_TOOLBAR, Search&Replace and Undo. 
267 Undo is experimental.");
268
269 $properties["ENABLE_DOUBLECLICKEDIT"] =
270 new boolean_define_commented_optional
271 ('ENABLE_DOUBLECLICKEDIT', 
272  array('true'  => "Enabled",
273        'false' => "Disabled"), "
274 Default: true");
275
276 $properties["ENABLE_XHTML_XML"] =
277 new boolean_define_commented_optional
278 ('ENABLE_XHTML_XML', 
279  array('false' => "Disabled",
280        'true'  => "Enabled"), "
281 Needed for inlined SVG and MathM, but may conflict with javascript:document.write(). 
282 Experimental. Default: false");
283
284 $properties["USECACHE"] =
285 new boolean_define_commented_optional
286 ('USECACHE', 
287  array('true'  => "Enabled",
288        'false' => "Disabled"), "
289 Store DB query results in memory to avoid duplicate queries.
290 Disable only for old php's with low memory or memory_limit=8MB.
291 Default: true");
292
293 $properties["ENABLE_SPAMASSASSIN"] =
294 new boolean_define_commented_optional
295 ('ENABLE_SPAMASSASSIN', 
296  array('true'  => "Enabled",
297        'false' => "Disabled"), "
298 Needs babycart installed. See http://phpwiki.org/SpamAssassinIntegration
299 Optionally define BABYCART_PATH. Default: /usr/local/bin/babycart");
300
301 $properties["GOOGLE_LINKS_NOFOLLOW"] =
302 new boolean_define_commented_optional
303 ('GOOGLE_LINKS_NOFOLLOW', 
304  array('true'  => "Enabled",
305        'false' => "Disabled"), "
306 If enabled ref=nofollow is added to all external links to discourage spam. 
307 You might want to turn it off, if you want to improve pageranks on external links.");
308
309 $properties["ENABLE_LIVESEARCH"] =
310 new boolean_define_commented_optional
311 ('ENABLE_LIVESEARCH', 
312  array('true'  => "Enabled",
313        'false' => "Disabled"), "
314 LiveSearch enables immediate title search results via XMLHttpRequest.
315 Displays the results in a dropdown under the titlesearch inputbox
316 while typing. (experimental, only with certain themes)
317 You'll have to copy livesearch.js from http://blog.bitflux.ch/wiki/LiveSearch
318 to themes/default/ and define ENABLE_LIVESEARCH in config.ini to true. 
319 See themes/blog/themeinfo.php.
320 Currently we use the bitflux.ch library, but we will change to 
321 the russian acdropdown soon. http://momche.net/publish/article.php?page=acdropdown");
322
323 $properties["USE_SAFE_DBSESSION"] =
324 new boolean_define_commented_optional
325 ('USE_SAFE_DBSESSION', 
326  array('false' => "Disabled",
327        'true'  => "Enabled"), "
328 USE_SAFE_DBSESSION should be enabled, if you encounter session problems, with duplicate INSERT 
329 sess_id warnings at the bottom of the page. Reason is a unreliable affected_rows implementation() 
330 in the sql backend. Default is Disabled, using the fastest DbSession UPDATE method.");
331
332 $properties["Part One"] =
333 new part('_part1', $SEPARATOR."\n", "
334 Part One: Authentication and security settings. See Part Three for more.");
335
336 $properties["Admin Username"] =
337 new _define_optional_notempty('ADMIN_USER', "", "
338 You must set this! Username and password of the administrator.",
339 "onchange=\"validate_ereg('Sorry, ADMIN_USER cannot be empty.', '^.+$', 'ADMIN_USER', this);\"");
340
341 $properties["Admin Password"] =
342 new _define_password_optional('ADMIN_PASSWD', "", "
343 For heaven's sake pick a good password.
344 If your version of PHP supports encrypted passwords, your password will be
345 automatically encrypted within the generated config file. 
346 Use the \"Create Random Password\" button to create a good (random) password.
347
348 ADMIN_PASSWD is ignored on HttpAuth",
349 "onchange=\"validate_ereg('Sorry, ADMIN_PASSWD must be at least 4 chars long.', '^....+$', 'ADMIN_PASSWD', this);\"");
350
351 $properties["Encrypted Passwords"] =
352 new boolean_define
353 ('ENCRYPTED_PASSWD',
354  array('true'  => "true.  use crypt for all passwords",
355        'false' => "false. use plaintest passwords (not recommended)"), "
356 It is recommended that you use encrypted passwords to be stored in the 
357 config.ini and the users homepages metadata.
358 You might want to use the passencrypt.php utility to encode the
359 admin password, in the event that someone gains ftp or ssh access to the
360 server and directory containing phpwiki. 
361 <i>SQL access passwords cannot be encrypted, besides using external DATABASE_DSN aliases within PDO.</i>
362
363 If true, all user passwords will be stored encrypted.
364 You might have to set it to false, if your PHP doesn't support crypt().
365 ");
366
367 $properties["Wiki Name"] =
368 new _define_optional('WIKI_NAME', 'PhpWiki', "
369 The name of your wiki.
370
371 This is used to generate a keywords meta tag in the HTML templates,
372 in bookmark titles for any bookmarks made to pages in your wiki,
373 and during RSS generation for the title of the RSS channel.
374
375 It is recommended this be a relatively short WikiWord like the
376 InterWiki monikers found in the InterWikiMap. (For examples, see
377 lib/interwiki.map).
378 ");
379
380 $properties["Reverse DNS"] =
381 new boolean_define_optional
382 ('ENABLE_REVERSE_DNS',
383  array('true'  => "true. perform additional reverse dns lookups",
384        'false' => "false. just record the address as given by the httpd server"),
385
386 If set, we will perform reverse dns lookups to try to convert the
387 users IP number to a host name, even if the http server didn't do it for us.");
388
389 $properties["ZIPdump Authentication"] =
390 new boolean_define_optional('ZIPDUMP_AUTH', 
391                     array('false' => "false. Everyone may download zip dumps",
392                           'true'  => "true. Only admin may download zip dumps"), "
393 If true, only the admin user can make zip dumps, else zip dumps
394 require no authentication.");
395
396 $properties["Enable RawHtml Plugin"] =
397 new boolean_define_commented_optional
398 ('ENABLE_RAW_HTML', 
399  array('true'  => "Enabled",
400        'false' => "Disabled"), "
401 The RawHtml plugin allows page authors to embed real, raw HTML into Wiki
402 pages.  This is a possible security threat, as much HTML (or, rather,
403 JavaScript) can be very risky.  If you are in a controlled environment,
404 however, it could be of use.");
405
406 $properties["Allow RawHtml Plugin only on locked pages"] =
407 new boolean_define_commented_optional
408 ('ENABLE_RAW_HTML_LOCKEDONLY', 
409  array('true'  => "Enabled",
410        'false' => "Disabled"), "
411 If this is set, only pages locked by the Administrator may contain the RawHtml plugin.");
412
413 $properties["Allow RawHtml Plugin if safe HTML code"] =
414 new boolean_define_commented_optional
415 ('ENABLE_RAW_HTML_SAFE', 
416  array('true'  => "Enabled",
417        'false' => "Disabled"), "
418 If this is set, all unsafe html code is stripped automatically (experimental!)
419 See <a href=\"http://chxo.com/scripts/safe_html-test.php\" target=\"_new\">chxo.com/scripts/safe_html-test.php</a>
420 ");
421
422 //FIXME: should be numeric_define_optional
423 $properties["Maximum Upload Size"] =
424 new numeric_define_optional('MAX_UPLOAD_SIZE', "16 * 1024 * 1024", "
425 The maximum file upload size.");
426
427 //FIXME: should be numeric_define_optional
428 $properties["Minor Edit Timeout"] =
429 new numeric_define_optional('MINOR_EDIT_TIMEOUT', "7 * 24 * 3600", "
430 If the last edit is older than MINOR_EDIT_TIMEOUT seconds, the
431 default state for the \"minor edit\" checkbox on the edit page form
432 will be off.");
433
434 $properties["Disabled Actions"] =
435 new array_define('DisabledActions', array(), "
436 Actions listed in this array will not be allowed. Actions are:
437 browse, create, diff, dumphtml, dumpserial, edit, loadfile, lock, remove, 
438 unlock, upload, viewsource, zip, ziphtml");
439
440 $properties["Access Log File"] =
441 new _define_commented_optional('ACCESS_LOG', "/var/logs/wiki_access.log", "
442 PhpWiki can generate an access_log (in \"NCSA combined log\" format)
443 for you. If you want one, define this to the name of the log file,
444 such as /tmp/wiki_access_log. Preferred is to use SQL access logging as below.
445
446 Default: empty - no access log file will be generated.");
447
448 $properties["Access Log SQL"] =
449 new _define_selection(
450 'ACCESS_LOG_SQL', 
451 array('0' => 'disable',
452       '1' => 'read only',
453       '2' => 'read + write'), "
454 PhpWiki can read and/or write apache-style mod_log_sql accesslog tables for faster
455 abuse detection and referer lists. 
456 See http://www.outoforder.cc/projects/apache/mod_log_sql/docs-2.0/#id2756178
457
458 If defined (e.g. 1) only read-access is done via SQL. 
459 If flag 2 is set, phpwiki also writes. (Default on SQL or ADODB)
460 This must use DATABASE_TYPE = SQL or ADODB.
461 ");
462
463 $properties["Compress Output"] =
464 new boolean_define_commented_optional
465 ( 'COMPRESS_OUTPUT', 
466   array(''      => 'GZIP compress when PhpWiki thinks appropriate.',
467         'false' => 'Never compress output.',
468         'true'  => 'Always try to compress output.'),
469 "
470 By default PhpWiki will try to have PHP compress it's output
471 before sending it to the browser (if you have a recent enough
472 version of PHP and the action and the browser supports it.)
473
474 Define COMPRESS_OUTPUT to false to prevent output compression at all.
475
476 Define COMPRESS_OUTPUT to true to force output compression,
477 even if we think your version of PHP does this in a buggy
478 fashion.
479
480 Leave it undefined to leave the choice up to PhpWiki.");
481
482 $properties["HTTP Cache Control"] =
483 new _define_selection_optional
484 ('CACHE_CONTROL',
485  array('LOOSE' => 'LOOSE',
486        'STRICT' => 'STRICT',
487        'NO_CACHE' => 'NO_CACHE',
488        'ALLOW_STALE' => 'ALLOW_STALE'),
489 "
490 HTTP CACHE_CONTROL
491
492 This controls how PhpWiki sets the HTTP cache control
493 headers (Expires: and Cache-Control:) 
494
495 Choose one of:
496
497 <dl>
498 <dt>NO_CACHE</dt>
499 <dd>This is roughly the old (pre 1.3.4) behaviour.  PhpWiki will
500     instruct proxies and browsers never to cache PhpWiki output.</dd>
501
502 <dt>STRICT</dt>
503 <dd>Cached pages will be invalidated whenever the database global
504     timestamp changes.  This should behave just like NONE (modulo
505     bugs in PhpWiki and your proxies and browsers), except that
506     things will be slightly more efficient.</dd>
507
508 <dt>LOOSE</dt>
509 <dd>Cached pages will be invalidated whenever they are edited,
510     or, if the pages include plugins, when the plugin output could
511     concievably have changed.
512
513     <p>Behavior should be much like STRICT, except that sometimes
514        wikilinks will show up as undefined (with the question mark)
515        when in fact they refer to (recently) created pages.
516        (Hitting your browsers reload or perhaps shift-reload button
517        should fix the problem.)</p></dd>
518
519 <dt>ALLOW_STALE</dt>
520 <dd>Proxies and browsers will be allowed to used stale pages.
521     (The timeout for stale pages is controlled by CACHE_CONTROL_MAX_AGE.)
522
523     <p>This setting will result in quirky behavior.  When you edit a
524        page your changes may not show up until you shift-reload the
525        page, etc...</p>
526
527     <p>This setting is generally not advisable, however it may be useful
528        in certain cases (e.g. if your wiki gets lots of page views,
529        and few edits by knowledgable people who won't freak over the quirks.)</p>
530 </dd>
531
532 The default is currently LOOSE.");
533
534 // FIXME: should be numeric_define_optional
535 $properties["HTTP Cache Control Max Age"] =
536 new numeric_define_optional('CACHE_CONTROL_MAX_AGE', 600,
537             "
538 Maximum page staleness, in seconds.");
539
540 $properties["Markup Caching"] =
541 new boolean_define_commented_optional
542 ('WIKIDB_NOCACHE_MARKUP',
543  array('false' => 'Enable markup cache',
544        'true'  => 'Disable markup cache'),
545 "
546 MARKUP CACHING
547
548 PhpWiki normally caches a preparsed version (i.e. mostly
549 converted to HTML) of the most recent version of each page.
550 (Parsing the wiki-markup takes a fair amount of CPU.)
551
552 Define WIKIDB_NOCACHE_MARKUP to true to disable the
553 caching of marked-up page content.
554
555 Note that you can also disable markup caching on a per-page
556 temporary basis by addinging a query arg of '?nocache=1'
557 to the URL to the page.  (Use '?nocache=purge' to completely
558 discard the cached version of the page.)
559
560 You can also purge the cached markup globally by using the
561 \"Purge Markup Cache\" button on the PhpWikiAdministration page.");
562
563 $properties["Path for PHP Session Support"] =
564     new _define_optional('SESSION_SAVE_PATH', ini_get('session.save_path'), "
565 The login code now uses PHP session support. Usually, the default
566 configuration of PHP is to store the session state information in
567 /tmp. That probably will work fine, but fails e.g. on clustered
568 servers where each server has their own distinct /tmp (this is the
569 case on SourceForge's project web server.) You can specify an
570 alternate directory in which to store state information like so
571 (whatever user your httpd runs as must have read/write permission
572 in this directory).
573
574 On USE_DB_SESSION = true you can ignore this.
575 ");
576
577 ///////// database selection
578
579 $properties["Part Two"] =
580 new part('_part2', $SEPARATOR."\n", "
581
582 Part Two:
583 Database Configuration
584 ");
585
586 $properties["Database Type"] =
587 new _define_selection("DATABASE_TYPE",
588               array('dba'   => "dba",
589                     'SQL'   => "SQL PEAR",
590                     'ADODB' => "SQL ADODB",
591                     'PDO'   => "PDO (php5 only)",
592                     'file'   => "flatfile",
593                     'cvs'   => "CVS File handler"), "
594 Select the database backend type:
595 Choose dba (default) to use one of the standard UNIX dba libraries. This is the fastest.
596 Choose ADODB or SQL to use an SQL database with ADODB or PEAR.
597 Choose PDO on php5 to use an SQL database.
598 flatfile is simple and slow.
599 CVS is highly experimental and slow.
600 Recommended is dba or SQL: PEAR or ADODB.");
601
602 $properties["SQL DSN Setup"] =
603 new unchangeable_variable('_sqldsnstuff', "", "
604 For SQL based backends, specify the database as a DSN
605 The most general form of a DSN looks like:
606 <pre>
607   phptype(dbsyntax)://username:password@protocol+hostspec/database?option=value
608 </pre>
609 For a MySQL database, the following should work:
610 <pre>
611    mysql://user:password@host/databasename
612 </pre>
613 To connect over a unix socket, use something like
614 <pre>
615    mysql://user:password@unix(/path/to/socket)/databasename
616 </pre>
617 <pre>
618   DATABASE_DSN = mysql://guest@:/var/lib/mysql/mysql.sock/phpwiki
619   DATABASE_DSN = mysql://guest@localhost/phpwiki
620   DATABASE_DSN = pgsql://localhost/user_phpwiki
621 </pre>");
622
623 // Choose ADODB or SQL to use an SQL database with ADODB or PEAR.
624 // Choose dba to use one of the standard UNIX dbm libraries.
625
626 $properties["SQL Type"] =
627 new _variable_selection('_dsn_sqltype',
628               array('mysql'  => "MySQL",
629                     'pgsql'  => "PostgreSQL",
630                     'mssql'  => "Microsoft SQL Server",
631                     'oci8'   => "Oracle 8",
632                     'mysqli' => "mysqli (only ADODB)",
633                     'mysqlt' => "mysqlt (only ADODB)",
634                     'ODBC'   => "ODBC (only ADODB or PDO)",
635                     'firebird' => "Firebird (only PDO)",
636                     'oracle'  => "Oracle (only PDO)",
637 ), "
638 SQL DB types. The DSN hosttype.");
639
640 $properties["SQL User"] =
641 new _variable('_dsn_sqluser', "wikiuser", "
642 SQL User Id:");
643
644 $properties["SQL Password"] =
645 new _variable('_dsn_sqlpass', "", "
646 SQL Password:");
647
648 $properties["SQL Database Host"] =
649 new _variable('_dsn_sqlhostorsock', "localhost", "
650 SQL Database Hostname:
651
652 To connect over a local named socket, use something like
653 <pre>
654   unix(/var/lib/mysql/mysql.sock)
655 </pre>
656 here. 
657 mysql on Windows via named pipes might need 127.0.0.1");
658
659 $properties["SQL Database Name"] =
660 new _variable('_dsn_sqldbname', "phpwiki", "
661 SQL Database Name:");
662
663 $dsn_sqltype = $properties["SQL Type"]->value();
664 $dsn_sqluser = $properties["SQL User"]->value();
665 $dsn_sqlpass = $properties["SQL Password"]->value();
666 $dsn_sqlhostorsock = $properties["SQL Database Host"]->value();
667 $dsn_sqldbname = $properties["SQL Database Name"]->value();
668 $dsn_sqlstring = $dsn_sqltype."://{$dsn_sqluser}:{$dsn_sqlpass}@{$dsn_sqlhostorsock}/{$dsn_sqldbname}";
669
670 $properties["SQL dsn"] =
671 new unchangeable_define("DATABASE_DSN", 
672                         "DATABASE_DSN = \"$dsn_sqlstring\"", "
673 Calculated from the settings above:");
674
675 $properties["Filename / Table name Prefix"] =
676 new _define_commented("DATABASE_PREFIX", "", "
677 Used by all DB types:
678
679 Prefix for filenames or table names, e.g. \"phpwiki_\"
680
681 Currently <b>you MUST EDIT THE SQL file too!</b> (in the schemas/
682 directory because we aren't doing on the fly sql generation
683 during the installation.");
684
685 $properties["DB Session table"] =
686 new _define_optional("DATABASE_SESSION_TABLE", "session", "
687 Tablename to store session information. Only supported by SQL backends.
688
689 A word of warning - any prefix defined above will be prepended to whatever is given here.
690 ");
691
692 //TODO: $TEMP
693 $temp = !empty($_ENV['TEMP']) ? $_ENV['TEMP'] : "/tmp";
694 $properties["dba directory"] =
695 new _define("DATABASE_DIRECTORY", $temp, "
696 dba directory:");
697
698 // TODO: list the available methods
699 $properties["dba handler"] =
700 new _define_selection('DATABASE_DBA_HANDLER',
701               array('gdbm' => "Gdbm - GNU database manager (recommended)",
702                     'dbm'  => "DBM - Redhat default. On sf.net there's dbm and gdbm",
703                     'db2'  => "DB2 - Sleepycat Software's DB2",
704                     'db3'  => "DB3 - Sleepycat Software's DB3. Default on Windows but not on every Linux",
705                     'db4'  => "DB4 - Sleepycat Software's DB4."), "
706 Use 'gdbm', 'dbm', 'db2', 'db3' or 'db4' depending on your DBA handler methods supported: <br >  "
707                       . (function_exists("dba_handlers") ? join(", ",dba_handlers()) : ""));
708
709 $properties["dba timeout"] =
710 new numeric_define("DATABASE_TIMEOUT", "12", "
711 Recommended values are 10-20 seconds. The more load the server has, the higher the timeout.");
712
713 $properties["DATABASE_PERSISTENT"] =
714 new boolean_define_commented_optional
715 ('DATABASE_PERSISTENT', 
716  array('false' => "Disabled",
717        'true'  => "Enabled"), "
718 Use persistent database connections for SQL databases, if the database backend supports it.
719 Not recommended for heavily loaded servers.
720 Default: false");
721
722 ///////////////////
723
724 $properties["Page Revisions"] =
725 new unchangeable_variable('_parttworevisions', "", "
726
727 Section 2a: Archive Cleanup
728 The next section controls how many old revisions of each page are kept in the database.
729
730 There are two basic classes of revisions: major and minor. Which
731 class a revision belongs in is determined by whether the author
732 checked the \"this is a minor revision\" checkbox when they saved the
733 page.
734  
735 There is, additionally, a third class of revisions: author
736 revisions. The most recent non-mergable revision from each distinct
737 author is and author revision.
738
739 The expiry parameters for each of those three classes of revisions
740 can be adjusted seperately. For each class there are five
741 parameters (usually, only two or three of the five are actually
742 set) which control how long those revisions are kept in the
743 database.
744 <dl>
745    <dt>max_keep:</dt> <dd>If set, this specifies an absolute maximum for the
746             number of archived revisions of that class. This is
747             meant to be used as a safety cap when a non-zero
748             min_age is specified. It should be set relatively high,
749             and it's purpose is to prevent malicious or accidental
750             database overflow due to someone causing an
751             unreasonable number of edits in a short period of time.</dd>
752
753   <dt>min_age:</dt>  <dd>Revisions younger than this (based upon the supplanted
754             date) will be kept unless max_keep is exceeded. The age
755             should be specified in days. It should be a
756             non-negative, real number,</dd>
757
758   <dt>min_keep:</dt> <dd>At least this many revisions will be kept.</dd>
759
760   <dt>keep:</dt>     <dd>No more than this many revisions will be kept.</dd>
761
762   <dt>max_age:</dt>  <dd>No revision older than this age will be kept.</dd>
763 </dl>
764 Supplanted date: Revisions are timestamped at the instant that they
765 cease being the current revision. Revision age is computed using
766 this timestamp, not the edit time of the page.
767
768 Merging: When a minor revision is deleted, if the preceding
769 revision is by the same author, the minor revision is merged with
770 the preceding revision before it is deleted. Essentially: this
771 replaces the content (and supplanted timestamp) of the previous
772 revision with the content after the merged minor edit, the rest of
773 the page metadata for the preceding version (summary, mtime, ...)
774 is not changed.
775 ");
776
777 // For now the expiration parameters are statically inserted as
778 // an unchangeable property. You'll have to edit the resulting
779 // config file if you really want to change these from the default.
780
781 $properties["Major Edits: keep minumum days"] =
782     new numeric_define("MAJOR_MIN_KEEP", "2147483647", "
783 Default: Keep at least for unlimited time. 
784 Set to 0 to enable archive cleanup");
785 $properties["Minor Edits: keep minumum days"] =
786     new numeric_define("MINOR_MIN_KEEP", "2147483647", "
787 Default: Keep at least for unlimited time. 
788 Set to 0 to enable archive cleanup");
789
790 $properties["Major Edits: how many"] =
791     new numeric_define("MAJOR_KEEP", "8", "
792 Keep up to 8 major edits");
793 $properties["Major Edits: how many days"] =
794     new numeric_define("MAJOR_MAX_AGE", "32", "
795 keep them no longer than a month");
796
797 $properties["Minor Edits: how many"] =
798     new numeric_define("MINOR_KEEP", "4", "
799 Keep up to 4 minor edits");
800 $properties["Minor Edits: how many days"] =
801     new numeric_define("MINOR_MAX_AGE", "7", "
802 keep them no longer than a week");
803
804 $properties["per Author: how many"] =
805     new numeric_define("AUTHOR_KEEP", "8", "
806 Keep the latest contributions of the last 8 authors,");
807 $properties["per Author: how many days"] =
808     new numeric_define("AUTHOR_MAX_AGE", "365", "
809 up to a year.");
810 $properties["per Author: keep minumum days"] =
811     new numeric_define("AUTHOR_MIN_AGE", "7", "
812 Additionally, (in the case of a particularly active page) try to
813 keep the latest contributions of all authors in the last week (even if there are more than eight of them,)");
814 $properties["per Author: max revisions"] =
815     new numeric_define("AUTHOR_MAX_KEEP", "20", "
816 but in no case keep more than twenty unique author revisions.");
817
818 /////////////////////////////////////////////////////////////////////
819
820 $properties["Part Three"] =
821 new part('_part3', $SEPARATOR."\n", "
822
823 Part Three: (optional)
824 Basic User Authentication Setup
825 ");
826
827 $properties["Publicly viewable"] =
828 new boolean_define_optional('ALLOW_ANON_USER',
829                     array('true'  => "true. Permit anonymous view. (Default)",
830                           'false' => "false. Force login even on view (strictly private)"), "
831 If ALLOW_ANON_USER is false, you have to login before viewing any page or doing any other action on a page.");
832
833 $properties["Allow anonymous edit"] =
834 new boolean_define_optional('ALLOW_ANON_EDIT',
835                     array('true'  => "true. Permit anonymous users to edit. (Default)",
836                           'false' => "false. Force login on edit (moderately locked)"), "
837 If ALLOW_ANON_EDIT is false, you have to login before editing or changing any page. See below.");
838
839 $properties["Allow Bogo Login"] =
840 new boolean_define_optional('ALLOW_BOGO_LOGIN',
841                     array('true'  => "true. Users may Sign In with any WikiWord, without password. (Default)",
842                           'false' => "false. Require stricter authentication."), "
843 If ALLOW_BOGO_LOGIN is false, you may not login with any wikiword username and empty password. 
844 If true, users are allowed to create themselves with any WikiWord username. See below.");
845
846 $properties["Allow User Passwords"] =
847 new boolean_define_optional('ALLOW_USER_PASSWORDS',
848                     array('true'  => "True user authentication with password checking. (Default)",
849                           'false' => "false. Ignore authentication settings below."), "
850 If ALLOW_USER_PASSWORDS is true, the authentication settings below define where and how to 
851 check against given username/passwords. For completely security disable BOGO_LOGIN and ANON_EDIT above.");
852
853 $properties["Allow User Passwords"] =
854     new array_define('USER_AUTH_ORDER', array("PersonalPage", "Db"), "
855 Many different methods can be used to check user's passwords. 
856 Try any of these in the given order:
857 <dl>
858 <dt>BogoLogin</dt>
859         <dd>WikiWord username, with no *actual* password checking,
860         although the user will still have to enter one.</dd>
861 <dt>PersonalPage</dt>
862         <dd>Store passwords in the users homepage metadata (simple)</dd>
863 <dt>Db</dt>
864         <dd>Use DBAUTH_AUTH_* (see below) with PearDB or ADODB only.</dd>
865 <dt>LDAP</dt>
866         <dd>Authenticate against LDAP_AUTH_HOST with LDAP_BASE_DN</dd>
867 <dt>IMAP</dt>
868         <dd>Authenticate against IMAP_AUTH_HOST (email account)</dd>
869 <dt>POP3</dt>
870         <dd>Authenticate against POP3_AUTH_HOST (email account)</dd>
871 <dt>Session</dt>
872         <dd>Get username and level from a PHP session variable. (e.g. for gforge)</dd>
873 <dt>File</dt>
874         <dd>Store username:crypted-passwords in .htaccess like files. 
875          Use Apache's htpasswd to manage this file.</dd>
876 <dt>HttpAuth</dt>
877         <dd>Use the protection by the webserver (.htaccess/.htpasswd) (experimental)
878         Enforcing HTTP Auth not yet. Note that the ADMIN_USER should exist also.
879         Using HttpAuth disables all other methods and no userauth sessions are used.</dd>
880 </dl>
881
882 Several of these methods can be used together, in the manner specified by
883 USER_AUTH_POLICY, below.  To specify multiple authentication methods,
884 separate the name of each one with colons.
885 <pre>
886   USER_AUTH_ORDER = 'PersonalPage : Db'
887   USER_AUTH_ORDER = 'BogoLogin : PersonalPage'</pre>");
888
889 $properties["PASSWORD_LENGTH_MINIMUM"] =
890     new numeric_define("PASSWORD_LENGTH_MINIMUM", "6", "
891 For 'security' purposes, you can specify that a password be at least a
892 certain number of characters long.  This applies even to the BogoLogin method. 
893 Default: 0 (to allow immediate passwordless BogoLogin)");
894
895 $properties["USER_AUTH_POLICY"] =
896 new _define_selection('USER_AUTH_POLICY',
897               array('first-only' => "first-only - use only the first method in USER_AUTH_ORDER",
898                     'old'       => "old - ignore USER_AUTH_ORDER (legacy)",
899                     'strict'    => "strict - check all methods for userid + password (recommended)",
900                     'stacked'   => "stacked - check all methods for userid, and if found for password"), "
901 The following policies are available for user authentication:
902 <dl>
903 <dt>first-only</dt>
904         <dd>use only the first method in USER_AUTH_ORDER</dd>
905 <dt>old</dt>
906         <dd>ignore USER_AUTH_ORDER and try to use all available 
907         methods as in the previous PhpWiki releases (slow)</dd>
908 <dt>strict</dt>
909         <dd>check if the user exists for all methods: 
910         on the first existing user, try the password. 
911         dont try the other methods on failure then</dd>
912 <dt>stacked</dt>
913         <dd>check the given user - password combination for all
914         methods and return true on the first success.</dd></dl>");
915
916 ///////////////////
917
918 $properties["Part Three A"] =
919 new part('_part3a', $SEPARATOR."\n", "
920
921 Part Three A: (optional)
922 Group Membership");
923
924 $properties["Group membership"] =
925 new _define_selection("GROUP_METHOD",
926               array('WIKIPAGE' => "WIKIPAGE - List at \"CategoryGroup\". (Slowest, but easiest to maintain)",
927                     '"NONE"'   => "NONE - Disable group membership (Fastest)",
928                     'DB'       => "DB - SQL Database, Optionally external. See USERS/GROUPS queries",
929                     'FILE'     => "Flatfile. See AUTH_GROUP_FILE below.",
930                     'LDAP'     => "LDAP - See \"LDAP authentication options\" above. (Experimental)"), "
931 Group membership.  PhpWiki supports defining permissions for a group as
932 well as for individual users.  This defines how group membership information
933 is obtained.  Supported values are:
934 <dl>
935 <dt>\"NONE\"</dt>
936           <dd>Disable group membership (Fastest). Note the required quoting.</dd>
937 <dt>WIKIPAGE</dt>
938           <dd>Define groups as list at \"CategoryGroup\". (Slowest, but easiest to maintain)</dd>
939 <dt>DB</dt>
940           <dd>Stored in an SQL database. Optionally external. See USERS/GROUPS queries</dd>
941 <dt>FILE</dt>
942           <dd>Flatfile. See AUTH_GROUP_FILE below.</dd>
943 <dt>LDAP</dt>
944           <dd>LDAP groups. See \"LDAP authentication options\" above and 
945           lib/WikiGroup.php. (experimental)</dd></dl>");
946
947 $properties["CATEGORY_GROUP_PAGE"] =
948   new _define_optional('CATEGORY_GROUP_PAGE', _("CategoryGroup"), "
949 If GROUP_METHOD = WIKIPAGE:
950
951 Page where all groups are listed.");
952
953 $properties["AUTH_GROUP_FILE"] =
954   new _define_optional('AUTH_GROUP_FILE', _("/etc/groups"), "
955 For GROUP_METHOD = FILE, the file given below is referenced to obtain
956 group membership information.  It should be in the same format as the
957 standard unix /etc/groups(5) file.");
958
959 $properties["Part Three B"] =
960 new part('_part3b', $SEPARATOR."\n", "
961
962 Part Three B: (optional)
963 External database authentication and authorization.
964
965 If USER_AUTH_ORDER includes Db, or GROUP_METHOD = DB, the options listed
966 below define the SQL queries used to obtain the information out of the
967 database, and (optionally) store the information back to the DB.");
968
969 $properties["DBAUTH_AUTH_DSN"] =
970   new _define_optional('DBAUTH_AUTH_DSN', $dsn_sqlstring, "
971 A database DSN to connect to.  Defaults to the DSN specified for the Wiki as a whole.");
972
973 $properties["User Exists Query"] =
974   new _define('DBAUTH_AUTH_USER_EXISTS', "\"SELECT userid FROM user WHERE userid='\$userid'\"", "
975 USER/PASSWORD queries:
976
977 For USER_AUTH_POLICY=strict and the Db method is required");
978
979 $properties["Check Query"] =
980   new _define_optional('DBAUTH_AUTH_CHECK', "\"SELECT IF(passwd='\$password',1,0) AS ok FROM user WHERE userid='\$userid'\"", "
981
982 Check to see if the supplied username/password pair is OK
983
984 Plaintext passwords: (DBAUTH_AUTH_CRYPT_METHOD = plain)<br>
985 ; DBAUTH_AUTH_CHECK = \"SELECT IF(passwd='\$password',1,0) AS ok FROM user WHERE userid='\$userid'\"
986
987 database-hashed passwords (more secure):<br>
988 ; DBAUTH_AUTH_CHECK = \"SELECT IF(passwd=PASSWORD('\$password'),1,0) AS ok FROM user WHERE userid='\$userid'\"");
989
990 $properties["Crypt Method"] =
991 new _define_selection_optional
992 ('DBAUTH_AUTH_CRYPT_METHOD',
993  array('plain' => 'plain',
994        'crypt' => 'crypt'), "
995 If you want to use Unix crypt()ed passwords, you can use DBAUTH_AUTH_CHECK
996 to get the password out of the database with a simple SELECT query, and
997 specify DBAUTH_AUTH_USER_EXISTS and DBAUTH_AUTH_CRYPT_METHOD:
998
999 ; DBAUTH_AUTH_CHECK = \"SELECT passwd FROM user where userid='\$userid'\" <br>
1000 ; DBAUTH_AUTH_CRYPT_METHOD = crypt");
1001
1002 $properties["Update the user's authentication credential"] =
1003     new _define('DBAUTH_AUTH_UPDATE', "\"UPDATE user SET passwd='\$password' WHERE userid='\$userid'\"", "
1004 If this is not defined but DBAUTH_AUTH_CHECK is, then the user will be unable to update their
1005 password.
1006
1007 Plaintext passwords:<br>
1008   DBAUTH_AUTH_UPDATE = \"UPDATE user SET passwd='\$password' WHERE userid='\$userid'\"<br>
1009 Database-hashed passwords:<br>
1010   DBAUTH_AUTH_UPDATE = \"UPDATE user SET passwd=PASSWORD('\$password') WHERE userid='\$userid'\"");
1011
1012 $properties["Allow the user to create their own account"] =
1013     new _define_optional('DBAUTH_AUTH_CREATE', "\"INSERT INTO user SET passwd=PASSWORD('\$password'),userid='\$userid'\"", "
1014 If this is empty, Db users cannot subscribe by their own.");
1015
1016 $properties["USER/PREFERENCE queries"] =
1017     new _define_optional('DBAUTH_PREF_SELECT', "\"SELECT prefs FROM user WHERE userid='\$userid'\"", "
1018 If you choose to store your preferences in an external database, enable
1019 the following queries.  Note that if you choose to store user preferences
1020 in the 'user' table, only registered users get their prefs from the database,
1021 self-created users do not.  Better to use the special 'pref' table.
1022
1023 The prefs field stores the serialized form of the user's preferences array,
1024 to ease the complication of storage.
1025 <pre>
1026   DBAUTH_PREF_SELECT = \"SELECT prefs FROM user WHERE userid='\$userid'\"
1027   DBAUTH_PREF_SELECT = \"SELECT prefs FROM pref WHERE userid='\$userid'\"
1028 </pre>");
1029
1030 $properties["Update the user's preferences"] =
1031     new _define_optional('DBAUTH_PREF_UPDATE', "\"UPDATE user SET prefs='\$pref_blob' WHERE userid='\$userid'\"", "
1032 Note that REPLACE works only with mysql and destroy all other columns!
1033
1034 Mysql: DBAUTH_PREF_UPDATE = \"REPLACE INTO pref SET prefs='\$pref_blob',userid='\$userid'\"");
1035
1036 $properties["USERS/GROUPS queries"] =
1037     new _define_optional('DBAUTH_IS_MEMBER', "\"SELECT user FROM user WHERE user='\$userid' AND group='\$groupname'\"", "
1038 You can define 1:n or n:m user<=>group relations, as you wish.
1039
1040 Sample configurations:
1041
1042 only one group per user (1:n):<br>
1043    DBAUTH_IS_MEMBER = \"SELECT user FROM user WHERE user='\$userid' AND group='\$groupname'\"<br>
1044    DBAUTH_GROUP_MEMBERS = \"SELECT user FROM user WHERE group='\$groupname'\"<br>
1045    DBAUTH_USER_GROUPS = \"SELECT group FROM user WHERE user='\$userid'\"<br>
1046 multiple groups per user (n:m):<br>
1047    DBAUTH_IS_MEMBER = \"SELECT userid FROM member WHERE userid='\$userid' AND groupname='\$groupname'\"<br>
1048    DBAUTH_GROUP_MEMBERS = \"SELECT DISTINCT userid FROM member WHERE groupname='\$groupname'\"<br>
1049    DBAUTH_USER_GROUPS = \"SELECT groupname FROM member WHERE userid='\$userid'\"<br>");
1050 $properties["DBAUTH_GROUP_MEMBERS"] =
1051     new _define_optional('DBAUTH_GROUP_MEMBERS', "\"SELECT user FROM user WHERE group='\$groupname'\"", "");
1052 $properties["DBAUTH_USER_GROUPS"] =
1053     new _define_optional('DBAUTH_USER_GROUPS', "\"SELECT group FROM user WHERE user='\$userid'\"", "");
1054
1055 if (function_exists('ldap_connect')) {
1056
1057 $properties["LDAP AUTH Host"] =
1058   new _define_optional('LDAP_AUTH_HOST', "ldap://localhost:389", "
1059 If USER_AUTH_ORDER contains Ldap:
1060
1061 The LDAP server to connect to.  Can either be a hostname, or a complete
1062 URL to the server (useful if you want to use ldaps or specify a different
1063 port number).");
1064
1065 $properties["LDAP BASE DN"] =
1066   new _define_optional('LDAP_BASE_DN', "ou=mycompany.com,o=My Company", "
1067 The organizational or domain BASE DN: e.g. \"dc=mydomain,dc=com\".
1068
1069 Note: ou=Users and ou=Groups are used for GroupLdap Membership
1070 Better use LDAP_OU_USERS and LDAP_OU_GROUP with GROUP_METHOD=LDAP.");
1071
1072 $properties["LDAP SET OPTION"] =
1073     new _define_optional('LDAP_SET_OPTION', "LDAP_OPT_PROTOCOL_VERSION=3:LDAP_OPT_REFERRALS=0", "
1074 Some LDAP servers need some more options, such as the Windows Active
1075 Directory Server.  Specify the options (as allowed by the PHP LDAP module)
1076 and their values as NAME=value pairs separated by colons.");
1077
1078 $properties["LDAP AUTH USER"] =
1079     new _define_optional('LDAP_AUTH_USER', "CN=ldapuser,ou=Users,o=Development,dc=mycompany.com", "
1080 DN to initially bind to the LDAP server as. This is needed if the server doesn't 
1081 allow anonymous queries. (Windows Active Directory Server)");
1082
1083 $properties["LDAP AUTH PASSWORD"] =
1084     new _define_optional('LDAP_AUTH_PASSWORD', "secret", "
1085 Password to use to initially bind to the LDAP server, as the DN 
1086 specified in the LDAP_AUTH_USER option (above).");
1087
1088 $properties["LDAP SEARCH FIELD"] =
1089     new _define_optional('LDAP_SEARCH_FIELD', "uid", "
1090 If you want to match usernames against an attribute other than uid,
1091 specify it here. Default: uid
1092
1093 e.g.: LDAP_SEARCH_FIELD = sAMAccountName");
1094
1095 $properties["LDAP OU USERS"] =
1096     new _define_optional('LDAP_OU_USERS', "ou=Users", "
1097 If you have an organizational unit for all users, define it here.
1098 This narrows the search, and is needed for LDAP group membership (if GROUP_METHOD=LDAP)
1099 Default: ou=Users");
1100
1101 $properties["LDAP OU GROUP"] =
1102     new _define_optional('LDAP_OU_GROUP', "ou=Groups", "
1103 If you have an organizational unit for all groups, define it here.
1104 This narrows the search, and is needed for LDAP group membership (if GROUP_METHOD=LDAP)
1105 The entries in this ou must have a gidNumber and cn attribute.
1106 Default: ou=Groups");
1107
1108 } else {
1109
1110 $properties["LDAP Authentication"] =
1111 new unchangeable_define('LDAP Authentication', "
1112 If USER_AUTH_ORDER contains Ldap:
1113
1114 The LDAP server to connect to.  Can either be a hostname, or a complete
1115 URL to the server (useful if you want to use ldaps or specify a different
1116 port number).
1117 ;LDAP_AUTH_HOST = \"ldap://localhost:389\"
1118
1119 ; The organizational or domain BASE DN: e.g. \"dc=mydomain,dc=com\".
1120 ;
1121 ; Note: ou=Users and ou=Groups are used for GroupLdap Membership
1122 ; Better use LDAP_OU_USERS and LDAP_OU_GROUP with GROUP_METHOD=LDAP.
1123 ;LDAP_BASE_DN = \"ou=Users,o=Development,dc=mycompany.com\"
1124
1125 ; Some LDAP servers need some more options, such as the Windows Active
1126 ; Directory Server.  Specify the options (as allowed by the PHP LDAP module)
1127 ; and their values as NAME=value pairs separated by colons.
1128 ; LDAP_SET_OPTION = \"LDAP_OPT_PROTOCOL_VERSION=3:LDAP_OPT_REFERRALS=0\"
1129
1130 ; DN to initially bind to the LDAP server as. This is needed if the server doesn't 
1131 ; allow anonymous queries. (Windows Active Directory Server)
1132 ; LDAP_AUTH_USER = \"CN=ldapuser,ou=Users,o=Development,dc=mycompany.com\"
1133
1134 ; Password to use to initially bind to the LDAP server, as the DN 
1135 ; specified in the LDAP_AUTH_USER option (above).
1136 ; LDAP_AUTH_PASSWORD = secret
1137
1138 ; If you want to match usernames against an attribute other than uid,
1139 ; specify it here. Default: uid
1140 ; LDAP_SEARCH_FIELD = sAMAccountName
1141
1142 ; If you have an organizational unit for all users, define it here.
1143 ; This narrows the search, and is needed for LDAP group membership (if GROUP_METHOD=LDAP)
1144 ; Default: ou=Users
1145 ; LDAP_OU_USERS = ou=Users
1146
1147 ; If you have an organizational unit for all groups, define it here.
1148 ; This narrows the search, and is needed for LDAP group membership (if GROUP_METHOD=LDAP)
1149 ; The entries in this ou must have a gidNumber and cn attribute.
1150 ; Default: ou=Groups
1151 ; LDAP_OU_GROUP = ou=Groups", "
1152 ; Ignored. No LDAP support in this php. configure --with-ldap");
1153 }
1154
1155 if (function_exists('imap_open')) {
1156
1157 $properties["IMAP Auth Host"] =
1158   new _define_optional('IMAP_AUTH_HOST', 'localhost:143/imap/notls', "
1159 If USER_AUTH_ORDER contains IMAP:
1160
1161 The IMAP server to check usernames from. Defaults to localhost.
1162
1163 Some IMAP_AUTH_HOST samples:
1164   localhost, localhost:143/imap/notls, 
1165   localhost:993/imap/ssl/novalidate-cert (SuSE refuses non-SSL conections)");
1166
1167 } else {
1168
1169 $properties["IMAP Authentication"] =
1170   new unchangeable_define('IMAP_AUTH_HOST',"
1171 ; If USER_AUTH_ORDER contains IMAP:
1172 ; The IMAP server to check usernames from. Defaults to localhost.
1173
1174 ; Some IMAP_AUTH_HOST samples:
1175 ;   localhost, localhost:143/imap/notls, 
1176 ;   localhost:993/imap/ssl/novalidate-cert (SuSE refuses non-SSL conections)
1177 ;IMAP_AUTH_HOST = localhost:143/imap/notls", "
1178 Ignored. No IMAP support in this php. configure --with-imap");
1179
1180 }
1181
1182 $properties["POP3 Authentication"] =
1183   new _define_optional('POP3_AUTH_HOST', 'localhost:110', "
1184 If USER_AUTH_ORDER contains POP3:
1185
1186 The POP3 mail server to check usernames and passwords against.");
1187 $properties["File Authentication"] =
1188   new _define_optional('AUTH_USER_FILE', '/etc/shadow', "
1189 If USER_AUTH_ORDER contains File:
1190
1191 File to read for authentication information.
1192 Popular choices are /etc/shadow and /etc/httpd/.htpasswd");
1193
1194 $properties["File Storable?"] =
1195 new boolean_define_commented_optional
1196 ('AUTH_USER_FILE_STORABLE',
1197  array('false'  => "Disabled",
1198        'true'   => "Enabled"), "
1199 Defines whether the user is able to change their own password via PhpWiki.
1200 Note that this means that the webserver user must be able to write to the
1201 file specified in AUTH_USER_FILE.");
1202
1203 $properties["Session Auth USER"] =
1204   new _define_optional('AUTH_SESS_USER', 'userid', "
1205 If USER_AUTH_ORDER contains Session:
1206
1207 Name of the session variable which holds the already authenticated username.
1208 Sample: 'userid', 'user[username]', 'user->username'");
1209
1210 $properties["Session Auth LEVEL"] =
1211   new numeric_define('AUTH_SESS_LEVEL', '2', "
1212 Which level will the user be? 1 = Bogo or 2 = Pass");
1213
1214 /////////////////////////////////////////////////////////////////////
1215
1216 $properties["Part Four"] =
1217 new part('_part4', $SEPARATOR."\n", "
1218
1219 Part Four:
1220 Page appearance and layout");
1221
1222 $properties["Theme"] =
1223 new _define_selection_optional('THEME',
1224               array('default'  => "default",
1225                     'MacOSX'   => "MacOSX",
1226                     'smaller'  => 'smaller',
1227                     'Wordpress'=> 'Wordpress',
1228                     'Portland' => "Portland",
1229                     'Hawaiian' => "Hawaiian",
1230                     'Sidebar'  => "Sidebar",
1231                     'Crao'     => 'Crao',
1232                     'wikilens' => 'wikilens (Ratings)',
1233                     'SpaceWiki' => "SpaceWiki",
1234                     'shamino_com' => 'shamino_com',
1235                     'MonoBook'  => 'MonoBook [experimental]',
1236                     'blog'      => 'blog [experimental]',
1237                     ), "
1238 THEME
1239
1240 Most of the page appearance is controlled by files in the theme
1241 subdirectory.
1242
1243 There are a number of pre-defined themes shipped with PhpWiki.
1244 Or you may create your own (e.g. by copying and then modifying one of
1245 stock themes.)
1246
1247 Problems:
1248 <pre>
1249   THEME = MonoBook (WikiPedia) [experimental. MSIE problems]
1250   THEME = blog     (Kubrick)   [experimental. Several links missing]
1251 </pre>");
1252
1253 $properties["Character Set"] =
1254 new _define_optional('CHARSET', 'iso-8859-1', "
1255 Select a valid charset name to be inserted into the xml/html pages, 
1256 and to reference links to the stylesheets (css). For more info see: 
1257 http://www.iana.org/assignments/character-sets. Note that PhpWiki 
1258 has been extensively tested only with the latin1 (iso-8859-1) 
1259 character set.
1260
1261 If you change the default from iso-8859-1 PhpWiki may not work 
1262 properly and it will require code modifications. However, character 
1263 sets similar to iso-8859-1 may work with little or no modification 
1264 depending on your setup. The database must also support the same 
1265 charset, and of course the same is true for the web browser. (Some 
1266 work is in progress hopefully to allow more flexibility in this 
1267 area in the future).");
1268
1269 $properties["Language"] =
1270 new _define_selection_optional('DEFAULT_LANGUAGE',
1271                array('en' => "English",
1272                      ''   => "<empty> (user-specific)",
1273                      'fr' => "Français",
1274                      'de' => "Deutsch",
1275                      'nl' => "Nederlands",
1276                      'es' => "Español",
1277                      'sv' => "Svenska",
1278                      'it' => "Italiano",
1279                      'ja' => "Japanese",
1280                      'zh' => "Chinese"), "
1281 Select your language/locale - default language is \"en\" for English.
1282 Other languages available:<pre>
1283 English \"en\"  (English    - HomePage)
1284 German  \"de\" (Deutsch    - StartSeite)
1285 French  \"fr\" (Français   - Accueil)
1286 Dutch   \"nl\" (Nederlands - ThuisPagina)
1287 Spanish \"es\" (Español    - PáginaPrincipal)
1288 Swedish \"sv\" (Svenska    - Framsida)
1289 Italian \"it\" (Italiano   - PaginaPrincipale)
1290 Japanese \"ja\" (Japanese   - Â¥Ã›Â¡Â¼Â¥Ã Â¥ÃšÂ¡Â¼Â¥Â¸)
1291 Chinese  \"zh\" (Chinese)
1292 </pre>
1293 If you set DEFAULT_LANGUAGE to the empty string, your systems default language
1294 (as determined by the applicable environment variables) will be
1295 used.");
1296
1297 $properties["Wiki Page Source"] =
1298 new _define_optional('WIKI_PGSRC', 'pgsrc', "
1299 WIKI_PGSRC -- specifies the source for the initial page contents of
1300 the Wiki. The setting of WIKI_PGSRC only has effect when the wiki is
1301 accessed for the first time (or after clearing the database.)
1302 WIKI_PGSRC can either name a directory or a zip file. In either case
1303 WIKI_PGSRC is scanned for files -- one file per page.
1304 <pre>
1305 // Default (old) behavior:
1306 define('WIKI_PGSRC', 'pgsrc'); 
1307 // New style:
1308 define('WIKI_PGSRC', 'wiki.zip'); 
1309 define('WIKI_PGSRC', 
1310        '../Logs/Hamwiki/hamwiki-20010830.zip'); 
1311 </pre>");
1312
1313 /*
1314 $properties["Default Wiki Page Source"] =
1315 new _define('DEFAULT_WIKI_PGSRC', 'pgsrc', "
1316 DEFAULT_WIKI_PGSRC is only used when the language is *not* the
1317 default (English) and when reading from a directory: in that case
1318 some English pages are inserted into the wiki as well.
1319 DEFAULT_WIKI_PGSRC defines where the English pages reside.
1320
1321 FIXME: is this really needed?
1322 ");
1323
1324 $properties["Generic Pages"] =
1325 new array_variable('GenericPages', array('ReleaseNotes', 'SteveWainstead', 'TestPage'), "
1326 These are the pages which will get loaded from DEFAULT_WIKI_PGSRC.      
1327
1328 FIXME: is this really needed?  Cannot we just copy these pages into
1329 the localized pgsrc?
1330 ");
1331 */
1332
1333 ///////////////////
1334
1335 $properties["Part Five"] =
1336 new part('_part5', $SEPARATOR."\n", "
1337
1338 Part Five:
1339 Mark-up options");
1340
1341 $properties["Allowed Protocols"] =
1342 new list_define('ALLOWED_PROTOCOLS', 'http|https|mailto|ftp|news|nntp|ssh|gopher', "
1343 Allowed protocols for links - be careful not to allow \"javascript:\"
1344 URL of these types will be automatically linked.
1345 within a named link [name|uri] one more protocol is defined: phpwiki");
1346
1347 $properties["Inline Images"] =
1348 new list_define('INLINE_IMAGES', 'png|jpg|gif', "
1349 URLs ending with the following extension should be inlined as images. 
1350 Scripts shoud not be allowed!");
1351
1352 $properties["WikiName Regexp"] =
1353 new _define('WIKI_NAME_REGEXP', "(?<![[:alnum:]])(?:[[:upper:]][[:lower:]]+){2,}(?![[:alnum:]])", "
1354 Perl regexp for WikiNames (\"bumpy words\")
1355 (?&lt;!..) &amp; (?!...) used instead of '\b' because \b matches '_' as well");
1356
1357 $properties["Subpage Separator"] =
1358 new _define_optional('SUBPAGE_SEPARATOR', '"/"', "
1359 One character which seperates pages from subpages. Defaults to '/', but '.' or ':' were also used.",
1360 "onchange=\"validate_ereg('Sorry, \'%s\' must be a single character. Currently only :, / or .', '^[/:.]$', 'SUBPAGE_SEPARATOR', this);\""
1361 );
1362
1363 $properties["InterWiki Map File"] =
1364 new _define('INTERWIKI_MAP_FILE', 'lib/interwiki.map', "
1365 InterWiki linking -- wiki-style links to other wikis on the web
1366
1367 The map will be taken from a page name InterWikiMap.
1368 If that page is not found (or is not locked), or map
1369 data can not be found in it, then the file specified
1370 by INTERWIKI_MAP_FILE (if any) will be used.");
1371
1372 $properties["WARN_NONPUBLIC_INTERWIKIMAP"] =
1373 new boolean_define('WARN_NONPUBLIC_INTERWIKIMAP',   
1374         array('true'  => "true",
1375               'false' => "false"), "
1376 Display a warning if the internal lib/interwiki.map is used, and 
1377 not the public InterWikiMap page. This map is not readable from outside.");
1378
1379
1380 $properties["Keyword Link Regexp"] =
1381 new _define_optional('KEYWORDS', '\"Category* OR Topic*\"', "
1382 Search term used for automatic page classification by keyword extraction.
1383
1384 Any links on a page to pages whose names match this search 
1385 will be used keywords in the keywords html meta tag. This is an aid to
1386 classification by search engines. The value of the match is
1387 used as the keyword.
1388
1389 The default behavior is to match Category* or Topic* links.");
1390
1391 $properties["Author and Copyright Site Navigation Links"] =
1392 new _define_commented_optional('COPYRIGHTPAGE_TITLE', "GNU General Public License", "
1393
1394 These will be inserted as <link rel> tags in the html header of
1395 every page, for search engines and for browsers like Mozilla which
1396 take advantage of link rel site navigation.
1397
1398 If you have your own copyright and contact information pages change
1399 these as appropriate.");
1400
1401 $properties["COPYRIGHTPAGE URL"] =
1402 new _define_commented_optional('COPYRIGHTPAGE_URL', "http://www.gnu.org/copyleft/gpl.html#SEC1", "
1403
1404 Other useful alternatives to consider:
1405 <pre>
1406  COPYRIGHTPAGE_TITLE = \"GNU Free Documentation License\"
1407  COPYRIGHTPAGE_URL = \"http://www.gnu.org/copyleft/fdl.html\"
1408  COPYRIGHTPAGE_TITLE = \"Creative Commons License 2.0\"
1409  COPYRIGHTPAGE_URL = \"http://creativecommons.org/licenses/by/2.0/\"</pre>
1410 See http://creativecommons.org/learn/licenses/ for variations");
1411
1412 $properties["AUTHORPAGE_TITLE"] =
1413     new _define_commented_optional('AUTHORPAGE_TITLE', "The PhpWiki Programming Team", "
1414 Default Author Names");
1415 $properties["AUTHORPAGE_URL"] =
1416     new _define_commented_optional('AUTHORPAGE_URL', "http://phpwiki.org/ThePhpWikiProgrammingTeam", "
1417 Default Author URL");
1418
1419 new boolean_define_optional
1420 ('TOC_FULL_SYNTAX', 
1421  array('true'  => "Enabled",
1422        'false' => "Disabled"), "
1423 Allow full markup in headers to be parsed by the CreateToc plugin.
1424
1425 If false you may not use WikiWords or [] links or any other markup in 
1426 headers in pages with the CreateToc plugin. But if false the parsing is 
1427 faster and more stable.");
1428
1429 ///////////////////
1430
1431 $properties["Part Six"] =
1432 new part('_part6', $SEPARATOR."\n", "
1433
1434 Part Six (optional):
1435 URL options -- you can probably skip this section.
1436
1437 For a pretty wiki (no index.php in the url) set a seperate DATA_PATH.");
1438
1439 global $HTTP_SERVER_VARS;
1440 $properties["Server Name"] =
1441 new _define_commented_optional('SERVER_NAME', $HTTP_SERVER_VARS['SERVER_NAME'], "
1442 Canonical name of the server on which this PhpWiki resides.");
1443
1444 $properties["Server Port"] =
1445 new numeric_define_commented('SERVER_PORT', $HTTP_SERVER_VARS['SERVER_PORT'], "
1446 Canonical httpd port of the server on which this PhpWiki resides.",
1447 "onchange=\"validate_ereg('Sorry, \'%s\' is no valid port number.', '^[0-9]+$', 'SERVER_PORT', this);\"");
1448
1449 $properties["Script Name"] =
1450 new _define_commented_optional('SCRIPT_NAME', $scriptname, "
1451 Relative URL (from the server root) of the PhpWiki script.");
1452
1453 $properties["Data Path"] =
1454 new _define_commented_optional('DATA_PATH', dirname($scriptname), "
1455 URL of the PhpWiki install directory.  (You only need to set this
1456 if you've moved index.php out of the install directory.)  This can
1457 be either a relative URL (from the directory where the top-level
1458 PhpWiki script is) or an absolute one.");
1459
1460
1461 $properties["PhpWiki Install Directory"] =
1462 new _define_commented_optional('PHPWIKI_DIR', dirname(__FILE__), "
1463 Path to the PhpWiki install directory.  This is the local
1464 filesystem counterpart to DATA_PATH.  (If you have to set
1465 DATA_PATH, your probably have to set this as well.)  This can be
1466 either an absolute path, or a relative path interpreted from the
1467 directory where the top-level PhpWiki script (normally index.php)
1468 resides.");
1469
1470 $properties["Use PATH_INFO"] =
1471 new boolean_define_commented_optional('USE_PATH_INFO', 
1472                     array('true'  => 'use PATH_INFO',
1473                           'false' => 'do not use PATH_INFO'), "
1474 PhpWiki will try to use short urls to pages, eg 
1475 http://www.example.com/index.php/HomePage
1476 If you want to use urls like 
1477 http://www.example.com/index.php?pagename=HomePage
1478 then define 'USE_PATH_INFO' as false by uncommenting the line below.
1479 NB:  If you are using Apache >= 2.0.30, then you may need to to use
1480 the directive \"AcceptPathInfo On\" in your Apache configuration file
1481 (or in an appropriate <.htaccess> file) for the short urls to work:  
1482 See http://httpd.apache.org/docs-2.0/mod/core.html#acceptpathinfo
1483
1484 See also http://phpwiki.sourceforge.net/phpwiki/PrettyWiki for more ideas
1485 on prettifying your urls.
1486
1487 Default: PhpWiki will try to divine whether use of PATH_INFO
1488 is supported in by your webserver/PHP configuration, and will
1489 use PATH_INFO if it thinks that is possible.");
1490
1491 $properties["Virtual Path"] =
1492 new _define_commented_optional('VIRTUAL_PATH', '/SomeWiki', "
1493 VIRTUAL_PATH is the canonical URL path under which your your wiki
1494 appears. Normally this is the same as dirname(SCRIPT_NAME), however
1495 using e.g. seperate starter scripts, apaches mod_actions (or mod_rewrite), 
1496 you can make it something different.
1497
1498 If you do this, you should set VIRTUAL_PATH here or in the starter scripts.
1499
1500 E.g. your phpwiki might be installed at at /scripts/phpwiki/index.php,
1501 but you've made it accessible through eg. /wiki/HomePage.
1502
1503 One way to do this is to create a directory named 'wiki' in your
1504 server root. The directory contains only one file: an .htaccess
1505 file which reads something like:
1506 <pre>
1507     Action x-phpwiki-page /scripts/phpwiki/index.php
1508     SetHandler x-phpwiki-page
1509     DirectoryIndex /scripts/phpwiki/index.php
1510 </pre>
1511 In that case you should set VIRTUAL_PATH to '/wiki'.
1512
1513 (VIRTUAL_PATH is only used if USE_PATH_INFO is true.)
1514 ");
1515
1516 ///////////////////
1517
1518 $properties["Part Seven"] =
1519 new part('_part7', $SEPARATOR."\n", "
1520
1521 Part Seven:
1522
1523 Miscellaneous settings
1524 ");
1525
1526 $properties["Strict Mailable Pagedumps"] =
1527 new boolean_define_optional
1528 ('STRICT_MAILABLE_PAGEDUMPS', 
1529  array('false' => "binary",
1530        'true'  => "quoted-printable"),
1531 "
1532 If you define this to true, (MIME-type) page-dumps (either zip dumps,
1533 or \"dumps to directory\" will be encoded using the quoted-printable
1534 encoding.  If you're actually thinking of mailing the raw page dumps,
1535 then this might be useful, since (among other things,) it ensures
1536 that all lines in the message body are under 80 characters in length.
1537
1538 Also, setting this will cause a few additional mail headers
1539 to be generated, so that the resulting dumps are valid
1540 RFC 2822 e-mail messages.
1541
1542 Probably, you can just leave this set to false, in which case you get
1543 raw ('binary' content-encoding) page dumps.");
1544
1545 $properties["HTML Dump Filename Suffix"] =
1546 new _define_optional('HTML_DUMP_SUFFIX', ".html", "
1547 Here you can change the filename suffix used for XHTML page dumps.
1548 If you don't want any suffix just comment this out.");
1549
1550 $properties["Default local Dump Directory"] =
1551 new _define_optional('DEFAULT_DUMP_DIR', "/tmp/wikidump", "
1552 Specify the default directory for local backups.");
1553
1554 $properties["Default local HTML Dump Directory"] =
1555 new _define_optional('HTML_DUMP_DIR', "/tmp/wikidumphtml", "
1556 Specify the default directory for local XHTML dumps.");
1557
1558 $properties["Pagename of Recent Changes"] =
1559 new _define_optional('RECENT_CHANGES', 'RecentChanges', "
1560 Page name of RecentChanges page.  Used for RSS Auto-discovery.");
1561
1562 $properties["Disable HTTP Redirects"] =
1563 new boolean_define_commented_optional
1564 ('DISABLE_HTTP_REDIRECT',
1565  array('false' => 'Enable HTTP Redirects',
1566        'true' => 'Disable HTTP Redirects'),
1567 "
1568 (You probably don't need to touch this.)
1569
1570 PhpWiki uses HTTP redirects for some of it's functionality.
1571 (e.g. after saving changes, PhpWiki redirects your browser to
1572 view the page you just saved.)
1573
1574 Some web service providers (notably free European Lycos) don't seem to
1575 allow these redirects.  (On Lycos the result in an \"Internal Server Error\"
1576 report.)  In that case you can set DISABLE_HTTP_REDIRECT to true.
1577 (In which case, PhpWiki will revert to sneakier tricks to try to
1578 redirect the browser...)");
1579
1580 $properties["Disable GETIMAGESIZE"] =
1581 new boolean_define_commented_optional
1582 ('DISABLE_GETIMAGESIZE',
1583  array('false' => 'Enable',
1584        'true'  => 'Disable'), "
1585 Set GETIMAGESIZE to disabled, if your php fails to calculate the size on 
1586 inlined images, or you don't want to disable too small images to be inlined.
1587
1588 Per default too small ploaded or external images are not displayed, 
1589 to prevent from external 1 pixel spam.");
1590
1591 $properties["EDITING_POLICY"] =
1592   new _define_optional('EDITING_POLICY', "EditingPolicy", "
1593 An interim page which gets displayed on every edit attempt, if it exists.");
1594
1595 $properties["ENABLE_MODERATEDPAGE_ALL"] =
1596 new boolean_define_commented_optional
1597 ('ENABLE_MODERATEDPAGE_ALL',
1598  array('false' => 'Disable',
1599        'true'  => 'Enable'), "
1600 ");
1601
1602 $properties["FORTUNE_DIR"] =
1603   new _define_commented_optional('FORTUNE_DIR', "/usr/share/fortune", "
1604 ");
1605 $properties["DBADMIN_USER"] =
1606   new _define_commented_optional('DBADMIN_USER', "", "
1607 ");
1608 $properties["DBADMIN_PASSWD"] =
1609   new _define_commented_optional('DBADMIN_PASSWD', "", "
1610 ");
1611 $properties["USE_EXTERNAL_HTML2PDF"] =
1612   new _define_commented_optional('USE_EXTERNAL_HTML2PDF', "htmldoc --quiet --format pdf14 --no-toc --no-title %s", "
1613 ");
1614 $properties["BABYCART_PATH"] =
1615   new _define_commented_optional('BABYCART_PATH', "/usr/local/bin/babycart", "
1616 ");
1617
1618 $properties["Part Seven A"] =
1619 new part('_part7a', $SEPARATOR."\n", "
1620
1621 Part Seven A:
1622
1623 Cached Plugin Settings. (pear Cache)
1624 ");
1625
1626 /*
1627 PLUGIN_CACHED_DATABASE = file
1628 ; PLUGIN_CACHED_CACHE_DIR = /tmp/cache
1629 PLUGIN_CACHED_FILENAME_PREFIX = phpwiki
1630 PLUGIN_CACHED_HIGHWATER = 4194304
1631 PLUGIN_CACHED_LOWWATER  = 3145728
1632 PLUGIN_CACHED_MAXLIFETIME = 2592000
1633 PLUGIN_CACHED_MAXARGLEN = 1000
1634 PLUGIN_CACHED_USECACHE = true
1635 PLUGIN_CACHED_FORCE_SYNCMAP = true
1636 PLUGIN_CACHED_IMGTYPES = "png|gif|gd|gd2|jpeg|wbmp|xbm|xpm"
1637 */
1638
1639 $end = "\n".$SEPARATOR."\n";
1640
1641 // end of configuration options
1642 ///////////////////////////////
1643 // begin class definitions
1644
1645 /**
1646  * A basic config-dist.ini configuration line in the form of a variable. 
1647  * (not needed anymore, we have only defines)
1648  *
1649  * Produces a string in the form "$name = value;"
1650  * e.g.:
1651  * $WikiNameRegexp = "value";
1652  */
1653 class _variable {
1654
1655     var $config_item_name;
1656     var $default_value;
1657     var $description;
1658     var $prefix;
1659     var $jscheck;
1660
1661     function _variable($config_item_name, $default_value, $description, $jscheck = '') {
1662         $this->config_item_name = $config_item_name;
1663         $this->description = $description;
1664         $this->default_value = $default_value;
1665         $this->jscheck = $jscheck;
1666         if (preg_match("/variable/i",get_class($this)))
1667             $this->prefix = "\$";
1668         elseif (preg_match("/ini_set/i",get_class($this)))
1669             $this->prefix = "ini_get: ";
1670         else
1671             $this->prefix = "";
1672     }
1673
1674     function value() {
1675       global $HTTP_POST_VARS;
1676       if (isset($HTTP_POST_VARS[$this->config_item_name]))
1677           return $HTTP_POST_VARS[$this->config_item_name];
1678       else 
1679           return $this->default_value;
1680     }
1681
1682     function _config_format($value) {
1683         $v = $this->get_config_item_name();
1684         // handle arrays: a|b --> a['b']
1685         if (strpos($v, '|')) {
1686             list($a, $b) = explode('|', $v);
1687             $v = sprintf("%s['%s']", $a, $b);
1688         }
1689         if (preg_match("/[\"']/", $value))
1690             $value = '"' . $value . '"';
1691         return sprintf("%s = %s", $v, $value);
1692     }
1693
1694     function get_config_item_name() {
1695         return $this->config_item_name;
1696     }
1697
1698     function get_config_item_id() {
1699         return str_replace('|', '-', $this->config_item_name);
1700     }
1701
1702     function get_config_item_header() {
1703        if (strchr($this->config_item_name,'|')) {
1704           list($var,$param) = explode('|',$this->config_item_name);
1705           return "<b>" . $this->prefix . $var . "['" . $param . "']</b><br />";
1706        }
1707        elseif ($this->config_item_name[0] != '_')
1708           return "<b>" . $this->prefix . $this->config_item_name . "</b><br />";
1709        else 
1710           return '';
1711     }
1712
1713     function _get_description() {
1714         return $this->description;
1715     }
1716
1717     function _get_config_line($posted_value) {
1718         return "\n" . $this->_config_format($posted_value);
1719     }
1720
1721     function get_config($posted_value) {
1722         $d = stripHtml($this->_get_description());
1723         $d = str_replace("\n", "\n; ", $d) . $this->_get_config_line($posted_value) ."\n";
1724         return $d;
1725     }
1726
1727     function get_instructions($title) {
1728         global $tdwidth;
1729         $i = "<h3>" . $title . "</h3>\n    " . nl2p($this->_get_description()) . "\n";
1730         return "<tr>\n<td width=\"$tdwidth\" class=\"instructions\">\n" . $i . "</td>\n";
1731     }
1732
1733     function get_html() {
1734         $size = strlen($this->default_value) > 45 ? 90 : 50;
1735         return $this->get_config_item_header() . 
1736             "<input type=\"text\" size=\"$50\" name=\"" . $this->get_config_item_name() . "\" value=\"" . htmlspecialchars($this->default_value) . "\" " . 
1737             $this->jscheck . " />" . "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: green\">Input accepted.</p>";
1738     }
1739 }
1740
1741 class unchangeable_variable
1742 extends _variable {
1743     function _config_format($value) {
1744         return "";
1745     }
1746     // function get_html() { return false; }
1747     function get_html() {
1748         return $this->get_config_item_header() . 
1749         "<em>Not editable.</em>" . 
1750         "<pre>" . $this->default_value."</pre>";
1751     }
1752     function _get_config_line($posted_value) {
1753         if ($this->description)
1754             $n = "\n";
1755         return "${n}".$this->default_value;
1756     }
1757     function get_instructions($title) {
1758         global $tdwidth;
1759         $i = "<h3>" . $title . "</h3>\n    " . nl2p($this->_get_description()) . "\n";
1760         // $i .= "<em>Not editable.</em><br />\n<pre>" . $this->default_value."</pre>";
1761         return '<tr><td width="100%" class="unchangeable-variable-top" colspan="2">'."\n".$i."</td></tr>\n" 
1762         . '<tr style="border-top: none;"><td class="unchangeable-variable-left" width="'.$tdwidth.'">&nbsp;</td>';
1763     }
1764 }
1765
1766 class unchangeable_define
1767 extends unchangeable_variable {
1768     function _config_format($value) {
1769         return "";
1770     }
1771 }
1772 class unchangeable_ini_set
1773 extends unchangeable_variable {
1774     function _config_format($value) {
1775         return "";
1776     }
1777 }
1778
1779 class _variable_selection
1780 extends _variable {
1781     function value() {
1782         global $HTTP_POST_VARS;
1783         if (!empty($HTTP_POST_VARS[$this->config_item_name]))
1784             return $HTTP_POST_VARS[$this->config_item_name];
1785         else {
1786             list($option, $label) = each($this->default_value);
1787             return $option;
1788         }
1789     }
1790     function get_html() {
1791         $output = $this->get_config_item_header();
1792         $output .= '<select name="' . $this->get_config_item_name() . "\">\n";
1793         /* The first option is the default */
1794         while(list($option, $label) = each($this->default_value)) {
1795             $output .= "  <option value=\"$option\">$label</option>\n";
1796         }
1797         $output .= "</select>\n";
1798         return $output;
1799     }
1800 }
1801
1802
1803 class _define
1804 extends _variable {
1805     function _config_format($value) {
1806         return sprintf("%s = %s", $this->get_config_item_name(), $value);
1807     }
1808     function _get_config_line($posted_value) {
1809         if ($this->description)
1810             $n = "\n";
1811         if ($posted_value == '')
1812             return "${n};" . $this->_config_format("");
1813         else
1814             return "${n}" . $this->_config_format($posted_value);
1815     }
1816     function get_html() {
1817         $size = strlen($this->default_value) > 45 ? 90 : 50;
1818         return $this->get_config_item_header() 
1819             . "<input type=\"text\" size=\"$size\" name=\"" . htmlentities($this->get_config_item_name()) 
1820             . "\" value=\"" . htmlentities($this->default_value) . "\" {$this->jscheck} />" 
1821             . "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: green\">Input accepted.</p>";
1822     }
1823 }
1824
1825 class _define_commented
1826 extends _define {
1827     function _get_config_line($posted_value) {
1828         if ($this->description)
1829             $n = "\n";
1830         if ($posted_value == $this->default_value)
1831             return "${n};" . $this->_config_format($posted_value);
1832         elseif ($posted_value == '')
1833             return "${n};" . $this->_config_format("");
1834         else
1835             return "${n}" . $this->_config_format($posted_value);
1836     }
1837 }
1838
1839 /** 
1840  * We don't use _optional anymore, because INI-style config's don't need that. 
1841  * IniConfig.php does the optional logic now.
1842  * But we use _optional for config-default.ini options
1843  */
1844 class _define_commented_optional
1845 extends _define_commented { }
1846
1847 class _define_optional
1848 extends _define { }
1849
1850 class _define_optional_notempty
1851 extends _define_optional {
1852     function get_html() {
1853         $s = $this->get_config_item_header() 
1854             . "<input type=\"text\" size=\"50\" name=\"" . $this->get_config_item_name() 
1855             . "\" value=\"" . $this->default_value . "\" {$this->jscheck} />";
1856         if (empty($this->default_value))
1857             return $s . "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: red\">Cannot be empty.</p>";
1858         else
1859             return $s . "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: green\">Input accepted.</p>";
1860     }
1861 }
1862
1863 class _variable_commented
1864 extends _variable {
1865     function _get_config_line($posted_value) {
1866         if ($this->description)
1867             $n = "\n";
1868         if ($posted_value == $this->default_value)
1869             return "${n};" . $this->_config_format($posted_value);
1870         elseif ($posted_value == '')
1871             return "${n};" . $this->_config_format("");
1872         else
1873             return "${n}" . $this->_config_format($posted_value);
1874     }
1875 }
1876
1877 class numeric_define
1878 extends _define {
1879
1880     function numeric_define($config_item_name, $default_value, $description, $jscheck = '') {
1881         $this->_define($config_item_name, $default_value, $description, $jscheck);
1882         if (!$jscheck)
1883             $this->jscheck = "onchange=\"validate_ereg('Sorry, \'%s\' is not an integer.', '^[-+]?[0-9]+$', '" . $this->get_config_item_name() . "', this);\"";
1884     }
1885     function _config_format($value) {
1886         //return sprintf("define('%s', %s);", $this->get_config_item_name(), $value);
1887         return sprintf("%s = %s", $this->get_config_item_name(), $value);
1888     }
1889     function _get_config_line($posted_value) {
1890         if ($this->description)
1891             $n = "\n";
1892         if ($posted_value == '')
1893             return "${n};" . $this->_config_format('0');
1894         else
1895             return "${n}" . $this->_config_format($posted_value);
1896     }
1897 }
1898
1899 class numeric_define_optional
1900 extends numeric_define {}
1901
1902 class numeric_define_commented
1903 extends numeric_define {
1904     function _get_config_line($posted_value) {
1905         if ($this->description)
1906             $n = "\n";
1907         if ($posted_value == $this->default_value)
1908             return "${n};" . $this->_config_format($posted_value);
1909         elseif ($posted_value == '')
1910             return "${n};" . $this->_config_format('0');
1911         else
1912             return "${n}" . $this->_config_format($posted_value);
1913     }
1914 }
1915
1916 class _define_selection
1917 extends _variable_selection {
1918     function _config_format($value) {
1919         return sprintf("%s = %s", $this->get_config_item_name(), $value);
1920     }
1921     function _get_config_line($posted_value) {
1922         return _define::_get_config_line($posted_value);
1923     }
1924     function get_html() {
1925         return _variable_selection::get_html();
1926     }
1927 }
1928
1929 class _define_selection_optional
1930 extends _define_selection { }
1931
1932 class _variable_selection_optional
1933 extends _variable_selection { }
1934
1935 class _define_password
1936 extends _define {
1937
1938     function _define_password($config_item_name, $default_value, $description, $jscheck = '') {
1939         $this->_define($config_item_name, $default_value, $description, $jscheck);
1940         if (!$jscheck)
1941             $this->jscheck = "onchange=\"validate_ereg('Sorry, \'%s\' cannot be empty.', '^.+$', '" . $this->get_config_item_name() . "', this);\"";
1942     }
1943     function _get_config_line($posted_value) {
1944         if ($this->description)
1945             $n = "\n";
1946         if ($posted_value == '') {
1947             $p = "${n};" . $this->_config_format("");
1948             $p .= "\n; If you used the passencrypt.php utility to encode the password";
1949             $p .= "\n; then uncomment this line:";
1950             $p .= "\n;ENCRYPTED_PASSWD = true";
1951             return $p;
1952         } else {
1953             if (function_exists('crypt')) {
1954                 $salt_length = max(CRYPT_SALT_LENGTH,
1955                                     2 * CRYPT_STD_DES,
1956                                     9 * CRYPT_EXT_DES,
1957                                    12 * CRYPT_MD5,
1958                                    16 * CRYPT_BLOWFISH);
1959                 // generate an encrypted password
1960                 $crypt_pass = crypt($posted_value, rand_ascii($salt_length));
1961                 $p = "${n}" . $this->_config_format($crypt_pass);
1962                 return $p . "\nENCRYPTED_PASSWD = true";
1963             } else {
1964                 $p = "${n}" . $this->_config_format($posted_value);
1965                 $p .= "\n; Encrypted passwords cannot be used:";
1966                 $p .= "\n; 'function crypt()' not available in this version of php";
1967                 $p .= "\nENCRYPTED_PASSWD = false";
1968                 return $p;
1969             }
1970         }
1971     }
1972     function get_html() {
1973         return _variable_password::get_html();
1974     }
1975 }
1976
1977 class _define_password_optional
1978 extends _define_password { }
1979
1980 class _variable_password
1981 extends _variable {
1982     function _variable_password($config_item_name, $default_value, $description, $jscheck = '') {
1983         $this->_define($config_item_name, $default_value, $description, $jscheck);
1984         if (!$jscheck)
1985             $this->jscheck = "onchange=\"validate_ereg('Sorry, \'%s\' cannot be empty.', '^.+$', '" . $this->get_config_item_name() . "', this);\"";
1986     }
1987     function get_html() {
1988         global $HTTP_POST_VARS, $HTTP_GET_VARS;
1989         $s = $this->get_config_item_header();
1990         if (isset($HTTP_POST_VARS['create']) or isset($HTTP_GET_VARS['create'])) {
1991             $new_password = random_good_password();
1992             $this->default_value = $new_password;
1993             $s .= "Created password: <strong>$new_password</strong><br />&nbsp;<br />";
1994         }
1995         $s .= "<input type=\"password\" name=\"" . $this->get_config_item_name()
1996            . "\" value=\"" . $this->default_value 
1997            . "\" {$this->jscheck} />" 
1998            . "&nbsp;&nbsp;<input type=\"submit\" name=\"create\" value=\"Create Random Password\" />";
1999         if (empty($this->default_value))
2000             $s .= "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: red\">Cannot be empty.</p>";
2001         elseif (strlen($this->default_value) < 4)
2002             $s .= "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: red\">Must be longer than 4 chars.</p>";
2003         else
2004             $s .= "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: green\">Input accepted.</p>";
2005         return $s;
2006     }
2007 }
2008
2009 class list_variable
2010 extends _variable {
2011     function _get_config_line($posted_value) {
2012         // split the phrase by any number of commas or space characters,
2013         // which include " ", \r, \t, \n and \f
2014         $list_values = preg_split("/[\s,]+/", $posted_value, -1, PREG_SPLIT_NO_EMPTY);
2015         $list_values = join("|", $list_values);
2016         return _variable::_get_config_line($list_values);
2017     }
2018     function get_html() {
2019         $list_values = explode("|", $this->default_value);
2020         $rows = max(3, count($list_values) +1);
2021         $list_values = join("\n", $list_values);
2022         $ta = $this->get_config_item_header();
2023         $ta .= "<textarea cols=\"18\" rows=\"". $rows ."\" name=\"".$this->get_config_item_name()."\" {$this->jscheck}>";
2024         $ta .= $list_values . "</textarea>";
2025         $ta .= "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: green\">Input accepted.</p>";
2026         return $ta;
2027     }
2028 }
2029
2030 class list_define
2031 extends _define {
2032     function _get_config_line($posted_value) {
2033         $list_values = preg_split("/[\s,]+/", $posted_value, -1, PREG_SPLIT_NO_EMPTY);
2034         $list_values = join("|", $list_values);
2035         return _variable::_get_config_line($list_values);
2036     }
2037     function get_html() {
2038         $list_values = explode("|", $this->default_value);
2039         $rows = max(3, count($list_values) +1);
2040         $list_values = join("\n", $list_values);
2041         $ta = $this->get_config_item_header();
2042         $ta .= "<textarea cols=\"18\" rows=\"". $rows ."\" name=\"".$this->get_config_item_name()."\" {$this->jscheck}>";
2043         $ta .= $list_values . "</textarea>";
2044         $ta .= "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: green\">Input accepted.</p>";
2045         return $ta;
2046     }
2047 }
2048
2049 class array_variable
2050 extends _variable {
2051     function _config_format($value) {
2052         return sprintf("%s = \"%s\"", $this->get_config_item_name(), 
2053                        is_array($value) ? join(':', $value) : $value);
2054     }
2055     function _get_config_line($posted_value) {
2056         // split the phrase by any number of commas or space characters,
2057         // which include " ", \r, \t, \n and \f
2058         $list_values = preg_split("/[\s,]+/", $posted_value, -1, PREG_SPLIT_NO_EMPTY);
2059         if (!empty($list_values)) {
2060             $list_values = "'".join("', '", $list_values)."'";
2061             return "\n" . $this->_config_format($list_values);
2062         } else
2063             return "\n;" . $this->_config_format('');
2064     }
2065     function get_html() {
2066         $list_values = join("\n", $this->default_value);
2067         $rows = max(3, count($this->default_value) +1);
2068         $ta = $this->get_config_item_header();
2069         $ta .= "<textarea cols=\"18\" rows=\"". $rows ."\" name=\"".$this->get_config_item_name()."\" {$this->jscheck}>";
2070         $ta .= $list_values . "</textarea>";
2071         $ta .= "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: green\">Input accepted.</p>";
2072         return $ta;
2073     }
2074 }
2075
2076 class array_define
2077 extends _define {
2078     function _config_format($value) {
2079         return sprintf("%s = \"%s\"", $this->get_config_item_name(), 
2080                        is_array($value) ? join(' : ', $value) : $value);
2081     }
2082     function _get_config_line($posted_value) {
2083         // split the phrase by any number of commas or space characters,
2084         // which include " ", \r, \t, \n and \f
2085         $list_values = preg_split("/[\s,:]+/", $posted_value, -1, PREG_SPLIT_NO_EMPTY);
2086         if (!empty($list_values)) {
2087             $list_values = "'".join("' : '", $list_values)."'";
2088             return "\n" . $this->_config_format($list_values);
2089         } else
2090             return "\n;" . $this->_config_format('');
2091     }
2092     function get_html() {
2093         $list_values = join("\n", $this->default_value);
2094         $rows = max(3, count($this->default_value) +1);
2095         $ta = $this->get_config_item_header();
2096         $ta .= "<textarea cols=\"18\" rows=\"". $rows ."\" name=\"".$this->get_config_item_name()."\" {$this->jscheck}>";
2097         $ta .= $list_values . "</textarea>";
2098         $ta .= "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: green\">Input accepted.</p>";
2099         return $ta;
2100     }
2101 }
2102
2103 /*
2104 class _ini_set
2105 extends _variable {
2106     function value() {
2107         global $HTTP_POST_VARS;
2108         if ($v = $HTTP_POST_VARS[$this->config_item_name])
2109             return $v;
2110         else {
2111             return ini_get($this->get_config_item_name);
2112         }
2113     }
2114     function _config_format($value) {
2115         return sprintf("ini_set('%s', '%s');", $this->get_config_item_name(), $value);
2116     }
2117     function _get_config_line($posted_value) {
2118         if ($posted_value && ! $posted_value == $this->default_value)
2119             return "\n" . $this->_config_format($posted_value);
2120         else
2121             return "\n;" . $this->_config_format($this->default_value);
2122     }
2123 }
2124 */
2125
2126 class boolean_define
2127 extends _define {
2128     function _get_config_line($posted_value) {
2129         if ($this->description)
2130             $n = "\n";
2131         return "${n}" . $this->_config_format($posted_value);
2132     }
2133     function _config_format($value) {
2134         if (strtolower(trim($value)) == 'false')
2135             $value = false;
2136         return sprintf("%s = %s", $this->get_config_item_name(),
2137                        (bool)$value ? 'true' : 'false');
2138     }
2139     function get_html() {
2140         $output = $this->get_config_item_header();
2141         $output .= '<select name="' . $this->get_config_item_name() . "\" {$this->jscheck}>\n";
2142         /* The first option is the default */
2143         list($option, $label) = each($this->default_value);
2144         $output .= "  <option value=\"$option\" selected='selected'>$label</option>\n";
2145         /* There can usually, only be two options, there can be
2146          * three options in the case of a boolean_define_commented_optional */
2147         while (list($option, $label) = each($this->default_value)) 
2148           $output .= "  <option value=\"$option\">$label</option>\n";
2149         $output .= "</select>\n";
2150         return $output;
2151     }
2152 }
2153
2154 class boolean_define_optional
2155 extends boolean_define {}
2156
2157 class boolean_define_commented
2158 extends boolean_define {
2159     function _get_config_line($posted_value) {
2160         if ($this->description)
2161             $n = "\n";
2162         list($default_value, $label) = each($this->default_value);
2163         if ($posted_value == $default_value)
2164             return "${n};" . $this->_config_format($posted_value);
2165         elseif ($posted_value == '')
2166             return "${n};" . $this->_config_format('false');
2167         else
2168             return "${n}" . $this->_config_format($posted_value);
2169     }
2170 }
2171
2172 class boolean_define_commented_optional
2173 extends boolean_define_commented {}
2174
2175 class part
2176 extends _variable {
2177     function value () { return; }
2178     function get_config($posted_value) {
2179         $d = stripHtml($this->_get_description());
2180         global $SEPARATOR;
2181         return "\n".$SEPARATOR . str_replace("\n", "\n; ", $d) ."\n".$this->default_value;
2182     }
2183     function get_instructions($title) {
2184         $group_name = preg_replace("/\W/","",$title);
2185         $i = "<tr class='header' id='$group_name'>\n<td class=\"part\" width=\"100%\" colspan=\"2\" bgcolor=\"#eeeeee\">\n";
2186         $i .= "<h2>" . $title . "</h2>\n    " . nl2p($this->_get_description()) ."\n";
2187         $i .= "<p><a href=\"javascript:toggle_group('$group_name')\" id=\"{$group_name}_text\">Hide options.</a></p>";
2188         return  $i ."</td>\n";
2189     }
2190     function get_html() {
2191         return "";
2192     }
2193 }
2194
2195 // html utility functions
2196 function nl2p($text) {
2197   preg_match_all("@\s*(<pre>.*?</pre>|<dl>.*?</dl>|.*?(?=\n\n|<pre>|<dl>|$))@s",
2198                  $text, $m, PREG_PATTERN_ORDER);
2199
2200   $text = '';
2201   foreach ($m[1] as $par) {
2202     if (!($par = trim($par)))
2203       continue;
2204     if (!preg_match('/^<(pre|dl)>/', $par))
2205       $par = "<p>$par</p>";
2206     $text .= $par;
2207   }
2208   return $text;
2209 }
2210
2211 function stripHtml($text) {
2212         $d = str_replace("<pre>", "", $text);
2213         $d = str_replace("</pre>", "", $d);
2214         $d = str_replace("<dl>", "", $d);
2215         $d = str_replace("</dl>", "", $d);
2216         $d = str_replace("<dt>", "", $d);
2217         $d = str_replace("</dt>", "", $d);
2218         $d = str_replace("<dd>", "", $d);
2219         $d = str_replace("</dd>", "", $d);
2220         $d = str_replace("<p>", "", $d);
2221         $d = str_replace("</p>", "", $d);
2222         //restore html entities into characters
2223         // http://www.php.net/manual/en/function.htmlentities.php
2224         $trans = get_html_translation_table (HTML_ENTITIES);
2225         $trans = array_flip ($trans);
2226         $d = strtr($d, $trans);
2227         return $d;
2228 }
2229
2230 include_once(dirname(__FILE__)."/lib/stdlib.php");
2231
2232 ////
2233 // Function to create better user passwords (much larger keyspace),
2234 // suitable for user passwords.
2235 // Sequence of random ASCII numbers, letters and some special chars.
2236 // Note: There exist other algorithms for easy-to-remember passwords.
2237 function random_good_password ($minlength = 5, $maxlength = 8) {
2238   $newpass = '';
2239   // assume ASCII ordering (not valid on EBCDIC systems!)
2240   $valid_chars = "!#%&+-.0123456789=@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz";
2241   $start = ord($valid_chars);
2242   $end   = ord(substr($valid_chars,-1));
2243   better_srand();
2244   if (function_exists('mt_rand')) // mersenne twister
2245       $length = mt_rand($minlength, $maxlength);
2246   else  // the usually bad glibc rand()
2247       $length = rand($minlength, $maxlength);
2248   while ($length > 0) {
2249       if (function_exists('mt_rand'))
2250           $newchar = mt_rand($start, $end);
2251       else
2252           $newchar = rand($start, $end);
2253       if (! strrpos($valid_chars,$newchar) ) continue; // skip holes
2254       $newpass .= sprintf("%c", $newchar);
2255       $length--;
2256   }
2257   return($newpass);
2258 }
2259
2260 // debugging
2261 function printArray($a) {
2262     echo "<hr />\n<pre>\n";
2263     print_r($a);
2264     echo "\n</pre>\n<hr />\n";
2265 }
2266
2267 // end of class definitions
2268 /////////////////////////////
2269 // begin auto generation code
2270
2271 if (!function_exists('is_a')) {
2272   function is_a($object, $class) {
2273     $class = strtolower($class);
2274     return (get_class($object) == $class) or is_subclass_of($object, $class);
2275   }
2276 }
2277
2278
2279 if (!empty($HTTP_POST_VARS['action']) 
2280     and $HTTP_POST_VARS['action'] == 'make_config') {
2281
2282     $timestamp = date ('dS of F, Y H:i:s');
2283
2284     $config = "
2285 ; This is a local configuration file for PhpWiki.
2286 ; It was automatically generated by the configurator script
2287 ; on the $timestamp.
2288 ;
2289 ; $preamble
2290 ";
2291
2292     $posted = $GLOBALS['HTTP_POST_VARS'];
2293
2294     if (defined('DEBUG'))
2295         printArray($GLOBALS['HTTP_POST_VARS']);
2296
2297     foreach($properties as $option_name => $a) {
2298         $posted_value = $posted[$a->config_item_name];
2299         $config .= $properties[$option_name]->get_config($posted_value);
2300     }
2301
2302     $config .= $end;
2303
2304     // I think writing this config file is a big security hole.
2305     // If this is installed in such a way that it can write an index-user.php,
2306     // then anyone can create a working index-user.php with, e.g. any
2307     // admin user and pw of their choosing...
2308     //
2309     // So I'm disabling it...
2310
2311     if (defined('ENABLE_FILE_OUTPUT') and ENABLE_FILE_OUPUT) {
2312       // We first check if the config-file exists.
2313       if (file_exists($fs_config_file)) {
2314         // We make a backup copy of the file
2315         // $config_file = 'index-user.php';
2316         $new_filename = preg_replace('/\.ini$/', time() . '.ini', $fs_config_file);
2317         if (@copy($fs_config_file, $new_filename)) {
2318             $fp = @fopen($fs_config_file, 'w');
2319         }
2320       } else {
2321         $fp = @fopen($fs_config_file, 'w');
2322       }
2323     }
2324     else {
2325       $fp = false;
2326     }
2327     
2328     if ($fp) {
2329         fputs($fp, $config);
2330         fclose($fp);
2331         echo "<p>The configuration was written to <code><b>$config_file</b></code>.</p>\n";
2332         if ($new_filename) {
2333             echo "<p>A backup was made to <code><b>$new_filename</b></code>.</p>\n";
2334         }
2335         echo "<p><strong>You must rename or copy this</strong> <code><b>$config_file</b></code> <strong>file to</strong> <code><b>index.php</b></code>.</p>\n";
2336     } else {
2337         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>config/config.ini</b></code>.</p>\n";
2338     }
2339
2340     echo "<hr />\n<p>Here's the configuration file based on your answers:</p>\n";
2341     echo "<form method=\"get\" action=\"", $configurator, "\">\n";
2342     echo "<textarea id='config-output' readonly='readonly' style='width:100%;' rows='30' cols='100'>\n";
2343     echo htmlentities($config);
2344     echo "</textarea></form>\n";
2345     echo "<hr />\n";
2346
2347     echo "<p>To make any corrections, <a href=\"configurator.php\">edit the settings again</a>.</p>\n";
2348
2349 } else { // first time or create password
2350     $posted = $GLOBALS['HTTP_POST_VARS'];
2351     // No action has been specified - we make a form.
2352
2353     echo '
2354 <form action="',$configurator,'" method="post">
2355 <input type="hidden" name="action" value="make_config" />
2356 <table cellpadding="4" cellspacing="0">
2357 ';
2358
2359     while(list($property, $obj) = each($properties)) {
2360         echo $obj->get_instructions($property);
2361         if ($h = $obj->get_html()) {
2362             if (defined('DEBUG') and DEBUG)  $h = get_class($obj) . "<br />\n" . $h;
2363             echo "<td>".$h."</td>\n";
2364         }
2365         echo '</tr>';
2366     }
2367
2368     echo '
2369 </table>
2370 <p><input type="submit" value="Save ',$config_file,'" /> <input type="reset" value="Clear" /></p>
2371 </form>
2372 ';
2373 }
2374 ?>
2375 </body>
2376 </html>