1 <?php printf("<?xml version=\"1.0\" encoding=\"%s\"?>\n", 'iso-8859-1'); ?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml">
6 <!-- $Id: configurator.php,v 1.4 2002-03-25 00:41:23 carstenklapp Exp $ -->
7 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
8 <title>Configuration tool for PhpWiki 1.3.x</title>
12 <h1>Configuration tool for PhpWiki 1.3.x</h1>
14 <p>This tool is provided for testing purposes only. It's not finished so don't try to use it to configure your server yet.</p>
19 * The Configurator is a php script to aid in the configuration of PhpWiki.
20 * Parts of this file are based on PHPWeather's configurator.php file.
21 * http://sourceforge.net/projects/phpweather/
24 * TO CHANGE THE CONFIGURATION OF YOUR PHPWIKI, DO *NOT* MODIFY THIS FILE!
25 * more instructions go here
28 * An index.php will be generated for you which you can also modify later if you wish.
32 //////////////////////////////
33 // begin configuration options
37 * Notes for the description parameter of $property:
39 * - Descriptive text will be changed into comments (preceeded by //)
40 * for the final output to index.php.
42 * - Only a limited set of html is allowed: pre, dl dt dd; it will be
43 * stripped from the final output.
45 * - Line breaks and spacing will be preserved for the final output.
47 * - Double line breaks are automatically converted to paragraphs
48 * for the html version of the descriptive text.
50 * - Double-quotes and dollar signs in the descriptive text must be
51 * escaped: \" and \$. Instead of escaping double-quotes you can use
52 * single (') quotes for the enclosing quotes.
54 * - Special characters like < and > must use html entities,
55 * they will be converted back to characters for the final output.
58 $SEPARATOR = "///////////////////////////////////////////////////////////////////";
61 Copyright 1999, 2000, 2001, 2002 $ThePhpWikiProgrammingTeam = array(
62 "Steve Wainstead", "Clifford A. Adams", "Lawrence Akka",
63 "Scott R. Anderson", "Jon Åslund", "Neil Brown", "Jeff Dairiki",
64 "Stéphane Gourichon", "Jan Hidders", "Arno Hollosi", "John Jorgensen",
65 "Antti Kaihola", "Jeremie Kass", "Carsten Klapp", "Marco Milanesi",
66 "Grant Morgan", "Jan Nieuwenhuizen", "Aredridel Niothke",
67 "Pablo Roca Rozas", "Sandino Araico Sánchez", "Joel Uckelman",
68 "Reini Urban", "Tim Voght");
70 This file is part of PhpWiki.
72 PhpWiki is free software; you can redistribute it and/or modify
73 it under the terms of the GNU General Public License as published by
74 the Free Software Foundation; either version 2 of the License, or
75 (at your option) any later version.
77 PhpWiki is distributed in the hope that it will be useful,
78 but WITHOUT ANY WARRANTY; without even the implied warranty of
79 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
80 GNU General Public License for more details.
82 You should have received a copy of the GNU General Public License
83 along with PhpWiki; if not, write to the Free Software
84 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
90 This is the starting file for PhpWiki. All this file does is set
91 configuration options, and at the end of the file it includes() the
92 file lib/main.php, where the real action begins.
94 This file is divided into six parts: Parts Zero, One, Two, Three,
95 Four and Five. Each one has different configuration settings you can
96 change; in all cases the default should work on your system,
97 however, we recommend you tailor things to your particular setting.
102 $properties['Part Zero'] =
103 new part('part0', false, "
104 Part Zero: If PHP needs help in finding where you installed the
105 rest of the PhpWiki code, you can set the include_path here.");
109 $properties['PHP include_path'] =
110 new _ini_set('include_path', "\$include_path", "
111 NOTE: phpwiki uses the PEAR library of php code for SQL database
112 access. Your PHP is probably already configured to set
113 include_path so that PHP can find the pear code. If not (or if you
114 change include_path here) make sure you include the path to the
115 PEAR code in include_path. (To find the PEAR code on your system,
116 search for a file named 'PEAR.php'. Some common locations are:
124 The above examples are already included by PhpWiki. You shouldn't
125 have to change this unless you see a WikiFatalError:
127 lib/FileFinder.php:82: Fatal[256]: DB.php: file not found
129 Define the include path for this wiki: pear plus the phpwiki path
131 $include_path = '.:/Apache/php/pear:/prog/php/phpwiki';
133 Windows needs ';' as path delimiter. cygwin, mac and unix ':'
135 if (substr(PHP_OS,0,3) == 'WIN') {
136 $include_path = implode(';',explode(':',$include_path));
137 } elseif (substr(PHP_OS,0,6) == 'CYGWIN') {
138 $include_path = '.:/usr/local/lib/php/pear:/usr/src/php/phpwiki';
145 $properties['Part Null'] =
146 new part('partnullheader', "", "
147 Part Null: Don't touch this!");
151 $properties['Part Null Settings'] =
152 new unchangeable_variable('partnullsettings', "
153 define ('PHPWIKI_VERSION', '1.3.3-jeffs-hacks');
154 require \"lib/prepend.php\";
155 rcs_id('\$Id: configurator.php,v 1.4 2002-03-25 00:41:23 carstenklapp Exp $');", "");
159 $properties['Part One'] =
160 new part('partone', $SEPARATOR."\n", "
163 Authentication and security settings:
168 $properties['Wiki Name'] =
169 new _define('WIKI_NAME', ''/*'PhpWiki'*/, "
170 The name of your wiki.
171 This is used to generate a keywords meta tag in the HTML templates,
172 in bookmark titles for any bookmarks made to pages in your wiki,
173 and during RSS generation for the title of the RSS channel.");
177 $properties['Reverse DNS'] =
178 new boolean_define('ENABLE_REVERSE_DNS',
179 array('true' => 'perform additional reverse dns lookups',
180 'false' => 'just record the address as given by the httpd server'), "
181 If set, we will perform reverse dns lookups to try to convert the
182 users IP number to a host name, even if the http server didn't do
187 $properties['Admin Username'] =
188 new _define('ADMIN_USER', "", "
189 Username and password of administrator.
190 Set these to your preferences. For heaven's sake
191 pick a good password!");
192 $properties['Admin Password'] =
193 new _define_password('ADMIN_PASSWD', "", "");
197 $properties['ZIPdump Authentication'] =
198 new boolean_define('ZIPDUMP_AUTH',
199 array('false' => 'everyone may download zip dumps',
200 'true' => 'only admin may download zip dumps'), "
201 If true, only the admin user can make zip dumps, else zip dumps
202 require no authentication.");
206 $properties['Strict Mailable Pagedumps'] =
207 new boolean_define('STRICT_MAILABLE_PAGEDUMPS',
208 array('false' => 'binary',
209 'true' => 'quoted-printable'), "
210 If you define this to true, (MIME-type) page-dumps (either zip dumps,
211 or \"dumps to directory\" will be encoded using the quoted-printable
212 encoding. If you're actually thinking of mailing the raw page dumps,
213 then this might be useful, since (among other things,) it ensures
214 that all lines in the message body are under 80 characters in length.
216 Also, setting this will cause a few additional mail headers
217 to be generated, so that the resulting dumps are valid
218 RFC 2822 e-mail messages.
220 Probably, you can just leave this set to false, in which case you get
221 raw ('binary' content-encoding) page dumps.");
225 $properties['Maximum Upload Size'] =
226 new numeric_define('MAX_UPLOAD_SIZE', "16 * 1024 * 1024", "
227 The maximum file upload size.");
231 $properties['Minor Edit Timeout'] =
232 new numeric_define('MINOR_EDIT_TIMEOUT', "7 * 24 * 3600", "
233 If the last edit is older than MINOR_EDIT_TIMEOUT seconds, the
234 default state for the \"minor edit\" checkbox on the edit page form
239 $properties['Disabled Actions'] =
240 new array_variable('DisabledActions', array(), "
241 Actions listed in this array will not be allowed. Actions are:
242 browse, diff, dumphtml, dumpserial, edit, loadfile, lock, remove,
243 unlock, upload, viewsource, zip, ziphtml");
247 $properties['Access Log'] =
248 new _define('ACCESS_LOG', "", "
249 PhpWiki can generate an access_log (in \"NCSA combined log\" format)
250 for you. If you want one, define this to the name of the log file,
251 such as /tmp/wiki_access_log.");
255 $properties['Strict Login'] =
256 new boolean_define('ALLOW_BOGO_LOGIN',
257 array('true' => 'Users may Sign In with any WikiWord',
258 'false' => 'Only admin may Sign In'), "
259 If ALLOW_BOGO_LOGIN is true, users are allowed to login (with
260 any/no password) using any userid which: 1) is not the ADMIN_USER,
261 2) is a valid WikiWord (matches \$WikiNameRegexp.)");
265 $properties['Require Sign In Before Editing'] =
266 new boolean_define('REQUIRE_SIGNIN_BEFORE_EDIT',
267 array('false' => 'Do not require Sign In',
268 'true' => 'Require Sign In'), "
269 If set, then if an anonymous user attempts to edit a page he will
270 be required to sign in. (If ALLOW_BOGO_LOGIN is true, of course,
271 no password is required, but the user must still sign in under
272 some sort of BogoUserId.)");
276 $properties['Path for PHP Session Support'] =
277 new _ini_set('session.save_path', 'some_other_directory', "
278 The login code now uses PHP's session support. Usually, the default
279 configuration of PHP is to store the session state information in
280 /tmp. That probably will work fine, but fails e.g. on clustered
281 servers where each server has their own distinct /tmp (this is the
282 case on SourceForge's project web server.) You can specify an
283 alternate directory in which to store state information like so
284 (whatever user your httpd runs as must have read/write permission
285 in this directory):");
289 $properties['Disable PHP Transparent Session ID'] =
290 new unchangeable_variable('session.use_trans_sid', "@ini_set('session.use_trans_sid', 0);", "
291 If your php was compiled with --enable-trans-sid it tries to
292 add a PHPSESSID query argument to all URL strings when cookie
293 support isn't detected in the client browser. For reasons
294 which aren't entirely clear (PHP bug) this screws up the URLs
295 generated by PhpWiki. Therefore, transparent session ids
296 should be disabled. This next line does that.
298 (At the present time, you will not be able to log-in to PhpWiki,
299 or set any user preferences, unless your browser supports cookies.)");
303 ///////// database selection
307 $properties['Part Two'] =
308 new part('parttwo', $SEPARATOR."\n", "
316 $properties['Database Type'] =
317 new _variable_selection("DBParams['dbtype']",
318 array('dba' => 'dba DBM',
320 'ADODB' => 'SQL ADODB'), "
321 Select the database type:");
325 $properties['Filename / Table name Prefix'] =
326 new _variable("DBParams['prefix']", "phpwiki_", "
327 Used by all DB types:
329 prefix for filenames or table names
331 currently you MUST EDIT THE SQL file too (in the schemas/
332 directory because we aren't doing on the fly sql generation
333 during the installation.:");
337 $properties['SQL dsn Setup'] =
338 new part("sqldsnstuff", "
340 For SQL based backends, specify the database as a DSN
341 The most general form of a DSN looks like:
343 phptype(dbsyntax)://username:password@protocol+hostspec/database
345 For a MySQL database, the following should work:
347 mysql://user:password@host/databasename
349 <dl><dd>FIXME:</dd> <dt>My version Pear::DB seems to be broken enough that there
350 is no way to connect to a mysql server over a socket right now.</dt></dl>
351 <pre>'dsn' => 'mysql://guest@:/var/lib/mysql/mysql.sock/test',
352 'dsn' => 'mysql://guest@localhost/test',
353 'dsn' => 'pgsql://localhost/test'</pre>,");
357 $properties['SQL Type'] =
358 new _variable_selection('dsn_sqltype',
359 array('mysql' => 'MySQL',
360 'pgsql' => 'PostgreSQL'), "
365 $properties['SQL User'] =
366 new _variable('dsn_sqluser', "wikiuser", "
371 $properties['SQL Password'] =
372 new _variable('dsn_sqlpass', "", "
377 $properties['SQL Database Host'] =
378 new _variable('dsn_sqlhostorsock', "localhost", "
379 SQL Database Hostname:");
383 $properties['SQL Database Name'] =
384 new _variable('dsn_sqldbname', "phpwiki", "
385 SQL Database Name:");
388 $properties['SQL dsn'] =
389 new unchangeable_variable("DBParams['dsn']", "\$DBParams['dsn'] = \"\$dsn_sqltype://\$dsn_sqluser:\$dsn_sqlpass@\$dsn_sqlhostorsock/\$dsn_sqldbname\";", "
398 $properties['dba directory'] =
399 new _variable("DBParams['directory']", "/tmp", "
404 $properties['dba handler'] =
405 new _variable("DBParams['dba_handler']", "gdbm", "
406 Use 'gdbm', 'db2', or db3 depending on your database:");
410 $properties['dba handler'] =
411 new _variable("DBParams['dba_handler']", "gdbm", "
412 Use 'gdbm', 'db2', or db3 depending on your database:");
415 $properties['dba timeout'] =
416 new _variable("DBParams['timeout']", "20", "
417 Recommended values are 20 or 5.");
425 $properties['Page Revisions'] =
426 new part('parttworevisions', "
429 The next section controls how many old revisions of each page are
430 kept in the database.
432 There are two basic classes of revisions: major and minor. Which
433 class a revision belongs in is determined by whether the author
434 checked the \"this is a minor revision\" checkbox when they saved the
437 There is, additionally, a third class of revisions: author
438 revisions. The most recent non-mergable revision from each distinct
439 author is and author revision.
441 The expiry parameters for each of those three classes of revisions
442 can be adjusted seperately. For each class there are five
443 parameters (usually, only two or three of the five are actually
444 set) which control how long those revisions are kept in the
447 <dt>max_keep:</dt> <dd>If set, this specifies an absolute maximum for the
448 number of archived revisions of that class. This is
449 meant to be used as a safety cap when a non-zero
450 min_age is specified. It should be set relatively high,
451 and it's purpose is to prevent malicious or accidental
452 database overflow due to someone causing an
453 unreasonable number of edits in a short period of time.</dd>
455 <dt>min_age:</dt> <dd>Revisions younger than this (based upon the supplanted
456 date) will be kept unless max_keep is exceeded. The age
457 should be specified in days. It should be a
458 non-negative, real number,</dd>
460 <dt>min_keep:</dt> <dd>At least this many revisions will be kept.</dd>
462 <dt>keep:</dt> <dd>No more than this many revisions will be kept.</dd>
464 <dt>max_age:</dt> <dd>No revision older than this age will be kept.</dd>
466 Supplanted date: Revisions are timestamped at the instant that they
467 cease being the current revision. Revision age is computed using
468 this timestamp, not the edit time of the page.
470 Merging: When a minor revision is deleted, if the preceding
471 revision is by the same author, the minor revision is merged with
472 the preceding revision before it is deleted. Essentially: this
473 replaces the content (and supplanted timestamp) of the previous
474 revision with the content after the merged minor edit, the rest of
475 the page metadata for the preceding version (summary, mtime, ...)
480 // For now the expiration parameters are statically inserted as
481 // an unchangeable property. You'll have to edit the resulting
482 // config file if you really want to change these from the default.
484 $properties['Expiration Parameters for Major Edits'] =
485 new unchangeable_variable('Expiration_Parameters_for_Major_Edits',
486 "\$ExpireParams['major'] = array('max_age' => 32,
488 Keep up to 8 major edits, but keep them no longer than a month.");
492 $properties['Expiration Parameters for Minor Edits'] =
493 new unchangeable_variable('Expiration_Parameters_for_Minor_Edits',
494 "\$ExpireParams['minor'] = array('max_age' => 7,
496 Keep up to 4 minor edits, but keep them no longer than a week.");
500 $properties['Expiration Parameters by Author'] =
501 new unchangeable_variable('Expiration_Parameters_by_Author',
502 "\$ExpireParams['author'] = array('max_age' => 365,
505 'max_keep' => 20);", "
506 Keep the latest contributions of the last 8 authors up to a year.
507 Additionally, (in the case of a particularly active page) try to
508 keep the latest contributions of all authors in the last week (even
509 if there are more than eight of them,) but in no case keep more
510 than twenty unique author revisions.");
515 $properties['Part Three'] =
516 new part('partthree', $SEPARATOR."\n", "
519 Page appearance and layout
524 $properties['Theme'] =
525 new _define_selection('THEME',
526 array('default' => 'default',
527 'Hawaiian' => 'Hawaiian',
528 'MacOSX' => 'MacOSX',
529 'Portland' => 'Portland',
530 'Sidebar' => 'Sidebar',
531 'SpaceWiki' => 'SpaceWiki'), "
534 Most of the page appearance is controlled by files in the theme
537 There are a number of pre-defined themes shipped with PhpWiki.
538 Or you may create your own (e.g. by copying and then modifying one of
543 define('THEME', 'default');
544 define('THEME', 'Hawaiian');
545 define('THEME', 'MacOSX');
546 define('THEME', 'Portland');
547 define('THEME', 'Sidebar');
548 define('THEME', 'SpaceWiki');</pre>");
553 $properties['Character Set'] =
554 new _define('CHARSET', 'iso-8859-1', "
555 Select a valid charset name to be inserted into the xml/html pages,
556 and to reference links to the stylesheets (css). For more info see:
557 http://www.iana.org/assignments/character-sets. Note that PhpWiki
558 has been extensively tested only with the latin1 (iso-8859-1)
561 If you change the default from iso-8859-1 PhpWiki may not work
562 properly and it will require code modifications. However, character
563 sets similar to iso-8859-1 may work with little or no modification
564 depending on your setup. The database must also support the same
565 charset, and of course the same is true for the web browser. (Some
566 work is in progress hopefully to allow more flexibility in this
567 area in the future).");
571 $properties['Language'] =
572 new _variable_selection('LANG',
573 array('C' => 'English',
574 'nl' => 'Nederlands',
581 Select your language/locale - default language is \"C\" for English.
582 Other languages available:<pre>
583 English \"C\" (English - HomePage)
584 Dutch \"nl\" (Nederlands - ThuisPagina)
585 Spanish \"es\" (Español - PáginaPrincipal)
586 French \"fr\" (Français - Accueil)
587 German \"de\" (Deutsch - StartSeite)
588 Swedish \"sv\" (Svenska - Framsida)
589 Italian \"it\" (Italiano - PaginaPrincipale)
591 If you set \$LANG to the empty string, your systems default language
592 (as determined by the applicable environment variables) will be
595 Note that on some systems, apprently using these short forms for
596 the locale won't work. On my home system 'LANG=de' won't result in
597 german pages. Somehow the system must recognize the locale as a
598 valid locale before gettext() will work, i.e., use 'de_DE', 'nl_NL'.");
602 $properties['Wiki Page Source'] =
603 new _define('WIKI_PGSRC', "pgsrc", "
604 WIKI_PGSRC -- specifies the source for the initial page contents of
605 the Wiki. The setting of WIKI_PGSRC only has effect when the wiki is
606 accessed for the first time (or after clearing the database.)
607 WIKI_PGSRC can either name a directory or a zip file. In either case
608 WIKI_PGSRC is scanned for files -- one file per page.
610 define('WIKI_PGSRC', 'pgsrc'); // Default (old) behavior.
611 define('WIKI_PGSRC', 'wiki.zip'); // New style.
612 define('WIKI_PGSRC', '../../../Logs/Hamwiki/hamwiki-20010830.zip'); // New style.
617 $properties['Default Wiki Page Source'] =
618 new _define('DEFAULT_WIKI_PGSRC', "pgsrc", "
619 DEFAULT_WIKI_PGSRC is only used when the language is *not* the
620 default (English) and when reading from a directory: in that case
621 some English pages are inserted into the wiki as well.
622 DEFAULT_WIKI_PGSRC defines where the English pages reside.
627 $properties['Default Wiki Page Source'] =
628 new _define('DEFAULT_WIKI_PGSRC', "pgsrc", "
629 DEFAULT_WIKI_PGSRC is only used when the language is *not* the
630 default (English) and when reading from a directory: in that case
631 some English pages are inserted into the wiki as well.
632 DEFAULT_WIKI_PGSRC defines where the English pages reside.
634 FIXME: is this really needed?
639 $properties['Generic Pages'] =
640 new array_variable('GenericPages', array("ReleaseNotes", "SteveWainstead", "TestPage"), "
641 These are the pages which will get loaded from DEFAULT_WIKI_PGSRC.
643 FIXME: is this really needed? Can't we just copy these pages into
650 $properties['Part Four'] =
651 new part('partfour', $SEPARATOR."\n", "
659 $properties['Allowed Protocols'] =
660 new list_variable('AllowedProtocols', "http|https|mailto|ftp|news|nntp|ssh|gopher", "
661 allowed protocols for links - be careful not to allow \"javascript:\"
662 URL of these types will be automatically linked.
663 within a named link [name|uri] one more protocol is defined: phpwiki");
667 $properties['Inline Images'] =
668 new list_variable('InlineImages', "png|jpg|gif", "
669 URLs ending with the following extension should be inlined as images");
673 $properties['WikiName Regexp'] =
674 new _variable('WikiNameRegexp', "(?<![[:alnum:]])(?:[[:upper:]][[:lower:]]+){2,}(?![[:alnum:]])", "
675 Perl regexp for WikiNames (\"bumpy words\")
676 (?<!..) & (?!...) used instead of '\b' because \b matches '_' as well");
680 $properties['InterWiki Map File'] =
681 new _define('INTERWIKI_MAP_FILE', "lib/interwiki.map", "
682 InterWiki linking -- wiki-style links to other wikis on the web
684 The map will be taken from a page name InterWikiMap.
685 If that page is not found (or is not locked), or map
686 data can not be found in it, then the file specified
687 by INTERWIKI_MAP_FILE (if any) will be used.");
691 $properties['Part Five'] =
692 new part('partfive', $SEPARATOR."\n", "
695 URL options -- you can probably skip this section.
700 $properties['Server Name'] =
701 new _define_commented('SERVER_NAME', "some.host.com", "
702 Canonical name and httpd port of the server on which this PhpWiki
707 $properties['Server Port'] =
708 new numeric_define_commented('SERVER_PORT', 80, "");
711 $properties['Script Name'] =
712 new _define_commented('SCRIPT_NAME', '/some/where/index.php', "
713 Relative URL (from the server root) of the PhpWiki script.");
717 $properties['Data Path'] =
718 new _define_commented('DATA_PATH', '/some/where/phpwiki', "
719 URL of the PhpWiki install directory. (You only need to set this
720 if you've moved index.php out of the install directory.) This can
721 be either a relative URL (from the directory where the top-level
722 PhpWiki script is) or an absolute one.");
726 $properties['PhpWiki Install Directory'] =
727 new _define_commented('PHPWIKI_DIR', '/htdocs/some/where/phpwiki', "
728 Path to the PhpWiki install directory. This is the local
729 filesystem counterpart to DATA_PATH. (If you have to set
730 DATA_PATH, your probably have to set this as well.) This can be
731 either an absolute path, or a relative path interpreted from the
732 directory where the top-level PhpWiki script (normally index.php)
737 $properties['Use PATH_INFO'] =
738 new boolean_define_commented('USE_PATH_INFO',
739 array('false' => 'do not use PATH_INFO',
740 'true' => 'use PATH_INFO'), "
741 Define to 'true' to use PATH_INFO to pass the pagenames.
742 e.g. http://www.some.where/index.php/HomePage instead
743 of http://www.some.where/index.php?pagename=HomePage
744 FIXME: more docs (maybe in README).");
748 $properties['Virtual Path'] =
749 new _define_commented('VIRTUAL_PATH', '/SomeWiki', "
750 VIRTUAL_PATH is the canonical URL path under which your your wiki
751 appears. Normally this is the same as dirname(SCRIPT_NAME), however
752 using, e.g. apaches mod_actions (or mod_rewrite), you can make it
755 If you do this, you should set VIRTUAL_PATH here.
757 E.g. your phpwiki might be installed at at /scripts/phpwiki/index.php,
758 but you've made it accessible through eg. /wiki/HomePage.
760 One way to do this is to create a directory named 'wiki' in your
761 server root. The directory contains only one file: an .htaccess
762 file which reads something like:
764 Action x-phpwiki-page /scripts/phpwiki/index.php
765 SetHandler x-phpwiki-page
766 DirectoryIndex /scripts/phpwiki/index.php
768 In that case you should set VIRTUAL_PATH to '/wiki'.
770 (VIRTUAL_PATH is only used if USE_PATH_INFO is true.)
778 // Okay... fire up the code:
781 include \"lib/main.php\";
783 // (c-file-style: \"gnu\")
788 // c-hanging-comment-ender-p: nil
789 // indent-tabs-mode: nil
796 // end of configuration options
797 ///////////////////////////////
798 // begin class definitions
801 * A basic index.php configuration line in the form of a variable.
803 * Produces a string in the form "$name = value;"
805 * $WikiNameRegexp = "value";
809 var $config_item_name;
813 function _variable($config_item_name, $default_value, $description) {
814 $this->config_item_name = $config_item_name;
815 $this->description = $description;
816 $this->default_value = $default_value;
819 function get_config_item_name() {
820 return $this->config_item_name;
823 function get_description() {
824 return $this->description;
827 function get_config_line($posted_value) {
828 return "\n\$" . $this->get_config_item_name() . " = \"$posted_value\";";
830 function get_config($posted_value) {
831 $d = stripHtml($this->get_description());
832 $d = str_replace("\n", "\n// ", $d) . $this->get_config_line($posted_value) ."\n";
836 function get_instructions($title) {
837 $i = "<p><b><h3>" . $title . "</h3></b></p>\n " . nl2p($this->get_description()) . "\n";
838 return "<tr>\n<td>\n" . $i . "</td>\n";
841 function get_html() {
842 return "<input type=\"text\" size=\"50\" name=\"" . $this->get_config_item_name() . "\" value=\"" . $this->default_value . "\">";
846 class unchangeable_variable
848 function get_html() {
851 function get_config_line($posted_value) {
852 if ($this->description)
854 return "${n}".$this->default_value;
856 function get_instructions($title) {
857 $i = "<p><b><h3>" . $title . "</h3></b></p>\n " . nl2p($this->get_description()) . "\n";
858 $i = $i ."<em>Not editable.</em><br />\n<pre>" . $this->default_value."</pre>";
859 return "<tr>\n<td colspan=\"2\">\n" .$i ."</td></tr>\n";
864 class _variable_selection
866 function get_html() {
867 $output = '<select name="' . $this->get_config_item_name() . "\">\n";
868 /* The first option is the default */
869 while(list($option, $label) = each($this->default_value)) {
870 $output .= " <option value=\"$option\">$label</option>\n";
872 $output .= " </select>\n </td>\n";
880 function get_config_line($posted_value) {
881 if ($this->description)
883 if ($posted_value == '')
884 return "${n}//define('".$this->get_config_item_name()."', \"\");";
886 return "${n}define('".$this->get_config_item_name()."', '$posted_value');";
890 class _define_commented
892 function get_config_line($posted_value) {
893 if ($this->description)
895 if ($posted_value == $this->default_value)
896 return "${n}//define('".$this->get_config_item_name()."', '$posted_value');";
897 else if ($posted_value == '')
898 return "${n}//define('".$this->get_config_item_name()."', \"\");";
900 return "${n}define('".$this->get_config_item_name()."', '$posted_value');";
904 class numeric_define_commented
906 function get_config_line($posted_value) {
907 if ($this->description)
909 if ($posted_value == $this->default_value)
910 return "${n}//define('".$this->get_config_item_name()."', $posted_value);";
911 else if ($posted_value == '')
912 return "${n}//define('".$this->get_config_item_name()."', 0);";
914 return "${n}define('".$this->get_config_item_name()."', $posted_value);";
918 class _define_selection
919 extends _variable_selection {
920 function get_config_line($posted_value) {
921 return _define::get_config_line($posted_value);
923 function get_html() {
924 return _variable_selection::get_html();
928 class _define_password
930 function get_config_line($posted_value) {
931 if ($this->description)
933 if ($posted_value == '') {
934 $p = "${n}//define('".$this->get_config_item_name()."', \"\");";
935 $p = $p . "\n// If you used the passencrypt.php utility to encode the password";
936 $p = $p . "\n// then uncomment this line:";
937 $p = $p . "\n//define('ENCRYPTED_PASSWD', true);";
940 if (function_exists('crypt')) {
941 $salt_length = max(CRYPT_SALT_LENGTH,
945 16 * CRYPT_BLOWFISH);
946 // generate an encrypted password
947 $crypt_pass = crypt($posted_value, rand_ascii($salt_length));
948 $p = "${n}define('".$this->get_config_item_name()."', '$crypt_pass');";
949 $p = $p . "\n// If you used the passencrypt.php utility to encode the password";
950 $p = $p . "\n// then uncomment this line:";
951 return $p . "\ndefine('ENCRYPTED_PASSWD', true);";
953 $p = "${n}define('".$this->get_config_item_name()."', '$posted_value');";
954 $p = $p . "\n// If you used the passencrypt.php utility to encode the password";
955 $p = $p . "\n// then uncomment this line:";
956 $p = $p . "\n//define('ENCRYPTED_PASSWD', true);";
957 $p = $p . "\n// Encrypted passwords cannot be used:";
958 $p = $p . "\n// 'function crypt()' not available in this version of php";
963 function get_html() {
964 return _variable_password::get_html();
968 class _variable_password
970 function get_html() {
971 return "<input type=\"password\" name=\"" . $this->get_config_item_name() . "\" value=\"" . $this->default_value . "\">";
977 function get_config_line($posted_value) {
978 if ($this->description)
980 if ($posted_value == '')
981 return "${n}//define('".$this->get_config_item_name()."', 0);";
983 return "${n}define('".$this->get_config_item_name()."', $posted_value);";
989 function get_config_line($posted_value) {
990 // split the phrase by any number of commas or space characters,
991 // which include " ", \r, \t, \n and \f
992 $list_values = preg_split("/[\s,]+/", $posted_value, -1, PREG_SPLIT_NO_EMPTY);
993 $list_values = join("|", $list_values);
994 return _variable::get_config_line($list_values);
996 function get_html() {
997 $list_values = explode("|", $this->default_value);
998 $rows = max(3, count($list_values) +1);
999 $list_values = join("\n", $list_values);
1000 $ta = "<textarea cols=\"18\" rows=\"". $rows ."\" name=\"".$this->get_config_item_name()."\">";
1001 $ta .= $list_values . "</textarea>";
1006 class array_variable
1008 function get_config_line($posted_value) {
1009 // split the phrase by any number of commas or space characters,
1010 // which include " ", \r, \t, \n and \f
1011 $list_values = preg_split("/[\s,]+/", $posted_value, -1, PREG_SPLIT_NO_EMPTY);
1012 if (!empty($list_values)) {
1013 $list_values = "'".join("', '", $list_values)."'";
1014 $list_values = "array(".$list_values.")";
1015 return "\n\$" . $this->get_config_item_name() . " = " . $list_values . ";";
1017 return "\n//\$" . $this->get_config_item_name() . " = array();";
1019 function get_html() {
1020 $list_values = join("\n", $this->default_value);
1021 $rows = max(3, count($this->default_value) +1);
1022 $ta = "<textarea cols=\"18\" rows=\"". $rows ."\" name=\"".$this->get_config_item_name()."\">";
1023 $ta .= $list_values . "</textarea>";
1031 function get_config_line($posted_value) {
1032 if ($posted_value && ! $posted_value == $this->default_value)
1033 return "\nini_set('".$this->get_config_item_name()."', '$posted_value');";
1035 return "\n//ini_set('".$this->get_config_item_name()."', '".$this->default_value."');";
1039 class boolean_define
1041 function get_config_line($posted_value) {
1042 if ($this->description)
1044 return "${n}define('".$this->get_config_item_name()."', $posted_value);";
1046 function get_html() {
1047 $output = '<select name="' . $this->get_config_item_name() . "\">\n";
1048 /* The first option is the default */
1049 list($option, $label) = each($this->default_value);
1050 $output .= " <option value=\"$option\" selected>$label</option>\n";
1051 /* There can only be two options */
1052 list($option, $label) = each($this->default_value);
1053 $output .= " <option value=\"$option\">$label</option>\n";
1054 $output .= "</select>\n </td>\n";
1059 class boolean_define_commented
1060 extends boolean_define {
1061 function get_config_line($posted_value) {
1062 if ($this->description)
1064 list($default_value, $label) = each($this->default_value);
1065 if ($posted_value == $default_value)
1066 return "${n}//define('".$this->get_config_item_name()."', $posted_value);";
1067 else if ($posted_value == '')
1068 return "${n}//define('".$this->get_config_item_name()."', false);";
1070 return "${n}define('".$this->get_config_item_name()."', $posted_value);";
1077 function get_config($posted_value) {
1078 $d = stripHtml($this->get_description());
1080 return "\n".$SEPARATOR . str_replace("\n", "\n// ", $d) ."\n$this->default_value";
1082 function get_instructions($title) {
1083 $i = "<p><b><h2>" . $title . "</h2></b></p>\n " . nl2p($this->get_description()) ."\n";
1084 return "<tr>\n<td colspan=\"2\" bgcolor=\"#eee\">\n" .$i ."</td></tr>\n";
1086 function get_html() {
1091 // html utility functions
1092 function nl2p($text) {
1093 return "<p>" . str_replace("\n\n", "</p>\n<p>", $text) . "</p>";
1096 function stripHtml($text) {
1097 $d = str_replace("<pre>", "", $text);
1098 $d = str_replace("</pre>", "", $d);
1099 $d = str_replace("<dl>", "", $d);
1100 $d = str_replace("</dl>", "", $d);
1101 $d = str_replace("<dt>", "", $d);
1102 $d = str_replace("</dt>", "", $d);
1103 $d = str_replace("<dd>", "", $d);
1104 $d = str_replace("</dd>", "", $d);
1105 //restore html entities into characters
1106 // http://www.php.net/manual/en/function.htmlentities.php
1107 $trans = get_html_translation_table (HTML_ENTITIES);
1108 $trans = array_flip ($trans);
1109 $d = strtr($d, $trans);
1114 * Seed the random number generator.
1116 * better_srand() ensures the randomizer is seeded only once.
1118 * How random do you want it? See:
1119 * http://www.php.net/manual/en/function.srand.php
1120 * http://www.php.net/manual/en/function.mt-srand.php
1122 function better_srand($seed = '') {
1123 static $wascalled = FALSE;
1125 $seed = $seed === '' ? (double) microtime() * 1000000 : $seed;
1128 //trigger_error("new random seed", E_USER_NOTICE); //debugging
1132 function rand_ascii($length = 1) {
1134 //srand((double) microtime() * 1000000);
1136 for ($i = 1; $i <= $length; $i++) {
1137 $s .= chr(rand(40, 126)); // return only typeable 7 bit ascii
1143 function printArray($a) {
1144 echo "<hr />\n<pre>\n";
1146 echo "\n</pre>\n<hr />\n";
1149 // end of class definitions
1150 /////////////////////////////
1151 // begin auto generation code
1153 if ($action == 'make_config') {
1155 $timestamp = date ('dS of F, Y H:i:s');
1158 /* This is a local configuration file for PhpWiki.
1159 * It was automatically generated by the configurator script
1160 * on the $timestamp.
1165 /////////////////////////////////////////////////////////////////////
1169 $posted = $GLOBALS['HTTP_POST_VARS'];
1171 if (defined('DEBUG'))
1172 printArray($GLOBALS['HTTP_POST_VARS']);
1174 foreach($properties as $option_name => $a) {
1175 $posted_value = $posted[$a->config_item_name];
1176 $config .= $properties[$option_name]->get_config($posted_value);
1179 $diemsg = "The configurator.php is provided for testing purposes only.\nYou can't use this file with your PhpWiki server yet!!";
1180 $config .= "\ndie(\"$diemsg\");\n";
1183 /* We first check if the config-file exists. */
1184 if (file_exists('defaults.php')) {
1185 /* We make a backup copy of the file */
1186 $new_filename = 'defaults.' . time() . '.php';
1187 if (@copy('defaults.php', $new_filename)) {
1188 $fp = @fopen('defaults.php', 'w');
1191 $fp = @fopen('defaults.php', 'w');
1195 fputs($fp, $config);
1197 echo "<p>The configuration was written to <code><b>defaults.php</b></code>. A backup was made to <code><b>$new_filename</b></code>.</p>\n";
1199 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>defaults.php</b></code>.</p>\n";
1202 echo "<hr />\n<p>Here's the configuration file based on your answers:</p>\n<pre>\n";
1203 echo htmlentities($config);
1204 echo "</pre>\n<hr />\n";
1206 echo "<!--If she can stand it, I can. Play it!-->\n";
1207 echo "<p>Would you like to <a href=\"configurator.php\">play again</a>?</p>\n";
1210 /* No action has been specified - we make a form. */
1213 <form action="configurator.php" method="post">
1214 <table border="1" cellpadding="4" cellspacing="0">
1215 <input type="hidden" name="action" value="make_config">
1218 while(list($property, $obj) = each($properties)) {
1219 echo $obj->get_instructions($property);
1220 if ($h = $obj->get_html()) {
1221 if (defined('DEBUG'))
1222 $h = get_class($obj) . "<br />\n" . $h;
1223 echo "<td>".$h."</td>\n";
1229 <p><input type="submit" value="Make config-file"> <input type="reset" value="Clear"></p>