4 * validate input (fix javascript, add POST checks)
5 * start this automatically the first time
7 * eval index-user.php or index.php to get the actual settings.
8 * ask to store it in index.php or index-user.php
10 * The file index-user.php will be generated which you can use as your index.php.
14 $config_file = 'index-user.php';
15 $fs_config_file = dirname(__FILE__) . (substr(PHP_OS,0,3) == 'WIN' ? '\\' : "/") . $config_file;
16 if (isset($HTTP_POST_VARS['create'])) header('Location: configurator.php?create=1#create');
17 printf("<?xml version=\"1.0\" encoding=\"%s\"?>\n", 'iso-8859-1');
19 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
20 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
21 <html xmlns="http://www.w3.org/1999/xhtml">
23 <!-- $Id: configurator.php,v 1.21 2004-02-22 23:20:31 rurban Exp $ -->
24 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
25 <title>Configuration tool for PhpWiki 1.3.x</title>
26 <style type="text/css" media="screen">
28 /* TABLE { border: thin solid black } */
29 body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 80%; }
30 pre { font-size: 120%; }
31 td { border: thin solid black }
33 tr.hidden { border: none; display: none; }
34 td.part { background-color: #eeaaaa; color: inherit; }
35 td.instructions { background-color: #ffffee; width: <?php echo $tdwidth ?>px; color: inherit; }
36 td.unchangeable-variable-top { border-bottom: none; background-color: #eeeeee; color:inherit; }
37 td.unchangeable-variable-left { border-top: none; background-color: #eeeeee; color:inherit; }
40 <script language="JavaScript" type="text/javascript">
42 function update(accepted, error, value, output) {
44 document.getElementById(output).innerHTML = "<font color=\"green\">Input accepted.</font>";
46 while ((index = error.indexOf("%s")) > -1) {
47 error = error.substring(0, index) + value + error.substring(index+2);
49 document.getElementById(output).innerHTML = "<font color=\"red\">" + error + "</font>";
53 function validate(error, value, output, field) {
54 update(field.value == value, error, field.value, output);
57 function validate_ereg(error, ereg, output, field) {
58 regex = new RegExp(ereg);
59 update(regex.test(field.value), error, field.value, output);
62 function validate_range(error, low, high, empty_ok, output, field) {
63 update((empty_ok == 1 && field.value == "") ||
64 (field.value >= low && field.value <= high),
65 error, field.value, output);
68 function toggle_group(id) {
69 var text = document.getElementById(id + "_text");
71 if (text.innerHTML == "Hide options.") {
73 text.innerHTML = "Show options.";
75 text.innerHTML = "Hide options.";
78 var rows = document.getElementsByTagName('tr');
80 for (i = 0; i < rows.length; i++) {
82 if (tr.className == 'header' && tr.id == id) {
87 for (; i < rows.length; i++) {
89 if (tr.className == 'header')
91 tr.className = do_hide ? 'hidden': 'nonhidden';
96 // Hide all groups. We do this via JavaScript to avoid
97 // hiding the groups if JavaScript is not supported...
98 var rows = document.getElementsByTagName('tr');
99 for (var i = 0; i < rows.length; i++) {
101 if (tr.className == 'header')
105 // Select text in textarea upon focus
106 var area = document.getElementById('config-output');
108 listener = { handleEvent: function (e) { area.select(); } };
109 area.addEventListener('focus', listener, false);
116 <body onload="do_init();">
118 <h1>Configuration tool for PhpWiki 1.3.x</h1>
121 //define('DEBUG', 1);
123 * The Configurator is a php script to aid in the configuration of PhpWiki.
124 * Parts of this file are based on PHPWeather's configurator.php file.
125 * http://sourceforge.net/projects/phpweather/
128 * TO CHANGE THE CONFIGURATION OF YOUR PHPWIKI, DO *NOT* MODIFY THIS FILE!
129 * more instructions go here
132 * * start this automatically the first time
134 * * eval index.php to get the actual settings.
135 * * ask to store it in index.php or settings.php
137 * The file settings.php will be generated which you can use as your index.php.
141 //////////////////////////////
142 // begin configuration options
146 * Notes for the description parameter of $property:
148 * - Descriptive text will be changed into comments (preceeded by //)
149 * for the final output to index.php.
151 * - Only a limited set of html is allowed: pre, dl dt dd; it will be
152 * stripped from the final output.
154 * - Line breaks and spacing will be preserved for the final output.
156 * - Double line breaks are automatically converted to paragraphs
157 * for the html version of the descriptive text.
159 * - Double-quotes and dollar signs in the descriptive text must be
160 * escaped: \" and \$. Instead of escaping double-quotes you can use
161 * single (') quotes for the enclosing quotes.
163 * - Special characters like < and > must use html entities,
164 * they will be converted back to characters for the final output.
167 $SEPARATOR = "///////////////////////////////////////////////////////////////////";
170 Copyright 1999, 2000, 2001, 2002 $ThePhpWikiProgrammingTeam = array(
171 "Steve Wainstead", "Clifford A. Adams", "Lawrence Akka",
172 "Scott R. Anderson", "Jon Åslund", "Neil Brown", "Jeff Dairiki",
173 "Stéphane Gourichon", "Jan Hidders", "Arno Hollosi", "John Jorgensen",
174 "Antti Kaihola", "Jeremie Kass", "Carsten Klapp", "Marco Milanesi",
175 "Grant Morgan", "Jan Nieuwenhuizen", "Aredridel Niothke",
176 "Pablo Roca Rozas", "Sandino Araico Sánchez", "Joel Uckelman",
177 "Reini Urban", "Tim Voght", "Jochen Kalmbach");
179 This file is part of PhpWiki.
181 PhpWiki is free software; you can redistribute it and/or modify
182 it under the terms of the GNU General Public License as published by
183 the Free Software Foundation; either version 2 of the License, or
184 (at your option) any later version.
186 PhpWiki is distributed in the hope that it will be useful,
187 but WITHOUT ANY WARRANTY; without even the implied warranty of
188 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
189 GNU General Public License for more details.
191 You should have received a copy of the GNU General Public License
192 along with PhpWiki; if not, write to the Free Software
193 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
199 This is the starting file for PhpWiki. All this file does is set
200 configuration options, and at the end of the file it includes() the
201 file lib/main.php, where the real action begins.
203 If you include this file to override the default settings here,
204 you must also include lib/main.php.
206 This file is divided into seven parts: Parts Zero, One, Two, Three,
207 Four, Five and Six. Each one has different configuration settings you can
208 change; in all cases the default should work on your system,
209 however, we recommend you tailor things to your particular setting.
214 $properties["Part Zero"] =
215 new part('_part0', false, "
216 Part Zero: If PHP needs help in finding where you installed the
217 rest of the PhpWiki code, you can set the include_path here.");
219 if (substr(PHP_OS,0,3) == 'WIN') {
220 $include_path = dirname(__FILE__) . ';' . ini_get('include_path');
221 if (strchr(ini_get('include_path'),'/'))
222 $include_path = strtr($include_path,'\\','/');
224 $include_path = dirname(__FILE__) . ':' . ini_get('include_path');
227 $properties["PHP include_path"] =
228 new _ini_set('include_path', $include_path, "
229 Define PHP's include path so that it can find the PHP source code
232 You shouldn't need to do this unless you've moved index.php out
233 of the PhpWiki install directory.
235 Note that on Windows-based servers, you should use ; rather than :
236 as the path separator.");
238 $properties["Part Null"] =
239 new part('_partnullheader', "", "
240 Part Null: Don't touch this!");
244 $properties["Part Null Settings"] =
245 new unchangeable_variable('_partnullsettings', "
246 define ('PHPWIKI_VERSION', '1.3.8pre');
247 require \"lib/prepend.php\";
248 rcs_id('\$Id: configurator.php,v 1.21 2004-02-22 23:20:31 rurban Exp $');", "");
250 $properties["Part One"] =
251 new part('_partone', $SEPARATOR."\n", "
254 Authentication and security settings. See Part Three for more.
259 $properties["Wiki Name"] =
260 new _define_optional('WIKI_NAME', 'PhpWiki', "
261 The name of your wiki.
262 This is used to generate a keywords meta tag in the HTML templates,
263 in bookmark titles for any bookmarks made to pages in your wiki,
264 and during RSS generation for the title of the RSS channel.");
267 $properties["Reverse DNS"] =
268 new boolean_define_optional
269 ('ENABLE_REVERSE_DNS',
270 array('true' => "true. perform additional reverse dns lookups",
271 'false' => "false. just record the address as given by the httpd server"),
273 If set, we will perform reverse dns lookups to try to convert the
274 users IP number to a host name, even if the http server didn't do it for us.");
276 $properties["Admin Username"] =
277 new _define_optional_notempty('ADMIN_USER', "", "
278 You must set this! Username and password of the administrator.",
279 "onchange=\"validate_ereg('Sorry, ADMIN_USER cannot be empty.', '^.+$', 'ADMIN_USER', this);\"");
281 $properties["Admin Password"] =
282 new _define_password_optional('ADMIN_PASSWD', "", "
283 For heaven's sake pick a good password.
284 If your version of PHP supports encrypted passwords, your password will be
285 automatically encrypted within the generated config file.
286 Use the \"Create Password\" button to create a good (random) password.",
287 "onchange=\"validate_ereg('Sorry, ADMIN_PASSWD must be at least 4 chars long.', '^....+$', 'ADMIN_PASSWD', this);\"");
290 $properties["ZIPdump Authentication"] =
291 new boolean_define_optional('ZIPDUMP_AUTH',
292 array('false' => "false. Everyone may download zip dumps",
293 'true' => "true. Only admin may download zip dumps"), "
294 If true, only the admin user can make zip dumps, else zip dumps
295 require no authentication.");
297 $properties["Enable Plugin RawHtml"] =
298 new boolean_define_commented_optional
300 array('true' => "Enabled",
301 'false' => "Disabled."), "
302 Allow < ?plugin RawHtml ...>. Define to false to disalbe the RawHtml plugin.");
304 $properties["Strict Mailable Pagedumps"] =
305 new boolean_define_optional
306 ('STRICT_MAILABLE_PAGEDUMPS',
307 array('false' => "binary",
308 'true' => "quoted-printable"),
310 If you define this to true, (MIME-type) page-dumps (either zip dumps,
311 or \"dumps to directory\" will be encoded using the quoted-printable
312 encoding. If you're actually thinking of mailing the raw page dumps,
313 then this might be useful, since (among other things,) it ensures
314 that all lines in the message body are under 80 characters in length.
316 Also, setting this will cause a few additional mail headers
317 to be generated, so that the resulting dumps are valid
318 RFC 2822 e-mail messages.
320 Probably, you can just leave this set to false, in which case you get
321 raw ('binary' content-encoding) page dumps.");
325 $properties["HTML Dump Filename Suffix"] =
326 new _variable('HTML_DUMP_SUFFIX', ".html", "
327 Here you can change the filename suffix used for XHTML page dumps.
328 If you don't want any suffix just comment this out.");
332 //FIXME: should be numeric_define_optional
333 $properties["Maximum Upload Size"] =
334 new numeric_define('MAX_UPLOAD_SIZE', "16 * 1024 * 1024", "
335 The maximum file upload size.");
339 //FIXME: should be numeric_define_optional
340 $properties["Minor Edit Timeout"] =
341 new numeric_define('MINOR_EDIT_TIMEOUT', "7 * 24 * 3600", "
342 If the last edit is older than MINOR_EDIT_TIMEOUT seconds, the
343 default state for the \"minor edit\" checkbox on the edit page form
348 $properties["Disabled Actions"] =
349 new array_variable('DisabledActions', array(), "
350 Actions listed in this array will not be allowed. Actions are:
351 browse, create, diff, dumphtml, dumpserial, edit, loadfile, lock, remove,
352 unlock, upload, viewsource, zip, ziphtml");
354 $properties["Access Log"] =
355 new _define_commented('ACCESS_LOG', "/var/logs/wiki_access.log", "
356 PhpWiki can generate an access_log (in \"NCSA combined log\" format)
357 for you. If you want one, define this to the name of the log file,
358 such as /tmp/wiki_access_log.");
360 $properties["Compress Output"] =
361 new boolean_define_commented_optional
363 array('' => 'Compress when PhpWiki thinks approriate.',
364 'false' => 'Never compress output.',
365 'true' => 'Always try to compress output.'),
367 By default PhpWiki will try to have PHP compress it's output
368 before sending it to the browser (if you have a recent enough
369 version of PHP and the browser supports it.)
371 Define COMPRESS_OUTPUT to false to prevent output compression.
373 Define COMPRESS_OUTPUT to true to force output compression,
374 even if we think your version of PHP does this in a buggy
377 Leave it undefined to leave the choice up to PhpWiki.");
379 $properties["HTTP Cache Control"] =
380 new _define_selection_optional
382 array('LOOSE' => 'LOOSE',
383 'STRICT' => 'STRICT',
385 'ALLOW_STALE' => 'ALLOW_STALE'),
389 This controls how PhpWiki sets the HTTP cache control
390 headers (Expires: and Cache-Control:)
396 <dd>This is roughly the old (pre 1.3.4) behavior. PhpWiki will
397 instruct proxies and browsers never to cache PhpWiki output.</dd>
400 <dd>Cached pages will be invalidated whenever the database global
401 timestamp changes. This should behave just like NONE (modulo
402 bugs in PhpWiki and your proxies and browsers), except that
403 things will be slightly more efficient.</dd>
406 <dd>Cached pages will be invalidated whenever they are edited,
407 or, if the pages include plugins, when the plugin output could
408 concievably have changed.
410 <p>Behavior should be much like STRICT, except that sometimes
411 wikilinks will show up as undefined (with the question mark)
412 when in fact they refer to (recently) created pages.
413 (Hitting your browsers reload or perhaps shift-reload button
414 should fix the problem.)</p></dd>
417 <dd>Proxies and browsers will be allowed to used stale pages.
418 (The timeout for stale pages is controlled by CACHE_CONTROL_MAX_AGE.)
420 <p>This setting will result in quirky behavior. When you edit a
421 page your changes may not show up until you shift-reload the
424 <p>This setting is generally not advisable, however it may be useful
425 in certain cases (e.g. if your wiki gets lots of page views,
426 and few edits by knowledgable people who won't freak over the quirks.)</p>
429 The default is currently LOOSE.");
431 // FIXME: should be numeric_define_optional
432 $properties["HTTP Cache Control Max Age"] =
433 new numeric_define('CACHE_CONTROL_MAX_AGE', 600,
435 Maximum page staleness, in seconds.");
437 $properties["Markup Caching"] =
438 new boolean_define_commented_optional
439 ('WIKIDB_NOCACHE_MARKUP',
440 array('false' => 'Enable markup cache',
441 'true' => 'Disable markup cache'),
445 PhpWiki normally caches a preparsed version (i.e. mostly
446 converted to HTML) of the most recent version of each page.
447 (Parsing the wiki-markup takes a fair amount of CPU.)
449 Define WIKIDB_NOCACHE_MARKUP to true to disable the
450 caching of marked-up page content.
452 Note that you can also disable markup caching on a per-page
453 temporary basis by addinging a query arg of '?nocache=1'
454 to the URL to the page. (Use '?nocache=purge' to completely
455 discard the cached version of the page.)
457 You can also purge the cached markup globally by using the
458 \"Purge Markup Cache\" button on the PhpWikiAdministration page.");
461 $properties["Path for PHP Session Support"] =
462 new _ini_set('session.save_path', '/tmp', "
463 The login code now uses PHP's session support. Usually, the default
464 configuration of PHP is to store the session state information in
465 /tmp. That probably will work fine, but fails e.g. on clustered
466 servers where each server has their own distinct /tmp (this is the
467 case on SourceForge's project web server.) You can specify an
468 alternate directory in which to store state information like so
469 (whatever user your httpd runs as must have read/write permission
470 in this directory):");
474 $properties["Disable PHP Transparent Session ID"] =
475 new unchangeable_ini_set('session.use_trans_sid', "@ini_set('session.use_trans_sid', 0);", "
476 If your php was compiled with --enable-trans-sid it tries to
477 add a PHPSESSID query argument to all URL strings when cookie
478 support isn't detected in the client browser. For reasons
479 which aren't entirely clear (PHP bug) this screws up the URLs
480 generated by PhpWiki. Therefore, transparent session ids
481 should be disabled. This next line does that.
483 (At the present time, you will not be able to log-in to PhpWiki,
484 or set any user preferences, unless your browser supports cookies.)");
488 ///////// database selection
491 $properties["Part Two"] =
492 new part('_parttwo', $SEPARATOR."\n", "
499 $properties["Database Type"] =
500 new _variable_selection("DBParams|dbtype",
501 array('dba' => "dba DBM",
503 'ADODB' => "SQL ADODB",
504 'cvs' => "CVS File handler"), "
505 Select the database backend type:
506 Choose ADODB or SQL to use an SQL database with ADODB or PEAR.
507 Choose dba to use one of the standard UNIX dbm libraries.
508 CVS is not yet tested nor supported.
509 Recommended is SQL PEAR.");
511 $properties["Filename / Table name Prefix"] =
512 new _variable_commented("DBParams|prefix", "phpwiki_", "
513 Used by all DB types:
515 Prefix for filenames or table names
517 Currently you MUST EDIT THE SQL file too (in the schemas/
518 directory because we aren't doing on the fly sql generation
519 during the installation.");
522 $properties["SQL dsn Setup"] =
523 new unchangeable_variable('_sqldsnstuff', "", "
524 For SQL based backends, specify the database as a DSN
525 The most general form of a DSN looks like:
527 phptype(dbsyntax)://username:password@protocol+hostspec/database
529 For a MySQL database, the following should work:
531 mysql://user:password@host/databasename
533 To connect over a unix socket, use something like
535 mysql://user:password@unix(/path/to/socket)/databasename
537 <pre>'dsn' => 'mysql://guest@:/var/lib/mysql/mysql.sock/test',
538 'dsn' => 'mysql://guest@localhost/test',
539 'dsn' => 'pgsql://localhost/test',</pre>");
541 // Choose ADODB or SQL to use an SQL database with ADODB or PEAR.
542 // Choose dba to use one of the standard UNIX dbm libraries.
544 $properties["SQL Type"] =
545 new _variable_selection('_dsn_sqltype',
546 array('mysql' => "MySQL",
547 'pgsql' => "PostgreSQL"), "
552 $properties["SQL User"] =
553 new _variable('_dsn_sqluser', "wikiuser", "
558 $properties["SQL Password"] =
559 new _variable('_dsn_sqlpass', "", "
564 $properties["SQL Database Host"] =
565 new _variable('_dsn_sqlhostorsock', "localhost", "
566 SQL Database Hostname:
568 To connect over a local named socket, use something like
570 unix(/var/lib/mysql/mysql.sock)
576 $properties["SQL Database Name"] =
577 new _variable('_dsn_sqldbname', "phpwiki", "
578 SQL Database Name:");
580 list($dsn_sqltype,) = $properties["SQL Type"]->value();
581 $dsn_sqluser = $properties["SQL User"]->value();
582 $dsn_sqlpass = $properties["SQL Password"]->value();
583 $dsn_sqlhostorsock = $properties["SQL Database Host"]->value();
584 $dsn_sqldbname = $properties["SQL Database Name"]->value();
586 $properties["SQL dsn"] =
587 new unchangeable_variable("DBParams['dsn']",
588 "\$DBParams['dsn'] = \"\$_dsn_sqltype://{$dsn_sqluser}:{$dsn_sqlpass}@{$dsn_sqlhostorsock}/{$dsn_sqldbname}\";", "");
590 $properties["dba directory"] =
591 new _variable("DBParams|directory", "/tmp", "
595 $properties["dba handler"] =
596 new _variable_selection('DBParams|dba_handler',
597 array('gdbm' => "Gdbm - GNU database manager",
598 'dbm' => "DBM - Redhat default. On sf.net there's dbm and gdbm",
599 'db2' => "DB2 - Sleepycat Software's DB2",
600 'db3' => "DB3 - Sleepycat Software's DB3. Fine on Windows but not on every Linux"), "
601 Use 'gdbm', 'dbm', 'db2' or 'db3' depending on your DBA handler methods supported:");
603 $properties["dba timeout"] =
604 new _variable("DBParams|timeout", "20", "
605 Recommended values are 20 or 5.");
613 $properties["Page Revisions"] =
614 new unchangeable_variable('_parttworevisions', "", "
616 The next section controls how many old revisions of each page are
617 kept in the database.
619 There are two basic classes of revisions: major and minor. Which
620 class a revision belongs in is determined by whether the author
621 checked the \"this is a minor revision\" checkbox when they saved the
624 There is, additionally, a third class of revisions: author
625 revisions. The most recent non-mergable revision from each distinct
626 author is and author revision.
628 The expiry parameters for each of those three classes of revisions
629 can be adjusted seperately. For each class there are five
630 parameters (usually, only two or three of the five are actually
631 set) which control how long those revisions are kept in the
634 <dt>max_keep:</dt> <dd>If set, this specifies an absolute maximum for the
635 number of archived revisions of that class. This is
636 meant to be used as a safety cap when a non-zero
637 min_age is specified. It should be set relatively high,
638 and it's purpose is to prevent malicious or accidental
639 database overflow due to someone causing an
640 unreasonable number of edits in a short period of time.</dd>
642 <dt>min_age:</dt> <dd>Revisions younger than this (based upon the supplanted
643 date) will be kept unless max_keep is exceeded. The age
644 should be specified in days. It should be a
645 non-negative, real number,</dd>
647 <dt>min_keep:</dt> <dd>At least this many revisions will be kept.</dd>
649 <dt>keep:</dt> <dd>No more than this many revisions will be kept.</dd>
651 <dt>max_age:</dt> <dd>No revision older than this age will be kept.</dd>
653 Supplanted date: Revisions are timestamped at the instant that they
654 cease being the current revision. Revision age is computed using
655 this timestamp, not the edit time of the page.
657 Merging: When a minor revision is deleted, if the preceding
658 revision is by the same author, the minor revision is merged with
659 the preceding revision before it is deleted. Essentially: this
660 replaces the content (and supplanted timestamp) of the previous
661 revision with the content after the merged minor edit, the rest of
662 the page metadata for the preceding version (summary, mtime, ...)
667 // For now the expiration parameters are statically inserted as
668 // an unchangeable property. You'll have to edit the resulting
669 // config file if you really want to change these from the default.
671 $properties["Expiration Parameters for Major Edits"] =
672 new unchangeable_variable('ExpireParams|major',
673 "\$ExpireParams['major'] = array('max_age' => 32,
675 Keep up to 8 major edits, but keep them no longer than a month.");
677 $properties["Expiration Parameters for Minor Edits"] =
678 new unchangeable_variable('ExpireParams|minor',
679 "\$ExpireParams['minor'] = array('max_age' => 7,
681 Keep up to 4 minor edits, but keep them no longer than a week.");
685 $properties["Expiration Parameters by Author"] =
686 new unchangeable_variable('ExpireParams|author',
687 "\$ExpireParams['author'] = array('max_age' => 365,
690 'max_keep' => 20);", "
691 Keep the latest contributions of the last 8 authors up to a year.
692 Additionally, (in the case of a particularly active page) try to
693 keep the latest contributions of all authors in the last week (even
694 if there are more than eight of them,) but in no case keep more
695 than twenty unique author revisions.");
697 /////////////////////////////////////////////////////////////////////
699 $properties["Part Three"] =
700 new part('_partthree', $SEPARATOR."\n", "
702 Part Three: (optional)
706 $properties["User Authentication"] =
707 new boolean_define_optional('ALLOW_USER_LOGIN',
708 array('true' => "true. Check any defined passwords. (Default)",
709 'false' => "false. Don't check passwords. Legacy < 1.3.4"), "
710 If ALLOW_USER_LOGIN is true, any defined internal and external
711 authentication method is tried.
712 If not, we don't care about passwords, but check the next two constants.");
714 $properties["HTTP Authentication"] =
715 new boolean_define_optional('ALLOW_HTTP_AUTH_LOGIN',
716 array('false' => "false. Ignore HTTP Authentication. (Default)",
717 'true' => "true. Allow .htpasswd users login automatically."), "
718 The wiki can be optionally be protected by HTTP Auth. Use the username and password
719 from there, and if this fails, try the other methods also.");
721 $properties["Strict Login"] =
722 new boolean_define_optional('ALLOW_BOGO_LOGIN',
723 array('true' => "Users may Sign In with any WikiWord",
724 'false' => "Only admin may Sign In"), "
725 If ALLOW_BOGO_LOGIN is true, users are allowed to login (with
726 any/no password) using any userid which: 1) is not the ADMIN_USER,
727 2) is a valid WikiWord (matches \$WikiNameRegexp.)
728 If true, users may be created by themselves. Otherwise we need seperate auth.");
730 $properties["Require Sign In Before Editing"] =
731 new boolean_define_optional('REQUIRE_SIGNIN_BEFORE_EDIT',
732 array('false' => "Do not require Sign In",
733 'true' => "Require Sign In"), "
734 If set, then if an anonymous user attempts to edit a page he will
735 be required to sign in. (If ALLOW_BOGO_LOGIN is true, of course,
736 no password is required, but the user must still sign in under
737 some sort of BogoUserId.)");
739 if (function_exists('ldap_connect')) {
740 $properties["LDAP Authentication"] =
741 new boolean_define_optional('ALLOW_LDAP_LOGIN',
742 array('true' => "Allow LDAP Authentication",
743 'false' => "Ignore LDAP"), "
746 $properties["LDAP Host"] =
747 new _define_optional('LDAP_AUTH_HOST', "localhost", "");
748 $properties["LDAP Root Search"] =
749 new _define_optional('LDAP_BASE_DN', "ou=mycompany.com,o=My Company", "
750 Give the right LDAP root search information in the next statement.");
754 $properties["LDAP Authentication"] =
755 new unchangeable_define('ALLOW_LDAP_LOGIN', "
756 if (!defined('ALLOW_LDAP_LOGIN')) define('ALLOW_LDAP_LOGIN', true and function_exists('ldap_connect'));
757 if (!defined('LDAP_AUTH_HOST')) define('LDAP_AUTH_HOST', 'localhost');
758 // Give the right LDAP root search information in the next statement.
759 if (!defined('LDAP_BASE_DN')) define('LDAP_BASE_DN', 'ou=mycompany.com,o=My Company');
761 Ignored. No LDAP support in this php. configure --with-ldap");
764 if (function_exists('imap_open')) {
765 $properties["IMAP Authentication"] =
766 new boolean_define_optional('ALLOW_IMAP_LOGIN',
767 array('true' => "Allow IMAP Authentication",
768 'false' => "Ignore IMAP"), "
771 $properties["IMAP Host"] =
772 new _define_optional('IMAP_AUTH_HOST', 'localhost', '');
774 $properties["IMAP Authentication"] =
775 new unchangeable_define('ALLOW_IMAP_LOGIN',"
776 // IMAP auth: check userid/passwords from a imap server, defaults to localhost
777 if (!defined('ALLOW_IMAP_LOGIN')) define('ALLOW_IMAP_LOGIN', true and function_exists('imap_open'));
778 if (!defined('IMAP_AUTH_HOST')) define('IMAP_AUTH_HOST', 'localhost');
779 ", "Ignored. No IMAP support in this php. configure --with-imap");
783 /////////////////////////////////////////////////////////////////////
785 $properties["Part Four"] =
786 new part('_partfour', $SEPARATOR."\n", "
789 Page appearance and layout
794 $properties["Theme"] =
795 new _define_selection_optional('THEME',
796 array('default' => "default",
797 'Hawaiian' => "Hawaiian",
798 'MacOSX' => "MacOSX",
799 'Portland' => "Portland",
800 'Sidebar' => "Sidebar",
801 'SpaceWiki' => "SpaceWiki"), "
804 Most of the page appearance is controlled by files in the theme
807 There are a number of pre-defined themes shipped with PhpWiki.
808 Or you may create your own (e.g. by copying and then modifying one of
813 define('THEME', 'default');
814 define('THEME', 'Hawaiian');
815 define('THEME', 'MacOSX');
816 define('THEME', 'Portland');
817 define('THEME', 'Sidebar');
818 define('THEME', 'SpaceWiki');</pre>");
822 $properties["Character Set"] =
823 new _define_optional('CHARSET', 'iso-8859-1', "
824 Select a valid charset name to be inserted into the xml/html pages,
825 and to reference links to the stylesheets (css). For more info see:
826 http://www.iana.org/assignments/character-sets. Note that PhpWiki
827 has been extensively tested only with the latin1 (iso-8859-1)
830 If you change the default from iso-8859-1 PhpWiki may not work
831 properly and it will require code modifications. However, character
832 sets similar to iso-8859-1 may work with little or no modification
833 depending on your setup. The database must also support the same
834 charset, and of course the same is true for the web browser. (Some
835 work is in progress hopefully to allow more flexibility in this
836 area in the future).");
840 $properties["Language"] =
841 new _define_selection_optional('DEFAULT_LANGUAGE',
842 array('en' => "English",
843 'nl' => "Nederlands",
851 Select your language/locale - default language is \"en\" for English.
852 Other languages available:<pre>
853 English \"en\" (English - HomePage)
854 Dutch \"nl\" (Nederlands - ThuisPagina)
855 Spanish \"es\" (Español - PáginaPrincipal)
856 French \"fr\" (Français - Accueil)
857 German \"de\" (Deutsch - StartSeite)
858 Swedish \"sv\" (Svenska - Framsida)
859 Italian \"it\" (Italiano - PaginaPrincipale)
860 Japanese \"ja\" (Japanese - ¥Û¡¼¥à¥Ú¡¼¥¸)
862 If you set DEFAULT_LANGUAGE to the empty string, your systems default language
863 (as determined by the applicable environment variables) will be
866 $properties["Wiki Page Source"] =
867 new _define_optional('WIKI_PGSRC', 'pgsrc', "
868 WIKI_PGSRC -- specifies the source for the initial page contents of
869 the Wiki. The setting of WIKI_PGSRC only has effect when the wiki is
870 accessed for the first time (or after clearing the database.)
871 WIKI_PGSRC can either name a directory or a zip file. In either case
872 WIKI_PGSRC is scanned for files -- one file per page.
874 // Default (old) behavior:
875 define('WIKI_PGSRC', 'pgsrc');
877 define('WIKI_PGSRC', 'wiki.zip');
879 '../Logs/Hamwiki/hamwiki-20010830.zip');
884 $properties["Default Wiki Page Source"] =
885 new _define('DEFAULT_WIKI_PGSRC', 'pgsrc', "
886 DEFAULT_WIKI_PGSRC is only used when the language is *not* the
887 default (English) and when reading from a directory: in that case
888 some English pages are inserted into the wiki as well.
889 DEFAULT_WIKI_PGSRC defines where the English pages reside.
891 FIXME: is this really needed?
896 $properties["Generic Pages"] =
897 new array_variable('GenericPages', array('ReleaseNotes', 'SteveWainstead', 'TestPage'), "
898 These are the pages which will get loaded from DEFAULT_WIKI_PGSRC.
900 FIXME: is this really needed? Can't we just copy these pages into
907 $properties["Part Five"] =
908 new part('_partfive', $SEPARATOR."\n", "
916 $properties["Allowed Protocols"] =
917 new list_variable('AllowedProtocols', 'http|https|mailto|ftp|news|nntp|ssh|gopher', "
918 allowed protocols for links - be careful not to allow \"javascript:\"
919 URL of these types will be automatically linked.
920 within a named link [name|uri] one more protocol is defined: phpwiki");
924 $properties["Inline Images"] =
925 new list_variable('InlineImages', 'png|jpg|gif', "
926 URLs ending with the following extension should be inlined as images");
930 $properties["WikiName Regexp"] =
931 new _variable('WikiNameRegexp', "(?<![[:alnum:]])(?:[[:upper:]][[:lower:]]+){2,}(?![[:alnum:]])", "
932 Perl regexp for WikiNames (\"bumpy words\")
933 (?<!..) & (?!...) used instead of '\b' because \b matches '_' as well");
935 $properties["Subpage Separator"] =
936 new _define_optional('SUBPAGE_SEPARATOR', '/', "
937 One character which seperates pages from subpages. Defaults to '/', but '.' or ':' were also used.",
938 "onchange=\"validate_ereg('Sorry, \'%s\' must be a single character. Currently only :, / or .', '^[/:.]$', 'SUBPAGE_SEPARATOR', this);\""
941 $properties["InterWiki Map File"] =
942 new _define('INTERWIKI_MAP_FILE', 'lib/interwiki.map', "
943 InterWiki linking -- wiki-style links to other wikis on the web
945 The map will be taken from a page name InterWikiMap.
946 If that page is not found (or is not locked), or map
947 data can not be found in it, then the file specified
948 by INTERWIKI_MAP_FILE (if any) will be used.");
950 $properties["WARN_NONPUBLIC_INTERWIKIMAP"] =
951 new boolean_define('WARN_NONPUBLIC_INTERWIKIMAP',
952 array('true' => "true",
953 'false' => "false"), "
954 Display a warning if the internal lib/interwiki.map is used, and
955 not the public InterWikiMap page. This map is not readable from outside.");
957 $properties["Keyword Link Regexp"] =
958 new _variable('KeywordLinkRegexp',
959 '(?<=^Category|^Topic)[[:upper:]].*$',
961 Regexp used for automatic keyword extraction.
963 Any links on a page to pages whose names match this regexp will
964 be used keywords in the keywords meta tag. (This is an aid to
965 classification by search engines.) The value of the match is
968 The default behavior is to match Category* and Topic* links.");
970 $properties["Part Six"] =
971 new part('_partsix', $SEPARATOR."\n", "
974 URL options -- you can probably skip this section.
977 $properties["Server Name"] =
978 new _define_commented_optional('SERVER_NAME', $HTTP_SERVER_VARS['SERVER_NAME'], "
979 Canonical name and httpd port of the server on which this PhpWiki
984 $properties["Server Port"] =
985 new numeric_define_commented('SERVER_PORT', $HTTP_SERVER_VARS['SERVER_PORT'], "",
986 "onchange=\"validate_ereg('Sorry, \'%s\' is no valid port number.', '^[0-9]+$', 'SERVER_PORT', this);\"");
988 $scriptname = preg_replace('/configurator.php/','index.php',$HTTP_SERVER_VARS["SCRIPT_NAME"]);
990 $properties["Script Name"] =
991 new _define_commented_optional('SCRIPT_NAME', $scriptname, "
992 Relative URL (from the server root) of the PhpWiki script.");
994 $properties["Data Path"] =
995 new _define_commented_optional('DATA_PATH', dirname($scriptname), "
996 URL of the PhpWiki install directory. (You only need to set this
997 if you've moved index.php out of the install directory.) This can
998 be either a relative URL (from the directory where the top-level
999 PhpWiki script is) or an absolute one.");
1003 $properties["PhpWiki Install Directory"] =
1004 new _define_commented_optional('PHPWIKI_DIR', dirname(__FILE__), "
1005 Path to the PhpWiki install directory. This is the local
1006 filesystem counterpart to DATA_PATH. (If you have to set
1007 DATA_PATH, your probably have to set this as well.) This can be
1008 either an absolute path, or a relative path interpreted from the
1009 directory where the top-level PhpWiki script (normally index.php)
1014 $properties["Use PATH_INFO"] =
1015 new boolean_define_commented_optional('USE_PATH_INFO',
1016 array('true' => 'use PATH_INFO',
1017 'false' => 'do not use PATH_INFO'), "
1018 PhpWiki will try to use short urls to pages, eg
1019 http://www.example.com/index.php/HomePage
1020 If you want to use urls like
1021 http://www.example.com/index.php?pagename=HomePage
1022 then define 'USE_PATH_INFO' as false by uncommenting the line below.
1023 NB: If you are using Apache >= 2.0.30, then you may need to to use
1024 the directive \"AcceptPathInfo On\" in your Apache configuration file
1025 (or in an appropriate <.htaccess> file) for the short urls to work:
1026 See http://httpd.apache.org/docs-2.0/mod/core.html#acceptpathinfo
1028 See also http://phpwiki.sourceforge.net/phpwiki/PrettyWiki for more ideas
1029 on prettifying your urls.
1031 Default: PhpWiki will try to divine whether use of PATH_INFO
1032 is supported in by your webserver/PHP configuration, and will
1033 use PATH_INFO if it thinks that is possible.");
1036 $properties["Virtual Path"] =
1037 new _define_commented_optional('VIRTUAL_PATH', '/SomeWiki', "
1038 VIRTUAL_PATH is the canonical URL path under which your your wiki
1039 appears. Normally this is the same as dirname(SCRIPT_NAME), however
1040 using, e.g. apaches mod_actions (or mod_rewrite), you can make it
1041 something different.
1043 If you do this, you should set VIRTUAL_PATH here.
1045 E.g. your phpwiki might be installed at at /scripts/phpwiki/index.php,
1046 but you've made it accessible through eg. /wiki/HomePage.
1048 One way to do this is to create a directory named 'wiki' in your
1049 server root. The directory contains only one file: an .htaccess
1050 file which reads something like:
1052 Action x-phpwiki-page /scripts/phpwiki/index.php
1053 SetHandler x-phpwiki-page
1054 DirectoryIndex /scripts/phpwiki/index.php
1056 In that case you should set VIRTUAL_PATH to '/wiki'.
1058 (VIRTUAL_PATH is only used if USE_PATH_INFO is true.)
1062 $properties["Part Seven"] =
1063 new part('_partseven', $SEPARATOR."\n", "
1067 Miscellaneous settings
1070 $properties["Pagename of Recent Changes"] =
1071 new _define_optional('RECENT_CHANGES', 'RecentChanges', "
1072 Page name of RecentChanges page. Used for RSS Auto-discovery.");
1074 $properties["Disable HTTP Redirects"] =
1075 new boolean_define_commented_optional
1076 ('DISABLE_HTTP_REDIRECT',
1077 array('false' => 'Enable HTTP Redirects',
1078 'true' => 'Disable HTTP Redirects'),
1080 (You probably don't need to touch this.)
1082 PhpWiki uses HTTP redirects for some of it's functionality.
1083 (e.g. after saving changes, PhpWiki redirects your browser to
1084 view the page you just saved.)
1086 Some web service providers (notably free European Lycos) don't seem to
1087 allow these redirects. (On Lycos the result in an \"Internal Server Error\"
1088 report.) In that case you can set DISABLE_HTTP_REDIRECT to true.
1089 (In which case, PhpWiki will revert to sneakier tricks to try to
1090 redirect the browser...)");
1095 // Check if we were included by some other wiki version (getimg, en, ...)
1097 // If the server requested this index.php fire up the code by loading lib/main.php.
1098 // Parallel wiki scripts can now simply include /index.php for the
1099 // main configuration, extend or redefine some settings and
1100 // load lib/main.php by themselves.
1101 // This overcomes the index as config problem.
1104 // This doesn't work with php as CGI yet!
1105 if (defined('VIRTUAL_PATH') and defined('USE_PATH_INFO')) {
1106 if (\$HTTP_SERVER_VARS['SCRIPT_NAME'] == VIRTUAL_PATH) {
1107 include \"lib/main.php\";
1110 if (defined('SCRIPT_NAME') and
1111 (\$HTTP_SERVER_VARS['SCRIPT_NAME'] == SCRIPT_NAME)) {
1112 include \"lib/main.php\";
1113 } elseif (strstr(\$HTTP_SERVER_VARS['PHP_SELF'],'index.php')) {
1114 include \"lib/main.php\";
1118 // (c-file-style: \"gnu\")
1122 // c-basic-offset: 4
1123 // c-hanging-comment-ender-p: nil
1124 // indent-tabs-mode: nil
1131 // end of configuration options
1132 ///////////////////////////////
1133 // begin class definitions
1136 * A basic index.php configuration line in the form of a variable.
1138 * Produces a string in the form "$name = value;"
1140 * $WikiNameRegexp = "value";
1144 var $config_item_name;
1150 function _variable($config_item_name, $default_value, $description, $jscheck = '') {
1151 $this->config_item_name = $config_item_name;
1152 $this->description = $description;
1153 $this->default_value = $default_value;
1154 $this->jscheck = $jscheck;
1155 if (preg_match("/variable/i",get_class($this)))
1156 $this->prefix = "\$";
1157 elseif (preg_match("/ini_set/i",get_class($this)))
1158 $this->prefix = "ini_get: ";
1164 global $HTTP_POST_VARS;
1165 if (isset($HTTP_POST_VARS[$this->config_item_name]))
1166 return $HTTP_POST_VARS[$this->config_item_name];
1168 return $this->default_value;
1171 function _config_format($value) {
1172 $v = $this->get_config_item_name();
1173 // handle arrays: a|b --> a['b']
1174 if (strpos($v, '|')) {
1175 list($a, $b) = explode('|', $v);
1176 $v = sprintf("%s['%s']", $a, $b);
1178 return sprintf("\$%s = \"%s\";", $v, $value);
1181 function get_config_item_name() {
1182 return $this->config_item_name;
1185 function get_config_item_id() {
1186 return str_replace('|', '-', $this->config_item_name);
1189 function get_config_item_header() {
1190 if (strchr($this->config_item_name,'|')) {
1191 list($var,$param) = explode('|',$this->config_item_name);
1192 return "<b>" . $this->prefix . $var . "['" . $param . "']</b><br />";
1194 elseif ($this->config_item_name[0] != '_')
1195 return "<b>" . $this->prefix . $this->config_item_name . "</b><br />";
1200 function _get_description() {
1201 return $this->description;
1204 function _get_config_line($posted_value) {
1205 return "\n" . $this->_config_format($posted_value);
1208 function get_config($posted_value) {
1209 $d = stripHtml($this->_get_description());
1210 $d = str_replace("\n", "\n// ", $d) . $this->_get_config_line($posted_value) ."\n";
1214 function get_instructions($title) {
1216 $i = "<h3>" . $title . "</h3>\n " . nl2p($this->_get_description()) . "\n";
1217 return "<tr>\n<td width=\"$tdwidth\" class=\"instructions\">\n" . $i . "</td>\n";
1220 function get_html() {
1221 return $this->get_config_item_header() .
1222 "<input type=\"text\" size=\"50\" name=\"" . $this->get_config_item_name() . "\" value=\"" . htmlspecialchars($this->default_value) . "\" " .
1223 $this->jscheck . " />" . "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: green\">Input accepted.</p>";
1227 class unchangeable_variable
1229 function _config_format($value) {
1232 // function get_html() { return false; }
1233 function get_html() {
1234 return $this->get_config_item_header() .
1235 "<em>Not editable.</em>" .
1236 "<pre>" . $this->default_value."</pre>";
1238 function _get_config_line($posted_value) {
1239 if ($this->description)
1241 return "${n}".$this->default_value;
1243 function get_instructions($title) {
1245 $i = "<h3>" . $title . "</h3>\n " . nl2p($this->_get_description()) . "\n";
1246 // $i = $i ."<em>Not editable.</em><br />\n<pre>" . $this->default_value."</pre>";
1247 return "<tr><td width=\"100%\" class=\"unchangeable-variable-top\" colspan=\"2\">\n".$i ."</td></tr>\n".
1248 "<tr style=\"border-top: none;\"><td class=\"unchangeable-variable-left\" width=\"$tdwidth\" bgcolor=\"#eeeeee\"> </td>";
1252 class unchangeable_define
1253 extends unchangeable_variable {
1254 function _config_format($value) {
1258 class unchangeable_ini_set
1259 extends unchangeable_variable {
1260 function _config_format($value) {
1266 class _variable_selection
1269 global $HTTP_POST_VARS;
1270 if (!empty($HTTP_POST_VARS[$this->config_item_name]))
1271 return $HTTP_POST_VARS[$this->config_item_name];
1273 list($option, $label) = current($this->default_value);
1274 return $this->$option;
1277 function get_html() {
1278 $output = $this->get_config_item_header();
1279 $output .= '<select name="' . $this->get_config_item_name() . "\">\n";
1280 /* The first option is the default */
1281 while(list($option, $label) = each($this->default_value)) {
1282 $output .= " <option value=\"$option\">$label</option>\n";
1284 $output .= "</select>\n";
1292 function _config_format($value) {
1293 return sprintf("define('%s', '%s');", $this->get_config_item_name(), $value);
1295 function _get_config_line($posted_value) {
1296 if ($this->description)
1298 if ($posted_value == '')
1299 return "${n}//" . $this->_config_format("");
1301 return "${n}" . $this->_config_format($posted_value);
1303 function get_html() {
1304 return $this->get_config_item_header() .
1305 "<input type=\"text\" size=\"50\" name=\"" . $this->get_config_item_name() . "\" value=\"" . $this->default_value . "\" {$this->jscheck} />" .
1306 "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: green\">Input accepted.</p>";
1310 class _define_commented
1312 function _get_config_line($posted_value) {
1313 if ($this->description)
1315 if ($posted_value == $this->default_value)
1316 return "${n}//" . $this->_config_format($posted_value);
1317 else if ($posted_value == '')
1318 return "${n}//" . $this->_config_format("");
1320 return "${n}" . $this->_config_format($posted_value);
1324 class _define_commented_optional
1325 extends _define_commented {
1326 function _config_format($value) {
1327 $name = $this->get_config_item_name();
1328 return sprintf("if (!defined('%s')) define('%s', '%s');", $name, $name, $value);
1332 class _define_optional
1334 function _config_format($value) {
1335 $name = $this->get_config_item_name();
1336 return sprintf("if (!defined('%s')) define('%s', '%s');", $name, $name, $value);
1340 class _define_optional_notempty
1341 extends _define_optional {
1342 function get_html() {
1343 $s = $this->get_config_item_header() .
1344 "<input type=\"text\" size=\"50\" name=\"" . $this->get_config_item_name() . "\" value=\"" . $this->default_value . "\" {$this->jscheck} />";
1345 if (empty($this->default_value))
1346 return $s . "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: red\">Cannot be empty.</p>";
1348 return $s . "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: green\">Input accepted.</p>";
1352 class _variable_commented
1354 function _get_config_line($posted_value) {
1355 if ($this->description)
1357 if ($posted_value == $this->default_value)
1358 return "${n}//" . $this->_config_format($posted_value);
1359 else if ($posted_value == '')
1360 return "${n}//" . $this->_config_format("");
1362 return "${n}" . $this->_config_format($posted_value);
1366 class numeric_define_commented
1368 // var $jscheck = "onchange=\"validate_ereg('Sorry, \'%s\' is not an integer.', '^[-+]?[0-9]+$', '" . $this->get_config_item_name() . "', this);\"";
1370 function get_html() {
1371 return numeric_define::get_html();
1373 function _get_config_line($posted_value) {
1374 if ($this->description)
1376 if ($posted_value == $this->default_value)
1377 return "${n}//" . $this->_config_format($posted_value);
1378 else if ($posted_value == '')
1379 return "${n}//" . $this->_config_format('0');
1381 return "${n}" . $this->_config_format($posted_value);
1385 class _define_selection
1386 extends _variable_selection {
1387 function _config_format($value) {
1388 return sprintf("define('%s', '%s');", $this->get_config_item_name(), $value);
1390 function _get_config_line($posted_value) {
1391 return _define::_get_config_line($posted_value);
1393 function get_html() {
1394 return _variable_selection::get_html();
1398 class _define_selection_optional
1399 extends _define_selection {
1400 function _config_format($value) {
1401 $name = $this->get_config_item_name();
1402 return sprintf("if (!defined('%s')) define('%s', '%s');", $name, $name, $value);
1406 class _variable_selection_optional
1407 extends _variable_selection {
1408 function _config_format($value) {
1409 $v = $this->get_config_item_name();
1410 // handle arrays: a|b --> a['b']
1411 if (strpos($v, '|')) {
1412 list($a, $b) = explode('|', $v);
1413 $v = sprintf("%s['%s']", $a, $b);
1415 return sprintf("if (!isset(\$%s)) { \$%s = \"%s\"; }", $v, $v, $value);
1419 class _define_password
1421 // var $jscheck = "onchange=\"validate_ereg('Sorry, \'%s\' cannot be empty.', '^.+$', '" . $this->get_config_item_name() . "', this);\"";
1423 function _get_config_line($posted_value) {
1424 if ($this->description)
1426 if ($posted_value == '') {
1427 $p = "${n}//" . $this->_config_format("");
1428 $p = $p . "\n// If you used the passencrypt.php utility to encode the password";
1429 $p = $p . "\n// then uncomment this line:";
1430 $p = $p . "\n//if (!defined('ENCRYPTED_PASSWD')) define('ENCRYPTED_PASSWD', true);";
1433 if (function_exists('crypt')) {
1434 $salt_length = max(CRYPT_SALT_LENGTH,
1438 16 * CRYPT_BLOWFISH);
1439 // generate an encrypted password
1440 $crypt_pass = crypt($posted_value, rand_ascii($salt_length));
1441 $p = "${n}" . $this->_config_format($crypt_pass);
1442 return $p . "\ndefine('ENCRYPTED_PASSWD', true);";
1444 $p = "${n}" . $this->_config_format($posted_value);
1445 $p = $p . "\n// Encrypted passwords cannot be used:";
1446 $p = $p . "\n// 'function crypt()' not available in this version of php";
1447 $p = $p . "\ndefine('ENCRYPTED_PASSWD', false);";
1452 function get_html() {
1453 return _variable_password::get_html();
1457 class _define_password_optional
1458 extends _define_password {
1459 function _config_format($value) {
1460 $name = $this->get_config_item_name();
1461 return sprintf("if (!defined('%s')) define('%s', '%s');", $name, $name, $value);
1466 class _variable_password
1468 // var $jscheck = "onchange=\"validate_ereg('Sorry, \'%s\' cannot be empty.', '^.+$', '" . $this->get_config_item_name() . "', this);\"";
1470 function get_html() {
1471 global $HTTP_POST_VARS, $HTTP_GET_VARS;
1472 $s = $this->get_config_item_header();
1473 if (isset($HTTP_POST_VARS['create']) or isset($HTTP_GET_VARS['create'])) {
1474 $new_password = random_good_password();
1475 $this->default_value = $new_password;
1476 $s .= "Created password: <strong>$new_password</strong><br /> <br />";
1478 $s .= "<input type=\"password\" name=\"" . $this->get_config_item_name() . "\" value=\"" . $this->default_value . "\" {$this->jscheck} />" .
1479 " <input type=\"submit\" name=\"create\" value=\"Create Password\" />";
1480 if (empty($this->default_value))
1481 $s .= "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: red\">Cannot be empty.</p>";
1482 elseif (strlen($this->default_value) < 4)
1483 $s .= "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: red\">Must be longer than 4 chars.</p>";
1485 $s .= "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: green\">Input accepted.</p>";
1490 class numeric_define
1492 // var $jscheck = "onchange=\"validate_ereg('Sorry, \'%s\' is not an integer.', '^[-+]?[0-9]+$', '" . $this->get_config_item_name() . "', this);\"";
1494 function _config_format($value) {
1495 return sprintf("define('%s', %s);", $this->get_config_item_name(), $value);
1497 function _get_config_line($posted_value) {
1498 if ($this->description)
1500 if ($posted_value == '')
1501 return "${n}//" . $this->_config_format('0');
1503 return "${n}" . $this->_config_format($posted_value);
1509 function _get_config_line($posted_value) {
1510 // split the phrase by any number of commas or space characters,
1511 // which include " ", \r, \t, \n and \f
1512 $list_values = preg_split("/[\s,]+/", $posted_value, -1, PREG_SPLIT_NO_EMPTY);
1513 $list_values = join("|", $list_values);
1514 return _variable::_get_config_line($list_values);
1516 function get_html() {
1517 $list_values = explode("|", $this->default_value);
1518 $rows = max(3, count($list_values) +1);
1519 $list_values = join("\n", $list_values);
1520 $ta = $this->get_config_item_header();
1521 $ta .= "<textarea cols=\"18\" rows=\"". $rows ."\" name=\"".$this->get_config_item_name()."\" {$this->jscheck}>";
1522 $ta .= $list_values . "</textarea>";
1523 $ta .= "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: green\">Input accepted.</p>";
1528 class array_variable
1530 function _config_format($value) {
1531 return sprintf("\$%s = array(%s);", $this->get_config_item_name(), $value);
1533 function _get_config_line($posted_value) {
1534 // split the phrase by any number of commas or space characters,
1535 // which include " ", \r, \t, \n and \f
1536 $list_values = preg_split("/[\s,]+/", $posted_value, -1, PREG_SPLIT_NO_EMPTY);
1537 if (!empty($list_values)) {
1538 $list_values = "'".join("', '", $list_values)."'";
1539 return "\n" . $this->_config_format($list_values);
1541 return "\n//" . $this->_config_format('');
1543 function get_html() {
1544 $list_values = join("\n", $this->default_value);
1545 $rows = max(3, count($this->default_value) +1);
1546 $ta = $this->get_config_item_header();
1547 $ta .= "<textarea cols=\"18\" rows=\"". $rows ."\" name=\"".$this->get_config_item_name()."\" {$this->jscheck}>";
1548 $ta .= $list_values . "</textarea>";
1549 $ta .= "<p id=\"" . $this->get_config_item_id() . "\" style=\"color: green\">Input accepted.</p>";
1558 global $HTTP_POST_VARS;
1559 if ($v = $HTTP_POST_VARS[$this->config_item_name])
1562 return ini_get($this->get_config_item_name);
1565 function _config_format($value) {
1566 return sprintf("ini_set('%s', '%s');", $this->get_config_item_name(), $value);
1568 function _get_config_line($posted_value) {
1569 if ($posted_value && ! $posted_value == $this->default_value)
1570 return "\n" . $this->_config_format($posted_value);
1572 return "\n//" . $this->_config_format($this->default_value);
1576 class boolean_define
1578 function _get_config_line($posted_value) {
1579 if ($this->description)
1581 return "${n}" . $this->_config_format($posted_value);
1583 function _config_format($value) {
1584 if (strtolower(trim($value)) == 'false')
1586 return sprintf("define('%s', %s);", $this->get_config_item_name(),
1587 (bool)$value ? 'true' : 'false');
1589 function get_html() {
1590 $output = $this->get_config_item_header();
1591 $output .= '<select name="' . $this->get_config_item_name() . "\" {$this->jscheck}>\n";
1592 /* The first option is the default */
1593 list($option, $label) = each($this->default_value);
1594 $output .= " <option value=\"$option\" selected='selected'>$label</option>\n";
1595 /* There can usually, only be two options, there can be
1596 * three options in the case of a boolean_define_commented_optional */
1597 while (list($option, $label) = each($this->default_value))
1598 $output .= " <option value=\"$option\">$label</option>\n";
1599 $output .= "</select>\n";
1604 class boolean_define_optional
1605 extends boolean_define {
1606 function _config_format($value) {
1607 $name = $this->get_config_item_name();
1608 return "if (!defined('$name')) " . boolean_define::_config_format($value);
1612 class boolean_define_commented
1613 extends boolean_define {
1614 function _get_config_line($posted_value) {
1615 if ($this->description)
1617 list($default_value, $label) = each($this->default_value);
1618 if ($posted_value == $default_value)
1619 return "${n}//" . $this->_config_format($posted_value);
1620 else if ($posted_value == '')
1621 return "${n}//" . $this->_config_format('false');
1623 return "${n}" . $this->_config_format($posted_value);
1627 class boolean_define_commented_optional
1628 extends boolean_define_commented {
1629 function _config_format($value) {
1630 $name = $this->get_config_item_name();
1631 return "if (!defined('$name')) " . boolean_define_commented::_config_format($value);
1637 function value () { return; }
1638 function get_config($posted_value) {
1639 $d = stripHtml($this->_get_description());
1641 return "\n".$SEPARATOR . str_replace("\n", "\n// ", $d) ."\n$this->default_value";
1643 function get_instructions($title) {
1644 $group_name = preg_replace("/\W/","",$title);
1645 $i = "<tr class='header' id='$group_name'>\n<td class=\"part\" width=\"100%\" colspan=\"2\" bgcolor=\"#eeaaaa\">\n";
1646 $i .= "<h2>" . $title . "</h2>\n " . nl2p($this->_get_description()) ."\n";
1647 $i .= "<p><a href=\"javascript:toggle_group('$group_name')\" id=\"{$group_name}_text\">Hide options.</a></p>";
1648 return $i ."</td>\n";
1650 function get_html() {
1655 // html utility functions
1656 function nl2p($text) {
1657 preg_match_all("@\s*(<pre>.*?</pre>|<dl>.*?</dl>|.*?(?=\n\n|<pre>|<dl>|$))@s",
1658 $text, $m, PREG_PATTERN_ORDER);
1661 foreach ($m[1] as $par) {
1662 if (!($par = trim($par)))
1664 if (!preg_match('/^<(pre|dl)>/', $par))
1665 $par = "<p>$par</p>";
1671 function stripHtml($text) {
1672 $d = str_replace("<pre>", "", $text);
1673 $d = str_replace("</pre>", "", $d);
1674 $d = str_replace("<dl>", "", $d);
1675 $d = str_replace("</dl>", "", $d);
1676 $d = str_replace("<dt>", "", $d);
1677 $d = str_replace("</dt>", "", $d);
1678 $d = str_replace("<dd>", "", $d);
1679 $d = str_replace("</dd>", "", $d);
1680 $d = str_replace("<p>", "", $d);
1681 $d = str_replace("</p>", "", $d);
1682 //restore html entities into characters
1683 // http://www.php.net/manual/en/function.htmlentities.php
1684 $trans = get_html_translation_table (HTML_ENTITIES);
1685 $trans = array_flip ($trans);
1686 $d = strtr($d, $trans);
1691 * Seed the random number generator.
1693 * better_srand() ensures the randomizer is seeded only once.
1695 * How random do you want it? See:
1696 * http://www.php.net/manual/en/function.srand.php
1697 * http://www.php.net/manual/en/function.mt-srand.php
1699 function better_srand($seed = '') {
1700 static $wascalled = FALSE;
1703 list($usec,$sec)=explode(" ",microtime());
1705 $seed = (double) $usec * $sec;
1706 else // once in a while use the combined LCG entropy
1707 $seed = (double) 1000000 * substr(uniqid("",true),13);
1709 if (function_exists('mt_srand')) {
1710 mt_srand($seed); // mersenne twister
1718 function rand_ascii($length = 1) {
1721 for ($i = 1; $i <= $length; $i++) {
1722 // return only typeable 7 bit ascii, avoid quotes
1723 if (function_exists('mt_rand'))
1724 // the usually bad glibc srand()
1725 $s .= chr(mt_rand(40, 126));
1727 $s .= chr(rand(40, 126));
1733 // Function to create better user passwords (much larger keyspace),
1734 // suitable for user passwords.
1735 // Sequence of random ASCII numbers, letters and some special chars.
1736 // Note: There exist other algorithms for easy-to-remember passwords.
1737 function random_good_password ($minlength = 5, $maxlength = 8) {
1739 // assume ASCII ordering (not valid on EBCDIC systems!)
1740 $valid_chars = "!#%&+-.0123456789=@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz";
1741 $start = ord($valid_chars);
1742 $end = ord(substr($valid_chars,-1));
1744 if (function_exists('mt_rand')) // mersenne twister
1745 $length = mt_rand($minlength, $maxlength);
1746 else // the usually bad glibc rand()
1747 $length = rand($minlength, $maxlength);
1748 while ($length > 0) {
1749 if (function_exists('mt_rand'))
1750 $newchar = mt_rand($start, $end);
1752 $newchar = rand($start, $end);
1753 if (! strrpos($valid_chars,$newchar) ) continue; // skip holes
1754 $newpass .= sprintf("%c",$newchar);
1761 function printArray($a) {
1762 echo "<hr />\n<pre>\n";
1764 echo "\n</pre>\n<hr />\n";
1767 // end of class definitions
1768 /////////////////////////////
1769 // begin auto generation code
1771 if (!function_exists('is_a'))
1773 function is_a($object, $class)
1775 $class = strtolower($class);
1776 return (get_class($object) == $class) or is_subclass_of($object, $class);
1781 if (@$HTTP_POST_VARS['action'] == 'make_config') {
1783 $timestamp = date ('dS of F, Y H:i:s');
1786 /* This is a local configuration file for PhpWiki.
1787 * It was automatically generated by the configurator script
1788 * on the $timestamp.
1793 /////////////////////////////////////////////////////////////////////
1797 $posted = $GLOBALS['HTTP_POST_VARS'];
1799 if (defined('DEBUG'))
1800 printArray($GLOBALS['HTTP_POST_VARS']);
1802 foreach($properties as $option_name => $a) {
1803 $posted_value = $posted[$a->config_item_name];
1804 $config .= $properties[$option_name]->get_config($posted_value);
1807 if (defined('DEBUG')) {
1808 $diemsg = "The configurator.php is provided for testing purposes only.
1809 You can't use this file with your PhpWiki server yet!!";
1810 $config .= "\ndie(\"$diemsg\");\n";
1814 // I think writing this config file is a big security hole.
1815 // If this is installed in such a way that it can write an index-user.php,
1816 // then anyone can create a working index-user.php with, e.g. any
1817 // admin user and pw of their choosing...
1819 // So I'm disabling it...
1821 if (defined(ENABLE_FILE_OUTPUT) and ENABLE_FILE_OUPUT) {
1822 /* We first check if the config-file exists. */
1823 if (file_exists($fs_config_file)) {
1824 /* We make a backup copy of the file */
1825 // $config_file = 'index-user.php';
1826 $new_filename = preg_replace('/\.php$/', time() . '.php', $fs_config_file);
1827 if (@copy($fs_config_file, $new_filename)) {
1828 $fp = @fopen($fs_config_file, 'w');
1831 $fp = @fopen($fs_config_file, 'w');
1840 fputs($fp, $config);
1842 echo "<p>The configuration was written to <code><b>$config_file</b></code>.</p>\n";
1843 if ($new_filename) {
1844 echo "<p>A backup was made to <code><b>$new_filename</b></code>.</p>\n";
1846 echo "<p><strong>You must rename or copy this</strong> <code><b>$config_file</b></code> <strong>file to</strong> <code><b>index.php</b></code>.</p>\n";
1848 echo "<p>A configuration file could <b>not</b> be written. You should copy the above configuration to a file, and manually save it as <code><b>index.php</b></code>.</p>\n";
1851 echo "<hr />\n<p>Here's the configuration file based on your answers:</p>\n";
1852 echo "<form method='get' action='$PHP_SELF'>\n";
1853 echo "<textarea id='config-output' readonly='readonly' style='width:100%;' rows='30' cols='100'>\n";
1854 echo htmlentities($config);
1855 echo "</textarea></form>\n";
1858 echo "<p>To make any corrections, <a href=\"configurator.php\">edit the settings again</a>.</p>\n";
1860 } else { // first time or create password
1861 $posted = $GLOBALS['HTTP_POST_VARS'];
1862 /* No action has been specified - we make a form. */
1865 <form action="configurator.php" method="post">
1866 <input type="hidden" name="action" value="make_config" />
1867 <table cellpadding="4" cellspacing="0">
1870 while(list($property, $obj) = each($properties)) {
1871 echo $obj->get_instructions($property);
1872 if ($h = $obj->get_html()) {
1873 if (defined('DEBUG')) $h = get_class($obj) . "<br />\n" . $h;
1874 echo "<td>".$h."</td>\n";
1881 <p><input type="submit" value="Save ',$config_file,'" /> <input type="reset" value="Clear" /></p>