* * This file is part of PhpWiki. * Parts of this file were based on PHPWeather's configurator.php file. * http://sourceforge.net/projects/phpweather/ * * PhpWiki is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * PhpWiki is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with PhpWiki; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** * Starts automatically the first time by IniConfig("config/config.ini") * if it doesn't exist. * * DONE: * o Initial expand ?show=_part1 (the part id) * o read config-default.ini and use this as default_values * o commented / optional: non-default values should not be commented! * default values if optional can be omitted. * o validate input (fix javascript, add POST checks) * o start this automatically the first time * o fix include_path * * 1.3.11 TODO: (or 1.3.12?) * o fix SQL quotes, AUTH_ORDER quotes and file forward slashes * o posted values validation, extend js validation for sane DB values * o read config-dist.ini into sections, comments, and optional/required settings * * A file config/config.ini will be automatically generated, if writable. * * NOTE: If you have a starterscript outside PHOWIKI_DIR but no * config/config.ini yet (very unlikely!), you must define DATA_PATH in the * starterscript, otherwise the webpath to configurator is unknown, and * subsequent requests will fail. (POST to save the INI) */ global $HTTP_SERVER_VARS, $HTTP_POST_VARS, $tdwidth; if (empty($_GET)) $_GET =& $GLOBALS['HTTP_GET_VARS']; if (empty($_ENV)) $_ENV =& $GLOBALS['HTTP_ENV_VARS']; if (empty($configurator)) $configurator = "configurator.php"; if (!strstr($HTTP_SERVER_VARS["SCRIPT_NAME"], $configurator) and defined('DATA_PATH')) $configurator = DATA_PATH . "/" . $configurator; $scriptname = str_replace('configurator.php', 'index.php', $HTTP_SERVER_VARS["SCRIPT_NAME"]); $tdwidth = 700; $config_file = (substr(PHP_OS,0,3) == 'WIN') ? 'config\\config.ini' : 'config/config.ini'; $fs_config_file = dirname(__FILE__) . (substr(PHP_OS,0,3) == 'WIN' ? '\\' : '/') . $config_file; if (isset($HTTP_POST_VARS['create'])) header('Location: '.$configurator.'?create=1#create'); // helpers from lib/WikiUser/HttpAuth.php function _http_user() { if (!isset($_SERVER)) $_SERVER = $GLOBALS['HTTP_SERVER_VARS']; if (!empty($_SERVER['PHP_AUTH_USER'])) return array($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); if (!empty($_SERVER['REMOTE_USER'])) return array($_SERVER['REMOTE_USER'], $_SERVER['PHP_AUTH_PW']); if (!empty($GLOBALS['HTTP_ENV_VARS']['REMOTE_USER'])) return array($GLOBALS['HTTP_ENV_VARS']['REMOTE_USER'], $GLOBALS['HTTP_ENV_VARS']['PHP_AUTH_PW']); if (!empty($GLOBALS['REMOTE_USER'])) return array($GLOBALS['REMOTE_USER'], $GLOBALS['PHP_AUTH_PW']); // MsWindows IIS: if (!empty($_SERVER['HTTP_AUTHORIZATION'])) { list($userid, $passwd) = explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6))); return array($userid, $passwd); } return array('',''); } function _http_logout() { if (!isset($_SERVER)) $_SERVER =& $GLOBALS['HTTP_SERVER_VARS']; // maybe we should random the realm to really force a logout. but the next login will fail. // better_srand(); $realm = microtime().rand(); header('WWW-Authenticate: Basic realm="'.WIKI_NAME.'"'); if (strstr(php_sapi_name(), 'apache')) header('HTTP/1.0 401 Unauthorized'); else header("Status: 401 Access Denied"); //IIS and CGI need that unset($GLOBALS['REMOTE_USER']); unset($_SERVER['PHP_AUTH_USER']); unset($_SERVER['PHP_AUTH_PW']); trigger_error("Permission denied. Require ADMIN_USER.", E_USER_ERROR); exit(); } // If config.ini exists, we require ADMIN_USER access by faking HttpAuth. // So nobody can see or reset the password(s). if (file_exists($fs_config_file)) { // Require admin user if (!defined('ADMIN_USER') or !defined('ADMIN_PASSWD')) { if (!function_exists("IniConfig")) { include_once("lib/prepend.php"); include_once("lib/IniConfig.php"); } IniConfig($fs_config_file); } if (!defined('ADMIN_USER') or ADMIN_USER == '') { trigger_error("Configuration problem:\nADMIN_USER not defined in \"$fs_config_file\".\n" . "Cannot continue: You have to fix that manually.", E_USER_ERROR); exit(); } list($admin_user, $admin_pw) = _http_user(); //$required_user = ADMIN_USER; if (empty($admin_user) or $admin_user != ADMIN_USER) { _http_logout(); } // check password if (ENCRYPTED_PASSWORD and function_exists('crypt')) { if (crypt($admin_pw, ADMIN_PASSWD) != ADMIN_PASSWD) _http_logout(); } elseif ($admin_pw != ADMIN_PASSWD) { _http_logout(); } } else { if (!function_exists("IniConfig")) { include_once("lib/prepend.php"); include_once("lib/IniConfig.php"); } $def_file = (substr(PHP_OS,0,3) == 'WIN') ? 'config\\config-default.ini' : 'config/config-default.ini'; $fs_def_file = dirname(__FILE__) . (substr(PHP_OS,0,3) == 'WIN' ? '\\' : '/') . $def_file; IniConfig($fs_def_file); } echo "<","?xml version=\"1.0\" encoding=\"'iso-8859-1'\"?",">\n"; ?>
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.)
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.)
phptype(dbsyntax)://username:password@protocol+hostspec/database?option=valueFor a MySQL database, the following should work:
mysql://user:password@host/databasenameTo connect over a unix socket, use something like
mysql://user:password@unix(/path/to/socket)/databasename
DATABASE_DSN = mysql://guest@:/var/lib/mysql/mysql.sock/phpwiki DATABASE_DSN = mysql://guest@localhost/phpwiki DATABASE_DSN = pgsql://localhost/user_phpwiki"); // Choose ADODB or SQL to use an SQL database with ADODB or PEAR. // Choose dba to use one of the standard UNIX dbm libraries. $properties["SQL Type"] = new _variable_selection('_dsn_sqltype', array('mysql' => "MySQL", 'pgsql' => "PostgreSQL", 'mssql' => "Microsoft SQL Server", 'oci8' => "Oracle 8", 'mysqli' => "mysqli (only ADODB)", 'mysqlt' => "mysqlt (only ADODB)", 'ODBC' => "ODBC (only ADODB or PDO)", 'firebird' => "Firebird (only PDO)", 'oracle' => "Oracle (only PDO)", ), " SQL DB types. The DSN hosttype."); $properties["SQL User"] = new _variable('_dsn_sqluser', "wikiuser", " SQL User Id:"); $properties["SQL Password"] = new _variable('_dsn_sqlpass', "", " SQL Password:"); $properties["SQL Database Host"] = new _variable('_dsn_sqlhostorsock', "localhost", " SQL Database Hostname: To connect over a local named socket, use something like
unix(/var/lib/mysql/mysql.sock)here. mysql on Windows via named pipes might need 127.0.0.1"); $properties["SQL Database Name"] = new _variable('_dsn_sqldbname', "phpwiki", " SQL Database Name:"); $dsn_sqltype = $properties["SQL Type"]->value(); $dsn_sqluser = $properties["SQL User"]->value(); $dsn_sqlpass = $properties["SQL Password"]->value(); $dsn_sqlhostorsock = $properties["SQL Database Host"]->value(); $dsn_sqldbname = $properties["SQL Database Name"]->value(); $dsn_sqlstring = $dsn_sqltype."://{$dsn_sqluser}:{$dsn_sqlpass}@{$dsn_sqlhostorsock}/{$dsn_sqldbname}"; $properties["SQL dsn"] = new unchangeable_define("DATABASE_DSN", "DATABASE_DSN = \"$dsn_sqlstring\"", " Calculated from the settings above:"); $properties["Filename / Table name Prefix"] = new _define_commented("DATABASE_PREFIX", DATABASE_PREFIX, " Used by all DB types: Prefix for filenames or table names, e.g. \"phpwiki_\" Currently you MUST EDIT THE SQL file too! (in the schemas/ directory because we aren't doing on the fly sql generation during the installation."); $properties["DB Session table"] = new _define_optional("DATABASE_SESSION_TABLE", DATABASE_SESSION_TABLE, " Tablename to store session information. Only supported by SQL backends. A word of warning - any prefix defined above will be prepended to whatever is given here. "); //TODO: $TEMP $temp = !empty($_ENV['TEMP']) ? $_ENV['TEMP'] : "/tmp"; $properties["dba directory"] = new _define("DATABASE_DIRECTORY", $temp, " dba directory:"); // TODO: list the available methods $properties["dba handler"] = new _define_selection('DATABASE_DBA_HANDLER', array('gdbm' => "Gdbm - GNU database manager (recommended)", 'dbm' => "DBM - Redhat default. On sf.net there's dbm and gdbm", 'db2' => "DB2 - Sleepycat Software's DB2", 'db3' => "DB3 - Sleepycat Software's DB3. Default on Windows but not on every Linux", 'db4' => "DB4 - Sleepycat Software's DB4."), " Use 'gdbm', 'dbm', 'db2', 'db3' or 'db4' depending on your DBA handler methods supported:
USER_AUTH_ORDER = 'PersonalPage : Db' USER_AUTH_ORDER = 'BogoLogin : PersonalPage'"); $properties["PASSWORD_LENGTH_MINIMUM"] = new numeric_define("PASSWORD_LENGTH_MINIMUM", "6", " For 'security' purposes, you can specify that a password be at least a certain number of characters long. This applies even to the BogoLogin method. Default: 0 (to allow immediate passwordless BogoLogin)"); $properties["USER_AUTH_POLICY"] = new _define_selection('USER_AUTH_POLICY', array('first-only' => "first-only - use only the first method in USER_AUTH_ORDER", 'old' => "old - ignore USER_AUTH_ORDER (legacy)", 'strict' => "strict - check all methods for userid + password (recommended)", 'stacked' => "stacked - check all methods for userid, and if found for password"), " The following policies are available for user authentication:
DBAUTH_PREF_SELECT = \"SELECT prefs FROM user WHERE userid='\$userid'\" DBAUTH_PREF_SELECT = \"SELECT prefs FROM pref WHERE userid='\$userid'\""); $properties["Update the user's preferences"] = new _define_optional('DBAUTH_PREF_UPDATE', "UPDATE user SET prefs='\$pref_blob' WHERE userid='\$userid'", " Note that REPLACE works only with mysql and destroy all other columns! Mysql: DBAUTH_PREF_UPDATE = \"REPLACE INTO pref SET prefs='\$pref_blob',userid='\$userid'\""); $properties["USERS/GROUPS queries"] = new _define_optional('DBAUTH_IS_MEMBER', "SELECT user FROM user WHERE user='\$userid' AND group='\$groupname'", " You can define 1:n or n:m user<=>group relations, as you wish. Sample configurations: only one group per user (1:n):
THEME = MonoBook (WikiPedia) [experimental. MSIE problems] THEME = blog (Kubrick) [experimental. Several links missing]"); $properties["Character Set"] = new _define_optional('CHARSET', 'iso-8859-1', " Select a valid charset name to be inserted into the xml/html pages, and to reference links to the stylesheets (css). For more info see: http://www.iana.org/assignments/character-sets. Note that PhpWiki has been extensively tested only with the latin1 (iso-8859-1) character set. If you change the default from iso-8859-1 PhpWiki may not work properly and it will require code modifications. However, character sets similar to iso-8859-1 may work with little or no modification depending on your setup. The database must also support the same charset, and of course the same is true for the web browser. (Some work is in progress hopefully to allow more flexibility in this area in the future)."); $properties["Language"] = new _define_selection_optional('DEFAULT_LANGUAGE', array('en' => "English", '' => "
English \"en\" (English - HomePage) German \"de\" (Deutsch - StartSeite) French \"fr\" (Français - Accueil) Dutch \"nl\" (Nederlands - ThuisPagina) Spanish \"es\" (Español - PáginaPrincipal) Swedish \"sv\" (Svenska - Framsida) Italian \"it\" (Italiano - PaginaPrincipale) Japanese \"ja\" (Japanese - ¥Û¡¼¥à¥Ú¡¼¥¸) Chinese \"zh\" (Chinese)If you set DEFAULT_LANGUAGE to the empty string, your systems default language (as determined by the applicable environment variables) will be used."); $properties["Wiki Page Source"] = new _define_optional('WIKI_PGSRC', 'pgsrc', " WIKI_PGSRC -- specifies the source for the initial page contents of the Wiki. The setting of WIKI_PGSRC only has effect when the wiki is accessed for the first time (or after clearing the database.) WIKI_PGSRC can either name a directory or a zip file. In either case WIKI_PGSRC is scanned for files -- one file per page.
// Default (old) behavior: define('WIKI_PGSRC', 'pgsrc'); // New style: define('WIKI_PGSRC', 'wiki.zip'); define('WIKI_PGSRC', '../Logs/Hamwiki/hamwiki-20010830.zip');"); /* $properties["Default Wiki Page Source"] = new _define('DEFAULT_WIKI_PGSRC', 'pgsrc', " DEFAULT_WIKI_PGSRC is only used when the language is *not* the default (English) and when reading from a directory: in that case some English pages are inserted into the wiki as well. DEFAULT_WIKI_PGSRC defines where the English pages reside. FIXME: is this really needed? "); $properties["Generic Pages"] = new array_variable('GenericPages', array('ReleaseNotes', 'SteveWainstead', 'TestPage'), " These are the pages which will get loaded from DEFAULT_WIKI_PGSRC. FIXME: is this really needed? Cannot we just copy these pages into the localized pgsrc? "); */ /////////////////// $properties["Part Five"] = new part('_part5', $SEPARATOR."\n", " Part Five: Mark-up options"); $properties["Allowed Protocols"] = new list_define('ALLOWED_PROTOCOLS', '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"); $properties["Inline Images"] = new list_define('INLINE_IMAGES', 'png|jpg|gif', " URLs ending with the following extension should be inlined as images. Scripts shoud not be allowed!"); $properties["WikiName Regexp"] = new _define('WIKI_NAME_REGEXP', "(? "true", 'false' => "false"), " Display a warning if the internal lib/interwiki.map is used, and not the public InterWikiMap page. This map is not readable from outside."); $properties["Keyword Link Regexp"] = new _define_optional('KEYWORDS', '\"Category* OR Topic*\"', " Search term used for automatic page classification by keyword extraction. Any links on a page to pages whose names match this search will be used keywords in the keywords html meta tag. This is an aid to classification by search engines. The value of the match is used as the keyword. The default behavior is to match Category* or Topic* links."); $properties["Author and Copyright Site Navigation Links"] = new _define_commented_optional('COPYRIGHTPAGE_TITLE', "GNU General Public License", " These will be inserted as tags in the html header of every page, for search engines and for browsers like Mozilla which take advantage of link rel site navigation. If you have your own copyright and contact information pages change these as appropriate."); $properties["COPYRIGHTPAGE URL"] = new _define_commented_optional('COPYRIGHTPAGE_URL', "http://www.gnu.org/copyleft/gpl.html#SEC1", " Other useful alternatives to consider:
COPYRIGHTPAGE_TITLE = \"GNU Free Documentation License\" COPYRIGHTPAGE_URL = \"http://www.gnu.org/copyleft/fdl.html\" COPYRIGHTPAGE_TITLE = \"Creative Commons License 2.0\" COPYRIGHTPAGE_URL = \"http://creativecommons.org/licenses/by/2.0/\"See http://creativecommons.org/learn/licenses/ for variations"); $properties["AUTHORPAGE_TITLE"] = new _define_commented_optional('AUTHORPAGE_TITLE', "The PhpWiki Programming Team", " Default Author Names"); $properties["AUTHORPAGE_URL"] = new _define_commented_optional('AUTHORPAGE_URL', "http://phpwiki.org/ThePhpWikiProgrammingTeam", " Default Author URL"); new boolean_define_optional ('TOC_FULL_SYNTAX', array('true' => "Enabled", 'false' => "Disabled"), " Allow full markup in headers to be parsed by the CreateToc plugin. If false you may not use WikiWords or [] links or any other markup in headers in pages with the CreateToc plugin. But if false the parsing is faster and more stable."); /////////////////// $properties["Part Six"] = new part('_part6', $SEPARATOR."\n", " Part Six (optional): URL options -- you can probably skip this section. For a pretty wiki (no index.php in the url) set a seperate DATA_PATH."); global $HTTP_SERVER_VARS; $properties["Server Name"] = new _define_commented_optional('SERVER_NAME', $HTTP_SERVER_VARS['SERVER_NAME'], " Canonical name of the server on which this PhpWiki resides."); $properties["Server Port"] = new numeric_define_commented('SERVER_PORT', $HTTP_SERVER_VARS['SERVER_PORT'], " Canonical httpd port of the server on which this PhpWiki resides.", "onchange=\"validate_ereg('Sorry, \'%s\' is no valid port number.', '^[0-9]+$', 'SERVER_PORT', this);\""); $properties["Script Name"] = new _define_commented_optional('SCRIPT_NAME', $scriptname, " Relative URL (from the server root) of the PhpWiki script."); $properties["Data Path"] = new _define_commented_optional('DATA_PATH', dirname($scriptname), " URL of the PhpWiki install directory. (You only need to set this if you've moved index.php out of the install directory.) This can be either a relative URL (from the directory where the top-level PhpWiki script is) or an absolute one."); $properties["PhpWiki Install Directory"] = new _define_commented_optional('PHPWIKI_DIR', dirname(__FILE__), " Path to the PhpWiki install directory. This is the local filesystem counterpart to DATA_PATH. (If you have to set DATA_PATH, your probably have to set this as well.) This can be either an absolute path, or a relative path interpreted from the directory where the top-level PhpWiki script (normally index.php) resides."); $properties["Use PATH_INFO"] = new _define_selection_optional_commented('USE_PATH_INFO', array('' => 'automatic', 'true' => 'use PATH_INFO', 'false' => 'do not use PATH_INFO'), " PhpWiki will try to use short urls to pages, eg http://www.example.com/index.php/HomePage If you want to use urls like http://www.example.com/index.php?pagename=HomePage then define 'USE_PATH_INFO' as false by uncommenting the line below. NB: If you are using Apache >= 2.0.30, then you may need to to use the directive \"AcceptPathInfo On\" in your Apache configuration file (or in an appropriate <.htaccess> file) for the short urls to work: See http://httpd.apache.org/docs-2.0/mod/core.html#acceptpathinfo See also http://phpwiki.sourceforge.net/phpwiki/PrettyWiki for more ideas on prettifying your urls. Default: PhpWiki will try to divine whether use of PATH_INFO is supported in by your webserver/PHP configuration, and will use PATH_INFO if it thinks that is possible."); $properties["Virtual Path"] = new _define_commented_optional('VIRTUAL_PATH', '/SomeWiki', " VIRTUAL_PATH is the canonical URL path under which your your wiki appears. Normally this is the same as dirname(SCRIPT_NAME), however using e.g. seperate starter scripts, apaches mod_actions (or mod_rewrite), you can make it something different. If you do this, you should set VIRTUAL_PATH here or in the starter scripts. E.g. your phpwiki might be installed at at /scripts/phpwiki/index.php, but you've made it accessible through eg. /wiki/HomePage. One way to do this is to create a directory named 'wiki' in your server root. The directory contains only one file: an .htaccess file which reads something like:
Action x-phpwiki-page /scripts/phpwiki/index.php SetHandler x-phpwiki-page DirectoryIndex /scripts/phpwiki/index.phpIn that case you should set VIRTUAL_PATH to '/wiki'. (VIRTUAL_PATH is only used if USE_PATH_INFO is true.) "); /////////////////// $properties["Part Seven"] = new part('_part7', $SEPARATOR."\n", " Part Seven: Miscellaneous settings "); $properties["Strict Mailable Pagedumps"] = new boolean_define_optional ('STRICT_MAILABLE_PAGEDUMPS', array('false' => "binary", 'true' => "quoted-printable"), " If you define this to true, (MIME-type) page-dumps (either zip dumps, or \"dumps to directory\" will be encoded using the quoted-printable encoding. If you're actually thinking of mailing the raw page dumps, then this might be useful, since (among other things,) it ensures that all lines in the message body are under 80 characters in length. Also, setting this will cause a few additional mail headers to be generated, so that the resulting dumps are valid RFC 2822 e-mail messages. Probably, you can just leave this set to false, in which case you get raw ('binary' content-encoding) page dumps."); $properties["HTML Dump Filename Suffix"] = new _define_optional('HTML_DUMP_SUFFIX', ".html", " Here you can change the filename suffix used for XHTML page dumps. If you don't want any suffix just comment this out."); $properties["Default local Dump Directory"] = new _define_optional('DEFAULT_DUMP_DIR', "/tmp/wikidump", " Specify the default directory for local backups."); $properties["Default local HTML Dump Directory"] = new _define_optional('HTML_DUMP_DIR', "/tmp/wikidumphtml", " Specify the default directory for local XHTML dumps."); $properties["Pagename of Recent Changes"] = new _define_optional('RECENT_CHANGES', 'RecentChanges', " Page name of RecentChanges page. Used for RSS Auto-discovery."); $properties["Disable HTTP Redirects"] = new boolean_define_commented_optional ('DISABLE_HTTP_REDIRECT', array('false' => 'Enable HTTP Redirects', 'true' => 'Disable HTTP Redirects'), " (You probably don't need to touch this.) PhpWiki uses HTTP redirects for some of it's functionality. (e.g. after saving changes, PhpWiki redirects your browser to view the page you just saved.) Some web service providers (notably free European Lycos) don't seem to allow these redirects. (On Lycos the result in an \"Internal Server Error\" report.) In that case you can set DISABLE_HTTP_REDIRECT to true. (In which case, PhpWiki will revert to sneakier tricks to try to redirect the browser...)"); $properties["Disable GETIMAGESIZE"] = new boolean_define_commented_optional ('DISABLE_GETIMAGESIZE', array('false' => 'Enable', 'true' => 'Disable'), " Set GETIMAGESIZE to disabled, if your php fails to calculate the size on inlined images, or you don't want to disable too small images to be inlined. Per default too small ploaded or external images are not displayed, to prevent from external 1 pixel spam."); $properties["EDITING_POLICY"] = new _define_optional('EDITING_POLICY', "EditingPolicy", " An interim page which gets displayed on every edit attempt, if it exists."); $properties["ENABLE_MODERATEDPAGE_ALL"] = new boolean_define_commented_optional ('ENABLE_MODERATEDPAGE_ALL', array('false' => 'Disable', 'true' => 'Enable'), " "); $properties["FORTUNE_DIR"] = new _define_commented_optional('FORTUNE_DIR', "/usr/share/fortune", " "); $properties["DBADMIN_USER"] = new _define_commented_optional('DBADMIN_USER', "", " "); $properties["DBADMIN_PASSWD"] = new _define_commented_optional('DBADMIN_PASSWD', "", " "); $properties["USE_EXTERNAL_HTML2PDF"] = new _define_commented_optional('USE_EXTERNAL_HTML2PDF', "htmldoc --quiet --format pdf14 --no-toc --no-title %s", " "); $properties["BABYCART_PATH"] = new _define_commented_optional('BABYCART_PATH', "/usr/local/bin/babycart", " "); $properties["Part Seven A"] = new part('_part7a', $SEPARATOR."\n", " Part Seven A: Cached Plugin Settings. (pear Cache) "); $properties["pear Cache USECACHE"] = new boolean_define_optional('PLUGIN_CACHED_USECACHE', array('true' => 'Enabled', 'false' => 'Disabled'), " Enable or disable pear caching of plugins."); $properties["pear Cache Database Container"] = new _define_selection_optional('PLUGIN_CACHED_DATABASE', array('file' => 'file'), " Curently only file is supported. db, trifile and imgfile might be supported, but you must hack that by yourself."); $properties["pear Cache cache directory"] = new _define_commented_optional('PLUGIN_CACHED_CACHE_DIR', "/tmp/cache", " Should be writable to the webserver."); $properties["pear Cache Filename Prefix"] = new _define_optional('PLUGIN_CACHED_FILENAME_PREFIX', "phpwiki", ""); $properties["pear Cache HIGHWATER"] = new numeric_define_optional('PLUGIN_CACHED_HIGHWATER', "4194304", " Garbage collection parameter."); $properties["pear Cache LOWWATER"] = new numeric_define_optional('PLUGIN_CACHED_LOWWATER', "3145728", " Garbage collection parameter."); $properties["pear Cache MAXLIFETIME"] = new numeric_define_optional('PLUGIN_CACHED_MAXLIFETIME', "2592000", " Garbage collection parameter."); $properties["pear Cache MAXARGLEN"] = new numeric_define_optional('PLUGIN_CACHED_MAXARGLEN', "1000", " max. generated url length."); $properties["pear Cache FORCE_SYNCMAP"] = new boolean_define_optional('PLUGIN_CACHED_FORCE_SYNCMAP', array('true' => 'Enabled', 'false' => 'Disabled'), ""); $properties["pear Cache IMGTYPES"] = new list_define('PLUGIN_CACHED_IMGTYPES', "png|gif|gd|gd2|jpeg|wbmp|xbm|xpm", " Handle those image types via GD handles. Check your GD supported image types."); $end = "\n".$SEPARATOR."\n"; // end of configuration options /////////////////////////////// // begin class definitions /** * A basic config-dist.ini configuration line in the form of a variable. * (not needed anymore, we have only defines) * * Produces a string in the form "$name = value;" * e.g.: * $WikiNameRegexp = "value"; */ class _variable { var $config_item_name; var $default_value; var $description; var $prefix; var $jscheck; function _variable($config_item_name, $default_value, $description, $jscheck = '') { $this->config_item_name = $config_item_name; $this->description = $description; if (defined($config_item_name) and !preg_match("/(selection|boolean)/", get_class($this)) and !preg_match("/(SCRIPT_NAME|VIRTUAL_PATH)/", $config_item_name)) $this->default_value = constant($config_item_name); // ignore given default value else $this->default_value = $default_value; $this->jscheck = $jscheck; if (preg_match("/variable/i",get_class($this))) $this->prefix = "\$"; elseif (preg_match("/ini_set/i",get_class($this))) $this->prefix = "ini_get: "; else $this->prefix = ""; } function value() { global $HTTP_POST_VARS; if (isset($HTTP_POST_VARS[$this->config_item_name])) return $HTTP_POST_VARS[$this->config_item_name]; else return $this->default_value; } function _config_format($value) { $v = $this->get_config_item_name(); // handle arrays: a|b --> a['b'] if (strpos($v, '|')) { list($a, $b) = explode('|', $v); $v = sprintf("%s['%s']", $a, $b); } if (preg_match("/[\"']/", $value)) $value = '"' . $value . '"'; return sprintf("%s = \"%s\"", $v, $value); } function get_config_item_name() { return $this->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); return "" . $this->prefix . $var . "['" . $param . "']
get_config_item_id() . "\" style=\"color: green\">Input accepted.
"; } } class unchangeable_variable extends _variable { function _config_format($value) { return ""; } // function get_html() { return false; } function get_html() { return $this->get_config_item_header() . "Not editable." . "" . $this->default_value.""; } function _get_config_line($posted_value) { if ($this->description) $n = "\n"; return "${n}".$this->default_value; } function get_instructions($title) { global $tdwidth; $i = "
" . $this->default_value.""; return '
get_config_item_id() . "\" style=\"color: green\">Input accepted.
"; } } class _define_commented extends _define { function _get_config_line($posted_value) { if ($this->description) $n = "\n"; if ($posted_value == $this->default_value) return "${n};" . $this->_config_format($posted_value); elseif ($posted_value == '') return "${n};" . $this->_config_format(""); else return "${n}" . $this->_config_format($posted_value); } } /** * We don't use _optional anymore, because INI-style config's don't need that. * IniConfig.php does the optional logic now. * But we use _optional for config-default.ini options */ class _define_commented_optional extends _define_commented { } class _define_optional extends _define { } class _define_notempty extends _define { function get_html() { $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_id() . "\" style=\"color: red\">Cannot be empty.
"; else return $s . "get_config_item_id() . "\" style=\"color: green\">Input accepted.
"; } } class _variable_commented extends _variable { function _get_config_line($posted_value) { if ($this->description) $n = "\n"; if ($posted_value == $this->default_value) return "${n};" . $this->_config_format($posted_value); elseif ($posted_value == '') return "${n};" . $this->_config_format(""); else return "${n}" . $this->_config_format($posted_value); } } class numeric_define extends _define { function numeric_define($config_item_name, $default_value, $description, $jscheck = '') { $this->_define($config_item_name, $default_value, $description, $jscheck); if (!$jscheck) $this->jscheck = "onchange=\"validate_ereg('Sorry, \'%s\' is not an integer.', '^[-+]?[0-9]+$', '" . $this->get_config_item_name() . "', this);\""; } function _config_format($value) { //return sprintf("define('%s', %s);", $this->get_config_item_name(), $value); return sprintf("%s = %s", $this->get_config_item_name(), $value); } function _get_config_line($posted_value) { if ($this->description) $n = "\n"; if ($posted_value == '') return "${n};" . $this->_config_format('0'); else return "${n}" . $this->_config_format($posted_value); } } class numeric_define_optional extends numeric_define {} class numeric_define_commented extends numeric_define { function _get_config_line($posted_value) { if ($this->description) $n = "\n"; if ($posted_value == $this->default_value) return "${n};" . $this->_config_format($posted_value); elseif ($posted_value == '') return "${n};" . $this->_config_format('0'); else return "${n}" . $this->_config_format($posted_value); } } class _define_selection extends _variable_selection { function _config_format($value) { return sprintf("%s = %s", $this->get_config_item_name(), $value); } function _get_config_line($posted_value) { return _define::_get_config_line($posted_value); } function get_html() { return _variable_selection::get_html(); } } class _define_selection_optional extends _define_selection { } class _variable_selection_optional extends _variable_selection { } class _define_selection_optional_commented extends _define_selection_optional { function _get_config_line($posted_value) { if ($this->description) $n = "\n"; if ($posted_value == $this->default_value) return "${n};" . $this->_config_format($posted_value); elseif ($posted_value == '') return "${n};" . $this->_config_format(""); else return "${n}" . $this->_config_format($posted_value); } } class _define_password extends _define { function _define_password($config_item_name, $default_value, $description, $jscheck = '') { $this->_define($config_item_name, $default_value, $description, $jscheck); if (!$jscheck) $this->jscheck = "onchange=\"validate_ereg('Sorry, \'%s\' cannot be empty.', '^.+$', '" . $this->get_config_item_name() . "', this);\""; } function _get_config_line($posted_value) { if ($this->description) $n = "\n"; if ($posted_value == '') { $p = "${n};" . $this->_config_format(""); $p .= "\n; If you used the passencrypt.php utility to encode the password"; $p .= "\n; then uncomment this line:"; $p .= "\n;ENCRYPTED_PASSWD = true"; return $p; } 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}" . $this->_config_format($crypt_pass); return $p . "\nENCRYPTED_PASSWD = true"; } else { $p = "${n}" . $this->_config_format($posted_value); $p .= "\n; Encrypted passwords cannot be used:"; $p .= "\n; 'function crypt()' not available in this version of php"; $p .= "\nENCRYPTED_PASSWD = false"; return $p; } } } function get_html() { return _variable_password::get_html(); } } class _define_password_optional extends _define_password { } class _variable_password extends _variable { function _variable_password($config_item_name, $default_value, $description, $jscheck = '') { $this->_define($config_item_name, $default_value, $description, $jscheck); if (!$jscheck) $this->jscheck = "onchange=\"validate_ereg('Sorry, \'%s\' cannot be empty.', '^.+$', '" . $this->get_config_item_name() . "', this);\""; } function get_html() { global $HTTP_POST_VARS, $HTTP_GET_VARS; $s = $this->get_config_item_header(); if (isset($HTTP_POST_VARS['create']) or isset($HTTP_GET_VARS['create'])) { $new_password = random_good_password(); $this->default_value = $new_password; $s .= "Created password: $new_passwordget_config_item_id() . "\" style=\"color: red\">Cannot be empty.
"; elseif (strlen($this->default_value) < 4) $s .= "get_config_item_id() . "\" style=\"color: red\">Must be longer than 4 chars.
"; else $s .= "get_config_item_id() . "\" style=\"color: green\">Input accepted.
"; return $s; } } class list_variable extends _variable { function _get_config_line($posted_value) { // split the phrase by any number of commas or space characters, // which include " ", \r, \t, \n and \f $list_values = preg_split("/[\s,]+/", $posted_value, -1, PREG_SPLIT_NO_EMPTY); $list_values = join("|", $list_values); return _variable::_get_config_line($list_values); } function get_html() { $list_values = explode("|", $this->default_value); $rows = max(3, count($list_values) +1); $list_values = join("\n", $list_values); $ta = $this->get_config_item_header(); $ta .= ""; $ta .= "get_config_item_id() . "\" style=\"color: green\">Input accepted.
"; return $ta; } } class list_define extends _define { function _get_config_line($posted_value) { $list_values = preg_split("/[\s,]+/", $posted_value, -1, PREG_SPLIT_NO_EMPTY); $list_values = join("|", $list_values); return _variable::_get_config_line($list_values); } function get_html() { $list_values = explode("|", $this->default_value); $rows = max(3, count($list_values) +1); $list_values = join("\n", $list_values); $ta = $this->get_config_item_header(); $ta .= ""; $ta .= "get_config_item_id() . "\" style=\"color: green\">Input accepted.
"; return $ta; } } class array_variable extends _variable { function _config_format($value) { return sprintf("%s = \"%s\"", $this->get_config_item_name(), is_array($value) ? join(':', $value) : $value); } function _get_config_line($posted_value) { // split the phrase by any number of commas or space characters, // which include " ", \r, \t, \n and \f $list_values = preg_split("/[\s,]+/", $posted_value, -1, PREG_SPLIT_NO_EMPTY); if (!empty($list_values)) { $list_values = "'".join("', '", $list_values)."'"; return "\n" . $this->_config_format($list_values); } else return "\n;" . $this->_config_format(''); } function get_html() { $list_values = join("\n", $this->default_value); $rows = max(3, count($this->default_value) +1); $ta = $this->get_config_item_header(); $ta .= ""; $ta .= "get_config_item_id() . "\" style=\"color: green\">Input accepted.
"; return $ta; } } class array_define extends _define { function _config_format($value) { return sprintf("%s = \"%s\"", $this->get_config_item_name(), is_array($value) ? join(' : ', $value) : $value); } function _get_config_line($posted_value) { // split the phrase by any number of commas or space characters, // which include " ", \r, \t, \n and \f $list_values = preg_split("/[\s,:]+/", $posted_value, -1, PREG_SPLIT_NO_EMPTY); if (!empty($list_values)) { $list_values = "'".join("' : '", $list_values)."'"; return "\n" . $this->_config_format($list_values); } else return "\n;" . $this->_config_format(''); } function get_html() { $list_values = join("\n", $this->default_value); $rows = max(3, count($this->default_value) +1); $ta = $this->get_config_item_header(); $ta .= ""; $ta .= "get_config_item_id() . "\" style=\"color: green\">Input accepted.
"; return $ta; } } /* class _ini_set extends _variable { function value() { global $HTTP_POST_VARS; if ($v = $HTTP_POST_VARS[$this->config_item_name]) return $v; else { return ini_get($this->get_config_item_name); } } function _config_format($value) { return sprintf("ini_set('%s', '%s');", $this->get_config_item_name(), $value); } function _get_config_line($posted_value) { if ($posted_value && ! $posted_value == $this->default_value) return "\n" . $this->_config_format($posted_value); else return "\n;" . $this->_config_format($this->default_value); } } */ class boolean_define extends _define { function _get_config_line($posted_value) { if ($this->description) $n = "\n"; return "${n}" . $this->_config_format($posted_value); } function _config_format($value) { if (strtolower(trim($value)) == 'false') $value = false; return sprintf("%s = %s", $this->get_config_item_name(), (bool)$value ? 'true' : 'false'); } function get_html() { $output = $this->get_config_item_header(); $output .= '\n"; return $output; } } class boolean_define_optional extends boolean_define {} class boolean_define_commented extends boolean_define { function _get_config_line($posted_value) { if ($this->description) $n = "\n"; list($default_value, $label) = each($this->default_value); if ($posted_value == $default_value) return "${n};" . $this->_config_format($posted_value); elseif ($posted_value == '') return "${n};" . $this->_config_format('false'); else return "${n}" . $this->_config_format($posted_value); } } class boolean_define_commented_optional extends boolean_define_commented {} class part extends _variable { function value () { return; } function get_config($posted_value) { $d = stripHtml($this->_get_description()); global $SEPARATOR; return "\n".$SEPARATOR . str_replace("\n", "\n; ", $d) ."\n".$this->default_value; } function get_instructions($title) { $id = preg_replace("/\W/","",$this->config_item_name); $group_name = preg_replace("/\W/","",$title); $i = ".*?|
|
$par
"; $text .= $par; } return $text; } function stripHtml($text) { $d = str_replace("", "", $text); $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); $trans = array_flip ($trans); $d = strtr($d, $trans); return $d; } include_once(dirname(__FILE__)."/lib/stdlib.php"); //// // Function to create better user passwords (much larger keyspace), // suitable for user passwords. // Sequence of random ASCII numbers, letters and some special chars. // Note: There exist other algorithms for easy-to-remember passwords. function random_good_password ($minlength = 5, $maxlength = 8) { $newpass = ''; // assume ASCII ordering (not valid on EBCDIC systems!) $valid_chars = "!#%&+-.0123456789=@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz"; $start = ord($valid_chars); $end = ord(substr($valid_chars,-1)); better_srand(); if (function_exists('mt_rand')) // mersenne twister $length = mt_rand($minlength, $maxlength); else // the usually bad glibc rand() $length = rand($minlength, $maxlength); while ($length > 0) { if (function_exists('mt_rand')) $newchar = mt_rand($start, $end); else $newchar = rand($start, $end); if (! strrpos($valid_chars,$newchar) ) continue; // skip holes $newpass .= sprintf("%c", $newchar); $length--; } return($newpass); } // debugging function printArray($a) { echo "\n"; print_r($a); echo "\n\n
The configuration was written to $config_file
.
A backup was made to $new_filename
.
You must rename or copy this $config_file
file to config/config.ini
.
The configuration file could not be written.
\n",
" You should copy the above configuration to a file, ",
"and manually save it as config/config.ini
.
Here's the configuration file based on your answers:
\n"; echo "To make any corrections, edit the settings again.
\n"; } else { // first time or create password $posted = $GLOBALS['HTTP_POST_VARS']; // No action has been specified - we make a form. echo ' '; } ?>