2 rcs_id('$Id: config.php,v 1.34 2001-02-16 04:43:07 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
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 //////////////////////////////////////////////////////////////////
99 // Autodetect URL settings:
101 if (!defined('SERVER_NAME')) define('SERVER_NAME', $SERVER_NAME);
102 if (!defined('SERVER_PORT')) define('SERVER_PORT', $SERVER_PORT);
103 if (!defined('SCRIPT_NAME')) define('SCRIPT_NAME', $SCRIPT_NAME);
104 if (!defined('DATA_PATH'))
105 define('DATA_PATH', dirname(SCRIPT_NAME));
106 if (!defined('USE_PATH_INFO'))
109 * If SCRIPT_NAME does not look like php source file,
110 * or user cgi we assume that php is getting run by an
111 * action handler in /cgi-bin. In this case,
112 * I think there is no way to get Apache to pass
113 * useful PATH_INFO to the php script (PATH_INFO
114 * is used to the the php interpreter where the
117 if (php_sapi_name() == 'apache')
118 define('USE_PATH_INFO', true);
120 define('USE_PATH_INFO', ereg('\.(php3?|cgi)$', $SCRIPT_NAME));
124 function IsProbablyRedirectToIndex ()
126 // This might be a redirect to the DirectoryIndex,
127 // e.g. REQUEST_URI = /dir/ got redirected
128 // to SCRIPT_NAME = /dir/index.php
130 // In this case, the proper virtual path is still
131 // $SCRIPT_NAME, since pages appear at
132 // e.g. /dir/index.php/FrontPage.
134 global $REQUEST_URI, $SCRIPT_NAME;
136 $requri = preg_quote($REQUEST_URI, '%');
137 return preg_match("%^${requri}[^/]*$%", $SCRIPT_NAME);
141 if (!defined('VIRTUAL_PATH'))
143 // We'd like to auto-detect when the cases where apaches
144 // 'Action' directive (or similar means) is used to
145 // redirect page requests to a cgi-handler.
147 // In cases like this, requests for e.g. /wiki/FrontPage
148 // get redirected to a cgi-script called, say,
149 // /path/to/wiki/index.php. The script gets all
150 // of /wiki/FrontPage as it's PATH_INFO.
153 // How to detect when this has happened reliably?
154 // How to pick out the "virtual path" (in this case '/wiki')?
156 // (Another time an redirect might occur is to a DirectoryIndex
157 // -- the requested URI is '/wikidir/', the request gets
158 // passed to '/wikidir/index.php'. In this case, the
159 // proper VIRTUAL_PATH is '/wikidir/index.php', since the
160 // pages will appear at e.g. '/wikidir/index.php/FrontPage'.
163 if (USE_PATH_INFO and isset($REDIRECT_URL)
164 and ! IsProbablyRedirectToIndex())
166 // FIXME: This is a hack, and won't work if the requested
167 // pagename has a slash in it.
168 define('VIRTUAL_PATH', dirname($REDIRECT_URL . 'x'));
171 define('VIRTUAL_PATH', SCRIPT_NAME);
174 if (SERVER_PORT && SERVER_PORT != 80)
176 "http://" . SERVER_NAME . ':' . SERVER_PORT);
179 "http://" . SERVER_NAME);
181 if (VIRTUAL_PATH != SCRIPT_NAME)
183 // Apache action handlers are used.
184 define('PATH_INFO_PREFIX', VIRTUAL_PATH . "/");
187 define("PATH_INFO_PREFIX", '/');
190 //////////////////////////////////////////////////////////////////
193 if (empty($DBParams['dbtype']))
195 if ( floor(phpversion()) == 3) {
196 $DBParams['dbtype'] = 'dbm';
198 $DBParams['dbtype'] = 'dba';
202 switch ($DBParams['dbtype'])
205 include 'lib/dbmlib.php';
208 include 'lib/dbalib.php';
211 include 'lib/mysql.php';
214 include 'lib/pgsql.php';
217 include 'lib/msql.php';
220 include "lib/db_filesystem.php";
223 ExitWiki($DBParams['dbtype'] . ": unknown DBTYPE");
226 // InterWiki linking -- wiki-style links to other wikis on the web
228 if (defined('INTERWIKI_MAP_FILE'))
230 include ('lib/interwiki.php');
234 if (!defined('ACCESS_LOG'))
235 define('ACCESS_LOG', '');
237 // Get remote host name, if apache hasn't done it for us
238 if (empty($REMOTE_HOST) && ENABLE_REVERSE_DNS)
239 $REMOTE_HOST = gethostbyaddr($REMOTE_ADDR);
245 // c-file-style: "ellemtel"