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.5 2002-03-26 22:29:06 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>
17 * The Configurator is a php script to aid in the configuration of PhpWiki.
18 * Parts of this file are based on PHPWeather's configurator.php file.
19 * http://sourceforge.net/projects/phpweather/
22 * TO CHANGE THE CONFIGURATION OF YOUR PHPWIKI, DO *NOT* MODIFY THIS FILE!
23 * more instructions go here
26 * An index.php will be generated for you which you can also modify later if you wish.
30 //////////////////////////////
31 // begin configuration options
35 * Notes for the description parameter of $property:
37 * - Descriptive text will be changed into comments (preceeded by //)
38 * for the final output to index.php.
40 * - Only a limited set of html is allowed: pre, dl dt dd; it will be
41 * stripped from the final output.
43 * - Line breaks and spacing will be preserved for the final output.
45 * - Double line breaks are automatically converted to paragraphs
46 * for the html version of the descriptive text.
48 * - Double-quotes and dollar signs in the descriptive text must be
49 * escaped: \" and \$. Instead of escaping double-quotes you can use
50 * single (') quotes for the enclosing quotes.
52 * - Special characters like < and > must use html entities,
53 * they will be converted back to characters for the final output.
56 $SEPARATOR = "///////////////////////////////////////////////////////////////////";
59 Copyright 1999, 2000, 2001, 2002 $ThePhpWikiProgrammingTeam = array(
60 "Steve Wainstead", "Clifford A. Adams", "Lawrence Akka",
61 "Scott R. Anderson", "Jon Åslund", "Neil Brown", "Jeff Dairiki",
62 "Stéphane Gourichon", "Jan Hidders", "Arno Hollosi", "John Jorgensen",
63 "Antti Kaihola", "Jeremie Kass", "Carsten Klapp", "Marco Milanesi",
64 "Grant Morgan", "Jan Nieuwenhuizen", "Aredridel Niothke",
65 "Pablo Roca Rozas", "Sandino Araico Sánchez", "Joel Uckelman",
66 "Reini Urban", "Tim Voght");
68 This file is part of PhpWiki.
70 PhpWiki is free software; you can redistribute it and/or modify
71 it under the terms of the GNU General Public License as published by
72 the Free Software Foundation; either version 2 of the License, or
73 (at your option) any later version.
75 PhpWiki is distributed in the hope that it will be useful,
76 but WITHOUT ANY WARRANTY; without even the implied warranty of
77 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
78 GNU General Public License for more details.
80 You should have received a copy of the GNU General Public License
81 along with PhpWiki; if not, write to the Free Software
82 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
88 This is the starting file for PhpWiki. All this file does is set
89 configuration options, and at the end of the file it includes() the
90 file lib/main.php, where the real action begins.
92 This file is divided into six parts: Parts Zero, One, Two, Three,
93 Four and Five. Each one has different configuration settings you can
94 change; in all cases the default should work on your system,
95 however, we recommend you tailor things to your particular setting.
100 $properties["Part Zero"] =
101 new part('_part0', false, "
102 Part Zero: If PHP needs help in finding where you installed the
103 rest of the PhpWiki code, you can set the include_path here.");
107 $properties["PHP include_path"] =
108 new _ini_set('include_path', "\$include_path", "
109 NOTE: phpwiki uses the PEAR library of php code for SQL database
110 access. Your PHP is probably already configured to set
111 include_path so that PHP can find the pear code. If not (or if you
112 change include_path here) make sure you include the path to the
113 PEAR code in include_path. (To find the PEAR code on your system,
114 search for a file named 'PEAR.php'. Some common locations are:
122 The above examples are already included by PhpWiki. You shouldn't
123 have to change this unless you see a WikiFatalError:
125 lib/FileFinder.php:82: Fatal[256]: DB.php: file not found
127 Define the include path for this wiki: pear plus the phpwiki path
129 $include_path = '.:/Apache/php/pear:/prog/php/phpwiki';
131 Windows needs ';' as path delimiter. cygwin, mac and unix ':'
133 if (substr(PHP_OS,0,3) == 'WIN') {
134 $include_path = implode(';',explode(':',$include_path));
135 } elseif (substr(PHP_OS,0,6) == 'CYGWIN') {
136 $include_path = '.:/usr/local/lib/php/pear:/usr/src/php/phpwiki';
143 $properties["Part Null"] =
144 new part('_partnullheader', "", "
145 Part Null: Don't touch this!");
149 $properties["Part Null Settings"] =
150 new unchangeable_variable('_partnullsettings', "
151 define ('PHPWIKI_VERSION', '1.3.3-jeffs-hacks');
152 require \"lib/prepend.php\";
153 rcs_id('\$Id: configurator.php,v 1.5 2002-03-26 22:29:06 carstenklapp Exp $');", "");
157 $properties["Part One"] =
158 new part('_partone', $SEPARATOR."\n", "
161 Authentication and security settings:
166 $properties["Wiki Name"] =
167 new _define('WIKI_NAME', ''/*'PhpWiki'*/, "
168 The name of your wiki.
169 This is used to generate a keywords meta tag in the HTML templates,
170 in bookmark titles for any bookmarks made to pages in your wiki,
171 and during RSS generation for the title of the RSS channel.");
175 $properties["Reverse DNS"] =
176 new boolean_define('ENABLE_REVERSE_DNS',
177 array('true' => "perform additional reverse dns lookups",
178 'false' => "just record the address as given by the httpd server"), "
179 If set, we will perform reverse dns lookups to try to convert the
180 users IP number to a host name, even if the http server didn't do
185 $properties["Admin Username"] =
186 new _define('ADMIN_USER', "", "
187 Username and password of administrator.
188 Set these to your preferences. For heaven's sake
189 pick a good password!");
190 $properties["Admin Password"] =
191 new _define_password('ADMIN_PASSWD', "", "");
195 $properties["ZIPdump Authentication"] =
196 new boolean_define('ZIPDUMP_AUTH',
197 array('false' => "everyone may download zip dumps",
198 'true' => "only admin may download zip dumps"), "
199 If true, only the admin user can make zip dumps, else zip dumps
200 require no authentication.");
204 $properties["Strict Mailable Pagedumps"] =
205 new boolean_define('STRICT_MAILABLE_PAGEDUMPS',
206 array('false' => "binary",
207 'true' => "quoted-printable"), "
208 If you define this to true, (MIME-type) page-dumps (either zip dumps,
209 or \"dumps to directory\" will be encoded using the quoted-printable
210 encoding. If you're actually thinking of mailing the raw page dumps,
211 then this might be useful, since (among other things,) it ensures
212 that all lines in the message body are under 80 characters in length.
214 Also, setting this will cause a few additional mail headers
215 to be generated, so that the resulting dumps are valid
216 RFC 2822 e-mail messages.
218 Probably, you can just leave this set to false, in which case you get
219 raw ('binary' content-encoding) page dumps.");
223 $properties["HTML Dump Filename Suffix"] =
224 new _variable('HTML_DUMP_SUFFIX', ".html", "
225 Here you can change the filename suffix used for XHTML page dumps.
226 If you don't want any suffix just comment this out.");
230 $properties["Maximum Upload Size"] =
231 new numeric_define('MAX_UPLOAD_SIZE', "16 * 1024 * 1024", "
232 The maximum file upload size.");
236 $properties["Minor Edit Timeout"] =
237 new numeric_define('MINOR_EDIT_TIMEOUT', "7 * 24 * 3600", "
238 If the last edit is older than MINOR_EDIT_TIMEOUT seconds, the
239 default state for the \"minor edit\" checkbox on the edit page form
244 $properties["Disabled Actions"] =
245 new array_variable('DisabledActions', array(), "
246 Actions listed in this array will not be allowed. Actions are:
247 browse, diff, dumphtml, dumpserial, edit, loadfile, lock, remove,
248 unlock, upload, viewsource, zip, ziphtml");
252 $properties["Access Log"] =
253 new _define('ACCESS_LOG', "", "
254 PhpWiki can generate an access_log (in \"NCSA combined log\" format)
255 for you. If you want one, define this to the name of the log file,
256 such as /tmp/wiki_access_log.");
260 $properties["Strict Login"] =
261 new boolean_define('ALLOW_BOGO_LOGIN',
262 array('true' => "Users may Sign In with any WikiWord",
263 'false' => "Only admin may Sign In"), "
264 If ALLOW_BOGO_LOGIN is true, users are allowed to login (with
265 any/no password) using any userid which: 1) is not the ADMIN_USER,
266 2) is a valid WikiWord (matches \$WikiNameRegexp.)");
270 $properties["Require Sign In Before Editing"] =
271 new boolean_define('REQUIRE_SIGNIN_BEFORE_EDIT',
272 array('false' => "Do not require Sign In",
273 'true' => "Require Sign In"), "
274 If set, then if an anonymous user attempts to edit a page he will
275 be required to sign in. (If ALLOW_BOGO_LOGIN is true, of course,
276 no password is required, but the user must still sign in under
277 some sort of BogoUserId.)");
281 $properties["Path for PHP Session Support"] =
282 new _ini_set('session.save_path', 'some_other_directory', "
283 The login code now uses PHP's session support. Usually, the default
284 configuration of PHP is to store the session state information in
285 /tmp. That probably will work fine, but fails e.g. on clustered
286 servers where each server has their own distinct /tmp (this is the
287 case on SourceForge's project web server.) You can specify an
288 alternate directory in which to store state information like so
289 (whatever user your httpd runs as must have read/write permission
290 in this directory):");
294 $properties["Disable PHP Transparent Session ID"] =
295 new unchangeable_variable('session.use_trans_sid', "@ini_set('session.use_trans_sid', 0);", "
296 If your php was compiled with --enable-trans-sid it tries to
297 add a PHPSESSID query argument to all URL strings when cookie
298 support isn't detected in the client browser. For reasons
299 which aren't entirely clear (PHP bug) this screws up the URLs
300 generated by PhpWiki. Therefore, transparent session ids
301 should be disabled. This next line does that.
303 (At the present time, you will not be able to log-in to PhpWiki,
304 or set any user preferences, unless your browser supports cookies.)");
308 ///////// database selection
312 $properties["Part Two"] =
313 new part('_parttwo', $SEPARATOR."\n", "
320 $properties["Database Type"] =
321 new _variable_selection("DBParams|dbtype",
322 array('dba' => "dba DBM",
324 'ADODB' => "SQL ADODB"), "
325 Select the database type:");
328 $properties["Filename / Table name Prefix"] =
329 new _variable_commented("DBParams|prefix", "phpwiki_", "
330 Used by all DB types:
332 prefix for filenames or table names
334 currently you MUST EDIT THE SQL file too (in the schemas/
335 directory because we aren't doing on the fly sql generation
336 during the installation.:");
340 $properties["SQL dsn Setup"] =
341 new part('_sqldsnstuff', "
343 For SQL based backends, specify the database as a DSN
344 The most general form of a DSN looks like:
346 phptype(dbsyntax)://username:password@protocol+hostspec/database
348 For a MySQL database, the following should work:
350 mysql://user:password@host/databasename
352 <dl><dd>FIXME:</dd> <dt>My version Pear::DB seems to be broken enough that there
353 is no way to connect to a mysql server over a socket right now.</dt></dl>
354 <pre>'dsn' => 'mysql://guest@:/var/lib/mysql/mysql.sock/test',
355 'dsn' => 'mysql://guest@localhost/test',
356 'dsn' => 'pgsql://localhost/test',</pre>");
360 $properties["SQL Type"] =
361 new _variable_selection('dsn_sqltype',
362 array('mysql' => "MySQL",
363 'pgsql' => "PostgreSQL"), "
368 $properties["SQL User"] =
369 new _variable('dsn_sqluser', "wikiuser", "
374 $properties["SQL Password"] =
375 new _variable('dsn_sqlpass', "", "
380 $properties["SQL Database Host"] =
381 new _variable('dsn_sqlhostorsock', "localhost", "
382 SQL Database Hostname:");
386 $properties["SQL Database Name"] =
387 new _variable('dsn_sqldbname', "phpwiki", "
388 SQL Database Name:");
391 $properties["SQL dsn"] =
392 new unchangeable_variable("DBParams['dsn']", "\$DBParams['dsn'] = \"\$dsn_sqltype://\$dsn_sqluser:\$dsn_sqlpass@\$dsn_sqlhostorsock/\$dsn_sqldbname\";", "
397 $properties["dba directory"] =
398 new _variable("DBParams|directory", "/tmp", "
402 $properties["dba handler"] =
403 new _variable_selection('DBParams|dba_handler',
404 array('gdbm' => "Gdbm - GNU database manager",
405 'db2' => "DB2 - Sleepycat Software's DB2",
406 'db3' => "DB3 - Sleepycat Software's DB3"), "
407 Use 'gdbm', 'db2', or db3 depending on your database:");
411 $properties["dba timeout"] =
412 new _variable("DBParams|timeout", "20", "
413 Recommended values are 20 or 5.");
421 $properties["Page Revisions"] =
422 new part('_parttworevisions', "
425 The next section controls how many old revisions of each page are
426 kept in the database.
428 There are two basic classes of revisions: major and minor. Which
429 class a revision belongs in is determined by whether the author
430 checked the \"this is a minor revision\" checkbox when they saved the
433 There is, additionally, a third class of revisions: author
434 revisions. The most recent non-mergable revision from each distinct
435 author is and author revision.
437 The expiry parameters for each of those three classes of revisions
438 can be adjusted seperately. For each class there are five
439 parameters (usually, only two or three of the five are actually
440 set) which control how long those revisions are kept in the
443 <dt>max_keep:</dt> <dd>If set, this specifies an absolute maximum for the
444 number of archived revisions of that class. This is
445 meant to be used as a safety cap when a non-zero
446 min_age is specified. It should be set relatively high,
447 and it's purpose is to prevent malicious or accidental
448 database overflow due to someone causing an
449 unreasonable number of edits in a short period of time.</dd>
451 <dt>min_age:</dt> <dd>Revisions younger than this (based upon the supplanted
452 date) will be kept unless max_keep is exceeded. The age
453 should be specified in days. It should be a
454 non-negative, real number,</dd>
456 <dt>min_keep:</dt> <dd>At least this many revisions will be kept.</dd>
458 <dt>keep:</dt> <dd>No more than this many revisions will be kept.</dd>
460 <dt>max_age:</dt> <dd>No revision older than this age will be kept.</dd>
462 Supplanted date: Revisions are timestamped at the instant that they
463 cease being the current revision. Revision age is computed using
464 this timestamp, not the edit time of the page.
466 Merging: When a minor revision is deleted, if the preceding
467 revision is by the same author, the minor revision is merged with
468 the preceding revision before it is deleted. Essentially: this
469 replaces the content (and supplanted timestamp) of the previous
470 revision with the content after the merged minor edit, the rest of
471 the page metadata for the preceding version (summary, mtime, ...)
476 // For now the expiration parameters are statically inserted as
477 // an unchangeable property. You'll have to edit the resulting
478 // config file if you really want to change these from the default.
480 $properties["Expiration Parameters for Major Edits"] =
481 new unchangeable_variable('Expiration_Parameters_for_Major_Edits',
482 "\$ExpireParams['major'] = array('max_age' => 32,
484 Keep up to 8 major edits, but keep them no longer than a month.");
488 $properties["Expiration Parameters for Minor Edits"] =
489 new unchangeable_variable('Expiration_Parameters_for_Minor_Edits',
490 "\$ExpireParams['minor'] = array('max_age' => 7,
492 Keep up to 4 minor edits, but keep them no longer than a week.");
496 $properties["Expiration Parameters by Author"] =
497 new unchangeable_variable('Expiration_Parameters_by_Author',
498 "\$ExpireParams['author'] = array('max_age' => 365,
501 'max_keep' => 20);", "
502 Keep the latest contributions of the last 8 authors up to a year.
503 Additionally, (in the case of a particularly active page) try to
504 keep the latest contributions of all authors in the last week (even
505 if there are more than eight of them,) but in no case keep more
506 than twenty unique author revisions.");
511 $properties["Part Three"] =
512 new part('_partthree', $SEPARATOR."\n", "
515 Page appearance and layout
520 $properties["Theme"] =
521 new _define_selection('THEME',
522 array('default' => "default",
523 'Hawaiian' => "Hawaiian",
524 'MacOSX' => "MacOSX",
525 'Portland' => "Portland",
526 'Sidebar' => "Sidebar",
527 'SpaceWiki' => "SpaceWiki"), "
530 Most of the page appearance is controlled by files in the theme
533 There are a number of pre-defined themes shipped with PhpWiki.
534 Or you may create your own (e.g. by copying and then modifying one of
539 define('THEME', 'default');
540 define('THEME', 'Hawaiian');
541 define('THEME', 'MacOSX');
542 define('THEME', 'Portland');
543 define('THEME', 'Sidebar');
544 define('THEME', 'SpaceWiki');</pre>");
549 $properties["Character Set"] =
550 new _define('CHARSET', 'iso-8859-1', "
551 Select a valid charset name to be inserted into the xml/html pages,
552 and to reference links to the stylesheets (css). For more info see:
553 http://www.iana.org/assignments/character-sets. Note that PhpWiki
554 has been extensively tested only with the latin1 (iso-8859-1)
557 If you change the default from iso-8859-1 PhpWiki may not work
558 properly and it will require code modifications. However, character
559 sets similar to iso-8859-1 may work with little or no modification
560 depending on your setup. The database must also support the same
561 charset, and of course the same is true for the web browser. (Some
562 work is in progress hopefully to allow more flexibility in this
563 area in the future).");
567 $properties["Language"] =
568 new _variable_selection('LANG',
569 array('C' => "English",
570 'nl' => "Nederlands",
577 Select your language/locale - default language is \"C\" for English.
578 Other languages available:<pre>
579 English \"C\" (English - HomePage)
580 Dutch \"nl\" (Nederlands - ThuisPagina)
581 Spanish \"es\" (Español - PáginaPrincipal)
582 French \"fr\" (Français - Accueil)
583 German \"de\" (Deutsch - StartSeite)
584 Swedish \"sv\" (Svenska - Framsida)
585 Italian \"it\" (Italiano - PaginaPrincipale)
587 If you set \$LANG to the empty string, your systems default language
588 (as determined by the applicable environment variables) will be
591 Note that on some systems, apprently using these short forms for
592 the locale won't work. On my home system 'LANG=de' won't result in
593 german pages. Somehow the system must recognize the locale as a
594 valid locale before gettext() will work, i.e., use 'de_DE', 'nl_NL'.");
598 $properties["Wiki Page Source"] =
599 new _define('WIKI_PGSRC', 'pgsrc', "
600 WIKI_PGSRC -- specifies the source for the initial page contents of
601 the Wiki. The setting of WIKI_PGSRC only has effect when the wiki is
602 accessed for the first time (or after clearing the database.)
603 WIKI_PGSRC can either name a directory or a zip file. In either case
604 WIKI_PGSRC is scanned for files -- one file per page.
606 define('WIKI_PGSRC', 'pgsrc'); // Default (old) behavior.
607 define('WIKI_PGSRC', 'wiki.zip'); // New style.
608 define('WIKI_PGSRC', '../../../Logs/Hamwiki/hamwiki-20010830.zip'); // New style.
613 $properties["Default Wiki Page Source"] =
614 new _define('DEFAULT_WIKI_PGSRC', 'pgsrc', "
615 DEFAULT_WIKI_PGSRC is only used when the language is *not* the
616 default (English) and when reading from a directory: in that case
617 some English pages are inserted into the wiki as well.
618 DEFAULT_WIKI_PGSRC defines where the English pages reside.
620 FIXME: is this really needed?
625 $properties["Generic Pages"] =
626 new array_variable('GenericPages', array('ReleaseNotes', 'SteveWainstead', 'TestPage'), "
627 These are the pages which will get loaded from DEFAULT_WIKI_PGSRC.
629 FIXME: is this really needed? Can't we just copy these pages into
636 $properties["Part Four"] =
637 new part('_partfour', $SEPARATOR."\n", "
645 $properties["Allowed Protocols"] =
646 new list_variable('AllowedProtocols', 'http|https|mailto|ftp|news|nntp|ssh|gopher', "
647 allowed protocols for links - be careful not to allow \"javascript:\"
648 URL of these types will be automatically linked.
649 within a named link [name|uri] one more protocol is defined: phpwiki");
653 $properties["Inline Images"] =
654 new list_variable('InlineImages', 'png|jpg|gif', "
655 URLs ending with the following extension should be inlined as images");
659 $properties["WikiName Regexp"] =
660 new _variable('WikiNameRegexp', "(?<![[:alnum:]])(?:[[:upper:]][[:lower:]]+){2,}(?![[:alnum:]])", "
661 Perl regexp for WikiNames (\"bumpy words\")
662 (?<!..) & (?!...) used instead of '\b' because \b matches '_' as well");
666 $properties["InterWiki Map File"] =
667 new _define('INTERWIKI_MAP_FILE', 'lib/interwiki.map', "
668 InterWiki linking -- wiki-style links to other wikis on the web
670 The map will be taken from a page name InterWikiMap.
671 If that page is not found (or is not locked), or map
672 data can not be found in it, then the file specified
673 by INTERWIKI_MAP_FILE (if any) will be used.");
677 $properties["Part Five"] =
678 new part('_partfive', $SEPARATOR."\n", "
681 URL options -- you can probably skip this section.
686 $properties["Server Name"] =
687 new _define_commented('SERVER_NAME', 'some.host.com', "
688 Canonical name and httpd port of the server on which this PhpWiki
693 $properties["Server Port"] =
694 new numeric_define_commented('SERVER_PORT', 80, "");
697 $properties["Script Name"] =
698 new _define_commented('SCRIPT_NAME', '/some/where/index.php', "
699 Relative URL (from the server root) of the PhpWiki script.");
703 $properties["Data Path"] =
704 new _define_commented('DATA_PATH', '/some/where/phpwiki', "
705 URL of the PhpWiki install directory. (You only need to set this
706 if you've moved index.php out of the install directory.) This can
707 be either a relative URL (from the directory where the top-level
708 PhpWiki script is) or an absolute one.");
712 $properties["PhpWiki Install Directory"] =
713 new _define_commented('PHPWIKI_DIR', '/htdocs/some/where/phpwiki', "
714 Path to the PhpWiki install directory. This is the local
715 filesystem counterpart to DATA_PATH. (If you have to set
716 DATA_PATH, your probably have to set this as well.) This can be
717 either an absolute path, or a relative path interpreted from the
718 directory where the top-level PhpWiki script (normally index.php)
723 $properties["Use PATH_INFO"] =
724 new boolean_define_commented('USE_PATH_INFO',
725 array('false' => 'do not use PATH_INFO',
726 'true' => 'use PATH_INFO'), "
727 Define to 'true' to use PATH_INFO to pass the pagenames.
728 e.g. http://www.some.where/index.php/HomePage instead
729 of http://www.some.where/index.php?pagename=HomePage
730 FIXME: more docs (maybe in README).");
734 $properties["Virtual Path"] =
735 new _define_commented('VIRTUAL_PATH', '/SomeWiki', "
736 VIRTUAL_PATH is the canonical URL path under which your your wiki
737 appears. Normally this is the same as dirname(SCRIPT_NAME), however
738 using, e.g. apaches mod_actions (or mod_rewrite), you can make it
741 If you do this, you should set VIRTUAL_PATH here.
743 E.g. your phpwiki might be installed at at /scripts/phpwiki/index.php,
744 but you've made it accessible through eg. /wiki/HomePage.
746 One way to do this is to create a directory named 'wiki' in your
747 server root. The directory contains only one file: an .htaccess
748 file which reads something like:
750 Action x-phpwiki-page /scripts/phpwiki/index.php
751 SetHandler x-phpwiki-page
752 DirectoryIndex /scripts/phpwiki/index.php
754 In that case you should set VIRTUAL_PATH to '/wiki'.
756 (VIRTUAL_PATH is only used if USE_PATH_INFO is true.)
764 // Okay... fire up the code:
767 include \"lib/main.php\";
769 // (c-file-style: \"gnu\")
774 // c-hanging-comment-ender-p: nil
775 // indent-tabs-mode: nil
782 // end of configuration options
783 ///////////////////////////////
784 // begin class definitions
787 * A basic index.php configuration line in the form of a variable.
789 * Produces a string in the form "$name = value;"
791 * $WikiNameRegexp = "value";
795 var $config_item_name;
799 function _variable($config_item_name, $default_value, $description) {
800 $this->config_item_name = $config_item_name;
801 $this->description = $description;
802 $this->default_value = $default_value;
805 function _config_format($value) {
806 $v = $this->get_config_item_name();
807 // handle arrays: a|b --> a['b']
808 if (strpos($v, '|')) {
809 list($a, $b) = explode('|', $v);
810 $v = sprintf("%s['%s']", $a, $b);
812 return sprintf("\$%s = \"%s\";", $v, $value);
814 function get_config_item_name() {
815 return $this->config_item_name;
818 function _get_description() {
819 return $this->description;
822 function _get_config_line($posted_value) {
823 return "\n" . $this->_config_format($posted_value);
825 function get_config($posted_value) {
826 $d = stripHtml($this->_get_description());
827 $d = str_replace("\n", "\n// ", $d) . $this->_get_config_line($posted_value) ."\n";
831 function get_instructions($title) {
832 $i = "<p><b><h3>" . $title . "</h3></b></p>\n " . nl2p($this->_get_description()) . "\n";
833 return "<tr>\n<td>\n" . $i . "</td>\n";
836 function get_html() {
837 return "<input type=\"text\" size=\"50\" name=\"" . $this->get_config_item_name() . "\" value=\"" . $this->default_value . "\">";
841 class unchangeable_variable
843 function _config_format($value) {
846 function get_html() {
849 function _get_config_line($posted_value) {
850 if ($this->description)
852 return "${n}".$this->default_value;
854 function get_instructions($title) {
855 $i = "<p><b><h3>" . $title . "</h3></b></p>\n " . nl2p($this->_get_description()) . "\n";
856 $i = $i ."<em>Not editable.</em><br />\n<pre>" . $this->default_value."</pre>";
857 return "<tr>\n<td colspan=\"2\">\n" .$i ."</td></tr>\n";
862 class _variable_selection
864 function get_html() {
865 $output = '<select name="' . $this->get_config_item_name() . "\">\n";
866 /* The first option is the default */
867 while(list($option, $label) = each($this->default_value)) {
868 $output .= " <option value=\"$option\">$label</option>\n";
870 $output .= " </select>\n </td>\n";
878 function _config_format($value) {
879 return sprintf("define('%s', '%s');", $this->get_config_item_name(), $value);
881 function _get_config_line($posted_value) {
882 if ($this->description)
884 if ($posted_value == '')
885 return "${n}//" . $this->_config_format("");
887 return "${n}" . $this->_config_format($posted_value);
891 class _define_commented
893 function _get_config_line($posted_value) {
894 if ($this->description)
896 if ($posted_value == $this->default_value)
897 return "${n}//" . $this->_config_format($posted_value);
898 else if ($posted_value == '')
899 return "${n}//" . $this->_config_format("");
901 return "${n}" . $this->_config_format($posted_value);
904 class _variable_commented
906 function _get_config_line($posted_value) {
907 if ($this->description)
909 if ($posted_value == $this->default_value)
910 return "${n}//" . $this->_config_format($posted_value);
911 else if ($posted_value == '')
912 return "${n}//" . $this->_config_format("");
914 return "${n}" . $this->_config_format($posted_value);
918 class numeric_define_commented
920 function _config_format($value) {
921 return sprintf("define('%s', %s);", $this->get_config_item_name(), $value);
923 function _get_config_line($posted_value) {
924 if ($this->description)
926 if ($posted_value == $this->default_value)
927 return "${n}//" . $this->_config_format($posted_value);
928 else if ($posted_value == '')
929 return "${n}//" . $this->_config_format('0');
931 return "${n}" . $this->_config_format($posted_value);
935 class _define_selection
936 extends _variable_selection {
937 function _config_format($value) {
938 return sprintf("define('%s', '%s');", $this->get_config_item_name(), $value);
940 function _get_config_line($posted_value) {
941 return _define::_get_config_line($posted_value);
943 function get_html() {
944 return _variable_selection::get_html();
948 class _define_password
950 function _get_config_line($posted_value) {
951 if ($this->description)
953 if ($posted_value == '') {
954 $p = "${n}//" . $this->_config_format("");
955 $p = $p . "\n// If you used the passencrypt.php utility to encode the password";
956 $p = $p . "\n// then uncomment this line:";
957 $p = $p . "\n//define('ENCRYPTED_PASSWD', true);";
960 if (function_exists('crypt')) {
961 $salt_length = max(CRYPT_SALT_LENGTH,
965 16 * CRYPT_BLOWFISH);
966 // generate an encrypted password
967 $crypt_pass = crypt($posted_value, rand_ascii($salt_length));
968 $p = "${n}" . $this->_config_format($crypt_pass);
969 $p = $p . "\n// If you used the passencrypt.php utility to encode the password";
970 $p = $p . "\n// then uncomment this line:";
971 return $p . "\ndefine('ENCRYPTED_PASSWD', true);";
973 $p = "${n}" . $this->_config_format($posted_value);
974 $p = $p . "\n// If you used the passencrypt.php utility to encode the password";
975 $p = $p . "\n// then uncomment this line:";
976 $p = $p . "\n//define('ENCRYPTED_PASSWD', true);";
977 $p = $p . "\n// Encrypted passwords cannot be used:";
978 $p = $p . "\n// 'function crypt()' not available in this version of php";
983 function get_html() {
984 return _variable_password::get_html();
988 class _variable_password
990 function get_html() {
991 return "<input type=\"password\" name=\"" . $this->get_config_item_name() . "\" value=\"" . $this->default_value . "\">";
997 function _config_format($value) {
998 return sprintf("define('%s', %s);", $this->get_config_item_name(), $value);
1000 function _get_config_line($posted_value) {
1001 if ($this->description)
1003 if ($posted_value == '')
1004 return "${n}//" . $this->_config_format('0');
1006 return "${n}" . $this->_config_format($posted_value);
1012 function _get_config_line($posted_value) {
1013 // split the phrase by any number of commas or space characters,
1014 // which include " ", \r, \t, \n and \f
1015 $list_values = preg_split("/[\s,]+/", $posted_value, -1, PREG_SPLIT_NO_EMPTY);
1016 $list_values = join("|", $list_values);
1017 return _variable::_get_config_line($list_values);
1019 function get_html() {
1020 $list_values = explode("|", $this->default_value);
1021 $rows = max(3, count($list_values) +1);
1022 $list_values = join("\n", $list_values);
1023 $ta = "<textarea cols=\"18\" rows=\"". $rows ."\" name=\"".$this->get_config_item_name()."\">";
1024 $ta .= $list_values . "</textarea>";
1029 class array_variable
1031 function _config_format($value) {
1032 return sprintf("\$%s = array(%s);", $this->get_config_item_name(), $value);
1034 function _get_config_line($posted_value) {
1035 // split the phrase by any number of commas or space characters,
1036 // which include " ", \r, \t, \n and \f
1037 $list_values = preg_split("/[\s,]+/", $posted_value, -1, PREG_SPLIT_NO_EMPTY);
1038 if (!empty($list_values)) {
1039 $list_values = "'".join("', '", $list_values)."'";
1040 return "\n" . $this->_config_format($list_values);
1042 return "\n//" . $this->_config_format('');
1044 function get_html() {
1045 $list_values = join("\n", $this->default_value);
1046 $rows = max(3, count($this->default_value) +1);
1047 $ta = "<textarea cols=\"18\" rows=\"". $rows ."\" name=\"".$this->get_config_item_name()."\">";
1048 $ta .= $list_values . "</textarea>";
1056 function _config_format($value) {
1057 return sprintf("ini_set('%s', '%s');", $this->get_config_item_name(), $value);
1059 function _get_config_line($posted_value) {
1060 if ($posted_value && ! $posted_value == $this->default_value)
1061 return "\n" . $this->_config_format($posted_value);
1063 return "\n//" . $this->_config_format($this->default_value);
1067 class boolean_define
1069 function _config_format($value) {
1070 return sprintf("define('%s', %s);", $this->get_config_item_name(), $value);
1072 function _get_config_line($posted_value) {
1073 if ($this->description)
1075 return "${n}" . $this->_config_format($posted_value);
1077 function get_html() {
1078 $output = '<select name="' . $this->get_config_item_name() . "\">\n";
1079 /* The first option is the default */
1080 list($option, $label) = each($this->default_value);
1081 $output .= " <option value=\"$option\" selected>$label</option>\n";
1082 /* There can only be two options */
1083 list($option, $label) = each($this->default_value);
1084 $output .= " <option value=\"$option\">$label</option>\n";
1085 $output .= "</select>\n </td>\n";
1090 class boolean_define_commented
1091 extends boolean_define {
1092 function _get_config_line($posted_value) {
1093 if ($this->description)
1095 list($default_value, $label) = each($this->default_value);
1096 if ($posted_value == $default_value)
1097 return "${n}//" . $this->_config_format($posted_value);
1098 else if ($posted_value == '')
1099 return "${n}//" . $this->_config_format('false');
1101 return "${n}" . $this->_config_format($posted_value);
1108 function get_config($posted_value) {
1109 $d = stripHtml($this->_get_description());
1111 return "\n".$SEPARATOR . str_replace("\n", "\n// ", $d) ."\n$this->default_value";
1113 function get_instructions($title) {
1114 $i = "<p><b><h2>" . $title . "</h2></b></p>\n " . nl2p($this->_get_description()) ."\n";
1115 return "<tr>\n<td colspan=\"2\" bgcolor=\"#eee\">\n" .$i ."</td></tr>\n";
1117 function get_html() {
1122 // html utility functions
1123 function nl2p($text) {
1124 return "<p>" . str_replace("\n\n", "</p>\n<p>", $text) . "</p>";
1127 function stripHtml($text) {
1128 $d = str_replace("<pre>", "", $text);
1129 $d = str_replace("</pre>", "", $d);
1130 $d = str_replace("<dl>", "", $d);
1131 $d = str_replace("</dl>", "", $d);
1132 $d = str_replace("<dt>", "", $d);
1133 $d = str_replace("</dt>", "", $d);
1134 $d = str_replace("<dd>", "", $d);
1135 $d = str_replace("</dd>", "", $d);
1136 //restore html entities into characters
1137 // http://www.php.net/manual/en/function.htmlentities.php
1138 $trans = get_html_translation_table (HTML_ENTITIES);
1139 $trans = array_flip ($trans);
1140 $d = strtr($d, $trans);
1145 * Seed the random number generator.
1147 * better_srand() ensures the randomizer is seeded only once.
1149 * How random do you want it? See:
1150 * http://www.php.net/manual/en/function.srand.php
1151 * http://www.php.net/manual/en/function.mt-srand.php
1153 function better_srand($seed = '') {
1154 static $wascalled = FALSE;
1156 $seed = $seed === '' ? (double) microtime() * 1000000 : $seed;
1159 //trigger_error("new random seed", E_USER_NOTICE); //debugging
1163 function rand_ascii($length = 1) {
1165 //srand((double) microtime() * 1000000);
1167 for ($i = 1; $i <= $length; $i++) {
1168 $s .= chr(rand(40, 126)); // return only typeable 7 bit ascii
1174 function printArray($a) {
1175 echo "<hr />\n<pre>\n";
1177 echo "\n</pre>\n<hr />\n";
1180 // end of class definitions
1181 /////////////////////////////
1182 // begin auto generation code
1184 if ($action == 'make_config') {
1186 $timestamp = date ('dS of F, Y H:i:s');
1189 /* This is a local configuration file for PhpWiki.
1190 * It was automatically generated by the configurator script
1191 * on the $timestamp.
1196 /////////////////////////////////////////////////////////////////////
1200 $posted = $GLOBALS['HTTP_POST_VARS'];
1202 if (defined('DEBUG'))
1203 printArray($GLOBALS['HTTP_POST_VARS']);
1205 foreach($properties as $option_name => $a) {
1206 $posted_value = $posted[$a->config_item_name];
1207 $config .= $properties[$option_name]->get_config($posted_value);
1210 if (defined('DEBUG')) {
1211 $diemsg = "The configurator.php is provided for testing purposes only.\nYou can't use this file with your PhpWiki server yet!!";
1212 $config .= "\ndie(\"$diemsg\");\n";
1216 /* We first check if the config-file exists. */
1217 if (file_exists('settings.php')) {
1218 /* We make a backup copy of the file */
1219 $new_filename = 'settings.' . time() . '.php';
1220 if (@copy('settings.php', $new_filename)) {
1221 $fp = @fopen('settings.php', 'w');
1224 $fp = @fopen('settings.php', 'w');
1228 fputs($fp, $config);
1230 echo "<p>The configuration was written to <code><b>settings.php</b></code>.</p>\n";
1231 if ($new_filename) {
1232 echo "<p>A backup was made to <code><b>$new_filename</b></code>.</p>\n";
1234 echo "<p><strong>You must rename or copy this</strong> <code><b>settings.php</b></code> <strong>file to</strong> <code><b>index.php</b></code>.</p>\n";
1236 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";
1239 echo "<hr />\n<p>Here's the configuration file based on your answers:</p>\n<pre>\n";
1240 echo htmlentities($config);
1241 echo "</pre>\n<hr />\n";
1243 echo "<p>To make any corrections, <a href=\"configurator.php\">edit the settings again</a>.</p>\n";
1246 /* No action has been specified - we make a form. */
1249 <form action="configurator.php" method="post">
1250 <table border="1" cellpadding="4" cellspacing="0">
1251 <input type="hidden" name="action" value="make_config">
1254 while(list($property, $obj) = each($properties)) {
1255 echo $obj->get_instructions($property);
1256 if ($h = $obj->get_html()) {
1257 if (defined('DEBUG'))
1258 $h = get_class($obj) . "<br />\n" . $h;
1259 echo "<td>".$h."</td>\n";
1265 <p><input type="submit" value="Make config-file"> <input type="reset" value="Clear"></p>