2 rcs_id('$Id: config.php,v 1.33 2001-02-15 05:57:18 dairiki 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
34 // Search PHP's include_path to find file or directory.
35 function FindFile ($file, $missing_okay = false)
37 // FIXME: This wont work for DOS filenames.
38 if (ereg('^/', $file))
41 if (file_exists($file))
46 $include_path = ini_get('include_path');
47 if (empty($include_path))
49 // FIXME: This wont work for DOS filenames.
50 $path = explode(':', $include_path);
51 while (list($i, $dir) = each ($path))
52 if (file_exists("$dir/$file"))
57 ExitWiki("$file: file not found");
61 // Search PHP's include_path to find file or directory.
62 // Searches for "locale/$LANG/$file", then for "$file".
63 function FindLocalizedFile ($file, $missing_okay = false)
67 // FIXME: This wont work for DOS filenames.
68 if (!ereg('^/', $file))
70 if ( ($path = FindFile("locale/$LANG/$file", 'missing_is_okay')) )
73 return FindFile($file, $missing_okay);
76 if (!function_exists ('gettext'))
80 function gettext ($text) {
82 if (!empty ($locale[$text]))
83 return $locale[$text];
87 if ( ($lcfile = FindLocalizedFile("LC_MESSAGES/phpwiki.php", 'missing_ok')) )
94 putenv ("LANG=$LANG");
95 bindtextdomain ("phpwiki", "./locale");
96 textdomain ("phpwiki");
99 //////////////////////////////////////////////////////////////////
100 // Autodetect URL settings:
102 if (!defined('SERVER_NAME')) define('SERVER_NAME', $SERVER_NAME);
103 if (!defined('SERVER_PORT')) define('SERVER_PORT', $SERVER_PORT);
104 if (!defined('SCRIPT_NAME')) define('SCRIPT_NAME', $SCRIPT_NAME);
105 if (!defined('DATA_PATH'))
106 define('DATA_PATH', dirname(SCRIPT_NAME));
107 if (!defined('USE_PATH_INFO'))
110 * If SCRIPT_NAME does not look like php source file,
111 * or user cgi we assume that php is getting run by an
112 * action handler in /cgi-bin. In this case,
113 * I think there is no way to get Apache to pass
114 * useful PATH_INFO to the php script (PATH_INFO
115 * is used to the the php interpreter where the
118 if (php_sapi_name() == 'apache')
119 define('USE_PATH_INFO', true);
121 define('USE_PATH_INFO', ereg('\.(php3?|cgi)$', $SCRIPT_NAME));
125 function IsProbablyRedirectToIndex ()
127 // This might be a redirect to the DirectoryIndex,
128 // e.g. REQUEST_URI = /dir/ got redirected
129 // to SCRIPT_NAME = /dir/index.php
131 // In this case, the proper virtual path is still
132 // $SCRIPT_NAME, since pages appear at
133 // e.g. /dir/index.php/FrontPage.
135 global $REQUEST_URI, $SCRIPT_NAME;
137 $requri = preg_quote($REQUEST_URI, '%');
138 return preg_match("%^${requri}[^/]*$%", $SCRIPT_NAME);
142 if (!defined('VIRTUAL_PATH'))
144 // We'd like to auto-detect when the cases where apaches
145 // 'Action' directive (or similar means) is used to
146 // redirect page requests to a cgi-handler.
148 // In cases like this, requests for e.g. /wiki/FrontPage
149 // get redirected to a cgi-script called, say,
150 // /path/to/wiki/index.php. The script gets all
151 // of /wiki/FrontPage as it's PATH_INFO.
154 // How to detect when this has happened reliably?
155 // How to pick out the "virtual path" (in this case '/wiki')?
157 // (Another time an redirect might occur is to a DirectoryIndex
158 // -- the requested URI is '/wikidir/', the request gets
159 // passed to '/wikidir/index.php'. In this case, the
160 // proper VIRTUAL_PATH is '/wikidir/index.php', since the
161 // pages will appear at e.g. '/wikidir/index.php/FrontPage'.
164 if (USE_PATH_INFO and isset($REDIRECT_URL)
165 and ! IsProbablyRedirectToIndex())
167 // FIXME: This is a hack, and won't work if the requested
168 // pagename has a slash in it.
169 define('VIRTUAL_PATH', dirname($REDIRECT_URL . 'x'));
172 define('VIRTUAL_PATH', SCRIPT_NAME);
175 if (SERVER_PORT && SERVER_PORT != 80)
177 "http://" . SERVER_NAME . ':' . SERVER_PORT);
180 "http://" . SERVER_NAME);
182 if (VIRTUAL_PATH != SCRIPT_NAME)
184 // Apache action handlers are used.
185 define('PATH_INFO_PREFIX', VIRTUAL_PATH . "/");
188 define("PATH_INFO_PREFIX", '/');
191 //////////////////////////////////////////////////////////////////
194 if (empty($DBParams['dbtype']))
196 if ( floor(phpversion()) == 3) {
197 $DBParams['dbtype'] = 'dbm';
199 $DBParams['dbtype'] = 'dba';
203 switch ($DBParams['dbtype'])
206 include 'lib/dbmlib.php';
209 include 'lib/dbalib.php';
212 include 'lib/mysql.php';
215 include 'lib/pgsql.php';
218 include 'lib/msql.php';
221 include "lib/db_filesystem.php";
224 ExitWiki($DBParams['dbtype'] . ": unknown DBTYPE");
227 // InterWiki linking -- wiki-style links to other wikis on the web
229 if (defined('INTERWIKI_MAP_FILE'))
231 include ('lib/interwiki.php');
237 // c-file-style: "ellemtel"