From: Carsten K. <car...@us...> - 2002-02-25 18:14:16
|
Update of /cvsroot/phpwiki/phpwiki In directory usw-pr-cvs1:/tmp/cvs-serv32766 Modified Files: configurator.php Log Message: Now handles about two thirds of the settings in config.php, and incorporates the password encryption functions from passencrypt.php for generating an encoded admin password if the crypt() function is available. Index: configurator.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/configurator.php,v retrieving revision 1.1 retrieving revision 1.2 diff -u -2 -b -p -d -r1.1 -r1.2 --- configurator.php 22 Feb 2002 07:12:09 -0000 1.1 +++ configurator.php 25 Feb 2002 18:14:11 -0000 1.2 @@ -74,6 +74,6 @@ $preamble = ' -$properties['part0'] = -new part('Part Zero', false, ' +$properties['Part Zero'] = +new part('part0', false, ' Part Zero: If PHP needs help in finding where you installed the rest of the PhpWiki code, you can set the include_path here.'); @@ -82,5 +82,5 @@ rest of the PhpWiki code, you can set th $properties['PHP include_path'] = -new iniset('include_path', false, " +new iniset('include_path', "\$include_path", " NOTE: phpwiki uses the PEAR library of php code for SQL database access. Your PHP is probably already configured to set @@ -117,15 +117,20 @@ if (substr(PHP_OS,0,3) == 'WIN') { -$properties['partnull'] = -new part('Part Null', " -define ('PHPWIKI_VERSION', '1.3.2-jeffs-hacks'); -require \"lib/prepend.php\"; -rcs_id('$Id$'); -", " +$properties['Part Null'] = +new part('partnullheader', "", " Part Null: Don't touch this!"); -$properties['partone'] = -new part('Part One', "/////////////////////////////////////////////////////////////////// + +$properties['Part Null Settings'] = +new unchangeable_property('partnullsettings', " +define ('PHPWIKI_VERSION', '1.3.3-jeffs-hacks'); +require \"lib/prepend.php\"; +rcs_id('\$Id$');", ""); + + + +$properties['Part One'] = +new part('partone', "/////////////////////////////////////////////////////////////////// ", " @@ -161,5 +166,5 @@ Set these to your preferences. For heave pick a good password!"); $properties['Admin Password'] = -new defines('ADMIN_PASSWD', "", ""); +new defines_password('ADMIN_PASSWD', "", ""); @@ -167,6 +172,6 @@ new defines('ADMIN_PASSWD', "", ""); $properties['ZIPdump Authentication'] = new defines_boolean('ZIPDUMP_AUTH', - array('false' => 'everyone', - 'true' => 'only admin'), " + array('false' => 'everyone may download zip dumps', + 'true' => 'only admin may download zip dumps'), " If true, only the admin user can make zip dumps, else zip dumps require no authentication."); @@ -207,8 +212,134 @@ will be off."); +//fixme: new property subclass +$properties['Disabled Actions'] = +new property('DisabledActions', "array('dumpserial', 'loadfile')", " +Actions listed in this array will not be allowed."); + + + +//fixme: commented out by default +$properties['Access Log'] = +new defines('ACCESS_LOG', "/tmp/wiki_access_log", " +PhpWiki can generate an access_log (in \"NCSA combined log\" format) +for you. If you want one, define this to the name of the log file."); + + + +$properties['Strict Login'] = +new defines_boolean('ALLOW_BOGO_LOGIN', + array('true' => 'Users may Sign In with any WikiWord', + 'false' => 'Only admin may Sign In'), " +If ALLOW_BOGO_LOGIN is true, users are allowed to login (with +any/no password) using any userid which: 1) is not the ADMIN_USER, +2) is a valid WikiWord (matches $WikiNameRegexp.)"); + + + +$properties['Require Sign In Before Editing'] = +new defines_boolean('REQUIRE_SIGNIN_BEFORE_EDIT', + array('false' => 'Do not require Sign In', + 'true' => 'Require Sign In'), " +If set, then if an anonymous user attempts to edit a page he will +be required to sign in. (If ALLOW_BOGO_LOGIN is true, of course, +no password is required, but the user must still sign in under +some sort of BogoUserId.)"); + + + +$properties['Path for PHP Session Support'] = +new iniset('session.save_path', 'some_other_directory', " +The login code now uses PHP's session support. Usually, the default +configuration of PHP is to store the session state information in +/tmp. That probably will work fine, but fails e.g. on clustered +servers where each server has their own distinct /tmp (this is the +case on SourceForge's project web server.) You can specify an +alternate directory in which to store state information like so +(whatever user your httpd runs as must have read/write permission +in this directory):"); + + + +$properties['Disable PHP Transparent Session ID'] = +new unchangeable_property('session.use_trans_sid', "@ini_set('session.use_trans_sid', 0);", " +If your php was compiled with --enable-trans-sid it tries to +add a PHPSESSID query argument to all URL strings when cookie +support isn't detected in the client browser. For reasons +which aren't entirely clear (PHP bug) this screws up the URLs +generated by PhpWiki. Therefore, transparent session ids +should be disabled. This next line does that. + +(At the present time, you will not be able to log-in to PhpWiki, +or set any user preferences, unless your browser supports cookies.)"); + + + +$properties['Part Two'] = +new part('parttwo', "/////////////////////////////////////////////////////////////////// +", " + +Part Two: +Database Selection +"); + + + +// MORE CONFIG OPTIONS GO IN HERE + + + +$properties['Page Revisions'] = +new part('parttworevisions', " +", " + +The next section controls how many old revisions of each page are +kept in the database. +There are two basic classes of revisions: major and minor. Which +class a revision belongs in is determined by whether the author +checked the \"this is a minor revision\" checkbox when they saved the +page. +There is, additionally, a third class of revisions: author +revisions. The most recent non-mergable revision from each distinct +author is and author revision. +The expiry parameters for each of those three classes of revisions +can be adjusted seperately. For each class there are five +parameters (usually, only two or three of the five are actually +set) which control how long those revisions are kept in the +database. +<pre> + max_keep: If set, this specifies an absolute maximum for the + number of archived revisions of that class. This is + meant to be used as a safety cap when a non-zero + min_age is specified. It should be set relatively high, + and it's purpose is to prevent malicious or accidental + database overflow due to someone causing an + unreasonable number of edits in a short period of time. + min_age: Revisions younger than this (based upon the supplanted + date) will be kept unless max_keep is exceeded. The age + should be specified in days. It should be a + non-negative, real number, + + min_keep: At least this many revisions will be kept. + + keep: No more than this many revisions will be kept. + + max_age: No revision older than this age will be kept. +</pre> +Supplanted date: Revisions are timestamped at the instant that they +cease being the current revision. Revision age is computed using +this timestamp, not the edit time of the page. + +Merging: When a minor revision is deleted, if the preceding +revision is by the same author, the minor revision is merged with +the preceding revision before it is deleted. Essentially: this +replaces the content (and supplanted timestamp) of the previous +revision with the content after the merged minor edit, the rest of +the page metadata for the preceding version (summary, mtime, ...) +is not changed. +"); @@ -218,4 +349,43 @@ will be off."); +$properties['Part Three'] = +new part('partthree', "/////////////////////////////////////////////////////////////////// +", " + +Part Three: +Page appearance and layout +"); + + + +$properties['Theme'] = +new defines_selection('THEME', + array('default' => 'default', + 'Hawaiian' => 'Hawaiian', + 'MacOSX' => 'MacOSX', + 'Portland' => 'Portland', + 'Sidebar' => 'Sidebar', + 'SpaceWiki' => 'SpaceWiki'), " +THEME + +Most of the page appearance is controlled by files in the theme +subdirectory. + +There are a number of pre-defined themes shipped with PhpWiki. +Or you may create your own (e.g. by copying and then modifying one of +stock themes.) + +Pick one. +<pre> +define('THEME', 'default'); +define('THEME', 'Hawaiian'); +define('THEME', 'MacOSX'); +define('THEME', 'Portland'); +define('THEME', 'Sidebar'); +define('THEME', 'SpaceWiki');</pre>"); + + + + $properties['Character Set'] = new defines('CHARSET', 'iso-8859-1', " @@ -270,4 +440,83 @@ valid locale before gettext() will work, +$properties['Part Four'] = +new part('partfour', "/////////////////////////////////////////////////////////////////// +", " + +Part Four: +Mark-up options. +"); + + + +//fixme: new property subclass +$properties['Allowed Protocols'] = +new property('AllowedProtocols', "http|https|mailto|ftp|news|nntp|ssh|gopher", " +allowed protocols for links - be careful not to allow \"javascript:\" +URL of these types will be automatically linked. +within a named link [name|uri] one more protocol is defined: phpwiki"); + + + +//fixme: new property subclass +$properties['Inline Images'] = +new property('InlineImages', "png|jpg|gif", " +URLs ending with the following extension should be inlined as images"); + + + +$properties['WikiName Regexp'] = +new property('WikiNameRegexp', "(?<![[:alnum:]])(?:[[:upper:]][[:lower:]]+){2,}(?![[:alnum:]])", " +Perl regexp for WikiNames (\"bumpy words\") +(?<!..) & (?!...) used instead of '\b' because \b matches '_' as well"); + + + +$properties['InterWiki Map File'] = +new defines('INTERWIKI_MAP_FILE', "lib/interwiki.map", " +InterWiki linking -- wiki-style links to other wikis on the web + +The map will be taken from a page name InterWikiMap. +If that page is not found (or is not locked), or map +data can not be found in it, then the file specified +by INTERWIKI_MAP_FILE (if any) will be used."); + + + +$properties['Part Five'] = +new part('partfive', "/////////////////////////////////////////////////////////////////// +", " + +Part Five: +URL options -- you can probably skip this section. +"); + + + +// MORE CONFIG OPTIONS GO IN HERE + + + +$end = ' + +//////////////////////////////////////////////////////////////// +// Okay... fire up the code: +//////////////////////////////////////////////////////////////// + +include "lib/main.php"; + +// (c-file-style: "gnu") +// Local Variables: +// mode: php +// tab-width: 8 +// c-basic-offset: 4 +// c-hanging-comment-ender-p: nil +// indent-tabs-mode: nil +// End: +?> +'; + + + // end of configuration options /////////////////////////////// @@ -321,4 +570,21 @@ class property { } +class unchangeable_property extends property { + function get_html() { + return ""; + } + function get_config_line($posted_value) { + if ($this->description) + $n = "\n"; + return "${n}".$this->default_value; + } + function get_instructions($title) { + $i = "<p><b><h3>" . $title . "</h3></b></p>\n <p>" . str_replace("\n\n", "</p><p>", $this->get_description()) . "</p>\n"; + $i = $i ."<em>Not editable.</em><br />\n<pre>" . $this->default_value."</pre>"; + return "<tr>\n<td colspan=\"2\">\n" .$i ."</td></tr>\n"; + } + +} + class selection extends property { function get_html() { @@ -345,4 +611,78 @@ class defines extends property { } +class defines_selection extends property { + function get_config_line($posted_value) { + return defines::get_config_line($posted_value); + } + function get_html() { + return selection::get_html(); + } +} + + +/** + * Seed the random number generator. + * + * better_srand() ensures the randomizer is seeded only once. + * + * How random do you want it? See: + * http://www.php.net/manual/en/function.srand.php + * http://www.php.net/manual/en/function.mt-srand.php + */ +function better_srand($seed = '') { + static $wascalled = FALSE; + if (!$wascalled) { + $seed = $seed === '' ? (double) microtime() * 1000000 : $seed; + srand($seed); + $wascalled = TRUE; + //trigger_error("new random seed", E_USER_NOTICE); //debugging + } +} + +function rand_ascii($length = 1) { + better_srand(); + //srand((double) microtime() * 1000000); + $s = ""; + for ($i = 1; $i <= $length; $i++) { + $s .= chr(rand(40, 126)); // return only typeable 7 bit ascii + } + return $s; +} +class defines_password extends defines { + function get_config_line($posted_value) { + if ($this->description) + $n = "\n"; + if ($posted_value == '') + return "${n}//define('".$this->get_config_item_name()."', \"\");"; + else { + if (function_exists('crypt')) { + $salt_length = max(CRYPT_SALT_LENGTH, + 2 * CRYPT_STD_DES, + 9 * CRYPT_EXT_DES, + 12 * CRYPT_MD5, + 16 * CRYPT_BLOWFISH); + // generate an encrypted password + $crypt_pass = crypt($posted_value, rand_ascii($salt_length)); + $p = "${n}define('".$this->get_config_item_name()."', '$crypt_pass');"; + $p = $p . "\n// If you used the passencrypt.php utility to encode the password"; + $p = $p . "\n// then uncomment this line:"; + return $p . "\ndefine('ENCRYPTED_PASSWD', true);"; + } else { + $p = "${n}define('".$this->get_config_item_name()."', '$posted_value');"; + $p = $p . "\n// If you used the passencrypt.php utility to encode the password"; + $p = $p . "\n// then uncomment this line:"; + $p = $p . "\n//define('ENCRYPTED_PASSWD', true);"; + $p = $p . "\n// Encrypted passwords cannot be used:"; + $p = $p . "\n// 'function crypt()' not available in this version of php"; + return $p; + } + } + } + function get_html() { + return "<input type=\"password\" name=\"" . $this->get_config_item_name() . "\" value=\"" . $this->default_value . "\">"; + } +} + + class defines_numeric extends property { function get_config_line($posted_value) { @@ -361,5 +701,5 @@ class iniset extends property { return "\nini_set('".$this->get_config_item_name()."', '$posted_value');"; else - return "\n//ini_set('".$this->get_config_item_name()."', '\$".$this->get_config_item_name()."');"; + return "\n//ini_set('".$this->get_config_item_name()."', '".$this->default_value."');"; } } @@ -386,9 +726,11 @@ class defines_boolean extends property { class part extends property { function get_config($posted_value) { + $d = str_replace("<pre>", "", $this->get_description()); + $d = str_replace("</pre>", "", $d); $separator = "\n/////////////////////////////////////////////////////////////////////"; - return $separator . str_replace("\n", "\n// ", $this->get_description()) ."\n$this->default_value"; + return $separator . str_replace("\n", "\n// ", $d) ."\n$this->default_value"; } function get_instructions($title) { - $i = "<h2>".$this->get_config_item_name()."</h2>\n$this->description\n"; + $i = "<p><b><h2>" . $title . "</h2></b></p>\n <p>" . str_replace("\n\n", "</p><p>", $this->get_description()) . "</p>\n"; return "<tr>\n<td colspan=\"2\" bgcolor=\"#eee\">\n" .$i ."</td></tr>\n"; } @@ -434,6 +776,6 @@ if ($action == 'make_config') { $diemsg = "The configurator.php is provided for testing purposes only.\nYou can't use this file with your PhpWiki server yet!!"; - $config .= "\ndie(\"$diemsg\");"; - $config .= "\n?>\n"; + $config .= "\ndie(\"$diemsg\");\n"; + $config .= $end; /* We first check if the config-file exists. */ |