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