* Copyright 2008-2009 Marc-Etienne Vargenau, Alcatel-Lucent * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 parse_ini_file("config-dist.ini") for the commented vars * o check automatically for commented and optional vars * o fix _optional, to ignore existing config.ini and only use config-default.ini values * o mixin class for commented * 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 PHPWIKI_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_POST_VARS, $tdwidth; if (empty($_SERVER)) $_SERVER =& $GLOBALS['HTTP_SERVER_VARS']; if (empty($_GET)) $_GET =& $GLOBALS['HTTP_GET_VARS']; if (empty($_ENV)) $_ENV =& $GLOBALS['HTTP_ENV_VARS']; if (empty($_POST)) $_POST =& $GLOBALS['HTTP_POST_VARS']; if (empty($configurator)) $configurator = "configurator.php"; if (!strstr($_SERVER["SCRIPT_NAME"], $configurator) and defined('DATA_PATH')) $configurator = DATA_PATH . "/" . $configurator; $scriptname = str_replace('configurator.php', 'index.php', $_SERVER["SCRIPT_NAME"]); if (strstr($_SERVER["SCRIPT_NAME"], "/php")) { // cgi got this different if (defined('DATA_PATH')) $scriptname = DATA_PATH . "/index.php"; else $scriptname = str_replace('configurator.php', 'index.php', $_SERVER["PHP_SELF"]); } $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($_POST['create'])) header('Location: ' . $configurator . '?show=_part1&create=1#create'); // helpers from lib/WikiUser/HttpAuth.php if (!function_exists('_http_user')) { 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_PASSWD 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="utf-8"?', ">\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", 'mssqlnative' => "Microsoft SQL Server (native)", '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", $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. Note: This prefix is NOT prepended to the default DBAUTH_ tables user, pref and member! "); $properties["DATABASE_PERSISTENT"] = new boolean_define_commented_optional ('DATABASE_PERSISTENT', array('false' => "Disabled", 'true' => "Enabled")); $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); // TODO: list the available methods $properties["dba handler"] = new _define_selection('DATABASE_DBA_HANDLER', array('gdbm' => "gdbm - GNU database manager (not recommended anymore)", 'dbm' => "DBM - Redhat default. On sf.net there's dbm and not gdbm anymore", 'db2' => "DB2 - BerkeleyDB (Sleepycat) DB2", 'db3' => "DB3 - BerkeleyDB (Sleepycat) DB3. Default on Windows but not on every Linux", 'db4' => "DB4 - BerkeleyDB (Sleepycat) 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["ENABLE_AUTH_OPENID"] = new boolean_define('ENABLE_AUTH_OPENID'); $properties["PASSWORD_LENGTH_MINIMUM"] = new numeric_define('PASSWORD_LENGTH_MINIMUM', PASSWORD_LENGTH_MINIMUM); $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["Create new user's preferences"] = new _define_optional('DBAUTH_PREF_INSERT', "INSERT INTO pref (userid,prefs) VALUES ('\$userid','\$pref_blob')", " Define this if new user can be create by themselves. "); $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 = Sidebar (default) THEME = default THEME = MacOSX THEME = MonoBook (WikiPedia) THEME = smaller THEME = Wordpress THEME = Portland THEME = Crao THEME = wikilens (with Ratings) THEME = Hawaiian THEME = SpaceWiki THEME = Hawaiian THEME = blog (Kubrick) [experimental]"); $properties["Character Set"] = new _define_optional('CHARSET', 'utf-8'); $properties["Ignore Charset Not Supported Warning"] = new _define_optional('IGNORE_CHARSET_NOT_SUPPORTED_WARNING'); $properties["Language"] = new _define_selection_optional('DEFAULT_LANGUAGE', array('en' => "English", '' => "<empty> (user-specific)", 'fr' => "Français", 'de' => "Deutsch", 'nl' => "Nederlands", 'es' => "Español", 'sv' => "Svenska", 'it' => "Italiano", 'ja' => "Japanese", 'zh' => "Chinese"), " Select your language/locale - default language is \"en\" for English. Other languages available:
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. "); $properties["Generic Pages"] = new array_variable('DEFAULT_WIKI_PAGES', array('ReleaseNotes', 'SteveWainstead', 'TestPage'), " These are ':'-seperated pages which will get loaded untranslated from DEFAULT_WIKI_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|jpeg|gif|swf'); $properties["WikiName Regexp"] = new _define('WIKI_NAME_REGEXP', "(? 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"); $properties["TOC_FULL_SYNTAX"] = new boolean_define_optional('TOC_FULL_SYNTAX'); $properties["ENABLE_MARKUP_COLOR"] = new boolean_define_optional('ENABLE_MARKUP_COLOR'); $properties["DISABLE_MARKUP_WIKIWORD"] = new boolean_define_optional('DISABLE_MARKUP_WIKIWORD'); $properties["ENABLE_MARKUP_DIVSPAN"] = new boolean_define_optional('ENABLE_MARKUP_DIVSPAN'); /////////////////// $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."); $properties["Server Name"] = new _define_commented_optional('SERVER_NAME', $_SERVER['SERVER_NAME'], " Canonical name of the server on which this PhpWiki resides."); $properties["Server Port"] = new numeric_define_commented('SERVER_PORT', $_SERVER['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["Server Protocol"] = new _define_selection_optional_commented('SERVER_PROTOCOL', array('http' => 'http', 'https' => 'https')); $properties["Script Name"] = new _define_commented_optional('SCRIPT_NAME', $scriptname); $properties["Data Path"] = new _define_commented_optional('DATA_PATH', dirname($scriptname)); $properties["PhpWiki Install Directory"] = new _define_commented_optional('PHPWIKI_DIR', dirname(__FILE__)); $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.) "); $upload_file_path = defined('UPLOAD_FILE_PATH') ? UPLOAD_FILE_PATH : getUploadFilePath(); new _define_optional('UPLOAD_FILE_PATH', $temp); $upload_data_path = defined('UPLOAD_DATA_PATH') ? UPLOAD_DATA_PATH : getUploadDataPath(); new _define_optional('UPLOAD_DATA_PATH', $temp); $temp = !empty($_ENV['TEMP']) ? $_ENV['TEMP'] : "/tmp"; $properties["TEMP_DIR"] = new _define_optional('TEMP_DIR', $temp); /////////////////// $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")); $properties["Default local Dump Directory"] = new _define_optional('DEFAULT_DUMP_DIR'); $properties["Default local HTML Dump Directory"] = new _define_optional('HTML_DUMP_DIR'); $properties["HTML Dump Filename Suffix"] = new _define_optional('HTML_DUMP_SUFFIX'); $properties["Pagename of Recent Changes"] = new _define_optional('RECENT_CHANGES', "RecentChanges"); $properties["Disable HTTP Redirects"] = new boolean_define_commented_optional('DISABLE_HTTP_REDIRECT'); $properties["Disable GETIMAGESIZE"] = new boolean_define_commented_optional('DISABLE_GETIMAGESIZE'); $properties["EDITING_POLICY"] = new _define_optional('EDITING_POLICY'); $properties["TOOLBAR_PAGELINK_PULLDOWN"] = new _define_commented_optional('TOOLBAR_PAGELINK_PULLDOWN'); $properties["TOOLBAR_TEMPLATE_PULLDOWN"] = new _define_commented_optional('TOOLBAR_TEMPLATE_PULLDOWN'); $properties["TOOLBAR_IMAGE_PULLDOWN"] = new _define_commented_optional('TOOLBAR_IMAGE_PULLDOWN'); $properties["FULLTEXTSEARCH_STOPLIST"] = new _define_commented_optional('FULLTEXTSEARCH_STOPLIST'); $properties["Part Seven A"] = new part('_part7a', $SEPARATOR . "\n", " Part Seven A: Optional Plugin Settings and external executables "); $properties["FORTUNE_DIR"] = new _define_commented_optional('FORTUNE_DIR', "/usr/share/fortune"); $properties["USE_EXTERNAL_HTML2PDF"] = new _define_commented_optional('USE_EXTERNAL_HTML2PDF', "htmldoc --quiet --format pdf14 --no-toc --no-title %s"); $properties["EXTERNAL_HTML2PDF_PAGELIST"] = new _define_commented_optional('EXTERNAL_HTML2PDF_PAGELIST'); $properties["BABYCART_PATH"] = new _define_commented_optional('BABYCART_PATH', "/usr/local/bin/babycart"); $properties["GOOGLE_LICENSE_KEY"] = new _define_commented_optional('GOOGLE_LICENSE_KEY'); $properties["RATEIT_IMGPREFIX"] = new _define_commented_optional('RATEIT_IMGPREFIX'); //BStar $properties["GRAPHVIZ_EXE"] = new _define_commented_optional('GRAPHVIZ_EXE', "/usr/bin/dot"); if (PHP_OS == "Darwin") // Mac OS X $ttfont = "/System/Library/Frameworks/JavaVM.framework/Versions/1.3.1/Home/lib/fonts/LucidaSansRegular.ttf"; elseif (isWindows()) { $ttfont = $_ENV['windir'] . '\Fonts\Arial.ttf'; } else { $ttfont = 'luximr'; // This is the only what sourceforge offered. //$ttfont = 'Helvetica'; } $properties["TTFONT"] = new _define_commented_optional('TTFONT', $ttfont); $properties["VISUALWIKIFONT"] = new _define_commented_optional('VISUALWIKIFONT'); // Arial $properties["VISUALWIKI_ALLOWOPTIONS"] = new boolean_define_commented_optional('VISUALWIKI_ALLOWOPTIONS'); // false $properties["PLOTICUS_EXE"] = new _define_commented_optional('PLOTICUS_EXE'); // /usr/local/bin/pl $properties["PLOTICUS_PREFABS"] = new _define_commented_optional('PLOTICUS_PREFABS'); // /usr/share/ploticus $properties["MY_JABBER_ID"] = new _define_commented_optional('MY_JABBER_ID'); // $properties["PHPWEATHER_BASE_DIR"] = new _define_commented_optional('PHPWEATHER_BASE_DIR'); // $properties["HIGHLIGHT_EXE"] = new _define_commented_optional('HIGHLIGHT_EXE'); // /usr/local/bin/highlight $properties["HIGHLIGHT_DATA_DIR"] = new _define_commented_optional('HIGHLIGHT_DATA_DIR'); // /usr/share/highlight $properties["Part Eight"] = new part('_part8', $SEPARATOR . "\n", " Part Eight: 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"; // performance hack text_from_dist("_MAGIC_CLOSE_FILE"); // 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; if (!$description) $description = text_from_dist($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|TEMP_DIR)$/", $config_item_name) ) $this->default_value = constant($config_item_name); // ignore given default value elseif ($config_item_name == $default_value) $this->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 _define($config_item_name, $default_value = '', $description = '', $jscheck = '') { $this->_variable($config_item_name, $default_value, $description, $jscheck); } 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) { return ''; $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 = '') { if ($config_item_name == $default_value) $default_value = ''; $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 { function _define_password_optional($config_item_name, $default_value = '', $description = '', $jscheck = '') { if ($config_item_name == $default_value) $default_value = ''; if (!$jscheck) $this->jscheck = " "; $this->_define($config_item_name, $default_value, $description, $jscheck); } function _get_config_line($posted_value) { if ($this->description) $n = "\n"; if ($posted_value == '') { return "${n};" . $this->_config_format(""); } else { return "${n}" . $this->_config_format($posted_value); } } function get_html() { $s = $this->get_config_item_header(); // dont re-encrypt already encrypted passwords $value = $this->value(); $encrypted = !empty($GLOBALS['properties']["Encrypted Passwords"]) and $GLOBALS['properties']["Encrypted Passwords"]->value(); if (empty($value)) $encrypted = false; $s .= "get_config_item_name() . "\" value=\"" . $value . "\" {$this->jscheck} />"; return $s; } } class _define_password_commented_optional extends _define_password_optional { } class _variable_password extends _variable { function _variable_password($config_item_name, $default_value = '', $description = '', $jscheck = '') { if ($config_item_name == $default_value) $default_value = ''; $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); if ($list_values) $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); if ($list_values) $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); if ($list_values) $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() { if (is_array($this->default_value)) $list_values = join("\n", $this->default_value); else $list_values = $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() { if (!$this->default_value) $this->default_value = array(); elseif (is_string($this->default_value)) $this->default_value = preg_split("/[\s,:]+/", $this->default_value, -1, PREG_SPLIT_NO_EMPTY); $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 { // adds ->values property, instead of ->default_value function boolean_define($config_item_name, $values = false, $description = '', $jscheck = '') { $this->config_item_name = $config_item_name; if (!$description) $description = text_from_dist($config_item_name); $this->description = $description; // TESTME: get boolean default value from config-default.ini if (defined($config_item_name)) $this->default_value = constant($config_item_name); // ignore given default value elseif (is_array($values)) list($this->default_value, $dummy) = $values[0]; if (!$values) $values = array('false' => "Disabled", 'true' => "Enabled"); $this->values = $values; $this->jscheck = $jscheck; $this->prefix = ""; } 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'); } //TODO: radiobuttons, no list function get_html() { $output = $this->get_config_item_header(); $name = $this->get_config_item_name(); $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 text_from_dist($var) { static $distfile = 0; static $f; if (!$distfile) { $sep = (substr(PHP_OS, 0, 3) == 'WIN' ? '\\' : '/'); $distfile = dirname(__FILE__) . $sep . "config" . $sep . "config-dist.ini"; $f = fopen($distfile, "r"); } if ($var == '_MAGIC_CLOSE_FILE') { fclose($f); return; } // if all vars would be in natural order as in the config-dist this would not be needed. fseek($f, 0); $par = "\n"; while (!feof($f)) { $s = fgets($f); if (preg_match("/^; \w/", $s)) { $par .= (substr($s, 2) . " "); } elseif (preg_match("/^;\s*$/", $s)) { $par .= "\n\n"; } if (preg_match("/^;?" . preg_quote($var) . "\s*=/", $s)) return $par; if (preg_match("/^\s*$/", $s)) // new paragraph $par = "\n"; } return ''; } 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. if (!empty($GLOBALS['HTTP_GET_VARS']['start_debug'])) $configurator .= ("?start_debug=" . $GLOBALS['HTTP_GET_VARS']['start_debug']); echo ' '; } ?>