From 3926882bbea5194f6c87f35f5a81662f432c0c51 Mon Sep 17 00:00:00 2001 From: dairiki Date: Tue, 4 Mar 2003 20:01:03 +0000 Subject: [PATCH] Add some missing config entries. Fix code so that it produces valid XHTML. Fix the show/hide section javascript. git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@2695 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- configurator.php | 310 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 247 insertions(+), 63 deletions(-) diff --git a/configurator.php b/configurator.php index 72b685e31..ffe21227b 100644 --- a/configurator.php +++ b/configurator.php @@ -20,7 +20,7 @@ printf("\n", 'iso-8859-1'); "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> - + Configuration tool for PhpWiki 1.3.x - +

Configuration tool for PhpWiki 1.3.x

@@ -144,7 +174,7 @@ Copyright 1999, 2000, 2001, 2002 $ThePhpWikiProgrammingTeam = array( "Antti Kaihola", "Jeremie Kass", "Carsten Klapp", "Marco Milanesi", "Grant Morgan", "Jan Nieuwenhuizen", "Aredridel Niothke", "Pablo Roca Rozas", "Sandino Araico Sánchez", "Joel Uckelman", -"Reini Urban", "Tim Voght"); +"Reini Urban", "Tim Voght", "Jochen Kalmbach"); This file is part of PhpWiki. @@ -238,9 +268,9 @@ Part Null: Don't touch this!"); $properties["Part Null Settings"] = new unchangeable_variable('_partnullsettings', " -define ('PHPWIKI_VERSION', '1.3.4pre'); +define ('PHPWIKI_VERSION', '1.3.5pre'); require \"lib/prepend.php\"; -rcs_id('\$Id: configurator.php,v 1.11 2003-01-15 05:45:47 carstenklapp Exp $');", ""); +rcs_id('\$Id: configurator.php,v 1.12 2003-03-04 20:01:03 dairiki Exp $');", ""); $properties["Part One"] = @@ -297,7 +327,7 @@ $properties["Enable Plugin RawHtml"] = new boolean_define_optional('ENABLE_RAW_HTML', array('false' => "Disabled. Recommended on public sites.", 'true' => "Enabled"), " -Allow < ?plugin RawHtml ...>. Don't do this on a publicly accessable wiki for now."); +Allow < ?plugin RawHtml ...>. Don't do this on a publicly accessable wiki for now."); $properties["Strict Mailable Pagedumps"] = new boolean_define('STRICT_MAILABLE_PAGEDUMPS', @@ -342,7 +372,7 @@ will be off."); $properties["Disabled Actions"] = new array_variable('DisabledActions', array(), " Actions listed in this array will not be allowed. Actions are: -browse, diff, dumphtml, dumpserial, edit, loadfile, lock, remove, +browse, create, diff, dumphtml, dumpserial, edit, loadfile, lock, remove, unlock, upload, viewsource, zip, ziphtml"); $properties["Access Log"] = @@ -351,6 +381,105 @@ 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, such as /tmp/wiki_access_log."); +$properties["Compress Output"] = +new boolean_define_commented_optional +( 'COMPRESS_OUTPUT', + array('' => 'Compress when PhpWiki thinks approriate.', + 'false' => 'Never compress output.', + 'true' => 'Always try to compress output.'), + " +By default PhpWiki will try to have PHP compress it's output +before sending it to the browser (if you have a recent enough +version of PHP and the browser supports it. + +Define COMPRESS_OUTPUT to false to prevent output compression. + +Define COMPRESS_OUTPUT to true to force output compression, +even if we think your version of PHP does this in a buggy +fashion. + +Leave it undefined to leave the choice up to PhpWiki."); + +$properties["HTTP Cache Control"] = +new _define_selection_optional +('CACHE_CONTROL', + array('LOOSE' => 'LOOSE', + 'STRICT' => 'STRICT', + 'NONE' => 'NONE', + 'ALLOW_STALE' => 'ALLOW_STALE'), + " +HTTP CACHE_CONTROL + +This controls how PhpWiki sets the HTTP cache control +headers (Expires: and Cache-Control:) + +Choose one of: + +
+
NONE
+
This is roughly the old (pre 1.3.4) behavior. PhpWiki will + instruct proxies and browsers never to cache PhpWiki output.
+ +
STRICT
+
Cached pages will be invalidated whenever the database global + timestamp changes. This should behave just like NONE (modulo + bugs in PhpWiki and your proxies and browsers), except that + things will be slightly more efficient.
+ +
LOOSE
+
Cached pages will be invalidated whenever they are edited, + or, if the pages include plugins, when the plugin output could + concievably have changed. + +

Behavior should be much like STRICT, except that sometimes + wikilinks will show up as undefined (with the question mark) + when in fact they refer to (recently) created pages. + (Hitting your browsers reload or perhaps shift-reload button + should fix the problem.)

+ +
ALLOW_STALE
+
Proxies and browsers will be allowed to used stale pages. + (The timeout for stale pages is controlled by CACHE_CONTROL_MAX_AGE.) + +

This setting will result in quirky behavior. When you edit a + page your changes may not show up until you shift-reload the + page, etc...

+ +

This setting is generally not advisable, however it may be useful + in certain cases (e.g. if your wiki gets lots of page views, + and few edits by knowledgable people who won't freak over the quirks.)

+
+ +The default is currently LOOSE."); + +$properties["HTTP Cache Control Max Age"] = +new numeric_define('CACHE_CONTROL_MAX_AGE', 600, + " +Maximum page staleness, in seconds."); + +$properties["Markup Caching"] = +new boolean_define_commented_optional +('WIKIDB_NOCACHE_MARKUP', + array('false' => 'Enable markup cache', + 'true' => 'Disable markup cache'), + " +MARKUP CACHING + +PhpWiki normally caches a preparsed version (i.e. mostly +converted to HTML) of the most recent version of each page. +(Parsing the wiki-markup takes a fair amount of CPU.) + +Define WIKIDB_NOCACHE_MARKUP to true to disable the +caching of marked-up page content. + +Note that you can also disable markup caching on a per-page +temporary basis by addinging a query arg of '?nocache=1' +to the URL to the page. (Use '?nocache=purge' to completely +discard the cached version of the page.) + +You can also purge the cached markup globally by using the +\"Purge Markup Cache\" button on the PhpWikiAdministration page."); + $properties["Path for PHP Session Support"] = new _ini_set('session.save_path', '/tmp', " @@ -424,8 +553,10 @@ For a MySQL database, the following should work:
    mysql://user:password@host/databasename
 
-
FIXME:
My version Pear::DB seems to be broken enough that there - is no way to connect to a mysql server over a socket right now.
+To connect over a unix socket, use something like +
+   mysql://user:password@unix(/path/to/socket)/databasename
+
'dsn' => 'mysql://guest@:/var/lib/mysql/mysql.sock/test',
 'dsn' => 'mysql://guest@localhost/test',
 'dsn' => 'pgsql://localhost/test',
"); @@ -455,7 +586,13 @@ SQL Password:"); $properties["SQL Database Host"] = new _variable('_dsn_sqlhostorsock', "localhost", " -SQL Database Hostname:"); +SQL Database Hostname: + +To connect over a local named socket, use something like +
+  unix(/var/lib/mysql/mysql.sock)
+
+here."); @@ -592,7 +729,7 @@ User Authentication $properties["User Authentication"] = new boolean_define_optional('ALLOW_USER_LOGIN', array('true' => "true. Check any defined passwords. (Default)", - 'false' => "false. Don't check passwords. Legacy < 1.3.4"), " + 'false' => "false. Don't check passwords. Legacy < 1.3.4"), " If ALLOW_USER_LOGIN is true, any defined internal and external authentication method is tried. If not, we don't care about passwords, but check the next two constants."); @@ -852,7 +989,7 @@ URLs ending with the following extension should be inlined as images"); $properties["WikiName Regexp"] = new _variable('WikiNameRegexp', "(?config_item_name; } + function get_config_item_id() { + return str_replace('|', '-', $this->config_item_name); + } + function get_config_item_header() { if (strchr($this->config_item_name,'|')) { list($var,$param) = explode('|',$this->config_item_name); @@ -1079,14 +1232,14 @@ class _variable { function get_instructions($title) { global $tdwidth; - $i = "

" . $title . "

\n " . nl2p($this->_get_description()) . "\n"; + $i = "

" . $title . "

\n " . nl2p($this->_get_description()) . "\n"; return "\n\n" . $i . "\n"; } function get_html() { return $this->get_config_item_header() . - "get_config_item_name() . "\" value=\"" . $this->default_value . "\" " . - $this->jscheck . " />" . "

get_config_item_name() . "\" style=\"color: green\">Input accepted.

"; + "get_config_item_name() . "\" value=\"" . htmlspecialchars($this->default_value) . "\" " . + $this->jscheck . " />" . "

get_config_item_id() . "\" style=\"color: green\">Input accepted.

"; } } @@ -1108,10 +1261,10 @@ extends _variable { } function get_instructions($title) { global $tdwidth; - $i = "

" . $title . "

\n " . nl2p($this->_get_description()) . "\n"; + $i = "

" . $title . "

\n " . nl2p($this->_get_description()) . "\n"; // $i = $i ."Not editable.
\n
" . $this->default_value."
"; - return "\n".$i ."\n". - " "; + return "\n".$i ."\n". + " "; } } @@ -1147,7 +1300,7 @@ extends _variable { while(list($option, $label) = each($this->default_value)) { $output .= " \n"; } - $output .= "\n \n"; + $output .= "\n"; return $output; } } @@ -1169,7 +1322,7 @@ extends _variable { function get_html() { return $this->get_config_item_header() . "get_config_item_name() . "\" value=\"" . $this->default_value . "\" {$this->jscheck} />" . - "

get_config_item_name() . "\" style=\"color: green\">Input accepted.

"; + "

get_config_item_id() . "\" style=\"color: green\">Input accepted.

"; } } @@ -1209,9 +1362,9 @@ extends _define_optional { $s = $this->get_config_item_header() . "get_config_item_name() . "\" value=\"" . $this->default_value . "\" {$this->jscheck} />"; if (empty($this->default_value)) - return $s . "

get_config_item_name() . "\" style=\"color: red\">Cannot be empty.

"; + return $s . "

get_config_item_id() . "\" style=\"color: red\">Cannot be empty.

"; else - return $s . "

get_config_item_name() . "\" style=\"color: green\">Input accepted.

"; + return $s . "

get_config_item_id() . "\" style=\"color: green\">Input accepted.

"; } } @@ -1346,11 +1499,11 @@ extends _variable { $s .= "
 
Created password: $new_password"; } if (empty($this->default_value)) - $s .= "

get_config_item_name() . "\" style=\"color: red\">Cannot be empty.

"; + $s .= "

get_config_item_id() . "\" style=\"color: red\">Cannot be empty.

"; elseif (strlen($this->default_value) < 4) - $s .= "

get_config_item_name() . "\" style=\"color: red\">Must be longer than 4 chars.

"; + $s .= "

get_config_item_id() . "\" style=\"color: red\">Must be longer than 4 chars.

"; else - $s .= "

get_config_item_name() . "\" style=\"color: green\">Input accepted.

"; + $s .= "

get_config_item_id() . "\" style=\"color: green\">Input accepted.

"; return $s; } } @@ -1388,7 +1541,7 @@ extends _variable { $ta = $this->get_config_item_header(); $ta .= ""; - $ta .= "

get_config_item_name() . "\" style=\"color: green\">Input accepted.

"; + $ta .= "

get_config_item_id() . "\" style=\"color: green\">Input accepted.

"; return $ta; } } @@ -1414,7 +1567,7 @@ extends _variable { $ta = $this->get_config_item_header(); $ta .= ""; - $ta .= "

get_config_item_name() . "\" style=\"color: green\">Input accepted.

"; + $ta .= "

get_config_item_id() . "\" style=\"color: green\">Input accepted.

"; return $ta; } @@ -1448,16 +1601,23 @@ extends _define { $n = "\n"; return "${n}" . $this->_config_format($posted_value); } + function _config_format($value) { + if (strtolower(trim($value)) == 'false') + $value = false; + return sprintf("define('%s', %s);", $this->get_config_item_name(), + (bool)$value ? 'true' : 'false'); + } function get_html() { $output = $this->get_config_item_header(); $output .= '\n \n"; + $output .= " \n"; + /* There can usually, only be two options, there can be + * three options in the case of a boolean_define_commented_optional */ + while (list($option, $label) = each($this->default_value)) + $output .= " \n"; + $output .= "\n"; return $output; } } @@ -1466,7 +1626,7 @@ class boolean_define_optional extends boolean_define { function _config_format($value) { $name = $this->get_config_item_name(); - return sprintf("if (!defined('%s')) define('%s', '%s');", $name, $name, $value); + return "if (!defined('$name')) " . boolean_define::_config_format($value); } } @@ -1489,7 +1649,7 @@ class boolean_define_commented_optional extends boolean_define_commented { function _config_format($value) { $name = $this->get_config_item_name(); - return sprintf("if (!defined('%s')) define('%s', '%s');", $name, $name, $value); + return "if (!defined('$name')) " . boolean_define_commented::_config_format($value); } } @@ -1503,12 +1663,10 @@ extends _variable { } function get_instructions($title) { $group_name = preg_replace("/\W/","",$title); - $i = "\n\n"; - if ($group_name == 'PartZero') $i = "
" . $i; - $i .= "

" . $title . "

\n " . nl2p($this->_get_description()) ."\n"; - $i .= ""; - $i .= "

Show options.

"; - return $i ."\n" . "
"; + $i = "\n\n"; + $i .= "

" . $title . "

\n " . nl2p($this->_get_description()) ."\n"; + $i .= "

Hide options.

"; + return $i ."\n"; } function get_html() { return ""; @@ -1517,7 +1675,18 @@ extends _variable { // html utility functions function nl2p($text) { - return "

" . str_replace("\n\n", "

\n

", $text) . "

"; + preg_match_all("@\s*(
.*?
|
.*?
|.*?(?=\n\n|
|
|$))@s", + $text, $m, PREG_PATTERN_ORDER); + + $text = ''; + foreach ($m[1] as $par) { + if (!($par = trim($par))) + continue; + if (!preg_match('/^<(pre|dl)>/', $par)) + $par = "

$par

"; + $text .= $par; + } + return $text; } function stripHtml($text) { @@ -1529,6 +1698,8 @@ function stripHtml($text) { $d = str_replace("", "", $d); $d = str_replace("
", "", $d); $d = str_replace("
", "", $d); + $d = str_replace("

", "", $d); + $d = str_replace("

", "", $d); //restore html entities into characters // http://www.php.net/manual/en/function.htmlentities.php $trans = get_html_translation_table (HTML_ENTITIES); @@ -1618,6 +1789,16 @@ function printArray($a) { ///////////////////////////// // begin auto generation code +if (!function_exists('is_a')) +{ + function is_a($object, $class) + { + $class = strtolower($class); + return (get_class($object) == $class) or is_subclass_of($object, $class); + } +} + + if (@$HTTP_POST_VARS['action'] == 'make_config') { $timestamp = date ('dS of F, Y H:i:s'); @@ -1675,9 +1856,12 @@ You can't use this file with your PhpWiki server yet!!"; echo "

A configuration file could not be written. You should copy the above configuration to a file, and manually save it as index.php.

\n"; } - echo "
\n

Here's the configuration file based on your answers:

\n
\n";
+    echo "
\n

Here's the configuration file based on your answers:

\n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; echo "

To make any corrections, edit the settings again.

\n"; @@ -1686,9 +1870,9 @@ You can't use this file with your PhpWiki server yet!!"; /* No action has been specified - we make a form. */ echo ' -
+ + - '; while(list($property, $obj) = each($properties)) { @@ -1701,8 +1885,8 @@ You can't use this file with your PhpWiki server yet!!"; } echo ' -
-

+ +

'; } -- 2.45.2