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