2 rcs_id('$Id: config.php,v 1.36 2001-03-11 17:56:36 wainstead Exp $');
4 * NOTE: the settings here should probably not need to be changed.
7 * (The user-configurable settings have been moved to index.php.)
10 // essential internal stuff
12 set_magic_quotes_runtime(0);
16 // "\x80"-"\x9f" (and "\x00" - "\x1f") are non-printing control
17 // chars in iso-8859-*
18 // $FieldSeparator = "\263"; //this is a superscript 3 in ISO-8859-1.
19 $FieldSeparator = "\x81";
22 // constants for flags in $pagehash
23 define("FLAG_PAGE_LOCKED", 1);
25 //////////////////////////////////////////////////////////////////
27 // Set up localization
33 // Search PHP's include_path to find file or directory.
34 function FindFile ($file, $missing_okay = false)
36 // FIXME: This wont work for DOS filenames.
37 if (ereg('^/', $file))
40 if (file_exists($file))
45 $include_path = ini_get('include_path');
46 if (empty($include_path))
48 // FIXME: This wont work for DOS filenames.
49 $path = explode(':', $include_path);
50 while (list($i, $dir) = each ($path))
51 if (file_exists("$dir/$file"))
56 ExitWiki("$file: file not found");
60 // Search PHP's include_path to find file or directory.
61 // Searches for "locale/$LANG/$file", then for "$file".
62 function FindLocalizedFile ($file, $missing_okay = false)
66 // FIXME: This wont work for DOS filenames.
67 if (!ereg('^/', $file))
69 if ( ($path = FindFile("locale/$LANG/$file", 'missing_is_okay')) )
72 return FindFile($file, $missing_okay);
75 if (!function_exists ('gettext'))
79 function gettext ($text) {
81 if (!empty ($locale[$text]))
82 return $locale[$text];
86 if ( ($lcfile = FindLocalizedFile("LC_MESSAGES/phpwiki.php", 'missing_ok')) )
93 putenv ("LANG=$LANG");
94 bindtextdomain ("phpwiki", "./locale");
95 textdomain ("phpwiki");
98 // To get the POSIX character classes in the PCRE's (e.g.
99 // [[:upper:]]) to match extended characters (e.g. GrüßGott), we have
100 // to set the locale, using setlocale().
102 // The problem is which locale to set? We would like to recognize all
103 // upper-case characters in the iso-8859-1 character set as upper-case
104 // characters --- not just the ones which are in the current $LANG.
106 // As it turns out, at least on my system (Linux/glibc-2.2) as long as
107 // you setlocale() to anything but "C" it works fine. (I'm not sure
108 // whether this is how it's supposed to be, or whether this is a bug
111 // We don't currently use the locale setting for anything else, so for
112 // now, just set the locale to US English.
114 // FIXME: Not all environments may support en_US? We should probably
115 // have a list of locales to try.
117 if (setlocale('LC_CTYPE', 0) == 'C')
118 setlocale('LC_CTYPE', 'en_US.iso-8859-1');
120 //////////////////////////////////////////////////////////////////
121 // Autodetect URL settings:
123 if (!defined('SERVER_NAME')) define('SERVER_NAME', $SERVER_NAME);
124 if (!defined('SERVER_PORT')) define('SERVER_PORT', $SERVER_PORT);
125 if (!defined('SCRIPT_NAME')) define('SCRIPT_NAME', $SCRIPT_NAME);
126 if (!defined('DATA_PATH'))
127 define('DATA_PATH', dirname(SCRIPT_NAME));
128 if (!defined('USE_PATH_INFO'))
131 * If SCRIPT_NAME does not look like php source file,
132 * or user cgi we assume that php is getting run by an
133 * action handler in /cgi-bin. In this case,
134 * I think there is no way to get Apache to pass
135 * useful PATH_INFO to the php script (PATH_INFO
136 * is used to the the php interpreter where the
139 if (php_sapi_name() == 'apache')
140 define('USE_PATH_INFO', true);
142 define('USE_PATH_INFO', ereg('\.(php3?|cgi)$', $SCRIPT_NAME));
146 function IsProbablyRedirectToIndex ()
148 // This might be a redirect to the DirectoryIndex,
149 // e.g. REQUEST_URI = /dir/ got redirected
150 // to SCRIPT_NAME = /dir/index.php
152 // In this case, the proper virtual path is still
153 // $SCRIPT_NAME, since pages appear at
154 // e.g. /dir/index.php/FrontPage.
156 global $REQUEST_URI, $SCRIPT_NAME;
158 $requri = preg_quote($REQUEST_URI, '%');
159 return preg_match("%^${requri}[^/]*$%", $SCRIPT_NAME);
163 if (!defined('VIRTUAL_PATH'))
165 // We'd like to auto-detect when the cases where apaches
166 // 'Action' directive (or similar means) is used to
167 // redirect page requests to a cgi-handler.
169 // In cases like this, requests for e.g. /wiki/FrontPage
170 // get redirected to a cgi-script called, say,
171 // /path/to/wiki/index.php. The script gets all
172 // of /wiki/FrontPage as it's PATH_INFO.
175 // How to detect when this has happened reliably?
176 // How to pick out the "virtual path" (in this case '/wiki')?
178 // (Another time an redirect might occur is to a DirectoryIndex
179 // -- the requested URI is '/wikidir/', the request gets
180 // passed to '/wikidir/index.php'. In this case, the
181 // proper VIRTUAL_PATH is '/wikidir/index.php', since the
182 // pages will appear at e.g. '/wikidir/index.php/FrontPage'.
185 if (USE_PATH_INFO and isset($REDIRECT_URL)
186 and ! IsProbablyRedirectToIndex())
188 // FIXME: This is a hack, and won't work if the requested
189 // pagename has a slash in it.
190 define('VIRTUAL_PATH', dirname($REDIRECT_URL . 'x'));
193 define('VIRTUAL_PATH', SCRIPT_NAME);
196 if (SERVER_PORT && SERVER_PORT != 80)
198 "http://" . SERVER_NAME . ':' . SERVER_PORT);
201 "http://" . SERVER_NAME);
203 if (VIRTUAL_PATH != SCRIPT_NAME)
205 // Apache action handlers are used.
206 define('PATH_INFO_PREFIX', VIRTUAL_PATH . "/");
209 define("PATH_INFO_PREFIX", '/');
212 //////////////////////////////////////////////////////////////////
215 if (empty($DBParams['dbtype']))
217 if ( floor(phpversion()) == 3) {
218 $DBParams['dbtype'] = 'dbm';
220 $DBParams['dbtype'] = 'dba';
224 switch ($DBParams['dbtype'])
227 include 'lib/dbmlib.php';
230 include 'lib/dbalib.php';
233 include 'lib/mysql.php';
236 include 'lib/pgsql.php';
239 include 'lib/msql.php';
242 include "lib/db_filesystem.php";
245 ExitWiki($DBParams['dbtype'] . ": unknown DBTYPE");
248 // InterWiki linking -- wiki-style links to other wikis on the web
250 if (defined('INTERWIKI_MAP_FILE'))
252 include ('lib/interwiki.php');
256 if (!defined('ACCESS_LOG'))
257 define('ACCESS_LOG', '');
259 // Get remote host name, if apache hasn't done it for us
260 if (empty($REMOTE_HOST) && ENABLE_REVERSE_DNS)
261 $REMOTE_HOST = gethostbyaddr($REMOTE_ADDR);
267 // c-file-style: "ellemtel"