]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - configurator.php
fix quoting and slashes, check against required ADMIN_USER
[SourceForge/phpwiki.git] / configurator.php
1 <?php 
2 // $Id: configurator.php,v 1.27 2005-02-16 15:53:15 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  * commented / optional: non-default values should not be commented!
10  *                       default values if optional can be omitted.
11  * read config-default.ini
12  * read config-dist.ini into sections, comments, and optional/required settings
13  *
14  * 1.3.9 Todo: 
15  * validate input (fix javascript, add POST checks)
16  * start this automatically the first time
17  * fix include_path
18  * eval index-user.php or index.php to get the actual settings.
19  * ask to store it in index.php or index-user.php
20  * 
21  * A file config/config.ini will be generated.
22  *
23  * NOTE: If you have a starterscript outside PHOWIKI_DIR but no 
24  * config/config.ini yet (very unlikely!), you must define DATA_PATH in the 
25  * starterscript, otherwise the webpath to configurator is unknown, and 
26  * subsequent requests will fail. (Save INI)
27  */
28
29 if (!defined('ENABLE_FILE_OUTPUT')) define('ENABLE_FILE_OUTPUT', true);
30
31 global $HTTP_SERVER_VARS, $HTTP_POST_VARS;
32 if (empty($configurator))
33     $configurator = "configurator.php";
34 if (!strstr($HTTP_SERVER_VARS["SCRIPT_NAME"], $configurator) and defined('DATA_PATH'))
35     $configurator = DATA_PATH . "/" . $configurator;
36 $scriptname = str_replace('configurator.php', 'index.php', $HTTP_SERVER_VARS["SCRIPT_NAME"]);
37
38 $tdwidth = 700;
39 $config_file = (substr(PHP_OS,0,3) == 'WIN') ? 'config\\config.ini' : 'config/config.ini';
40 $fs_config_file = dirname(__FILE__) . (substr(PHP_OS,0,3) == 'WIN' ? '\\' : '/') . $config_file;
41 if (isset($HTTP_POST_VARS['create']))  header('Location: '.$configurator.'?create=1#create');
42 printf("<?xml version=\"1.0\" encoding=\"%s\"?>\n", 'iso-8859-1'); 
43 ?>
44 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
45   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
46 <html xmlns="http://www.w3.org/1999/xhtml">
47 <head>
48 <!-- $Id: configurator.php,v 1.27 2005-02-16 15:53:15 rurban Exp $ -->
49 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
50 <title>Configuration tool for PhpWiki <?php echo $config_file ?></title>
51 <style type="text/css" media="screen">
52 <!--
53 /* TABLE { border: thin solid black } */
54 body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 80%; }
55 pre { font-size: 120%; }
56 td { border: thin solid black }
57 tr { border: none }
58 tr.hidden { border: none; display: none; }
59 td.part { background-color: #eeeeee; color: inherit; }
60 td.instructions { background-color: #ffffee; width: <?php echo $tdwidth ?>px; color: inherit; }
61 td.unchangeable-variable-top   { border-bottom: none; background-color: #ffffee; color:inherit; }
62 td.unchangeable-variable-left  { border-top: none; background-color: #ffffee; color:inherit; }
63 -->
64 </style>
65 <script language="JavaScript" type="text/javascript">
66 <!--
67 function update(accepted, error, value, output) {
68   if (accepted) {
69     document.getElementById(output).innerHTML = "<font color=\"green\">Input accepted.</font>";
70   } else {
71     while ((index = error.indexOf("%s")) > -1) {
72       error = error.substring(0, index) + value + error.substring(index+2);
73     }
74     document.getElementById(output).innerHTML = "<font color=\"red\">" + error + "</font>";
75   }
76 }
77
78 function validate(error, value, output, field) {
79   update(field.value == value, error, field.value, output);
80 }
81
82 function validate_ereg(error, ereg, output, field) {
83   regex = new RegExp(ereg);
84   update(regex.test(field.value), error, field.value, output);
85 }
86
87 function validate_range(error, low, high, empty_ok, output, field) {
88   update((empty_ok == 1 && field.value == "") ||
89          (field.value >= low && field.value <= high),
90          error, field.value, output);
91 }
92
93 function toggle_group(id) {
94   var text = document.getElementById(id + "_text");
95   var do_hide = false;
96   if (text.innerHTML == "Hide options.") {
97     do_hide = true;
98     text.innerHTML = "Show options.";
99   } else {
100     text.innerHTML = "Hide options.";
101   }
102
103   var rows = document.getElementsByTagName('tr');
104   var i = 0;
105   for (i = 0; i < rows.length; i++) {
106     var tr = rows[i];
107     if (tr.className == 'header' && tr.id == id) {
108       i++;
109       break;
110     }
111   }
112   for (; i < rows.length; i++) {
113     var tr = rows[i];
114     if (tr.className == 'header')
115       break;
116     tr.className = do_hide ? 'hidden': 'nonhidden';
117   }
118 }
119
120 function do_init() {
121   // Hide all groups.  We do this via JavaScript to avoid
122   // hiding the groups if JavaScript is not supported...
123   var rows = document.getElementsByTagName('tr');
124   for (var i = 0; i < rows.length; i++) {
125     var tr = rows[i];
126     if (tr.className == 'header')
127       toggle_group(tr.id);
128   }
129
130   // Select text in textarea upon focus
131   var area = document.getElementById('config-output');
132   if (area) {
133     listener = { handleEvent: function (e) { area.select(); } };
134     area.addEventListener('focus', listener, false);
135   }
136 }
137   
138 -->
139 </script>
140 </head>
141 <body onload="do_init();">
142
143       <h1>Configuration for PhpWiki <?php echo $config_file ?></h1>
144
145 <?php
146 //define('DEBUG', 1);
147 /**
148  * The Configurator is a php script to aid in the configuration of PhpWiki.
149  * Parts of this file were based on PHPWeather's configurator.php file.
150  *   http://sourceforge.net/projects/phpweather/
151  *
152  * TO CHANGE THE CONFIGURATION OF YOUR PHPWIKI, DO *NOT* MODIFY THIS FILE!
153  * more instructions go here
154  *
155  * Todo: 
156  *   * fix include_path
157  *   * eval config.ini to get the actual settings.
158  */
159
160 //////////////////////////////
161 // begin configuration options
162
163 /**
164  * Notes for the description parameter of $property:
165  *
166  * - Descriptive text will be changed into comments (preceeded by ; )
167  *   for the final output to config.ini.
168  *
169  * - Only a limited set of html is allowed: pre, dl dt dd; it will be
170  *   stripped from the final output.
171  *
172  * - Line breaks and spacing will be preserved for the final output.
173  *
174  * - Double line breaks are automatically converted to paragraphs
175  *   for the html version of the descriptive text.
176  *
177  * - Double-quotes and dollar signs in the descriptive text must be
178  *   escaped: \" and \$. Instead of escaping double-quotes you can use 
179  *   single (') quotes for the enclosing quotes. 
180  *
181  * - Special characters like < and > must use html entities,
182  *   they will be converted back to characters for the final output.
183  */
184
185 $SEPARATOR = ";=========================================================================";
186
187 $preamble = "
188 ; This is the main configuration file for PhpWiki in INI-style format.
189 ; Note that certain characters are used as comment char and therefore 
190 ; these entries must be in double-quotes. Such as \":\", \";\", \",\" and \"|\"
191 ; Take special care for DBAUTH_ sql statements. (Part 3a)
192 ;
193 ; This file is divided into several parts: Each one has different configuration 
194 ; settings you can change; in all cases the default should work on your system,
195 ; however, we recommend you tailor things to your particular setting.
196 ";
197
198 $properties["Part Zero"] =
199 new part('_part0', $SEPARATOR."\n", "
200 Part Zero: (optional)
201 Latest Development and Tricky Options");
202
203 if (substr(PHP_OS,0,3) == 'WIN') {
204     $include_path = dirname(__FILE__) . ';' . ini_get('include_path');
205     if (strchr(ini_get('include_path'),'/'))
206         $include_path = strtr($include_path,'\\','/');
207 } else {
208     $include_path = dirname(__FILE__) . ':' . ini_get('include_path');
209 }
210
211 $properties["PHP include_path"] =
212     new _define('INCLUDE_PATH', ini_get('include_path'), "
213 If PHP needs help in finding where you installed the rest of the PhpWiki
214 code, you can set the include_path here.
215
216 Override the PHP include path so that it can find some needed additional libraries.
217 You shouldn't need to do this unless your system include_path esp. your 
218 system pear libs are broken or oudated. The PHPWIKI_DIR is automatically 
219 put to the front and the local lib/pear path is automatically added to the end.
220 But if you define it, be sure to include either the system pear path or 
221 the phpwiki/lib/pear path to override your Pear_DB.
222 Note that on Windows-based servers, you should use ; rather than :
223 as the path separator.");
224
225 // TODO: convert this a checkbox row as in tests/unit/test.pgp
226 $properties["DEBUG"] =
227 new numeric_define_optional('DEBUG', '0', "
228 Set DEBUG to 1 to view the XHTML and CSS validator icons, page
229 processing timer, and possibly other debugging messages at the
230 bottom of each page. 65 for a more verbose level with AUTH hints. 
231 See lib/config.php for all supported values.");
232
233 $properties["ENABLE_USER_NEW"] =
234 new boolean_define_commented_optional
235 ('ENABLE_USER_NEW', 
236  array('true'  => "Enabled",
237        'false' => "Disabled."), "
238 Enable the new method of handling WikiUser Authetincation and Preferences. 
239 It's best to leave it on, and only disable it if you have problems with it.
240 Servers with memory-limit problems might want to turn it off. It costs ~300KB
241 Default: true");
242
243 $properties["ENABLE_PAGEPERM"] =
244 new boolean_define_commented_optional
245 ('ENABLE_PAGEPERM', 
246  array('true'  => "Enabled",
247        'false' => "Disabled."), "
248 Use access control lists (as in Solaris and Windows NTFS) per page and group, 
249 not per user for the whole wiki.
250
251 I suspect ACL page permissions to degrade speed by 10%. 
252 GROUP_METHOD=WIKIPAGE is slowest. (See Part 3a)
253 Default: true");
254
255 $properties["ENABLE_EDIT_TOOLBAR"] =
256 new boolean_define_commented_optional
257 ('ENABLE_EDIT_TOOLBAR', 
258  array('true'  => "Enabled",
259        'false' => "Disabled."), "
260 Graphical buttons on edit. Default: true.
261 Reportedly broken on MacOSX Safari");
262
263 $properties["JS_SEARCHREPLACE"] =
264 new boolean_define_commented_optional
265 ('JS_SEARCHREPLACE', 
266  array('true'  => "Enabled",
267        'false' => "Disabled"), "
268 Adds two additional buttons in EDIT_TOOLBAR, Search&Replace and Undo. 
269 Undo is experimental.");
270
271 $properties["ENABLE_DOUBLECLICKEDIT"] =
272 new boolean_define_commented_optional
273 ('ENABLE_DOUBLECLICKEDIT', 
274  array('true'  => "Enabled",
275        'false' => "Disabled"), "
276 Default: true");
277
278 $properties["ENABLE_XHTML_XML"] =
279 new boolean_define_commented_optional
280 ('ENABLE_XHTML_XML', 
281  array('false' => "Disabled",
282        'true'  => "Enabled"), "
283 Needed for inlined SVG and MathM, but may conflict with javascript:document.write(). 
284 Experimental. Default: false");
285
286 $properties["USECACHE"] =
287 new boolean_define_commented_optional
288 ('USECACHE', 
289  array('true'  => "Enabled",
290        'false' => "Disabled"), "
291 Store DB query results in memory to avoid duplicate queries.
292 Disable only for old php's with low memory or memory_limit=8MB.
293 Default: true");
294
295 $properties["ENABLE_SPAMASSASSIN"] =
296 new boolean_define_commented_optional
297 ('ENABLE_SPAMASSASSIN', 
298  array('true'  => "Enabled",
299        'false' => "Disabled"), "
300 Needs babycart installed. See http://phpwiki.org/SpamAssassinIntegration
301 Optionally define BABYCART_PATH. Default: /usr/local/bin/babycart");
302
303 $properties["GOOGLE_LINKS_NOFOLLOW"] =
304 new boolean_define_commented_optional
305 ('GOOGLE_LINKS_NOFOLLOW', 
306  array('true'  => "Enabled",
307        'false' => "Disabled"), "
308 If enabled ref=nofollow is added to all external links to discourage spam. 
309 You might want to turn it off, if you want to improve pageranks on external links.");
310
311 $properties["ENABLE_LIVESEARCH"] =
312 new boolean_define_commented_optional
313 ('ENABLE_LIVESEARCH', 
314  array('true'  => "Enabled",
315        'false' => "Disabled"), "
316 LiveSearch enables immediate title search results via XMLHttpRequest.
317 Displays the results in a dropdown under the titlesearch inputbox
318 while typing. (experimental, only with certain themes)
319 You'll have to copy livesearch.js from http://blog.bitflux.ch/wiki/LiveSearch
320 to themes/default/ and define ENABLE_LIVESEARCH in config.ini to true. 
321 See themes/blog/themeinfo.php.
322 Currently we use the bitflux.ch library, but we will change to 
323 the russian acdropdown soon. http://momche.net/publish/article.php?page=acdropdown");
324
325 $properties["USE_SAFE_DBSESSION"] =
326 new boolean_define_commented_optional
327 ('USE_SAFE_DBSESSION', 
328  array('false' => "Disabled",
329        'true'  => "Enabled"), "
330 USE_SAFE_DBSESSION should be enabled, if you encounter session problems, with duplicate INSERT 
331 sess_id warnings at the bottom of the page. Reason is a unreliable affected_rows implementation() 
332 in the sql backend. Default is Disabled, using the fastest DbSession UPDATE method.");
333
334 $properties["Part One"] =
335 new part('_part1', $SEPARATOR."\n", "
336 Part One: Authentication and security settings. See Part Three for more.");
337
338 $properties["Admin Username"] =
339 new _define_notempty('ADMIN_USER', "", "
340 You must set this! Username and password of the administrator.",
341 "onchange=\"validate_ereg('Sorry, ADMIN_USER cannot be empty.', '^.+$', 'ADMIN_USER', this);\"");
342
343 $properties["Admin Password"] =
344 new _define_password('ADMIN_PASSWD', "", "
345 For heaven's sake pick a good password.
346 If your version of PHP supports encrypted passwords, your password will be
347 automatically encrypted within the generated config file. 
348 Use the \"Create Random Password\" button to create a good (random) password.
349
350 ADMIN_PASSWD is ignored on HttpAuth",
351 "onchange=\"validate_ereg('Sorry, ADMIN_PASSWD must be at least 4 chars long.', '^....+$', 'ADMIN_PASSWD', this);\"");
352
353 $properties["Encrypted Passwords"] =
354 new boolean_define
355 ('ENCRYPTED_PASSWD',
356  array('true'  => "true.  use crypt for all passwords",
357        'false' => "false. use plaintest passwords (not recommended)"), "
358 It is recommended that you use encrypted passwords to be stored in the 
359 config.ini and the users homepages metadata.
360 You might want to use the passencrypt.php utility to encode the
361 admin password, in the event that someone gains ftp or ssh access to the
362 server and directory containing phpwiki. 
363 <i>SQL access passwords cannot be encrypted, besides using external DATABASE_DSN aliases within PDO.</i>
364
365 If true, all user passwords will be stored encrypted.
366 You might have to set it to false, if your PHP doesn't support crypt().
367 ");
368
369 $properties["Wiki Name"] =
370 new _define_optional('WIKI_NAME', 'PhpWiki', "
371 The name of your wiki.
372
373 This is used to generate a keywords meta tag in the HTML templates,
374 in bookmark titles for any bookmarks made to pages in your wiki,
375 and during RSS generation for the title of the RSS channel.
376
377 It is recommended this be a relatively short WikiWord like the
378 InterWiki monikers found in the InterWikiMap. (For examples, see
379 lib/interwiki.map).
380 ");
381
382 $properties["Reverse DNS"] =
383 new boolean_define_optional
384 ('ENABLE_REVERSE_DNS',
385  array('true'  => "true. perform additional reverse dns lookups",
386        'false' => "false. just record the address as given by the httpd server"),
387
388 If set, we will perform reverse dns lookups to try to convert the
389 users IP number to a host name, even if the http server didn't do it for us.");
390
391 $properties["ZIPdump Authentication"] =
392 new boolean_define_optional('ZIPDUMP_AUTH', 
393                     array('false' => "false. Everyone may download zip dumps",
394                           'true'  => "true. Only admin may download zip dumps"), "
395 If true, only the admin user can make zip dumps, else zip dumps
396 require no authentication.");
397
398 $properties["Enable RawHtml Plugin"] =
399 new boolean_define_commented_optional
400 ('ENABLE_RAW_HTML', 
401  array('true'  => "Enabled",
402        'false' => "Disabled"), "
403 The RawHtml plugin allows page authors to embed real, raw HTML into Wiki
404 pages.  This is a possible security threat, as much HTML (or, rather,
405 JavaScript) can be very risky.  If you are in a controlled environment,
406 however, it could be of use.");
407
408 $properties["Allow RawHtml Plugin only on locked pages"] =
409 new boolean_define_commented_optional
410 ('ENABLE_RAW_HTML_LOCKEDONLY', 
411  array('true'  => "Enabled",
412        'false' => "Disabled"), "
413 If this is set, only pages locked by the Administrator may contain the RawHtml plugin.");
414
415 $properties["Allow RawHtml Plugin if safe HTML code"] =
416 new boolean_define_commented_optional
417 ('ENABLE_RAW_HTML_SAFE', 
418  array('true'  => "Enabled",
419        'false' => "Disabled"), "
420 If this is set, all unsafe html code is stripped automatically (experimental!)
421 See <a href=\"http://chxo.com/scripts/safe_html-test.php\" target=\"_new\">chxo.com/scripts/safe_html-test.php</a>
422 ");
423
424 $properties["Maximum Upload Size"] =
425 new numeric_define_optional('MAX_UPLOAD_SIZE', "16 * 1024 * 1024", "
426 The maximum file upload size.");
427
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('DISABLED_ACTIONS', 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 $properties["pear Cache USECACHE"] =
1627 new boolean_define_optional('PLUGIN_CACHED_USECACHE', 
1628                     array('true'  => 'Enabled',
1629                           'false' => 'Disabled'), "
1630 Enable or disable pear caching of plugins.");
1631 $properties["pear Cache Database Container"] =
1632 new _define_selection_optional('PLUGIN_CACHED_DATABASE', 
1633                                array('file' => 'file'), "
1634 Curently only file is supported. 
1635 db, trifile and imgfile might be supported, but you must hack that by yourself.");
1636
1637 $properties["pear Cache cache directory"] =
1638 new _define_commented_optional('PLUGIN_CACHED_CACHE_DIR', "/tmp/cache", "
1639 Should be writable to the webserver.");
1640 $properties["pear Cache Filename Prefix"] =
1641 new _define_optional('PLUGIN_CACHED_FILENAME_PREFIX', "phpwiki", "");
1642 $properties["pear Cache HIGHWATER"] =
1643 new numeric_define_optional('PLUGIN_CACHED_HIGHWATER', "4194304", "
1644 Garbage collection parameter.");
1645 $properties["pear Cache LOWWATER"] =
1646 new numeric_define_optional('PLUGIN_CACHED_LOWWATER', "3145728", "
1647 Garbage collection parameter.");
1648 $properties["pear Cache MAXLIFETIME"] =
1649 new numeric_define_optional('PLUGIN_CACHED_MAXLIFETIME', "2592000", "
1650 Garbage collection parameter.");
1651 $properties["pear Cache MAXARGLEN"] =
1652 new numeric_define_optional('PLUGIN_CACHED_MAXARGLEN', "1000", "
1653 max. generated url length.");
1654 $properties["pear Cache FORCE_SYNCMAP"] =
1655 new boolean_define_optional('PLUGIN_CACHED_FORCE_SYNCMAP', 
1656                     array('true'  => 'Enabled',
1657                           'false' => 'Disabled'), "");
1658 $properties["pear Cache IMGTYPES"] =
1659 new list_define('PLUGIN_CACHED_IMGTYPES', "png|gif|gd|gd2|jpeg|wbmp|xbm|xpm", "
1660 Handle those image types via GD handles. Check your GD supported image types.");
1661
1662 $end = "\n".$SEPARATOR."\n";
1663
1664 // end of configuration options
1665 ///////////////////////////////
1666 // begin class definitions
1667
1668 /**
1669  * A basic config-dist.ini configuration line in the form of a variable. 
1670  * (not needed anymore, we have only defines)
1671  *
1672  * Produces a string in the form "$name = value;"
1673  * e.g.:
1674  * $WikiNameRegexp = "value";
1675  */
1676 class _variable {
1677
1678     var $config_item_name;
1679     var $default_value;
1680     var $description;
1681     var $prefix;
1682     var $jscheck;
1683
1684     function _variable($config_item_name, $default_value, $description, $jscheck = '') {
1685         $this->config_item_name = $config_item_name;
1686         $this->description = $description;
1687         $this->default_value = $default_value;
1688         $this->jscheck = $jscheck;
1689         if (preg_match("/variable/i",get_class($this)))
1690             $this->prefix = "\$";
1691         elseif (preg_match("/ini_set/i",get_class($this)))
1692             $this->prefix = "ini_get: ";
1693         else
1694             $this->prefix = "";
1695     }
1696
1697     function value() {
1698       global $HTTP_POST_VARS;
1699       if (isset($HTTP_POST_VARS[$this->config_item_name]))
1700           return $HTTP_POST_VARS[$this->config_item_name];
1701       else 
1702           return $this->default_value;
1703     }
1704
1705     function _config_format($value) {
1706         $v = $this->get_config_item_name();
1707         // handle arrays: a|b --> a['b']
1708         if (strpos($v, '|')) {
1709             list($a, $b) = explode('|', $v);
1710             $v = sprintf("%s['%s']", $a, $b);
1711         }
1712         if (preg_match("/[\"']/", $value))
1713             $value = '"' . $value . '"';
1714         return sprintf("%s = \"%s\"", $v, $value);
1715     }
1716
1717     function get_config_item_name() {
1718         return $this->config_item_name;
1719     }
1720
1721     function get_config_item_id() {
1722         return str_replace('|', '-', $this->config_item_name);
1723     }
1724
1725     function get_config_item_header() {
1726        if (strchr($this->config_item_name,'|')) {
1727           list($var,$param) = explode('|',$this->config_item_name);
1728           return "<b>" . $this->prefix . $var . "['" . $param . "']</b><br />";
1729        }
1730        elseif ($this->config_item_name[0] != '_')
1731           return "<b>" . $this->prefix . $this->config_item_name . "</b><br />";
1732        else 
1733           return '';
1734     }
1735
1736     function _get_description() {
1737         return $this->description;
1738     }
1739
1740     function _get_config_line($posted_value) {
1741         return "\n" . $this->_config_format($posted_value);
1742     }
1743
1744     function get_config($posted_value) {
1745         $d = stripHtml($this->_get_description());
1746         $d = str_replace("\n", "\n; ", $d) . $this->_get_config_line($posted_value) ."\n";
1747         return $d;
1748     }
1749
1750     function get_instructions($title) {
1751         global $tdwidth;
1752         $i = "<h3>" . $title . "</h3>\n    " . nl2p($this->_get_description()) . "\n";
1753         return "<tr>\n<td width=\"$tdwidth\" class=\"instructions\">\n" . $i . "</td>\n";
1754     }
1755
1756     function get_html() {
1757         $size = strlen($this->default_value) > 45 ? 90 : 50;
1758         return $this->get_config_item_header() . 
1759             "<input type=\"text\" size=\"$50\" name=\"" . $this->get_config_item_name() . "\" value=\"" . htmlspecialchars($this->default_value) . "\" " . 
1760             $this->jscheck . " />" . "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: green\">Input accepted.</p>";
1761     }
1762 }
1763
1764 class unchangeable_variable
1765 extends _variable {
1766     function _config_format($value) {
1767         return "";
1768     }
1769     // function get_html() { return false; }
1770     function get_html() {
1771         return $this->get_config_item_header() . 
1772         "<em>Not editable.</em>" . 
1773         "<pre>" . $this->default_value."</pre>";
1774     }
1775     function _get_config_line($posted_value) {
1776         if ($this->description)
1777             $n = "\n";
1778         return "${n}".$this->default_value;
1779     }
1780     function get_instructions($title) {
1781         global $tdwidth;
1782         $i = "<h3>" . $title . "</h3>\n    " . nl2p($this->_get_description()) . "\n";
1783         // $i .= "<em>Not editable.</em><br />\n<pre>" . $this->default_value."</pre>";
1784         return '<tr><td width="100%" class="unchangeable-variable-top" colspan="2">'."\n".$i."</td></tr>\n" 
1785         . '<tr style="border-top: none;"><td class="unchangeable-variable-left" width="'.$tdwidth.'">&nbsp;</td>';
1786     }
1787 }
1788
1789 class unchangeable_define
1790 extends unchangeable_variable {
1791     function _config_format($value) {
1792         return "";
1793     }
1794 }
1795 class unchangeable_ini_set
1796 extends unchangeable_variable {
1797     function _config_format($value) {
1798         return "";
1799     }
1800 }
1801
1802 class _variable_selection
1803 extends _variable {
1804     function value() {
1805         global $HTTP_POST_VARS;
1806         if (!empty($HTTP_POST_VARS[$this->config_item_name]))
1807             return $HTTP_POST_VARS[$this->config_item_name];
1808         else {
1809             list($option, $label) = each($this->default_value);
1810             return $option;
1811         }
1812     }
1813     function get_html() {
1814         $output = $this->get_config_item_header();
1815         $output .= '<select name="' . $this->get_config_item_name() . "\">\n";
1816         /* The first option is the default */
1817         while(list($option, $label) = each($this->default_value)) {
1818             $output .= "  <option value=\"$option\">$label</option>\n";
1819         }
1820         $output .= "</select>\n";
1821         return $output;
1822     }
1823 }
1824
1825
1826 class _define
1827 extends _variable {
1828     function _config_format($value) {
1829         return sprintf("%s = \"%s\"", $this->get_config_item_name(), $value);
1830     }
1831     function _get_config_line($posted_value) {
1832         if ($this->description)
1833             $n = "\n";
1834         if ($posted_value == '')
1835             return "${n};" . $this->_config_format("");
1836         else
1837             return "${n}" . $this->_config_format($posted_value);
1838     }
1839     function get_html() {
1840         $size = strlen($this->default_value) > 45 ? 90 : 50;
1841         return $this->get_config_item_header() 
1842             . "<input type=\"text\" size=\"$size\" name=\"" . htmlentities($this->get_config_item_name()) 
1843             . "\" value=\"" . htmlentities($this->default_value) . "\" {$this->jscheck} />" 
1844             . "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: green\">Input accepted.</p>";
1845     }
1846 }
1847
1848 class _define_commented
1849 extends _define {
1850     function _get_config_line($posted_value) {
1851         if ($this->description)
1852             $n = "\n";
1853         if ($posted_value == $this->default_value)
1854             return "${n};" . $this->_config_format($posted_value);
1855         elseif ($posted_value == '')
1856             return "${n};" . $this->_config_format("");
1857         else
1858             return "${n}" . $this->_config_format($posted_value);
1859     }
1860 }
1861
1862 /** 
1863  * We don't use _optional anymore, because INI-style config's don't need that. 
1864  * IniConfig.php does the optional logic now.
1865  * But we use _optional for config-default.ini options
1866  */
1867 class _define_commented_optional
1868 extends _define_commented { }
1869
1870 class _define_optional
1871 extends _define { }
1872
1873 class _define_notempty
1874 extends _define {
1875     function get_html() {
1876         $s = $this->get_config_item_header() 
1877             . "<input type=\"text\" size=\"50\" name=\"" . $this->get_config_item_name() 
1878             . "\" value=\"" . $this->default_value . "\" {$this->jscheck} />";
1879         if (empty($this->default_value))
1880             return $s . "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: red\">Cannot be empty.</p>";
1881         else
1882             return $s . "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: green\">Input accepted.</p>";
1883     }
1884 }
1885
1886 class _variable_commented
1887 extends _variable {
1888     function _get_config_line($posted_value) {
1889         if ($this->description)
1890             $n = "\n";
1891         if ($posted_value == $this->default_value)
1892             return "${n};" . $this->_config_format($posted_value);
1893         elseif ($posted_value == '')
1894             return "${n};" . $this->_config_format("");
1895         else
1896             return "${n}" . $this->_config_format($posted_value);
1897     }
1898 }
1899
1900 class numeric_define
1901 extends _define {
1902
1903     function numeric_define($config_item_name, $default_value, $description, $jscheck = '') {
1904         $this->_define($config_item_name, $default_value, $description, $jscheck);
1905         if (!$jscheck)
1906             $this->jscheck = "onchange=\"validate_ereg('Sorry, \'%s\' is not an integer.', '^[-+]?[0-9]+$', '" . $this->get_config_item_name() . "', this);\"";
1907     }
1908     function _config_format($value) {
1909         //return sprintf("define('%s', %s);", $this->get_config_item_name(), $value);
1910         return sprintf("%s = %s", $this->get_config_item_name(), $value);
1911     }
1912     function _get_config_line($posted_value) {
1913         if ($this->description)
1914             $n = "\n";
1915         if ($posted_value == '')
1916             return "${n};" . $this->_config_format('0');
1917         else
1918             return "${n}" . $this->_config_format($posted_value);
1919     }
1920 }
1921
1922 class numeric_define_optional
1923 extends numeric_define {}
1924
1925 class numeric_define_commented
1926 extends numeric_define {
1927     function _get_config_line($posted_value) {
1928         if ($this->description)
1929             $n = "\n";
1930         if ($posted_value == $this->default_value)
1931             return "${n};" . $this->_config_format($posted_value);
1932         elseif ($posted_value == '')
1933             return "${n};" . $this->_config_format('0');
1934         else
1935             return "${n}" . $this->_config_format($posted_value);
1936     }
1937 }
1938
1939 class _define_selection
1940 extends _variable_selection {
1941     function _config_format($value) {
1942         return sprintf("%s = %s", $this->get_config_item_name(), $value);
1943     }
1944     function _get_config_line($posted_value) {
1945         return _define::_get_config_line($posted_value);
1946     }
1947     function get_html() {
1948         return _variable_selection::get_html();
1949     }
1950 }
1951
1952 class _define_selection_optional
1953 extends _define_selection { }
1954
1955 class _variable_selection_optional
1956 extends _variable_selection { }
1957
1958 class _define_password
1959 extends _define {
1960
1961     function _define_password($config_item_name, $default_value, $description, $jscheck = '') {
1962         $this->_define($config_item_name, $default_value, $description, $jscheck);
1963         if (!$jscheck)
1964             $this->jscheck = "onchange=\"validate_ereg('Sorry, \'%s\' cannot be empty.', '^.+$', '" . $this->get_config_item_name() . "', this);\"";
1965     }
1966     function _get_config_line($posted_value) {
1967         if ($this->description)
1968             $n = "\n";
1969         if ($posted_value == '') {
1970             $p = "${n};" . $this->_config_format("");
1971             $p .= "\n; If you used the passencrypt.php utility to encode the password";
1972             $p .= "\n; then uncomment this line:";
1973             $p .= "\n;ENCRYPTED_PASSWD = true";
1974             return $p;
1975         } else {
1976             if (function_exists('crypt')) {
1977                 $salt_length = max(CRYPT_SALT_LENGTH,
1978                                     2 * CRYPT_STD_DES,
1979                                     9 * CRYPT_EXT_DES,
1980                                    12 * CRYPT_MD5,
1981                                    16 * CRYPT_BLOWFISH);
1982                 // generate an encrypted password
1983                 $crypt_pass = crypt($posted_value, rand_ascii($salt_length));
1984                 $p = "${n}" . $this->_config_format($crypt_pass);
1985                 return $p . "\nENCRYPTED_PASSWD = true";
1986             } else {
1987                 $p = "${n}" . $this->_config_format($posted_value);
1988                 $p .= "\n; Encrypted passwords cannot be used:";
1989                 $p .= "\n; 'function crypt()' not available in this version of php";
1990                 $p .= "\nENCRYPTED_PASSWD = false";
1991                 return $p;
1992             }
1993         }
1994     }
1995     function get_html() {
1996         return _variable_password::get_html();
1997     }
1998 }
1999
2000 class _define_password_optional
2001 extends _define_password { }
2002
2003 class _variable_password
2004 extends _variable {
2005     function _variable_password($config_item_name, $default_value, $description, $jscheck = '') {
2006         $this->_define($config_item_name, $default_value, $description, $jscheck);
2007         if (!$jscheck)
2008             $this->jscheck = "onchange=\"validate_ereg('Sorry, \'%s\' cannot be empty.', '^.+$', '" . $this->get_config_item_name() . "', this);\"";
2009     }
2010     function get_html() {
2011         global $HTTP_POST_VARS, $HTTP_GET_VARS;
2012         $s = $this->get_config_item_header();
2013         if (isset($HTTP_POST_VARS['create']) or isset($HTTP_GET_VARS['create'])) {
2014             $new_password = random_good_password();
2015             $this->default_value = $new_password;
2016             $s .= "Created password: <strong>$new_password</strong><br />&nbsp;<br />";
2017         }
2018         $s .= "<input type=\"password\" name=\"" . $this->get_config_item_name()
2019            . "\" value=\"" . $this->default_value 
2020            . "\" {$this->jscheck} />" 
2021            . "&nbsp;&nbsp;<input type=\"submit\" name=\"create\" value=\"Create Random Password\" />";
2022         if (empty($this->default_value))
2023             $s .= "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: red\">Cannot be empty.</p>";
2024         elseif (strlen($this->default_value) < 4)
2025             $s .= "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: red\">Must be longer than 4 chars.</p>";
2026         else
2027             $s .= "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: green\">Input accepted.</p>";
2028         return $s;
2029     }
2030 }
2031
2032 class list_variable
2033 extends _variable {
2034     function _get_config_line($posted_value) {
2035         // split the phrase by any number of commas or space characters,
2036         // which include " ", \r, \t, \n and \f
2037         $list_values = preg_split("/[\s,]+/", $posted_value, -1, PREG_SPLIT_NO_EMPTY);
2038         $list_values = join("|", $list_values);
2039         return _variable::_get_config_line($list_values);
2040     }
2041     function get_html() {
2042         $list_values = explode("|", $this->default_value);
2043         $rows = max(3, count($list_values) +1);
2044         $list_values = join("\n", $list_values);
2045         $ta = $this->get_config_item_header();
2046         $ta .= "<textarea cols=\"18\" rows=\"". $rows ."\" name=\"".$this->get_config_item_name()."\" {$this->jscheck}>";
2047         $ta .= $list_values . "</textarea>";
2048         $ta .= "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: green\">Input accepted.</p>";
2049         return $ta;
2050     }
2051 }
2052
2053 class list_define
2054 extends _define {
2055     function _get_config_line($posted_value) {
2056         $list_values = preg_split("/[\s,]+/", $posted_value, -1, PREG_SPLIT_NO_EMPTY);
2057         $list_values = join("|", $list_values);
2058         return _variable::_get_config_line($list_values);
2059     }
2060     function get_html() {
2061         $list_values = explode("|", $this->default_value);
2062         $rows = max(3, count($list_values) +1);
2063         $list_values = join("\n", $list_values);
2064         $ta = $this->get_config_item_header();
2065         $ta .= "<textarea cols=\"18\" rows=\"". $rows ."\" name=\"".$this->get_config_item_name()."\" {$this->jscheck}>";
2066         $ta .= $list_values . "</textarea>";
2067         $ta .= "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: green\">Input accepted.</p>";
2068         return $ta;
2069     }
2070 }
2071
2072 class array_variable
2073 extends _variable {
2074     function _config_format($value) {
2075         return sprintf("%s = \"%s\"", $this->get_config_item_name(), 
2076                        is_array($value) ? join(':', $value) : $value);
2077     }
2078     function _get_config_line($posted_value) {
2079         // split the phrase by any number of commas or space characters,
2080         // which include " ", \r, \t, \n and \f
2081         $list_values = preg_split("/[\s,]+/", $posted_value, -1, PREG_SPLIT_NO_EMPTY);
2082         if (!empty($list_values)) {
2083             $list_values = "'".join("', '", $list_values)."'";
2084             return "\n" . $this->_config_format($list_values);
2085         } else
2086             return "\n;" . $this->_config_format('');
2087     }
2088     function get_html() {
2089         $list_values = join("\n", $this->default_value);
2090         $rows = max(3, count($this->default_value) +1);
2091         $ta = $this->get_config_item_header();
2092         $ta .= "<textarea cols=\"18\" rows=\"". $rows ."\" name=\"".$this->get_config_item_name()."\" {$this->jscheck}>";
2093         $ta .= $list_values . "</textarea>";
2094         $ta .= "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: green\">Input accepted.</p>";
2095         return $ta;
2096     }
2097 }
2098
2099 class array_define
2100 extends _define {
2101     function _config_format($value) {
2102         return sprintf("%s = \"%s\"", $this->get_config_item_name(), 
2103                        is_array($value) ? join(' : ', $value) : $value);
2104     }
2105     function _get_config_line($posted_value) {
2106         // split the phrase by any number of commas or space characters,
2107         // which include " ", \r, \t, \n and \f
2108         $list_values = preg_split("/[\s,:]+/", $posted_value, -1, PREG_SPLIT_NO_EMPTY);
2109         if (!empty($list_values)) {
2110             $list_values = "'".join("' : '", $list_values)."'";
2111             return "\n" . $this->_config_format($list_values);
2112         } else
2113             return "\n;" . $this->_config_format('');
2114     }
2115     function get_html() {
2116         $list_values = join("\n", $this->default_value);
2117         $rows = max(3, count($this->default_value) +1);
2118         $ta = $this->get_config_item_header();
2119         $ta .= "<textarea cols=\"18\" rows=\"". $rows ."\" name=\"".$this->get_config_item_name()."\" {$this->jscheck}>";
2120         $ta .= $list_values . "</textarea>";
2121         $ta .= "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: green\">Input accepted.</p>";
2122         return $ta;
2123     }
2124 }
2125
2126 /*
2127 class _ini_set
2128 extends _variable {
2129     function value() {
2130         global $HTTP_POST_VARS;
2131         if ($v = $HTTP_POST_VARS[$this->config_item_name])
2132             return $v;
2133         else {
2134             return ini_get($this->get_config_item_name);
2135         }
2136     }
2137     function _config_format($value) {
2138         return sprintf("ini_set('%s', '%s');", $this->get_config_item_name(), $value);
2139     }
2140     function _get_config_line($posted_value) {
2141         if ($posted_value && ! $posted_value == $this->default_value)
2142             return "\n" . $this->_config_format($posted_value);
2143         else
2144             return "\n;" . $this->_config_format($this->default_value);
2145     }
2146 }
2147 */
2148
2149 class boolean_define
2150 extends _define {
2151     function _get_config_line($posted_value) {
2152         if ($this->description)
2153             $n = "\n";
2154         return "${n}" . $this->_config_format($posted_value);
2155     }
2156     function _config_format($value) {
2157         if (strtolower(trim($value)) == 'false')
2158             $value = false;
2159         return sprintf("%s = %s", $this->get_config_item_name(),
2160                        (bool)$value ? 'true' : 'false');
2161     }
2162     function get_html() {
2163         $output = $this->get_config_item_header();
2164         $output .= '<select name="' . $this->get_config_item_name() . "\" {$this->jscheck}>\n";
2165         /* The first option is the default */
2166         list($option, $label) = each($this->default_value);
2167         $output .= "  <option value=\"$option\" selected='selected'>$label</option>\n";
2168         /* There can usually, only be two options, there can be
2169          * three options in the case of a boolean_define_commented_optional */
2170         while (list($option, $label) = each($this->default_value)) 
2171           $output .= "  <option value=\"$option\">$label</option>\n";
2172         $output .= "</select>\n";
2173         return $output;
2174     }
2175 }
2176
2177 class boolean_define_optional
2178 extends boolean_define {}
2179
2180 class boolean_define_commented
2181 extends boolean_define {
2182     function _get_config_line($posted_value) {
2183         if ($this->description)
2184             $n = "\n";
2185         list($default_value, $label) = each($this->default_value);
2186         if ($posted_value == $default_value)
2187             return "${n};" . $this->_config_format($posted_value);
2188         elseif ($posted_value == '')
2189             return "${n};" . $this->_config_format('false');
2190         else
2191             return "${n}" . $this->_config_format($posted_value);
2192     }
2193 }
2194
2195 class boolean_define_commented_optional
2196 extends boolean_define_commented {}
2197
2198 class part
2199 extends _variable {
2200     function value () { return; }
2201     function get_config($posted_value) {
2202         $d = stripHtml($this->_get_description());
2203         global $SEPARATOR;
2204         return "\n".$SEPARATOR . str_replace("\n", "\n; ", $d) ."\n".$this->default_value;
2205     }
2206     function get_instructions($title) {
2207         $group_name = preg_replace("/\W/","",$title);
2208         $i = "<tr class='header' id='$group_name'>\n<td class=\"part\" width=\"100%\" colspan=\"2\" bgcolor=\"#eeeeee\">\n";
2209         $i .= "<h2>" . $title . "</h2>\n    " . nl2p($this->_get_description()) ."\n";
2210         $i .= "<p><a href=\"javascript:toggle_group('$group_name')\" id=\"{$group_name}_text\">Hide options.</a></p>";
2211         return  $i ."</td>\n";
2212     }
2213     function get_html() {
2214         return "";
2215     }
2216 }
2217
2218 // html utility functions
2219 function nl2p($text) {
2220   preg_match_all("@\s*(<pre>.*?</pre>|<dl>.*?</dl>|.*?(?=\n\n|<pre>|<dl>|$))@s",
2221                  $text, $m, PREG_PATTERN_ORDER);
2222
2223   $text = '';
2224   foreach ($m[1] as $par) {
2225     if (!($par = trim($par)))
2226       continue;
2227     if (!preg_match('/^<(pre|dl)>/', $par))
2228       $par = "<p>$par</p>";
2229     $text .= $par;
2230   }
2231   return $text;
2232 }
2233
2234 function stripHtml($text) {
2235         $d = str_replace("<pre>", "", $text);
2236         $d = str_replace("</pre>", "", $d);
2237         $d = str_replace("<dl>", "", $d);
2238         $d = str_replace("</dl>", "", $d);
2239         $d = str_replace("<dt>", "", $d);
2240         $d = str_replace("</dt>", "", $d);
2241         $d = str_replace("<dd>", "", $d);
2242         $d = str_replace("</dd>", "", $d);
2243         $d = str_replace("<p>", "", $d);
2244         $d = str_replace("</p>", "", $d);
2245         //restore html entities into characters
2246         // http://www.php.net/manual/en/function.htmlentities.php
2247         $trans = get_html_translation_table (HTML_ENTITIES);
2248         $trans = array_flip ($trans);
2249         $d = strtr($d, $trans);
2250         return $d;
2251 }
2252
2253 include_once(dirname(__FILE__)."/lib/stdlib.php");
2254
2255 ////
2256 // Function to create better user passwords (much larger keyspace),
2257 // suitable for user passwords.
2258 // Sequence of random ASCII numbers, letters and some special chars.
2259 // Note: There exist other algorithms for easy-to-remember passwords.
2260 function random_good_password ($minlength = 5, $maxlength = 8) {
2261   $newpass = '';
2262   // assume ASCII ordering (not valid on EBCDIC systems!)
2263   $valid_chars = "!#%&+-.0123456789=@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz";
2264   $start = ord($valid_chars);
2265   $end   = ord(substr($valid_chars,-1));
2266   better_srand();
2267   if (function_exists('mt_rand')) // mersenne twister
2268       $length = mt_rand($minlength, $maxlength);
2269   else  // the usually bad glibc rand()
2270       $length = rand($minlength, $maxlength);
2271   while ($length > 0) {
2272       if (function_exists('mt_rand'))
2273           $newchar = mt_rand($start, $end);
2274       else
2275           $newchar = rand($start, $end);
2276       if (! strrpos($valid_chars,$newchar) ) continue; // skip holes
2277       $newpass .= sprintf("%c", $newchar);
2278       $length--;
2279   }
2280   return($newpass);
2281 }
2282
2283 // debugging
2284 function printArray($a) {
2285     echo "<hr />\n<pre>\n";
2286     print_r($a);
2287     echo "\n</pre>\n<hr />\n";
2288 }
2289
2290 // end of class definitions
2291 /////////////////////////////
2292 // begin auto generation code
2293
2294 if (!function_exists('is_a')) {
2295   function is_a($object, $class) {
2296     $class = strtolower($class);
2297     return (get_class($object) == $class) or is_subclass_of($object, $class);
2298   }
2299 }
2300
2301
2302 if (!empty($HTTP_POST_VARS['action']) 
2303     and $HTTP_POST_VARS['action'] == 'make_config'
2304     and !empty($HTTP_POST_VARS['ADMIN_USER'])
2305     and !empty($HTTP_POST_VARS['ADMIN_PASSWD'])
2306     )
2307 {
2308
2309     $timestamp = date ('dS of F, Y H:i:s');
2310
2311     $config = "
2312 ; This is a local configuration file for PhpWiki.
2313 ; It was automatically generated by the configurator script
2314 ; on the $timestamp.
2315 ;
2316 ; $preamble
2317 ";
2318
2319     $posted = $GLOBALS['HTTP_POST_VARS'];
2320
2321     if (defined('DEBUG'))
2322         printArray($GLOBALS['HTTP_POST_VARS']);
2323
2324     foreach($properties as $option_name => $a) {
2325         $posted_value = stripslashes($posted[$a->config_item_name]);
2326         $config .= $properties[$option_name]->get_config($posted_value);
2327     }
2328
2329     $config .= $end;
2330
2331     // I think writing this config file is a big security hole.
2332     // If this is installed in such a way that it can write an index-user.php,
2333     // then anyone can create a working index-user.php with, e.g. any
2334     // admin user and pw of their choosing...
2335     //
2336     // So I'm disabling it...
2337
2338     if (defined('ENABLE_FILE_OUTPUT') and ENABLE_FILE_OUPUT) {
2339       // We first check if the config-file exists.
2340       if (file_exists($fs_config_file)) {
2341         // We make a backup copy of the file
2342         $new_filename = preg_replace('/\.ini$/', '-' . time() . '.ini', $fs_config_file);
2343         if (@copy($fs_config_file, $new_filename)) {
2344             $fp = @fopen($fs_config_file, 'w');
2345         }
2346       } else {
2347         $fp = @fopen($fs_config_file, 'w');
2348       }
2349     }
2350     else {
2351       $fp = false;
2352     }
2353     
2354     if ($fp) {
2355         fputs($fp, $config);
2356         fclose($fp);
2357         echo "<p>The configuration was written to <code><b>$config_file</b></code>.</p>\n";
2358         if ($new_filename) {
2359             echo "<p>A backup was made to <code><b>$new_filename</b></code>.</p>\n";
2360         } else {
2361             ; //echo "<p><strong>You must rename or copy this</strong> <code><b>$config_file</b></code> <strong>file to</strong> <code><b>config/config.ini</b></code>.</p>\n";
2362         }
2363     } else {
2364         echo "<p>The 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";
2365     }
2366
2367     echo "<hr />\n<p>Here's the configuration file based on your answers:</p>\n";
2368     echo "<form method=\"get\" action=\"", $configurator, "\">\n";
2369     echo "<textarea id='config-output' readonly='readonly' style='width:100%;' rows='30' cols='100'>\n";
2370     echo htmlentities($config);
2371     echo "</textarea></form>\n";
2372     echo "<hr />\n";
2373
2374     echo "<p>To make any corrections, <a href=\"configurator.php\">edit the settings again</a>.</p>\n";
2375
2376 } else { // first time or create password
2377     $posted = $GLOBALS['HTTP_POST_VARS'];
2378     // No action has been specified - we make a form.
2379
2380     echo '
2381 <form action="',$configurator,'" method="post">
2382 <input type="hidden" name="action" value="make_config" />
2383 <table cellpadding="4" cellspacing="0">
2384 ';
2385
2386     while(list($property, $obj) = each($properties)) {
2387         echo $obj->get_instructions($property);
2388         if ($h = $obj->get_html()) {
2389             if (defined('DEBUG') and DEBUG)  $h = get_class($obj) . "<br />\n" . $h;
2390             echo "<td>".$h."</td>\n";
2391         }
2392         echo '</tr>';
2393     }
2394
2395     echo '
2396 </table>
2397 <p><input type="submit" value="Save ',$config_file,'" /> <input type="reset" value="Clear" /></p>
2398 </form>
2399 ';
2400 }
2401 ?>
2402 </body>
2403 </html>