3 * Copyright 2002,2003,2005,2008-2010 $ThePhpWikiProgrammingTeam
4 * Copyright 2002 Martin Geisler <gimpster@gimpster.com>
5 * Copyright 2008-2009 Marc-Etienne Vargenau, Alcatel-Lucent
7 * This file is part of PhpWiki.
8 * Parts of this file were based on PHPWeather's configurator.php file.
9 * http://sourceforge.net/projects/phpweather/
11 * PhpWiki is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * PhpWiki is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with PhpWiki; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 * Starts automatically the first time by IniConfig("config/config.ini")
28 * if it doesn't exist.
31 * o Initial expand ?show=_part1 (the part id)
32 * o read config-default.ini and use this as default_values
33 * o commented / optional: non-default values should not be commented!
34 * default values if optional can be omitted.
35 * o validate input (fix javascript, add POST checks)
36 * o start this automatically the first time
39 * 1.3.11 TODO: (or 1.3.12?)
40 * o parse_ini_file("config-dist.ini") for the commented vars
41 * o check automatically for commented and optional vars
42 * o fix _optional, to ignore existing config.ini and only use config-default.ini values
43 * o mixin class for commented
44 * o fix SQL quotes, AUTH_ORDER quotes and file forward slashes
45 * o posted values validation, extend js validation for sane DB values
46 * o read config-dist.ini into sections, comments, and optional/required settings
48 * A file config/config.ini will be automatically generated, if writable.
50 * NOTE: If you have a starterscript outside PHPWIKI_DIR but no
51 * config/config.ini yet (very unlikely!), you must define DATA_PATH in the
52 * starterscript, otherwise the webpath to configurator is unknown, and
53 * subsequent requests will fail. (POST to save the INI)
56 global $HTTP_SERVER_VARS, $HTTP_POST_VARS, $tdwidth;
57 if (empty($_SERVER)) $_SERVER =& $GLOBALS['HTTP_SERVER_VARS'];
58 if (empty($_GET)) $_GET =& $GLOBALS['HTTP_GET_VARS'];
59 if (empty($_ENV)) $_ENV =& $GLOBALS['HTTP_ENV_VARS'];
60 if (empty($_POST)) $_POST =& $GLOBALS['HTTP_POST_VARS'];
62 if (empty($configurator))
63 $configurator = "configurator.php";
64 if (!strstr($_SERVER["SCRIPT_NAME"], $configurator) and defined('DATA_PATH'))
65 $configurator = DATA_PATH . "/" . $configurator;
66 $scriptname = str_replace('configurator.php', 'index.php', $_SERVER["SCRIPT_NAME"]);
67 if (strstr($_SERVER["SCRIPT_NAME"],"/php")) { // cgi got this different
68 if (defined('DATA_PATH'))
69 $scriptname = DATA_PATH . "/index.php";
71 $scriptname = str_replace('configurator.php', 'index.php', $_SERVER["PHP_SELF"]);
75 $config_file = (substr(PHP_OS,0,3) == 'WIN') ? 'config\\config.ini' : 'config/config.ini';
76 $fs_config_file = dirname(__FILE__) . (substr(PHP_OS,0,3) == 'WIN' ? '\\' : '/') . $config_file;
77 if (isset($_POST['create'])) header('Location: '.$configurator.'?show=_part1&create=1#create');
79 // helpers from lib/WikiUser/HttpAuth.php
80 if (!function_exists('_http_user')) {
81 function _http_user() {
83 $_SERVER = $GLOBALS['HTTP_SERVER_VARS'];
84 if (!empty($_SERVER['PHP_AUTH_USER']))
85 return array($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
86 if (!empty($_SERVER['REMOTE_USER']))
87 return array($_SERVER['REMOTE_USER'], $_SERVER['PHP_AUTH_PW']);
88 if (!empty($GLOBALS['HTTP_ENV_VARS']['REMOTE_USER']))
89 return array($GLOBALS['HTTP_ENV_VARS']['REMOTE_USER'],
90 $GLOBALS['HTTP_ENV_VARS']['PHP_AUTH_PW']);
91 if (!empty($GLOBALS['REMOTE_USER']))
92 return array($GLOBALS['REMOTE_USER'], $GLOBALS['PHP_AUTH_PW']);
95 if (!empty($_SERVER['HTTP_AUTHORIZATION'])) {
96 list($userid, $passwd) = explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6)));
97 return array($userid, $passwd);
101 function _http_logout() {
102 if (!isset($_SERVER))
103 $_SERVER =& $GLOBALS['HTTP_SERVER_VARS'];
104 // maybe we should random the realm to really force a logout. but the next login will fail.
105 // better_srand(); $realm = microtime().rand();
106 header('WWW-Authenticate: Basic realm="'.WIKI_NAME.'"');
107 if (strstr(php_sapi_name(), 'apache'))
108 header('HTTP/1.0 401 Unauthorized');
110 header("Status: 401 Access Denied"); //IIS and CGI need that
111 unset($GLOBALS['REMOTE_USER']);
112 unset($_SERVER['PHP_AUTH_USER']);
113 unset($_SERVER['PHP_AUTH_PW']);
115 trigger_error("Permission denied. Require ADMIN_USER.", E_USER_ERROR);
120 // If config.ini exists, we require ADMIN_USER access by faking HttpAuth.
121 // So nobody can see or reset the password(s).
122 if (file_exists($fs_config_file)) {
123 // Require admin user
124 if (!defined('ADMIN_USER') or !defined('ADMIN_PASSWD')) {
125 if (!function_exists("IniConfig")) {
126 include_once 'lib/prepend.php';
127 include_once 'lib/IniConfig.php';
129 IniConfig($fs_config_file);
131 if (!defined('ADMIN_USER') or ADMIN_USER == '') {
132 trigger_error("Configuration problem:\nADMIN_USER not defined in \"$fs_config_file\".\n"
133 . "Cannot continue: You have to fix that manually.", E_USER_ERROR);
137 list($admin_user, $admin_pw) = _http_user();
138 //$required_user = ADMIN_USER;
139 if (empty($admin_user) or $admin_user != ADMIN_USER)
144 if (ENCRYPTED_PASSWD and function_exists('crypt')) {
145 if (crypt($admin_pw, ADMIN_PASSWD) != ADMIN_PASSWD)
147 } elseif ($admin_pw != ADMIN_PASSWD) {
151 if (!function_exists("IniConfig")) {
152 include_once 'lib/prepend.php';
153 include_once 'lib/IniConfig.php';
155 $def_file = (substr(PHP_OS,0,3) == 'WIN') ? 'config\\config-default.ini' : 'config/config-default.ini';
156 $fs_def_file = dirname(__FILE__) . (substr(PHP_OS,0,3) == 'WIN' ? '\\' : '/') . $def_file;
157 IniConfig($fs_def_file);
160 echo '<','?xml version="1.0" encoding="utf-8"?',">\n";
162 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
163 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
164 <html xmlns="http://www.w3.org/1999/xhtml">
166 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
167 <title>Configuration tool for PhpWiki <?php echo $config_file ?></title>
168 <style type="text/css" media="screen">
170 /* TABLE { border: thin solid black } */
171 body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 80%; }
172 pre { font-size: 120%; }
173 td { border: thin solid black }
175 div.hint { background-color: #eeeeee; }
176 tr.hidden { border: none; display: none; }
177 td.part { background-color: #eeeeee; color: inherit; }
178 td.instructions { background-color: #ffffee; width: <?php echo $tdwidth ?>px; color: inherit; }
179 td.unchangeable-variable-top { border-bottom: none; background-color: #ffffee; color:inherit; }
180 td.unchangeable-variable-left { border-top: none; background-color: #ffffee; color:inherit; }
183 <script type="text/javascript">
185 function update(accepted, error, value, output) {
186 var msg = document.getElementById(output);
188 /* MSIE 5.0 fails here */
189 if (msg && msg.innerHTML) { msg.innerHTML = "<font color=\"green\">Input accepted.</font>"; }
191 while ((index = error.indexOf("%s")) > -1) {
192 error = error.substring(0, index) + value + error.substring(index+2);
194 if (msg) { msg.innerHTML = "<font color=\"red\">" + error + "</font>"; }
196 if (submit = document.getElementById('submit')) submit.disabled = accepted ? false : true;
199 function validate(error, value, output, field) {
200 update(field.value == value, error, field.value, output);
203 function validate_ereg(error, ereg, output, field) {
204 regex = new RegExp(ereg);
205 update(regex.test(field.value), error, field.value, output);
208 function validate_range(error, low, high, empty_ok, output, field) {
209 update((empty_ok == 1 && field.value == "") ||
210 (field.value >= low && field.value <= high),
211 error, field.value, output);
214 function toggle_group(id) {
215 var text = document.getElementById(id + "_text");
217 if (text.innerHTML == "Hide options.") {
219 text.innerHTML = "Show options.";
221 text.innerHTML = "Hide options.";
224 var rows = document.getElementsByTagName('tr');
226 for (i = 0; i < rows.length; i++) {
228 if (tr.className == 'header' && tr.id == id) {
233 for (; i < rows.length; i++) {
235 if (tr.className == 'header')
237 tr.className = do_hide ? 'hidden': 'nonhidden';
242 // Hide all groups. We do this via JavaScript to avoid
243 // hiding the groups if JavaScript is not supported...
244 var rows = document.getElementsByTagName('tr');
245 var show = '<?php echo $_GET["show"] ?>';
246 for (var i = 0; i < rows.length; i++) {
248 if (tr.className == 'header')
249 if (!show || tr.id != show)
253 // Select text in textarea upon focus
254 var area = document.getElementById('config-output');
256 listener = { handleEvent: function (e) { area.select(); } };
257 area.addEventListener('focus', listener, false);
264 <body onload="do_init();">
266 <h1>Configuration for PhpWiki <?php echo $config_file ?></h1>
269 Using this configurator.php is experimental!<br />
270 On any configuration problems, please edit the resulting config.ini manually.
275 //define('DEBUG', 1);
277 * The Configurator is a php script to aid in the configuration of PhpWiki.
278 * Parts of this file were based on PHPWeather's configurator.php file.
279 * http://sourceforge.net/projects/phpweather/
281 * TO CHANGE THE CONFIGURATION OF YOUR PHPWIKI, DO *NOT* MODIFY THIS FILE!
282 * more instructions go here
286 * * eval config.ini to get the actual settings.
289 //////////////////////////////
290 // begin configuration options
293 * Notes for the description parameter of $property:
295 * - Descriptive text will be changed into comments (preceeded by ; )
296 * for the final output to config.ini.
298 * - Only a limited set of html is allowed: pre, dl dt dd; it will be
299 * stripped from the final output.
301 * - Line breaks and spacing will be preserved for the final output.
303 * - Double line breaks are automatically converted to paragraphs
304 * for the html version of the descriptive text.
306 * - Double-quotes and dollar signs in the descriptive text must be
307 * escaped: \" and \$. Instead of escaping double-quotes you can use
308 * single (') quotes for the enclosing quotes.
310 * - Special characters like < and > must use html entities,
311 * they will be converted back to characters for the final output.
314 $SEPARATOR = ";=========================================================================";
317 ; This is the main configuration file for PhpWiki in INI-style format.
318 ; Note that certain characters are used as comment char and therefore
319 ; these entries must be in double-quotes. Such as \":\", \";\", \",\" and \"|\"
320 ; Take special care for DBAUTH_ sql statements. (Part 3a)
322 ; This file is divided into several parts: Each one has different configuration
323 ; settings you can change; in all cases the default should work on your system,
324 ; however, we recommend you tailor things to your particular setting.
325 ; Here undefined definitions get defined by config-default.ini settings.
328 // Detect not here listed configs:
329 // for x in `perl -ne 'print $1,"\n" if /^;(\w+) =/' config/config-dist.ini`; do \
330 // grep \'$x\' configurator.php >/dev/null || echo $x ; done
332 $properties["Part Zero"] =
333 new part('_part0', $SEPARATOR."\n", "
334 Part Zero: (optional)
335 Latest Development and Tricky Options");
337 if (defined('INCLUDE_PATH'))
338 $include_path = INCLUDE_PATH;
340 if (substr(PHP_OS,0,3) == 'WIN') {
341 $include_path = dirname(__FILE__) . ';' . ini_get('include_path');
342 if (strchr(ini_get('include_path'),'/'))
343 $include_path = strtr($include_path,'\\','/');
345 $include_path = dirname(__FILE__) . ':' . ini_get('include_path');
349 $properties["PHP include_path"] =
350 new _define('INCLUDE_PATH', $include_path);
352 // TODO: Convert this to a checkbox row as in tests/unit/test.php
353 $properties["DEBUG"] =
354 new numeric_define_optional('DEBUG', DEBUG);
356 $properties["ENABLE_EDIT_TOOLBAR"] =
357 new boolean_define_commented_optional('ENABLE_EDIT_TOOLBAR');
359 $properties["JS_SEARCHREPLACE"] =
360 new boolean_define_commented_optional('JS_SEARCHREPLACE');
362 // TESTME: use config-default: = false
363 $properties["ENABLE_DOUBLECLICKEDIT"] =
364 new boolean_define_commented_optional('ENABLE_DOUBLECLICKEDIT');
366 $properties["ENABLE_WYSIWYG"] =
367 new boolean_define_commented_optional('ENABLE_WYSIWYG');
369 $properties["WYSIWYG_BACKEND"] =
370 new _define_selection(
372 array('Wikiwyg' => 'Wikiwyg',
373 'tinymce' => 'tinymce',
374 'FCKeditor' => 'FCKeditor',
376 'htmlarea3' => 'htmlarea3',
377 'htmlarea2' => 'htmlarea2',
380 $properties["WYSIWYG_DEFAULT_PAGETYPE_HTML"] =
381 new boolean_define_commented_optional('WYSIWYG_DEFAULT_PAGETYPE_HTML');
383 $properties["UPLOAD_USERDIR"] =
384 new boolean_define_commented_optional('UPLOAD_USERDIR');
386 $properties["DISABLE_UNITS"] =
387 new boolean_define_commented_optional('DISABLE_UNITS');
389 $properties["UNITS_EXE"] =
390 new _define_commented_optional('UNITS_EXE');
392 $properties["ENABLE_XHTML_XML"] =
393 new boolean_define_commented_optional('ENABLE_XHTML_XML');
395 $properties["ENABLE_OPEN_GRAPH"] =
396 new boolean_define_commented_optional('ENABLE_OPEN_GRAPH');
398 $properties["ENABLE_SPAMASSASSIN"] =
399 new boolean_define_commented_optional('ENABLE_SPAMASSASSIN');
401 $properties["ENABLE_SPAMBLOCKLIST"] =
402 new boolean_define_optional('ENABLE_SPAMBLOCKLIST');
404 $properties["NUM_SPAM_LINKS"] =
405 new numeric_define_optional('NUM_SPAM_LINKS');
407 $properties["GOOGLE_LINKS_NOFOLLOW"] =
408 new boolean_define_commented_optional('GOOGLE_LINKS_NOFOLLOW');
410 $properties["ENABLE_LIVESEARCH"] =
411 new boolean_define_commented_optional('ENABLE_LIVESEARCH');
413 $properties["ENABLE_ACDROPDOWN"] =
414 new boolean_define_commented_optional('ENABLE_ACDROPDOWN');
416 $properties["ENABLE_DISCUSSION_LINK"] =
417 new boolean_define_commented_optional('ENABLE_DISCUSSION_LINK');
419 $properties["ENABLE_CAPTCHA"] =
420 new boolean_define_commented_optional('ENABLE_CAPTCHA');
422 $properties["USE_CAPTCHA_RANDOM_WORD"] =
423 new boolean_define_commented_optional('USE_CAPTCHA_RANDOM_WORD');
425 $properties["USE_SAFE_DBSESSION"] =
426 new boolean_define_commented_optional('USE_SAFE_DBSESSION');
428 $properties["BLOG_DEFAULT_EMPTY_PREFIX"] =
429 new boolean_define_commented_optional('BLOG_DEFAULT_EMPTY_PREFIX');
431 $properties["ENABLE_SEARCHHIGHLIGHT"] =
432 new boolean_define_commented_optional('ENABLE_SEARCHHIGHLIGHT');
434 $properties["Part One"] =
435 new part('_part1', $SEPARATOR."\n", "
436 Part One: Authentication and security settings. See Part Three for more.");
438 $properties["Wiki Name"] =
439 new _define_optional('WIKI_NAME', WIKI_NAME);
441 $properties["Admin Username"] =
442 new _define_notempty('ADMIN_USER', ADMIN_USER, "
443 You must set this! Username and password of the administrator.",
444 "onchange=\"validate_ereg('Sorry, ADMIN_USER cannot be empty.', '^.+$', 'ADMIN_USER', this);\"");
446 $properties["Admin Password"] =
447 new _define_password('ADMIN_PASSWD', ADMIN_PASSWD, "
449 For heaven's sake pick a good password.
451 If your version of PHP supports encrypted passwords, your password will be
452 automatically encrypted within the generated config file.
453 Use the \"Create Random Password\" button to create a good (random) password.
455 ADMIN_PASSWD is ignored on HttpAuth",
456 "onchange=\"validate_ereg('Sorry, ADMIN_PASSWD must be at least 4 chars long.', '^....+$', 'ADMIN_PASSWD', this);\"");
458 $properties["Encrypted Passwords"] =
461 array('true' => "true. use crypt for all passwords",
462 'false' => "false. use plaintest passwords (not recommended)"));
464 $properties["Reverse DNS"] =
465 new boolean_define_optional
466 ('ENABLE_REVERSE_DNS',
467 array('true' => "true. perform additional reverse dns lookups",
468 'false' => "false. just record the address as given by the httpd server"));
470 $properties["ZIP Dump Authentication"] =
471 new boolean_define_optional('ZIPDUMP_AUTH',
472 array('false' => "false. Everyone may download zip dumps",
473 'true' => "true. Only admin may download zip dumps"));
475 $properties["Enable RawHtml Plugin"] =
476 new boolean_define_commented_optional('ENABLE_RAW_HTML');
478 $properties["Allow RawHtml Plugin only on locked pages"] =
479 new boolean_define_commented_optional('ENABLE_RAW_HTML_LOCKEDONLY');
481 $properties["Allow RawHtml Plugin if safe HTML code"] =
482 new boolean_define_commented_optional('ENABLE_RAW_HTML_SAFE','', "
483 If this is set, all unsafe html code is stripped automatically (experimental!)
484 See <a href=\"http://chxo.com/scripts/safe_html-test.php\" target=\"_new\">chxo.com/scripts/safe_html-test.php</a>
487 $properties["Maximum Upload Size"] =
488 new numeric_define_optional('MAX_UPLOAD_SIZE', MAX_UPLOAD_SIZE);
490 $properties["Minor Edit Timeout"] =
491 new numeric_define_optional('MINOR_EDIT_TIMEOUT', MINOR_EDIT_TIMEOUT);
493 $properties["Disabled Actions"] =
494 new array_define('DISABLED_ACTIONS', DISABLED_ACTIONS /*array()*/);
496 $properties["Moderate all Pagechanges"] =
497 new boolean_define_commented_optional('ENABLE_MODERATEDPAGE_ALL');
499 $properties["Access Log File"] =
500 new _define_commented_optional('ACCESS_LOG', ACCESS_LOG);
502 $properties["Access Log SQL"] =
503 new _define_selection(
505 array('0' => 'disabled',
507 '2' => 'read + write'));
509 $properties["Compress Output"] =
510 new boolean_define_commented_optional
512 array('' => 'undefined - GZIP compress when appropriate.',
513 'false' => 'Never compress output.',
514 'true' => 'Always try to compress output.'));
516 $properties["HTTP Cache Control"] =
517 new _define_selection_optional
519 array('LOOSE' => 'LOOSE',
520 'STRICT' => 'STRICT',
521 'NO_CACHE' => 'NO_CACHE',
522 'ALLOW_STALE' => 'ALLOW_STALE'),
526 This controls how PhpWiki sets the HTTP cache control
527 headers (Expires: and Cache-Control:)
532 <dd>This is roughly the old (pre 1.3.4) behaviour. PhpWiki will
533 instruct proxies and browsers never to cache PhpWiki output.</dd>
535 <dd>Cached pages will be invalidated whenever the database global
536 timestamp changes. This should behave just like NONE (modulo
537 bugs in PhpWiki and your proxies and browsers), except that
538 things will be slightly more efficient.</dd>
540 <dd>Cached pages will be invalidated whenever they are edited,
541 or, if the pages include plugins, when the plugin output could
542 concievably have changed.
543 <p>Behavior should be much like STRICT, except that sometimes
544 wikilinks will show up as undefined (with the question mark)
545 when in fact they refer to (recently) created pages.
546 (Hitting your browsers reload or perhaps shift-reload button
547 should fix the problem.)</p></dd>
549 <dd>Proxies and browsers will be allowed to used stale pages.
550 (The timeout for stale pages is controlled by CACHE_CONTROL_MAX_AGE.)
551 <p>This setting will result in quirky behavior. When you edit a
552 page your changes may not show up until you shift-reload the
554 <p>This setting is generally not advisable, however it may be useful
555 in certain cases (e.g. if your wiki gets lots of page views,
556 and few edits by knowledgable people who won't freak over the quirks.)</p>
559 The default is currently LOOSE.");
561 $properties["HTTP Cache Control Max Age"] =
562 new numeric_define_optional('CACHE_CONTROL_MAX_AGE', CACHE_CONTROL_MAX_AGE);
564 $properties["Markup Caching"] =
565 new boolean_define_commented_optional
566 ('WIKIDB_NOCACHE_MARKUP',
567 array('false' => 'Enable markup cache',
568 'true' => 'Disable markup cache'));
570 $properties["COOKIE_EXPIRATION_DAYS"] =
571 new numeric_define_optional('COOKIE_EXPIRATION_DAYS', COOKIE_EXPIRATION_DAYS);
573 $properties["COOKIE_DOMAIN"] =
574 new _define_commented_optional('COOKIE_DOMAIN', COOKIE_DOMAIN);
576 $properties["Path for PHP Session Support"] =
577 new _define_optional('SESSION_SAVE_PATH', defined('SESSION_SAVE_PATH') ? SESSION_SAVE_PATH : ini_get('session.save_path'));
579 $properties["Force PHP Database Sessions"] =
580 new boolean_define_commented_optional
582 array('false' => 'Disable database sessions, use files',
583 'true' => 'Enable database sessions'));
585 ///////// database selection
587 $properties["Part Two"] =
588 new part('_part2', $SEPARATOR."\n", "
591 Database Configuration
594 $properties["Database Type"] =
595 new _define_selection("DATABASE_TYPE",
596 array('dba' => "dba",
598 'ADODB' => "SQL ADODB",
599 'PDO' => "PDO (php5 only)",
600 'file' => "flatfile",
601 'cvs' => "CVS File handler")/*, "
602 Select the database backend type:
603 Choose dba (default) to use one of the standard UNIX dba libraries. This is the fastest.
604 Choose ADODB or SQL to use an SQL database with ADODB or PEAR.
605 Choose PDO on php5 to use an SQL database. (experimental, no paging yet)
606 flatfile is simple and slow.
607 CVS is highly experimental and slow.
608 Recommended is dba or SQL: PEAR or ADODB."*/);
610 $properties["SQL DSN Setup"] =
611 new unchangeable_variable('_sqldsnstuff', "", "
612 For SQL based backends, specify the database as a DSN
613 The most general form of a DSN looks like:
615 phptype(dbsyntax)://username:password@protocol+hostspec/database?option=value
617 For a MySQL database, the following should work:
619 mysql://user:password@host/databasename
621 To connect over a unix socket, use something like
623 mysql://user:password@unix(/path/to/socket)/databasename
626 DATABASE_DSN = mysql://guest@:/var/lib/mysql/mysql.sock/phpwiki
627 DATABASE_DSN = mysql://guest@localhost/phpwiki
628 DATABASE_DSN = pgsql://localhost/user_phpwiki
631 // Choose ADODB or SQL to use an SQL database with ADODB or PEAR.
632 // Choose dba to use one of the standard UNIX dbm libraries.
634 $properties["SQL Type"] =
635 new _variable_selection('_dsn_sqltype',
636 array('mysql' => "MySQL",
637 'pgsql' => "PostgreSQL",
638 'mssql' => "Microsoft SQL Server",
639 'mssqlnative' => "Microsoft SQL Server (native)",
640 'oci8' => "Oracle 8",
641 'mysqli' => "mysqli (only ADODB)",
642 'mysqlt' => "mysqlt (only ADODB)",
643 'ODBC' => "ODBC (only ADODB or PDO)",
644 'firebird' => "Firebird (only PDO)",
645 'oracle' => "Oracle (only PDO)",
647 SQL DB types. The DSN hosttype.");
649 $properties["SQL User"] =
650 new _variable('_dsn_sqluser', "wikiuser", "
653 $properties["SQL Password"] =
654 new _variable('_dsn_sqlpass', "", "
657 $properties["SQL Database Host"] =
658 new _variable('_dsn_sqlhostorsock', "localhost", "
659 SQL Database Hostname:
661 To connect over a local named socket, use something like
663 unix(/var/lib/mysql/mysql.sock)
666 mysql on Windows via named pipes might need 127.0.0.1");
668 $properties["SQL Database Name"] =
669 new _variable('_dsn_sqldbname', "phpwiki", "
670 SQL Database Name:");
672 $dsn_sqltype = $properties["SQL Type"]->value();
673 $dsn_sqluser = $properties["SQL User"]->value();
674 $dsn_sqlpass = $properties["SQL Password"]->value();
675 $dsn_sqlhostorsock = $properties["SQL Database Host"]->value();
676 $dsn_sqldbname = $properties["SQL Database Name"]->value();
677 $dsn_sqlstring = $dsn_sqltype."://{$dsn_sqluser}:{$dsn_sqlpass}@{$dsn_sqlhostorsock}/{$dsn_sqldbname}";
679 $properties["SQL dsn"] =
680 new unchangeable_define("DATABASE_DSN",
682 Calculated from the settings above:");
684 $properties["Filename / Table name Prefix"] =
685 new _define_commented('DATABASE_PREFIX', DATABASE_PREFIX, "
686 Used by all DB types:
688 Prefix for filenames or table names, e.g. \"phpwiki_\"
690 Currently <b>you MUST EDIT THE SQL file too!</b> (in the schemas/
691 directory because we aren't doing on the fly sql generation
692 during the installation.
694 Note: This prefix is NOT prepended to the default DBAUTH_
695 tables user, pref and member!
698 $properties["DATABASE_PERSISTENT"] =
699 new boolean_define_commented_optional
700 ('DATABASE_PERSISTENT',
701 array('false' => "Disabled",
702 'true' => "Enabled"));
704 $properties["DB Session table"] =
705 new _define_optional("DATABASE_SESSION_TABLE", DATABASE_SESSION_TABLE, "
706 Tablename to store session information. Only supported by SQL backends.
708 A word of warning - any prefix defined above will be prepended to whatever is given here.
712 $temp = !empty($_ENV['TEMP']) ? $_ENV['TEMP'] : "/tmp";
713 $properties["dba directory"] =
714 new _define("DATABASE_DIRECTORY", $temp);
716 // TODO: list the available methods
717 $properties["dba handler"] =
718 new _define_selection('DATABASE_DBA_HANDLER',
719 array('gdbm' => "gdbm - GNU database manager (not recommended anymore)",
720 'dbm' => "DBM - Redhat default. On sf.net there's dbm and not gdbm anymore",
721 'db2' => "DB2 - BerkeleyDB (Sleepycat) DB2",
722 'db3' => "DB3 - BerkeleyDB (Sleepycat) DB3. Default on Windows but not on every Linux",
723 'db4' => "DB4 - BerkeleyDB (Sleepycat) DB4."), "
724 Use 'gdbm', 'dbm', 'db2', 'db3' or 'db4' depending on your DBA handler methods supported: <br /> "
725 . join(", ",dba_handlers())
726 . "\n\nBetter not use other hacks such as inifile, flatfile or cdb");
728 $properties["dba timeout"] =
729 new numeric_define("DATABASE_TIMEOUT", DATABASE_TIMEOUT, "
730 Recommended values are 10-20 seconds. The more load the server has, the higher the timeout.");
732 $properties["DATABASE_OPTIMISE_FREQUENCY"] =
733 new numeric_define_optional('DATABASE_OPTIMISE_FREQUENCY', DATABASE_OPTIMISE_FREQUENCY);
735 $properties["DBADMIN_USER"] =
736 new _define_optional('DBADMIN_USER', DBADMIN_USER);
738 $properties["DBADMIN_PASSWD"] =
739 new _define_password_optional('DBADMIN_PASSWD', DBADMIN_PASSWD);
741 $properties["USECACHE"] =
742 new boolean_define_commented_optional('USECACHE');
746 $properties["Page Revisions"] =
747 new unchangeable_variable('_parttworevisions', "", "
749 Section 2a: Archive Cleanup
750 The next section controls how many old revisions of each page are kept in the database.
752 There are two basic classes of revisions: major and minor. Which
753 class a revision belongs in is determined by whether the author
754 checked the \"this is a minor revision\" checkbox when they saved the
757 There is, additionally, a third class of revisions: author
758 revisions. The most recent non-mergable revision from each distinct
759 author is and author revision.
761 The expiry parameters for each of those three classes of revisions
762 can be adjusted seperately. For each class there are five
763 parameters (usually, only two or three of the five are actually
764 set) which control how long those revisions are kept in the
767 <dt>max_keep:</dt> <dd>If set, this specifies an absolute maximum for the
768 number of archived revisions of that class. This is
769 meant to be used as a safety cap when a non-zero
770 min_age is specified. It should be set relatively high,
771 and it's purpose is to prevent malicious or accidental
772 database overflow due to someone causing an
773 unreasonable number of edits in a short period of time.</dd>
775 <dt>min_age:</dt> <dd>Revisions younger than this (based upon the supplanted
776 date) will be kept unless max_keep is exceeded. The age
777 should be specified in days. It should be a
778 non-negative, real number,</dd>
780 <dt>min_keep:</dt> <dd>At least this many revisions will be kept.</dd>
782 <dt>keep:</dt> <dd>No more than this many revisions will be kept.</dd>
784 <dt>max_age:</dt> <dd>No revision older than this age will be kept.</dd>
786 Supplanted date: Revisions are timestamped at the instant that they
787 cease being the current revision. Revision age is computed using
788 this timestamp, not the edit time of the page.
790 Merging: When a minor revision is deleted, if the preceding
791 revision is by the same author, the minor revision is merged with
792 the preceding revision before it is deleted. Essentially: this
793 replaces the content (and supplanted timestamp) of the previous
794 revision with the content after the merged minor edit, the rest of
795 the page metadata for the preceding version (summary, mtime, ...)
799 // For now the expiration parameters are statically inserted as
800 // an unchangeable property. You'll have to edit the resulting
801 // config file if you really want to change these from the default.
803 $properties["Major Edits: keep minimum days"] =
804 new numeric_define('MAJOR_MIN_KEEP', MAJOR_MIN_KEEP, "
805 Default: Keep for unlimited time.
806 Set to 0 to enable archive cleanup");
807 $properties["Minor Edits: keep minumum days"] =
808 new numeric_define('MINOR_MIN_KEEP', MINOR_MIN_KEEP, "
809 Default: Keep for unlimited time.
810 Set to 0 to enable archive cleanup");
812 $properties["Major Edits: how many"] =
813 new numeric_define('MAJOR_KEEP', MAJOR_KEEP, "
814 Keep up to 8 major edits");
815 $properties["Major Edits: how many days"] =
816 new numeric_define('MAJOR_MAX_AGE', MAJOR_MAX_AGE, "
817 keep them no longer than a month");
819 $properties["Minor Edits: how many"] =
820 new numeric_define("MINOR_KEEP", MINOR_KEEP, "
821 Keep up to 4 minor edits");
822 $properties["Minor Edits: how many days"] =
823 new numeric_define("MINOR_MAX_AGE", "7", "
824 keep them no longer than a week");
826 $properties["per Author: how many"] =
827 new numeric_define("AUTHOR_KEEP", "8", "
828 Keep the latest contributions of the last 8 authors,");
829 $properties["per Author: how many days"] =
830 new numeric_define("AUTHOR_MAX_AGE", "365", "
832 $properties["per Author: keep minumum days"] =
833 new numeric_define("AUTHOR_MIN_AGE", "7", "
834 Additionally, (in the case of a particularly active page) try to
835 keep the latest contributions of all authors in the last week (even if there are more than eight of them,)");
836 $properties["per Author: max revisions"] =
837 new numeric_define("AUTHOR_MAX_KEEP", "20", "
838 but in no case keep more than twenty unique author revisions.");
840 /////////////////////////////////////////////////////////////////////
842 $properties["Part Three"] =
843 new part('_part3', $SEPARATOR."\n", "
845 Part Three: (optional)
846 Basic User Authentication Setup
849 $properties["Publicly viewable"] =
850 new boolean_define_optional('ALLOW_ANON_USER',
851 array('true' => "true. Permit anonymous view. (Default)",
852 'false' => "false. Force login even on view (strictly private)"), "
853 If ALLOW_ANON_USER is false, you have to login before viewing any page or doing any other action on a page.");
855 $properties["Allow anonymous edit"] =
856 new boolean_define_optional('ALLOW_ANON_EDIT',
857 array('true' => "true. Permit anonymous users to edit. (Default)",
858 'false' => "false. Force login on edit (moderately locked)"), "
859 If ALLOW_ANON_EDIT is false, you have to login before editing or changing any page. See below.");
861 $properties["Allow Bogo Login"] =
862 new boolean_define_optional('ALLOW_BOGO_LOGIN',
863 array('true' => "true. Users may Sign In with any WikiWord, without password. (Default)",
864 'false' => "false. Require stricter authentication."), "
865 If ALLOW_BOGO_LOGIN is false, you may not login with any wikiword username and empty password.
866 If true, users are allowed to create themselves with any WikiWord username. See below.");
868 $properties["Allow User Passwords"] =
869 new boolean_define_optional('ALLOW_USER_PASSWORDS',
870 array('true' => "True user authentication with password checking. (Default)",
871 'false' => "false. Ignore authentication settings below."), "
872 If ALLOW_USER_PASSWORDS is true, the authentication settings below define where and how to
873 check against given username/passwords. For completely security disable BOGO_LOGIN and ANON_EDIT above.");
875 $properties["User Authentication Methods"] =
876 new array_define('USER_AUTH_ORDER', array("PersonalPage", "Db"), "
877 Many different methods can be used to check user's passwords.
878 Try any of these in the given order:
881 <dd>WikiWord username, with no *actual* password checking,
882 although the user will still have to enter one.</dd>
883 <dt>PersonalPage</dt>
884 <dd>Store passwords in the users homepage metadata (simple)</dd>
886 <dd>Use DBAUTH_AUTH_* (see below) with PearDB or ADODB only.</dd>
888 <dd>Authenticate against LDAP_AUTH_HOST with LDAP_BASE_DN.</dd>
890 <dd>Authenticate against IMAP_AUTH_HOST (email account)</dd>
892 <dd>Authenticate against POP3_AUTH_HOST (email account)</dd>
894 <dd>Get username and level from a PHP session variable. (e.g. for FusionForge)</dd>
896 <dd>Store username:crypted-passwords in .htaccess like files.
897 Use Apache's htpasswd to manage this file.</dd>
899 <dd>Use the protection by the webserver (.htaccess/.htpasswd) (experimental)
900 Enforcing HTTP Auth not yet. Note that the ADMIN_USER should exist also.
901 Using HttpAuth disables all other methods and no userauth sessions are used.</dd>
904 Several of these methods can be used together, in the manner specified by
905 USER_AUTH_POLICY, below. To specify multiple authentication methods,
906 separate the name of each one with colons.
908 USER_AUTH_ORDER = 'PersonalPage : Db'
909 USER_AUTH_ORDER = 'BogoLogin : PersonalPage'
912 $properties["ENABLE_AUTH_OPENID"] =
913 new boolean_define('ENABLE_AUTH_OPENID');
915 $properties["PASSWORD_LENGTH_MINIMUM"] =
916 new numeric_define('PASSWORD_LENGTH_MINIMUM', PASSWORD_LENGTH_MINIMUM);
918 $properties["USER_AUTH_POLICY"] =
919 new _define_selection('USER_AUTH_POLICY',
920 array('first-only' => "first-only - use only the first method in USER_AUTH_ORDER",
921 'old' => "old - ignore USER_AUTH_ORDER (legacy)",
922 'strict' => "strict - check all methods for userid + password (recommended)",
923 'stacked' => "stacked - check all methods for userid, and if found for password"), "
924 The following policies are available for user authentication:
927 <dd>use only the first method in USER_AUTH_ORDER</dd>
929 <dd>ignore USER_AUTH_ORDER and try to use all available
930 methods as in the previous PhpWiki releases (slow)</dd>
932 <dd>check if the user exists for all methods:
933 on the first existing user, try the password.
934 dont try the other methods on failure then</dd>
936 <dd>check the given user - password combination for all
937 methods and return true on the first success.</dd></dl>");
939 $properties["ENABLE_USER_NEW"] =
940 new boolean_define_commented_optional('ENABLE_USER_NEW');
942 $properties["ENABLE_PAGEPERM"] =
943 new boolean_define_commented_optional('ENABLE_PAGEPERM');
947 $properties["Part Three A"] =
948 new part('_part3a', $SEPARATOR."\n", "
950 Part Three A: (optional)
953 $properties["Group membership"] =
954 new _define_selection("GROUP_METHOD",
955 array('WIKIPAGE' => "WIKIPAGE - List at \"CategoryGroup\". (Slowest, but easiest to maintain)",
956 '"NONE"' => "NONE - Disable group membership (Fastest)",
957 'DB' => "DB - SQL Database, Optionally external. See USERS/GROUPS queries",
958 'FILE' => "Flatfile. See AUTH_GROUP_FILE below.",
959 'LDAP' => "LDAP - See \"LDAP authentication options\" above. (Experimental)"), "
960 Group membership. PhpWiki supports defining permissions for a group as
961 well as for individual users. This defines how group membership information
962 is obtained. Supported values are:
965 <dd>Disable group membership (Fastest). Note the required quoting.</dd>
967 <dd>Define groups as list at \"CategoryGroup\". (Slowest, but easiest to maintain)</dd>
969 <dd>Stored in an SQL database. Optionally external. See USERS/GROUPS queries</dd>
971 <dd>Flatfile. See AUTH_GROUP_FILE below.</dd>
973 <dd>LDAP groups. See \"LDAP authentication options\" above and
974 lib/WikiGroup.php. (experimental)</dd></dl>");
976 $properties["CATEGORY_GROUP_PAGE"] =
977 new _define_optional('CATEGORY_GROUP_PAGE', _("CategoryGroup"), "
978 If GROUP_METHOD = WIKIPAGE:
980 Page where all groups are listed.");
982 $properties["AUTH_GROUP_FILE"] =
983 new _define_optional('AUTH_GROUP_FILE', _("/etc/groups"), "
984 For GROUP_METHOD = FILE, the file given below is referenced to obtain
985 group membership information. It should be in the same format as the
986 standard unix /etc/groups(5) file.");
988 $properties["Part Three B"] =
989 new part('_part3b', $SEPARATOR."\n", "
991 Part Three B: (optional)
992 External database authentication and authorization.
994 If USER_AUTH_ORDER includes Db, or GROUP_METHOD = DB, the options listed
995 below define the SQL queries used to obtain the information out of the
996 database, and (optionally) store the information back to the DB.");
998 $properties["DBAUTH_AUTH_DSN"] =
999 new _define_optional('DBAUTH_AUTH_DSN', $dsn_sqlstring, "
1000 A database DSN to connect to. Defaults to the DSN specified for the Wiki as a whole.");
1002 $properties["User Exists Query"] =
1003 new _define('DBAUTH_AUTH_USER_EXISTS', "SELECT userid FROM user WHERE userid='\$userid'", "
1004 USER/PASSWORD queries:
1006 For USER_AUTH_POLICY=strict and the Db method is required");
1008 $properties["Check Query"] =
1009 new _define_optional('DBAUTH_AUTH_CHECK', "SELECT IF(passwd='\$password',1,0) AS ok FROM user WHERE userid='\$userid'", "
1011 Check to see if the supplied username/password pair is OK
1013 Plaintext passwords: (DBAUTH_AUTH_CRYPT_METHOD = plain)<br />
1014 ; DBAUTH_AUTH_CHECK = \"SELECT IF(passwd='\$password',1,0) AS ok FROM user WHERE userid='\$userid'\"
1016 database-hashed passwords (more secure):<br />
1017 ; DBAUTH_AUTH_CHECK = \"SELECT IF(passwd=PASSWORD('\$password'),1,0) AS ok FROM user WHERE userid='\$userid'\"");
1019 $properties["Crypt Method"] =
1020 new _define_selection_optional
1021 ('DBAUTH_AUTH_CRYPT_METHOD',
1022 array('plain' => 'plain',
1023 'crypt' => 'crypt'), "
1024 If you want to use Unix crypt()ed passwords, you can use DBAUTH_AUTH_CHECK
1025 to get the password out of the database with a simple SELECT query, and
1026 specify DBAUTH_AUTH_USER_EXISTS and DBAUTH_AUTH_CRYPT_METHOD:
1028 ; DBAUTH_AUTH_CHECK = \"SELECT passwd FROM user where userid='\$userid'\" <br />
1029 ; DBAUTH_AUTH_CRYPT_METHOD = crypt");
1031 $properties["Update the user's authentication credential"] =
1032 new _define('DBAUTH_AUTH_UPDATE', "UPDATE user SET passwd='\$password' WHERE userid='\$userid'", "
1033 If this is not defined but DBAUTH_AUTH_CHECK is, then the user will be unable to update their
1036 Plaintext passwords:<br />
1037 DBAUTH_AUTH_UPDATE = \"UPDATE user SET passwd='\$password' WHERE userid='\$userid'\"<br />
1038 Database-hashed passwords:<br />
1039 DBAUTH_AUTH_UPDATE = \"UPDATE user SET passwd=PASSWORD('\$password') WHERE userid='\$userid'\"");
1041 $properties["Allow the user to create their own account"] =
1042 new _define_optional('DBAUTH_AUTH_CREATE', "INSERT INTO user SET passwd=PASSWORD('\$password'),userid='\$userid'", "
1043 If this is empty, Db users cannot subscribe by their own.");
1045 $properties["USER/PREFERENCE queries"] =
1046 new _define_optional('DBAUTH_PREF_SELECT', "SELECT prefs FROM user WHERE userid='\$userid'", "
1047 If you choose to store your preferences in an external database, enable
1048 the following queries. Note that if you choose to store user preferences
1049 in the 'user' table, only registered users get their prefs from the database,
1050 self-created users do not. Better to use the special 'pref' table.
1052 The prefs field stores the serialized form of the user's preferences array,
1053 to ease the complication of storage.
1055 DBAUTH_PREF_SELECT = \"SELECT prefs FROM user WHERE userid='\$userid'\"
1056 DBAUTH_PREF_SELECT = \"SELECT prefs FROM pref WHERE userid='\$userid'\"
1059 $properties["Update the user's preferences"] =
1060 new _define_optional('DBAUTH_PREF_UPDATE', "UPDATE user SET prefs='\$pref_blob' WHERE userid='\$userid'", "
1061 Note that REPLACE works only with mysql and destroy all other columns!
1063 Mysql: DBAUTH_PREF_UPDATE = \"REPLACE INTO pref SET prefs='\$pref_blob',userid='\$userid'\"");
1065 $properties["Create new user's preferences"] =
1066 new _define_optional('DBAUTH_PREF_INSERT', "INSERT INTO pref (userid,prefs) VALUES ('\$userid','\$pref_blob')", "
1067 Define this if new user can be create by themselves.
1070 $properties["USERS/GROUPS queries"] =
1071 new _define_optional('DBAUTH_IS_MEMBER', "SELECT user FROM user WHERE user='\$userid' AND group='\$groupname'", "
1072 You can define 1:n or n:m user<=>group relations, as you wish.
1074 Sample configurations:
1076 only one group per user (1:n):<br />
1077 DBAUTH_IS_MEMBER = \"SELECT user FROM user WHERE user='\$userid' AND group='\$groupname'\"<br />
1078 DBAUTH_GROUP_MEMBERS = \"SELECT user FROM user WHERE group='\$groupname'\"<br />
1079 DBAUTH_USER_GROUPS = \"SELECT group FROM user WHERE user='\$userid'\"<br />
1080 multiple groups per user (n:m):<br />
1081 DBAUTH_IS_MEMBER = \"SELECT userid FROM member WHERE userid='\$userid' AND groupname='\$groupname'\"<br />
1082 DBAUTH_GROUP_MEMBERS = \"SELECT DISTINCT userid FROM member WHERE groupname='\$groupname'\"<br />
1083 DBAUTH_USER_GROUPS = \"SELECT groupname FROM member WHERE userid='\$userid'\"<br />");
1084 $properties["DBAUTH_GROUP_MEMBERS"] =
1085 new _define_optional('DBAUTH_GROUP_MEMBERS', "SELECT user FROM user WHERE group='\$groupname'", "");
1086 $properties["DBAUTH_USER_GROUPS"] =
1087 new _define_optional('DBAUTH_USER_GROUPS', "SELECT group FROM user WHERE user='\$userid'", "");
1089 if (function_exists('ldap_connect')) {
1091 $properties["LDAP AUTH Host"] =
1092 new _define_optional('LDAP_AUTH_HOST', "ldap://localhost:389", "
1093 If USER_AUTH_ORDER contains Ldap:
1095 The LDAP server to connect to. Can either be a hostname, or a complete
1096 URL to the server (useful if you want to use ldaps or specify a different
1099 $properties["LDAP BASE DN"] =
1100 new _define_optional('LDAP_BASE_DN', "ou=mycompany.com,o=My Company", "
1101 The organizational or domain BASE DN: e.g. \"dc=mydomain,dc=com\".
1103 Note: ou=Users and ou=Groups are used for GroupLdap Membership
1104 Better use LDAP_OU_USERS and LDAP_OU_GROUP with GROUP_METHOD=LDAP.");
1106 $properties["LDAP SET OPTION"] =
1107 new _define_optional('LDAP_SET_OPTION', "LDAP_OPT_PROTOCOL_VERSION=3:LDAP_OPT_REFERRALS=0", "
1108 Some LDAP servers need some more options, such as the Windows Active
1109 Directory Server. Specify the options (as allowed by the PHP LDAP module)
1110 and their values as NAME=value pairs separated by colons.");
1112 $properties["LDAP AUTH USER"] =
1113 new _define_optional('LDAP_AUTH_USER', "CN=ldapuser,ou=Users,o=Development,dc=mycompany.com", "
1114 DN to initially bind to the LDAP server as. This is needed if the server doesn't
1115 allow anonymous queries. (Windows Active Directory Server)");
1117 $properties["LDAP AUTH PASSWORD"] =
1118 new _define_optional('LDAP_AUTH_PASSWORD', "secret", "
1119 Password to use to initially bind to the LDAP server, as the DN
1120 specified in the LDAP_AUTH_USER option (above).");
1122 $properties["LDAP SEARCH FIELD"] =
1123 new _define_optional('LDAP_SEARCH_FIELD', "uid", "
1124 If you want to match usernames against an attribute other than uid,
1125 specify it here. Default: uid
1127 e.g.: LDAP_SEARCH_FIELD = sAMAccountName");
1129 $properties["LDAP OU USERS"] =
1130 new _define_optional('LDAP_OU_USERS', "ou=Users", "
1131 If you have an organizational unit for all users, define it here.
1132 This narrows the search, and is needed for LDAP group membership (if GROUP_METHOD=LDAP)
1133 Default: ou=Users");
1135 $properties["LDAP OU GROUP"] =
1136 new _define_optional('LDAP_OU_GROUP', "ou=Groups", "
1137 If you have an organizational unit for all groups, define it here.
1138 This narrows the search, and is needed for LDAP group membership (if GROUP_METHOD=LDAP)
1139 The entries in this ou must have a gidNumber and cn attribute.
1140 Default: ou=Groups");
1142 } else { // function_exists('ldap_connect')
1144 $properties["LDAP Authentication"] =
1145 new unchangeable_variable('LDAP Authentication', "
1146 ; If USER_AUTH_ORDER contains Ldap:
1148 ; The LDAP server to connect to. Can either be a hostname, or a complete
1149 ; URL to the server (useful if you want to use ldaps or specify a different
1151 ;LDAP_AUTH_HOST = \"ldap://localhost:389\"
1153 ; The organizational or domain BASE DN: e.g. \"dc=mydomain,dc=com\".
1155 ; Note: ou=Users and ou=Groups are used for GroupLdap Membership
1156 ; Better use LDAP_OU_USERS and LDAP_OU_GROUP with GROUP_METHOD=LDAP.
1157 ;LDAP_BASE_DN = \"ou=Users,o=Development,dc=mycompany.com\"
1159 ; Some LDAP servers need some more options, such as the Windows Active
1160 ; Directory Server. Specify the options (as allowed by the PHP LDAP module)
1161 ; and their values as NAME=value pairs separated by colons.
1162 ; LDAP_SET_OPTION = \"LDAP_OPT_PROTOCOL_VERSION=3:LDAP_OPT_REFERRALS=0\"
1164 ; DN to initially bind to the LDAP server as. This is needed if the server doesn't
1165 ; allow anonymous queries. (Windows Active Directory Server)
1166 ; LDAP_AUTH_USER = \"CN=ldapuser,ou=Users,o=Development,dc=mycompany.com\"
1168 ; Password to use to initially bind to the LDAP server, as the DN
1169 ; specified in the LDAP_AUTH_USER option (above).
1170 ; LDAP_AUTH_PASSWORD = secret
1172 ; If you want to match usernames against an attribute other than uid,
1173 ; specify it here. Default: uid
1174 ; LDAP_SEARCH_FIELD = sAMAccountName
1176 ; If you have an organizational unit for all users, define it here.
1177 ; This narrows the search, and is needed for LDAP group membership (if GROUP_METHOD=LDAP)
1179 ; LDAP_OU_USERS = ou=Users
1181 ; If you have an organizational unit for all groups, define it here.
1182 ; This narrows the search, and is needed for LDAP group membership (if GROUP_METHOD=LDAP)
1183 ; The entries in this ou must have a gidNumber and cn attribute.
1184 ; Default: ou=Groups
1185 ; LDAP_OU_GROUP = ou=Groups", "
1186 ; Ignored. No LDAP support in this php. configure --with-ldap");
1189 if (function_exists('imap_open')) {
1191 $properties["IMAP Auth Host"] =
1192 new _define_optional('IMAP_AUTH_HOST', 'localhost:143/imap/notls', "
1193 If USER_AUTH_ORDER contains IMAP:
1195 The IMAP server to check usernames from. Defaults to localhost.
1197 Some IMAP_AUTH_HOST samples:
1198 localhost, localhost:143/imap/notls,
1199 localhost:993/imap/ssl/novalidate-cert (SuSE refuses non-SSL conections)");
1201 } else { // function_exists('imap_open')
1203 $properties["IMAP Authentication"] =
1204 new unchangeable_variable('IMAP_AUTH_HOST',"
1205 ; If USER_AUTH_ORDER contains IMAP:
1206 ; The IMAP server to check usernames from. Defaults to localhost.
1208 ; Some IMAP_AUTH_HOST samples:
1209 ; localhost, localhost:143/imap/notls,
1210 ; localhost:993/imap/ssl/novalidate-cert (SuSE refuses non-SSL conections)
1211 ;IMAP_AUTH_HOST = localhost:143/imap/notls", "
1212 Ignored. No IMAP support in this php. configure --with-imap");
1216 $properties["POP3 Authentication"] =
1217 new _define_optional('POP3_AUTH_HOST', 'localhost:110', "
1218 If USER_AUTH_ORDER contains POP3:
1220 The POP3 mail server to check usernames and passwords against.");
1221 $properties["File Authentication"] =
1222 new _define_optional('AUTH_USER_FILE', '/etc/shadow', "
1223 If USER_AUTH_ORDER contains File:
1225 File to read for authentication information.
1226 Popular choices are /etc/shadow and /etc/httpd/.htpasswd");
1228 $properties["File Storable?"] =
1229 new boolean_define_commented_optional('AUTH_USER_FILE_STORABLE');
1231 $properties["Session Auth USER"] =
1232 new _define_optional('AUTH_SESS_USER', 'userid', "
1233 If USER_AUTH_ORDER contains Session:
1235 Name of the session variable which holds the already authenticated username.
1236 Sample: 'userid', 'user[username]', 'user->username'");
1238 $properties["Session Auth LEVEL"] =
1239 new numeric_define('AUTH_SESS_LEVEL', '2', "
1240 Which level will the user be? 1 = Bogo or 2 = Pass");
1242 /////////////////////////////////////////////////////////////////////
1244 $properties["Part Four"] =
1245 new part('_part4', $SEPARATOR."\n", "
1248 Page appearance and layout");
1250 $properties["Theme"] =
1251 new _define_selection_optional('THEME',
1252 array('default' => "default",
1253 'MacOSX' => "MacOSX",
1254 'smaller' => 'smaller',
1255 'Wordpress'=> 'Wordpress',
1256 'Portland' => "Portland",
1257 'Sidebar' => "Sidebar",
1259 'wikilens' => 'wikilens (Ratings)',
1260 'shamino_com' => 'shamino_com',
1261 'SpaceWiki' => "SpaceWiki",
1262 'Hawaiian' => "Hawaiian",
1263 'MonoBook' => 'MonoBook [experimental]',
1264 'blog' => 'blog [experimental]',
1268 Most of the page appearance is controlled by files in the theme
1271 There are a number of pre-defined themes shipped with PhpWiki.
1272 Or you may create your own, deriving from existing ones.
1274 THEME = Sidebar (default)
1277 THEME = MonoBook (WikiPedia)
1282 THEME = wikilens (with Ratings)
1286 THEME = blog (Kubrick) [experimental]
1289 $properties["Character Set"] =
1290 new _define_optional('CHARSET', 'iso-8859-1');
1292 $properties["Ignore Charset Not Supported Warning"] =
1293 new _define_optional('IGNORE_CHARSET_NOT_SUPPORTED_WARNING');
1295 $properties["Language"] =
1296 new _define_selection_optional('DEFAULT_LANGUAGE',
1297 array('en' => "English",
1298 '' => "<empty> (user-specific)",
1301 'nl' => "Nederlands",
1306 'zh' => "Chinese"), "
1307 Select your language/locale - default language is \"en\" for English.
1308 Other languages available:<pre>
1309 English \"en\" (English - HomePage)
1310 German \"de\" (Deutsch - StartSeite)
1311 French \"fr\" (Français - Accueil)
1312 Dutch \"nl\" (Nederlands - ThuisPagina)
1313 Spanish \"es\" (Español - PáginaPrincipal)
1314 Swedish \"sv\" (Svenska - Framsida)
1315 Italian \"it\" (Italiano - PaginaPrincipale)
1316 Japanese \"ja\" (Japanese - ホームページ)
1317 Chinese \"zh\" (Chinese - 首頁)
1319 If you set DEFAULT_LANGUAGE to the empty string, your systems default language
1320 (as determined by the applicable environment variables) will be
1323 $properties["Wiki Page Source"] =
1324 new _define_optional('WIKI_PGSRC', 'pgsrc', "
1325 WIKI_PGSRC -- specifies the source for the initial page contents of
1326 the Wiki. The setting of WIKI_PGSRC only has effect when the wiki is
1327 accessed for the first time (or after clearing the database.)
1328 WIKI_PGSRC can either name a directory or a zip file. In either case
1329 WIKI_PGSRC is scanned for files -- one file per page.
1331 // Default (old) behavior:
1332 define('WIKI_PGSRC', 'pgsrc');
1334 define('WIKI_PGSRC', 'wiki.zip');
1335 define('WIKI_PGSRC',
1336 '../Logs/Hamwiki/hamwiki-20010830.zip');
1339 $properties["Default Wiki Page Source"] =
1340 new _define('DEFAULT_WIKI_PGSRC', 'pgsrc', "
1341 DEFAULT_WIKI_PGSRC is only used when the language is *not* the
1342 default (English) and when reading from a directory: in that case
1343 some English pages are inserted into the wiki as well.
1344 DEFAULT_WIKI_PGSRC defines where the English pages reside.
1347 $properties["Generic Pages"] =
1348 new array_variable('DEFAULT_WIKI_PAGES', array('ReleaseNotes', 'SteveWainstead', 'TestPage'), "
1349 These are ':'-seperated pages which will get loaded untranslated from DEFAULT_WIKI_PGSRC.
1354 $properties["Part Five"] =
1355 new part('_part5', $SEPARATOR."\n", "
1360 $properties["Allowed Protocols"] =
1361 new list_define('ALLOWED_PROTOCOLS', 'http|https|mailto|ftp|news|nntp|ssh|gopher', "
1362 Allowed protocols for links - be careful not to allow \"javascript:\"
1363 URL of these types will be automatically linked.
1364 within a named link [name|uri] one more protocol is defined: phpwiki");
1366 $properties["Inline Images"] =
1367 new list_define('INLINE_IMAGES', 'png|jpg|jpeg|gif');
1369 $properties["WikiName Regexp"] =
1370 new _define('WIKI_NAME_REGEXP', "(?<![[:alnum:]])(?:[[:upper:]][[:lower:]]+){2,}(?![[:alnum:]])", "
1371 Perl regexp for WikiNames (\"bumpy words\")
1372 (?<!..) & (?!...) used instead of '\b' because \b matches '_' as well");
1374 $properties["Subpage Separator"] =
1375 new _define_optional('SUBPAGE_SEPARATOR', '"/"', "
1376 One character which seperates pages from subpages. Defaults to '/', but '.' or ':' were also used.",
1377 "onchange=\"validate_ereg('Sorry, \'%s\' must be a single character. Currently only :, / or .', '^[/:.]$', 'SUBPAGE_SEPARATOR', this);\""
1380 $properties["InterWiki Map File"] =
1381 new _define('INTERWIKI_MAP_FILE', 'lib/interwiki.map', "
1382 InterWiki linking -- wiki-style links to other wikis on the web
1384 The map will be taken from a page name InterWikiMap.
1385 If that page is not found (or is not locked), or map
1386 data can not be found in it, then the file specified
1387 by INTERWIKI_MAP_FILE (if any) will be used.");
1389 $properties["WARN_NONPUBLIC_INTERWIKIMAP"] =
1390 new boolean_define('WARN_NONPUBLIC_INTERWIKIMAP');
1392 $properties["Keyword Link Regexp"] =
1393 new _define_optional('KEYWORDS', '\"Category* OR Topic*\"', "
1394 Search term used for automatic page classification by keyword extraction.
1396 Any links on a page to pages whose names match this search
1397 will be used keywords in the keywords html meta tag. This is an aid to
1398 classification by search engines. The value of the match is
1399 used as the keyword.
1401 The default behavior is to match Category* or Topic* links.");
1403 $properties["Author and Copyright Site Navigation Links"] =
1404 new _define_commented_optional('COPYRIGHTPAGE_TITLE', "GNU General Public License", "
1406 These will be inserted as <link rel> tags in the html header of
1407 every page, for search engines and for browsers like Mozilla which
1408 take advantage of link rel site navigation.
1410 If you have your own copyright and contact information pages change
1411 these as appropriate.");
1413 $properties["COPYRIGHTPAGE URL"] =
1414 new _define_commented_optional('COPYRIGHTPAGE_URL', "http://www.gnu.org/copyleft/gpl.html#SEC1", "
1416 Other useful alternatives to consider:
1418 COPYRIGHTPAGE_TITLE = \"GNU Free Documentation License\"
1419 COPYRIGHTPAGE_URL = \"http://www.gnu.org/copyleft/fdl.html\"
1420 COPYRIGHTPAGE_TITLE = \"Creative Commons License 2.0\"
1421 COPYRIGHTPAGE_URL = \"http://creativecommons.org/licenses/by/2.0/\"</pre>
1422 See http://creativecommons.org/learn/licenses/ for variations");
1424 $properties["AUTHORPAGE_TITLE"] =
1425 new _define_commented_optional('AUTHORPAGE_TITLE', "The PhpWiki Programming Team", "
1426 Default Author Names");
1427 $properties["AUTHORPAGE_URL"] =
1428 new _define_commented_optional('AUTHORPAGE_URL', "http://phpwiki.org/ThePhpWikiProgrammingTeam", "
1429 Default Author URL");
1431 $properties["TOC_FULL_SYNTAX"] =
1432 new boolean_define_optional('TOC_FULL_SYNTAX');
1434 $properties["ENABLE_MARKUP_COLOR"] =
1435 new boolean_define_optional('ENABLE_MARKUP_COLOR');
1437 $properties["DISABLE_MARKUP_WIKIWORD"] =
1438 new boolean_define_optional('DISABLE_MARKUP_WIKIWORD');
1440 $properties["ENABLE_MARKUP_DIVSPAN" ] =
1441 new boolean_define_optional('ENABLE_MARKUP_DIVSPAN');
1445 $properties["Part Six"] =
1446 new part('_part6', $SEPARATOR."\n", "
1448 Part Six (optional):
1449 URL options -- you can probably skip this section.
1451 For a pretty wiki (no index.php in the url) set a seperate DATA_PATH.");
1453 $properties["Server Name"] =
1454 new _define_commented_optional('SERVER_NAME', $_SERVER['SERVER_NAME'], "
1455 Canonical name of the server on which this PhpWiki resides.");
1457 $properties["Server Port"] =
1458 new numeric_define_commented('SERVER_PORT', $_SERVER['SERVER_PORT'], "
1459 Canonical httpd port of the server on which this PhpWiki resides.",
1460 "onchange=\"validate_ereg('Sorry, \'%s\' is no valid port number.', '^[0-9]+$', 'SERVER_PORT', this);\"");
1462 $properties["Server Protocol"] =
1463 new _define_selection_optional_commented('SERVER_PROTOCOL',
1464 array('http' => 'http',
1465 'https' => 'https'));
1467 $properties["Script Name"] =
1468 new _define_commented_optional('SCRIPT_NAME', $scriptname);
1470 $properties["Data Path"] =
1471 new _define_commented_optional('DATA_PATH', dirname($scriptname));
1473 $properties["PhpWiki Install Directory"] =
1474 new _define_commented_optional('PHPWIKI_DIR', dirname(__FILE__));
1476 $properties["Use PATH_INFO"] =
1477 new _define_selection_optional_commented('USE_PATH_INFO',
1478 array('' => 'automatic',
1479 'true' => 'use PATH_INFO',
1480 'false' => 'do not use PATH_INFO'), "
1481 PhpWiki will try to use short urls to pages, eg
1482 http://www.example.com/index.php/HomePage
1483 If you want to use urls like
1484 http://www.example.com/index.php?pagename=HomePage
1485 then define 'USE_PATH_INFO' as false by uncommenting the line below.
1486 NB: If you are using Apache >= 2.0.30, then you may need to to use
1487 the directive \"AcceptPathInfo On\" in your Apache configuration file
1488 (or in an appropriate <.htaccess> file) for the short urls to work:
1489 See http://httpd.apache.org/docs-2.0/mod/core.html#acceptpathinfo
1491 See also http://phpwiki.sourceforge.net/phpwiki/PrettyWiki for more ideas
1492 on prettifying your urls.
1494 Default: PhpWiki will try to divine whether use of PATH_INFO
1495 is supported in by your webserver/PHP configuration, and will
1496 use PATH_INFO if it thinks that is possible.");
1498 $properties["Virtual Path"] =
1499 new _define_commented_optional('VIRTUAL_PATH', '/SomeWiki', "
1500 VIRTUAL_PATH is the canonical URL path under which your your wiki
1501 appears. Normally this is the same as dirname(SCRIPT_NAME), however
1502 using e.g. seperate starter scripts, apaches mod_actions (or mod_rewrite),
1503 you can make it something different.
1505 If you do this, you should set VIRTUAL_PATH here or in the starter scripts.
1507 E.g. your phpwiki might be installed at at /scripts/phpwiki/index.php,
1508 but you've made it accessible through eg. /wiki/HomePage.
1510 One way to do this is to create a directory named 'wiki' in your
1511 server root. The directory contains only one file: an .htaccess
1512 file which reads something like:
1514 Action x-phpwiki-page /scripts/phpwiki/index.php
1515 SetHandler x-phpwiki-page
1516 DirectoryIndex /scripts/phpwiki/index.php
1518 In that case you should set VIRTUAL_PATH to '/wiki'.
1520 (VIRTUAL_PATH is only used if USE_PATH_INFO is true.)
1523 $upload_file_path = defined('UPLOAD_FILE_PATH') ? UPLOAD_FILE_PATH : getUploadFilePath();
1524 new _define_optional('UPLOAD_FILE_PATH', $temp);
1526 $upload_data_path = defined('UPLOAD_DATA_PATH') ? UPLOAD_DATA_PATH : getUploadDataPath();
1527 new _define_optional('UPLOAD_DATA_PATH', $temp);
1529 $temp = !empty($_ENV['TEMP']) ? $_ENV['TEMP'] : "/tmp";
1530 $properties["TEMP_DIR"] =
1531 new _define_optional('TEMP_DIR', $temp);
1535 $properties["Part Seven"] =
1536 new part('_part7', $SEPARATOR."\n", "
1540 Miscellaneous settings
1543 $properties["Strict Mailable Pagedumps"] =
1544 new boolean_define_optional('STRICT_MAILABLE_PAGEDUMPS',
1545 array('false' => "binary",
1546 'true' => "quoted-printable"));
1548 $properties["Default local Dump Directory"] =
1549 new _define_optional('DEFAULT_DUMP_DIR');
1551 $properties["Default local HTML Dump Directory"] =
1552 new _define_optional('HTML_DUMP_DIR');
1554 $properties["HTML Dump Filename Suffix"] =
1555 new _define_optional('HTML_DUMP_SUFFIX');
1557 $properties["Pagename of Recent Changes"] =
1558 new _define_optional('RECENT_CHANGES',
1561 $properties["Disable HTTP Redirects"] =
1562 new boolean_define_commented_optional('DISABLE_HTTP_REDIRECT');
1564 $properties["Disable GETIMAGESIZE"] =
1565 new boolean_define_commented_optional('DISABLE_GETIMAGESIZE');
1567 $properties["EDITING_POLICY"] =
1568 new _define_optional('EDITING_POLICY');
1570 $properties["TOOLBAR_PAGELINK_PULLDOWN"] =
1571 new _define_commented_optional('TOOLBAR_PAGELINK_PULLDOWN');
1572 $properties["TOOLBAR_TEMPLATE_PULLDOWN"] =
1573 new _define_commented_optional('TOOLBAR_TEMPLATE_PULLDOWN');
1574 $properties["TOOLBAR_IMAGE_PULLDOWN"] =
1575 new _define_commented_optional('TOOLBAR_IMAGE_PULLDOWN');
1576 $properties["FULLTEXTSEARCH_STOPLIST"] =
1577 new _define_commented_optional('FULLTEXTSEARCH_STOPLIST');
1579 $properties["Part Seven A"] =
1580 new part('_part7a', $SEPARATOR."\n", "
1584 Optional Plugin Settings and external executables
1587 $properties["FORTUNE_DIR"] =
1588 new _define_commented_optional('FORTUNE_DIR', "/usr/share/fortune");
1589 $properties["USE_EXTERNAL_HTML2PDF"] =
1590 new _define_commented_optional('USE_EXTERNAL_HTML2PDF', "htmldoc --quiet --format pdf14 --no-toc --no-title %s");
1591 $properties["EXTERNAL_HTML2PDF_PAGELIST"] =
1592 new _define_commented_optional('EXTERNAL_HTML2PDF_PAGELIST');
1593 $properties["BABYCART_PATH"] =
1594 new _define_commented_optional('BABYCART_PATH', "/usr/local/bin/babycart");
1595 $properties["GOOGLE_LICENSE_KEY"] =
1596 new _define_commented_optional('GOOGLE_LICENSE_KEY');
1597 $properties["RATEIT_IMGPREFIX"] =
1598 new _define_commented_optional('RATEIT_IMGPREFIX'); //BStar
1599 $properties["GRAPHVIZ_EXE"] =
1600 new _define_commented_optional('GRAPHVIZ_EXE'); // /usr/local/bin/dot
1602 if (PHP_OS == "Darwin") // Mac OS X
1603 $ttfont = "/System/Library/Frameworks/JavaVM.framework/Versions/1.3.1/Home/lib/fonts/LucidaSansRegular.ttf";
1604 elseif (isWindows()) {
1605 $ttfont = $_ENV['windir'].'\Fonts\Arial.ttf';
1607 $ttfont = 'luximr'; // This is the only what sourceforge offered.
1608 //$ttfont = 'Helvetica';
1610 $properties["TTFONT"] =
1611 new _define_commented_optional('TTFONT',$ttfont);
1612 $properties["VISUALWIKIFONT"] =
1613 new _define_commented_optional('VISUALWIKIFONT'); // Arial
1614 $properties["VISUALWIKI_ALLOWOPTIONS"] =
1615 new boolean_define_commented_optional('VISUALWIKI_ALLOWOPTIONS'); // false
1616 $properties["PLOTICUS_EXE"] =
1617 new _define_commented_optional('PLOTICUS_EXE'); // /usr/local/bin/pl
1618 $properties["PLOTICUS_PREFABS"] =
1619 new _define_commented_optional('PLOTICUS_PREFABS'); // /usr/share/ploticus
1620 $properties["MY_JABBER_ID"] =
1621 new _define_commented_optional('MY_JABBER_ID'); //
1622 $properties["PHPWEATHER_BASE_DIR"] =
1623 new _define_commented_optional('PHPWEATHER_BASE_DIR'); //
1624 $properties["HIGHLIGHT_EXE"] =
1625 new _define_commented_optional('HIGHLIGHT_EXE'); // /usr/local/bin/highlight
1626 $properties["HIGHLIGHT_DATA_DIR"] =
1627 new _define_commented_optional('HIGHLIGHT_DATA_DIR'); // /usr/share/highlight
1629 $properties["Part Eight"] =
1630 new part('_part8', $SEPARATOR."\n", "
1634 Cached Plugin Settings. (pear Cache)
1637 $properties["pear Cache USECACHE"] =
1638 new boolean_define_optional('PLUGIN_CACHED_USECACHE',
1639 array('true' => 'Enabled',
1640 'false' => 'Disabled'), "
1641 Enable or disable pear caching of plugins.");
1642 $properties["pear Cache Database Container"] =
1643 new _define_selection_optional('PLUGIN_CACHED_DATABASE',
1644 array('file' => 'file'), "
1645 Curently only file is supported.
1646 db, trifile and imgfile might be supported, but you must hack that by yourself.");
1648 $properties["pear Cache cache directory"] =
1649 new _define_commented_optional('PLUGIN_CACHED_CACHE_DIR', "/tmp/cache", "
1650 Should be writable to the webserver.");
1651 $properties["pear Cache Filename Prefix"] =
1652 new _define_optional('PLUGIN_CACHED_FILENAME_PREFIX', "phpwiki", "");
1653 $properties["pear Cache HIGHWATER"] =
1654 new numeric_define_optional('PLUGIN_CACHED_HIGHWATER', "4194304", "
1655 Garbage collection parameter.");
1656 $properties["pear Cache LOWWATER"] =
1657 new numeric_define_optional('PLUGIN_CACHED_LOWWATER', "3145728", "
1658 Garbage collection parameter.");
1659 $properties["pear Cache MAXLIFETIME"] =
1660 new numeric_define_optional('PLUGIN_CACHED_MAXLIFETIME', "2592000", "
1661 Garbage collection parameter.");
1662 $properties["pear Cache MAXARGLEN"] =
1663 new numeric_define_optional('PLUGIN_CACHED_MAXARGLEN', "1000", "
1664 max. generated url length.");
1665 $properties["pear Cache FORCE_SYNCMAP"] =
1666 new boolean_define_optional('PLUGIN_CACHED_FORCE_SYNCMAP',
1667 array('true' => 'Enabled',
1668 'false' => 'Disabled'), "");
1669 $properties["pear Cache IMGTYPES"] =
1670 new list_define('PLUGIN_CACHED_IMGTYPES', "png|gif|gd|gd2|jpeg|wbmp|xbm|xpm", "
1671 Handle those image types via GD handles. Check your GD supported image types.");
1673 $end = "\n".$SEPARATOR."\n";
1676 text_from_dist("_MAGIC_CLOSE_FILE");
1678 // end of configuration options
1679 ///////////////////////////////
1680 // begin class definitions
1683 * A basic config-dist.ini configuration line in the form of a variable.
1684 * (not needed anymore, we have only defines)
1686 * Produces a string in the form "$name = value;"
1688 * $WikiNameRegexp = "value";
1692 var $config_item_name;
1698 function _variable($config_item_name, $default_value='', $description = '', $jscheck = '') {
1699 $this->config_item_name = $config_item_name;
1701 $description = text_from_dist($config_item_name);
1702 $this->description = $description;
1703 if (defined($config_item_name)
1704 and !preg_match("/(selection|boolean)/", get_class($this))
1705 and !preg_match("/^(SCRIPT_NAME|VIRTUAL_PATH|TEMP_DIR)$/", $config_item_name))
1706 $this->default_value = constant($config_item_name); // ignore given default value
1707 elseif ($config_item_name == $default_value)
1708 $this->default_value = '';
1710 $this->default_value = $default_value;
1711 $this->jscheck = $jscheck;
1712 if (preg_match("/variable/i", get_class($this)))
1713 $this->prefix = "\$";
1714 elseif (preg_match("/ini_set/i", get_class($this)))
1715 $this->prefix = "ini_get: ";
1720 function _define($config_item_name, $default_value='', $description = '', $jscheck = '') {
1721 $this->_variable($config_item_name, $default_value, $description, $jscheck);
1725 global $HTTP_POST_VARS;
1726 if (isset($HTTP_POST_VARS[$this->config_item_name]))
1727 return $HTTP_POST_VARS[$this->config_item_name];
1729 return $this->default_value;
1732 function _config_format($value) {
1734 $v = $this->get_config_item_name();
1735 // handle arrays: a|b --> a['b']
1736 if (strpos($v, '|')) {
1737 list($a, $b) = explode('|', $v);
1738 $v = sprintf("%s['%s']", $a, $b);
1740 if (preg_match("/[\"']/", $value))
1741 $value = '"' . $value . '"';
1742 return sprintf("%s = \"%s\"", $v, $value);
1745 function get_config_item_name() {
1746 return $this->config_item_name;
1749 function get_config_item_id() {
1750 return str_replace('|', '-', $this->config_item_name);
1753 function get_config_item_header() {
1754 if (strchr($this->config_item_name,'|')) {
1755 list($var,$param) = explode('|',$this->config_item_name);
1756 return "<b>" . $this->prefix . $var . "['" . $param . "']</b><br />";
1758 elseif ($this->config_item_name[0] != '_')
1759 return "<b>" . $this->prefix . $this->config_item_name . "</b><br />";
1764 function _get_description() {
1765 return $this->description;
1768 function _get_config_line($posted_value) {
1769 return "\n" . $this->_config_format($posted_value);
1772 function get_config($posted_value) {
1773 $d = stripHtml($this->_get_description());
1774 $d = str_replace("\n", "\n; ", $d) . $this->_get_config_line($posted_value) ."\n";
1778 function get_instructions($title) {
1780 $i = "<h3>" . $title . "</h3>\n " . nl2p($this->_get_description()) . "\n";
1781 return "<tr>\n<td width=\"$tdwidth\" class=\"instructions\">\n" . $i . "</td>\n";
1784 function get_html() {
1785 $size = strlen($this->default_value) > 45 ? 90 : 50;
1786 return $this->get_config_item_header() .
1787 "<input type=\"text\" size=\"$50\" name=\"" . $this->get_config_item_name() . "\" value=\"" . htmlspecialchars($this->default_value) . "\" " .
1788 $this->jscheck . " />" . "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: green\">Input accepted.</p>";
1792 class unchangeable_variable
1794 function _config_format($value) {
1797 // function get_html() { return false; }
1798 function get_html() {
1799 return $this->get_config_item_header() .
1800 "<em>Not editable.</em>" .
1801 "<pre>" . $this->default_value."</pre>";
1803 function _get_config_line($posted_value) {
1804 if ($this->description)
1806 return "${n}".$this->default_value;
1808 function get_instructions($title) {
1810 $i = "<h3>" . $title . "</h3>\n " . nl2p($this->_get_description()) . "\n";
1811 // $i .= "<em>Not editable.</em><br />\n<pre>" . $this->default_value."</pre>";
1812 return '<tr><td width="100%" class="unchangeable-variable-top" colspan="2">'."\n".$i."</td></tr>\n"
1813 . '<tr style="border-top: none;"><td class="unchangeable-variable-left" width="'.$tdwidth.'"> </td>';
1817 class unchangeable_define
1818 extends unchangeable_variable {
1819 function _get_config_line($posted_value) {
1820 if ($this->description)
1823 $posted_value = $this->default_value;
1824 return "${n}".$this->_config_format($posted_value);
1826 function _config_format($value) {
1827 return sprintf("%s = \"%s\"", $this->get_config_item_name(), $value);
1830 class unchangeable_ini_set
1831 extends unchangeable_variable {
1832 function _config_format($value) {
1837 class _variable_selection
1840 global $HTTP_POST_VARS;
1841 if (!empty($HTTP_POST_VARS[$this->config_item_name]))
1842 return $HTTP_POST_VARS[$this->config_item_name];
1844 list($option, $label) = each($this->default_value);
1848 function get_html() {
1849 $output = $this->get_config_item_header();
1850 $output .= '<select name="' . $this->get_config_item_name() . "\">\n";
1851 /* The first option is the default */
1852 $values = $this->default_value;
1853 if (defined($this->get_config_item_name()))
1854 $this->default_value = constant($this->get_config_item_name());
1856 $this->default_value = null;
1858 foreach ($values as $option => $label) {
1859 if (!is_null($this->default_value) && $this->default_value === $option)
1860 $output .= " <option value=\"$option\" selected=\"selected\">$label</option>\n";
1862 $output .= " <option value=\"$option\">$label</option>\n";
1864 $output .= "</select>\n";
1871 function _config_format($value) {
1872 return sprintf("%s = \"%s\"", $this->get_config_item_name(), $value);
1874 function _get_config_line($posted_value) {
1875 if ($this->description)
1877 if ($posted_value == '')
1878 return "${n};" . $this->_config_format("");
1880 return "${n}" . $this->_config_format($posted_value);
1882 function get_html() {
1883 $size = strlen($this->default_value) > 45 ? 90 : 50;
1884 return $this->get_config_item_header()
1885 . "<input type=\"text\" size=\"$size\" name=\"" . htmlentities($this->get_config_item_name())
1886 . "\" value=\"" . htmlentities($this->default_value) . "\" {$this->jscheck} />"
1887 . "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: green\">Input accepted.</p>";
1891 class _define_commented
1893 function _get_config_line($posted_value) {
1894 if ($this->description)
1896 if ($posted_value == $this->default_value)
1897 return "${n};" . $this->_config_format($posted_value);
1898 elseif ($posted_value == '')
1899 return "${n};" . $this->_config_format("");
1901 return "${n}" . $this->_config_format($posted_value);
1906 * We don't use _optional anymore, because INI-style config's don't need that.
1907 * IniConfig.php does the optional logic now.
1908 * But we use _optional for config-default.ini options
1910 class _define_commented_optional
1911 extends _define_commented { }
1913 class _define_optional
1916 class _define_notempty
1918 function get_html() {
1919 $s = $this->get_config_item_header()
1920 . "<input type=\"text\" size=\"50\" name=\"" . $this->get_config_item_name()
1921 . "\" value=\"" . $this->default_value . "\" {$this->jscheck} />";
1922 if (empty($this->default_value))
1923 return $s . "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: red\">Cannot be empty.</p>";
1925 return $s . "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: green\">Input accepted.</p>";
1929 class _variable_commented
1931 function _get_config_line($posted_value) {
1932 if ($this->description)
1934 if ($posted_value == $this->default_value)
1935 return "${n};" . $this->_config_format($posted_value);
1936 elseif ($posted_value == '')
1937 return "${n};" . $this->_config_format("");
1939 return "${n}" . $this->_config_format($posted_value);
1943 class numeric_define
1946 function numeric_define($config_item_name, $default_value='', $description = '', $jscheck = '') {
1947 $this->_define($config_item_name, $default_value, $description, $jscheck);
1949 $this->jscheck = "onchange=\"validate_ereg('Sorry, \'%s\' is not an integer.', '^[-+]?[0-9]+$', '" . $this->get_config_item_name() . "', this);\"";
1951 function _config_format($value) {
1952 //return sprintf("define('%s', %s);", $this->get_config_item_name(), $value);
1953 return sprintf("%s = %s", $this->get_config_item_name(), $value);
1955 function _get_config_line($posted_value) {
1956 if ($this->description)
1958 if ($posted_value == '')
1959 return "${n};" . $this->_config_format('0');
1961 return "${n}" . $this->_config_format($posted_value);
1965 class numeric_define_optional
1966 extends numeric_define {}
1968 class numeric_define_commented
1969 extends numeric_define {
1970 function _get_config_line($posted_value) {
1971 if ($this->description)
1973 if ($posted_value == $this->default_value)
1974 return "${n};" . $this->_config_format($posted_value);
1975 elseif ($posted_value == '')
1976 return "${n};" . $this->_config_format('0');
1978 return "${n}" . $this->_config_format($posted_value);
1982 class _define_selection
1983 extends _variable_selection {
1984 function _config_format($value) {
1985 return sprintf("%s = %s", $this->get_config_item_name(), $value);
1987 function _get_config_line($posted_value) {
1988 return _define::_get_config_line($posted_value);
1990 function get_html() {
1991 return _variable_selection::get_html();
1995 class _define_selection_optional
1996 extends _define_selection { }
1998 class _variable_selection_optional
1999 extends _variable_selection { }
2001 class _define_selection_optional_commented
2002 extends _define_selection_optional {
2003 function _get_config_line($posted_value) {
2004 if ($this->description)
2006 if ($posted_value == $this->default_value)
2007 return "${n};" . $this->_config_format($posted_value);
2008 elseif ($posted_value == '')
2009 return "${n};" . $this->_config_format("");
2011 return "${n}" . $this->_config_format($posted_value);
2015 class _define_password
2018 function _define_password($config_item_name, $default_value='', $description = '', $jscheck = '') {
2019 if ($config_item_name == $default_value) $default_value = '';
2020 $this->_define($config_item_name, $default_value, $description, $jscheck);
2022 $this->jscheck = "onchange=\"validate_ereg('Sorry, \'%s\' cannot be empty.', '^.+$', '"
2023 . $this->get_config_item_name() . "', this);\"";
2025 function _get_config_line($posted_value) {
2026 if ($this->description)
2028 if ($posted_value == '') {
2029 $p = "${n};" . $this->_config_format("");
2030 $p .= "\n; If you used the passencrypt.php utility to encode the password";
2031 $p .= "\n; then uncomment this line:";
2032 $p .= "\n;ENCRYPTED_PASSWD = true";
2035 if (function_exists('crypt')) {
2036 $salt_length = max(CRYPT_SALT_LENGTH,
2040 16 * CRYPT_BLOWFISH);
2041 // generate an encrypted password
2042 $crypt_pass = crypt($posted_value, rand_ascii($salt_length));
2043 $p = "${n}" . $this->_config_format($crypt_pass);
2044 return $p . "\nENCRYPTED_PASSWD = true";
2046 $p = "${n}" . $this->_config_format($posted_value);
2047 $p .= "\n; Encrypted passwords cannot be used:";
2048 $p .= "\n; 'function crypt()' not available in this version of php";
2049 $p .= "\nENCRYPTED_PASSWD = false";
2054 function get_html() {
2055 return _variable_password::get_html();
2059 class _define_password_optional
2060 extends _define_password {
2062 function _define_password_optional($config_item_name, $default_value='', $description = '', $jscheck = '') {
2063 if ($config_item_name == $default_value) $default_value = '';
2064 if (!$jscheck) $this->jscheck = " ";
2065 $this->_define($config_item_name, $default_value, $description, $jscheck);
2068 function _get_config_line($posted_value) {
2069 if ($this->description)
2071 if ($posted_value == '') {
2072 return "${n};" . $this->_config_format("");
2074 return "${n}" . $this->_config_format($posted_value);
2077 function get_html() {
2078 $s = $this->get_config_item_header();
2079 // dont re-encrypt already encrypted passwords
2080 $value = $this->value();
2081 $encrypted = !empty($GLOBALS['properties']["Encrypted Passwords"]) and
2082 $GLOBALS['properties']["Encrypted Passwords"]->value();
2085 $s .= "<input type=\"". ($encrypted ? "text" : "password") . "\" name=\"" . $this->get_config_item_name()
2086 . "\" value=\"" . $value . "\" {$this->jscheck} />";
2091 class _define_password_commented_optional
2092 extends _define_password_optional { }
2094 class _variable_password
2096 function _variable_password($config_item_name, $default_value='', $description = '', $jscheck = '') {
2097 if ($config_item_name == $default_value) $default_value = '';
2098 $this->_define($config_item_name, $default_value, $description, $jscheck);
2100 $this->jscheck = "onchange=\"validate_ereg('Sorry, \'%s\' cannot be empty.', '^.+$', '" . $this->get_config_item_name() . "', this);\"";
2102 function get_html() {
2103 global $HTTP_POST_VARS, $HTTP_GET_VARS;
2104 $s = $this->get_config_item_header();
2105 if (isset($HTTP_POST_VARS['create']) or isset($HTTP_GET_VARS['create'])) {
2106 $new_password = random_good_password();
2107 $this->default_value = $new_password;
2108 $s .= "Created password: <strong>$new_password</strong><br /> <br />";
2110 // dont re-encrypt already encrypted passwords
2111 $value = $this->value();
2112 $encrypted = !empty($GLOBALS['properties']["Encrypted Passwords"]) and
2113 $GLOBALS['properties']["Encrypted Passwords"]->value();
2116 $s .= "<input type=\"". ($encrypted ? "text" : "password") . "\" name=\"" . $this->get_config_item_name()
2117 . "\" value=\"" . $value . "\" {$this->jscheck} />"
2118 . " <input type=\"submit\" name=\"create\" value=\"Create Random Password\" />";
2120 $s .= "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: red\">Cannot be empty.</p>";
2121 elseif (strlen($this->default_value) < 4)
2122 $s .= "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: red\">Must be longer than 4 chars.</p>";
2124 $s .= "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: green\">Input accepted.</p>";
2131 function _get_config_line($posted_value) {
2132 // split the phrase by any number of commas or space characters,
2133 // which include " ", \r, \t, \n and \f
2134 $list_values = preg_split("/[\s,]+/", $posted_value, -1, PREG_SPLIT_NO_EMPTY);
2136 $list_values = join("|", $list_values);
2137 return _variable::_get_config_line($list_values);
2139 function get_html() {
2140 $list_values = explode("|", $this->default_value);
2141 $rows = max(3, count($list_values) +1);
2142 $list_values = join("\n", $list_values);
2143 $ta = $this->get_config_item_header();
2144 $ta .= "<textarea cols=\"18\" rows=\"". $rows ."\" name=\"".$this->get_config_item_name()."\" {$this->jscheck}>";
2145 $ta .= $list_values . "</textarea>";
2146 $ta .= "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: green\">Input accepted.</p>";
2153 function _get_config_line($posted_value) {
2154 $list_values = preg_split("/[\s,]+/", $posted_value, -1, PREG_SPLIT_NO_EMPTY);
2156 $list_values = join("|", $list_values);
2157 return _variable::_get_config_line($list_values);
2159 function get_html() {
2160 $list_values = explode("|", $this->default_value);
2161 $rows = max(3, count($list_values) +1);
2163 $list_values = join("\n", $list_values);
2164 $ta = $this->get_config_item_header();
2165 $ta .= "<textarea cols=\"18\" rows=\"". $rows ."\" name=\"".$this->get_config_item_name()."\" {$this->jscheck}>";
2166 $ta .= $list_values . "</textarea>";
2167 $ta .= "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: green\">Input accepted.</p>";
2172 class array_variable
2174 function _config_format($value) {
2175 return sprintf("%s = \"%s\"", $this->get_config_item_name(),
2176 is_array($value) ? join(':', $value) : $value);
2178 function _get_config_line($posted_value) {
2179 // split the phrase by any number of commas or space characters,
2180 // which include " ", \r, \t, \n and \f
2181 $list_values = preg_split("/[\s,]+/", $posted_value, -1, PREG_SPLIT_NO_EMPTY);
2182 if (!empty($list_values)) {
2183 $list_values = "'".join("', '", $list_values)."'";
2184 return "\n" . $this->_config_format($list_values);
2186 return "\n;" . $this->_config_format('');
2188 function get_html() {
2189 if (is_array($this->default_value))
2190 $list_values = join("\n", $this->default_value);
2192 $list_values = $this->default_value;
2193 $rows = max(3, count($this->default_value) +1);
2194 $ta = $this->get_config_item_header();
2195 $ta .= "<textarea cols=\"18\" rows=\"". $rows ."\" name=\"".$this->get_config_item_name()."\" {$this->jscheck}>";
2196 $ta .= $list_values . "</textarea>";
2197 $ta .= "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: green\">Input accepted.</p>";
2204 function _config_format($value) {
2205 return sprintf("%s = \"%s\"", $this->get_config_item_name(),
2206 is_array($value) ? join(' : ', $value) : $value);
2208 function _get_config_line($posted_value) {
2209 // split the phrase by any number of commas or space characters,
2210 // which include " ", \r, \t, \n and \f
2211 $list_values = preg_split("/[\s,:]+/", $posted_value, -1, PREG_SPLIT_NO_EMPTY);
2212 if (!empty($list_values)) {
2213 $list_values = join(" : ", $list_values);
2214 return "\n" . $this->_config_format($list_values);
2216 return "\n;" . $this->_config_format('');
2218 function get_html () {
2219 if (!$this->default_value)
2220 $this->default_value = array();
2221 elseif (is_string($this->default_value))
2222 $this->default_value = preg_split("/[\s,:]+/", $this->default_value, -1, PREG_SPLIT_NO_EMPTY);
2223 $list_values = join(" : \n", $this->default_value);
2224 $rows = max(3, count($this->default_value) + 1);
2225 $ta = $this->get_config_item_header();
2226 $ta .= "<textarea cols=\"18\" rows=\"". $rows ."\" name=\"".$this->get_config_item_name()."\" {$this->jscheck}>";
2227 $ta .= $list_values . "</textarea>";
2228 $ta .= "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: green\">Input accepted.</p>";
2237 global $HTTP_POST_VARS;
2238 if ($v = $HTTP_POST_VARS[$this->config_item_name])
2241 return ini_get($this->get_config_item_name);
2244 function _config_format($value) {
2245 return sprintf("ini_set('%s', '%s');", $this->get_config_item_name(), $value);
2247 function _get_config_line($posted_value) {
2248 if ($posted_value && ! $posted_value == $this->default_value)
2249 return "\n" . $this->_config_format($posted_value);
2251 return "\n;" . $this->_config_format($this->default_value);
2256 class boolean_define
2259 // adds ->values property, instead of ->default_value
2260 function boolean_define($config_item_name, $values = false, $description = '', $jscheck = '') {
2261 $this->config_item_name = $config_item_name;
2263 $description = text_from_dist($config_item_name);
2264 $this->description = $description;
2265 // TESTME: get boolean default value from config-default.ini
2266 if (defined($config_item_name))
2267 $this->default_value = constant($config_item_name); // ignore given default value
2268 elseif (is_array($values))
2269 list($this->default_value,$dummy) = $values[0];
2271 $values = array('false' => "Disabled",
2272 'true' => "Enabled");
2273 $this->values = $values;
2274 $this->jscheck = $jscheck;
2277 function _get_config_line($posted_value) {
2278 if ($this->description)
2280 return "${n}" . $this->_config_format($posted_value);
2282 function _config_format($value) {
2283 if (strtolower(trim($value)) == 'false')
2285 return sprintf("%s = %s", $this->get_config_item_name(),
2286 (bool)$value ? 'true' : 'false');
2288 //TODO: radiobuttons, no list
2289 function get_html() {
2290 $output = $this->get_config_item_header();
2291 $name = $this->get_config_item_name();
2292 $output .= '<select name="' . $name . "\" {$this->jscheck}>\n";
2293 $values = $this->values;
2294 $default_value = $this->default_value ? 'true' : 'false';
2295 /* There can usually only be two options, there can be
2296 * three options in the case of a boolean_define_commented_optional */
2297 while (list($option, $label) = each($values)) {
2298 if (!is_null($this->default_value) and $option === $default_value)
2299 $output .= " <option value=\"$option\" selected=\"selected\">$label</option>\n";
2301 $output .= " <option value=\"$option\">$label</option>\n";
2303 $output .= "</select>\n";
2308 class boolean_define_optional
2309 extends boolean_define {}
2311 class boolean_define_commented
2312 extends boolean_define {
2313 function _get_config_line($posted_value) {
2314 if ($this->description)
2316 list($default_value, $label) = each($this->default_value);
2317 if ($posted_value == $default_value)
2318 return "${n};" . $this->_config_format($posted_value);
2319 elseif ($posted_value == '')
2320 return "${n};" . $this->_config_format('false');
2322 return "${n}" . $this->_config_format($posted_value);
2326 class boolean_define_commented_optional
2327 extends boolean_define_commented {}
2331 function value () { return; }
2332 function get_config($posted_value) {
2333 $d = stripHtml($this->_get_description());
2335 return "\n".$SEPARATOR . str_replace("\n", "\n; ", $d) ."\n".$this->default_value;
2337 function get_instructions($title) {
2338 $id = preg_replace("/\W/","",$this->config_item_name);
2339 $group_name = preg_replace("/\W/","",$title);
2340 $i = "<tr class=\"header\" id=\"$id\">\n<td class=\"part\" width=\"100%\" colspan=\"2\" bgcolor=\"#eeeeee\">\n";
2341 $i .= "<h2>" . $title . "</h2>\n " . nl2p($this->_get_description()) ."\n";
2342 $i .= "<p><a href=\"javascript:toggle_group('$id')\" id=\"{$id}_text\">Hide options.</a></p>";
2343 return $i ."</td>\n";
2345 function get_html() {
2350 // html utility functions
2351 function nl2p($text) {
2352 preg_match_all("@\s*(<pre>.*?</pre>|<dl>.*?</dl>|.*?(?=\n\n|<pre>|<dl>|$))@s",
2353 $text, $m, PREG_PATTERN_ORDER);
2356 foreach ($m[1] as $par) {
2357 if (!($par = trim($par)))
2359 if (!preg_match('/^<(pre|dl)>/', $par))
2360 $par = "<p>$par</p>";
2366 function text_from_dist($var) {
2367 static $distfile = 0;
2371 $sep = (substr(PHP_OS,0,3) == 'WIN' ? '\\' : '/');
2372 $distfile = dirname(__FILE__) . $sep . "config" . $sep . "config-dist.ini";
2373 $f = fopen($distfile, "r");
2375 if ($var == '_MAGIC_CLOSE_FILE') {
2379 // if all vars would be in natural order as in the config-dist this would not be needed.
2384 if (preg_match("/^; \w/", $s)) {
2385 $par .= (substr($s,2) . " ");
2386 } elseif (preg_match("/^;\s*$/", $s)) {
2389 if (preg_match("/^;?".preg_quote($var)."\s*=/", $s))
2391 if (preg_match("/^\s*$/", $s)) // new paragraph
2397 function stripHtml($text) {
2398 $d = str_replace("<pre>", "", $text);
2399 $d = str_replace("</pre>", "", $d);
2400 $d = str_replace("<dl>", "", $d);
2401 $d = str_replace("</dl>", "", $d);
2402 $d = str_replace("<dt>", "", $d);
2403 $d = str_replace("</dt>", "", $d);
2404 $d = str_replace("<dd>", "", $d);
2405 $d = str_replace("</dd>", "", $d);
2406 $d = str_replace("<p>", "", $d);
2407 $d = str_replace("</p>", "", $d);
2408 //restore html entities into characters
2409 // http://www.php.net/manual/en/function.htmlentities.php
2410 $trans = get_html_translation_table (HTML_ENTITIES);
2411 $trans = array_flip ($trans);
2412 $d = strtr($d, $trans);
2416 include_once(dirname(__FILE__)."/lib/stdlib.php");
2419 // Function to create better user passwords (much larger keyspace),
2420 // suitable for user passwords.
2421 // Sequence of random ASCII numbers, letters and some special chars.
2422 // Note: There exist other algorithms for easy-to-remember passwords.
2423 function random_good_password ($minlength = 5, $maxlength = 8) {
2425 // assume ASCII ordering (not valid on EBCDIC systems!)
2426 $valid_chars = "!#%&+-.0123456789=@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz";
2427 $start = ord($valid_chars);
2428 $end = ord(substr($valid_chars,-1));
2430 if (function_exists('mt_rand')) // mersenne twister
2431 $length = mt_rand($minlength, $maxlength);
2432 else // the usually bad glibc rand()
2433 $length = rand($minlength, $maxlength);
2434 while ($length > 0) {
2435 if (function_exists('mt_rand'))
2436 $newchar = mt_rand($start, $end);
2438 $newchar = rand($start, $end);
2439 if (! strrpos($valid_chars,$newchar) ) continue; // skip holes
2440 $newpass .= sprintf("%c", $newchar);
2447 function printArray($a) {
2448 echo "<hr />\n<pre>\n";
2450 echo "\n</pre>\n<hr />\n";
2453 // end of class definitions
2454 /////////////////////////////
2455 // begin auto generation code
2457 if (!function_exists('is_a')) {
2458 function is_a($object, $class) {
2459 $class = strtolower($class);
2460 return (get_class($object) == $class) or is_subclass_of($object, $class);
2464 if (!empty($HTTP_POST_VARS['action'])
2465 and $HTTP_POST_VARS['action'] == 'make_config'
2466 and !empty($HTTP_POST_VARS['ADMIN_USER'])
2467 and !empty($HTTP_POST_VARS['ADMIN_PASSWD'])
2471 $timestamp = date ('dS \of F, Y H:i:s');
2474 ; This is a local configuration file for PhpWiki.
2475 ; It was automatically generated by the configurator script
2476 ; on the $timestamp.
2481 $posted = $GLOBALS['HTTP_POST_VARS'];
2482 /*if (defined('DEBUG'))
2483 printArray($GLOBALS['HTTP_POST_VARS']);*/
2485 foreach ($properties as $option_name => $a) {
2486 $posted_value = stripslashes($posted[$a->config_item_name]);
2487 $config .= $properties[$option_name]->get_config($posted_value);
2492 if (is_writable($fs_config_file)) {
2493 // We first check if the config-file exists.
2494 if (file_exists($fs_config_file)) {
2495 // We make a backup copy of the file
2496 $new_filename = preg_replace('/\.ini$/', '-' . time() . '.ini', $fs_config_file);
2497 if (@copy($fs_config_file, $new_filename)) {
2498 $fp = @fopen($fs_config_file, 'w');
2501 $fp = @fopen($fs_config_file, 'w');
2509 fputs($fp, utf8_encode($config));
2511 echo "<p>The configuration was written to <code><b>$config_file</b></code>.</p>\n";
2512 if ($new_filename) {
2513 echo "<p>A backup was made to <code><b>$new_filename</b></code>.</p>\n";
2515 ; //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";
2518 echo "<p>The configuration file could <b>not</b> be written.<br />\n",
2519 " You should copy the above configuration to a file, ",
2520 "and manually save it as <code><b>config/config.ini</b></code>.</p>\n";
2523 echo "<hr />\n<p>Here's the configuration file based on your answers:</p>\n";
2524 echo "<form method=\"get\" action=\"", $configurator, "\">\n";
2525 echo "<textarea id='config-output' readonly='readonly' style='width:100%;' rows='30' cols='100'>\n";
2526 echo htmlentities($config, ENT_COMPAT, "UTF-8");
2527 echo "</textarea></form>\n";
2530 echo "<p>To make any corrections, <a href=\"configurator.php\">edit the settings again</a>.</p>\n";
2532 } else { // first time or create password
2533 $posted = $GLOBALS['HTTP_POST_VARS'];
2534 // No action has been specified - we make a form.
2536 if (!empty($GLOBALS['HTTP_GET_VARS']['start_debug']))
2537 $configurator .= ("?start_debug=" . $GLOBALS['HTTP_GET_VARS']['start_debug']);
2539 <form action="',$configurator,'" method="post">
2540 <input type="hidden" name="action" value="make_config" />
2541 <table cellpadding="4" cellspacing="0">
2544 while (list($property, $obj) = each($properties)) {
2545 echo $obj->get_instructions($property);
2546 if ($h = $obj->get_html()) {
2547 if (defined('DEBUG') and DEBUG) $h = get_class($obj) . "<br />\n" . $h;
2548 echo "<td>".$h."</td>\n";
2555 <p><input type="submit" id="submit" value="Save ',$config_file,'" /> <input type="reset" value="Clear" /></p>