]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/IniConfig.php
check more config-default and predefined constants
[SourceForge/phpwiki.git] / lib / IniConfig.php
1 <?php
2 rcs_id('$Id: IniConfig.php,v 1.22 2004-05-16 22:07:35 rurban Exp $');
3
4 /**
5  * A configurator intended to read it's config from a PHP-style INI file,
6  * instead of a PHP file.
7  *
8  * Pass a filename to the IniConfig() function and it will read all it's
9  * definitions from there, all by itself, and proceed to do a mass-define
10  * of all valid PHPWiki config items.  In this way, we can hopefully be
11  * totally backwards-compatible with the old index.php method, while still
12  * providing a much tastier on-going experience.
13  *
14  * @author: Joby Walker, Reini Urban, Matthew Palmer
15  */
16 /*
17  * Copyright 2004 $ThePhpWikiProgrammingTeam
18  *
19  * This file is part of PhpWiki.
20  *
21  * PhpWiki is free software; you can redistribute it and/or modify
22  * it under the terms of the GNU General Public License as published by
23  * the Free Software Foundation; either version 2 of the License, or
24  * (at your option) any later version.
25  * 
26  * PhpWiki is distributed in the hope that it will be useful,
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29  * GNU General Public License for more details.
30  * 
31  * You should have received a copy of the GNU General Public License
32  * along with PhpWiki; if not, write to the Free Software
33  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
34  */
35
36 /** TODO
37  * - Convert the value lists to provide defaults, so that every "if
38  *      (defined())" and "if (!defined())" can fuck off to the dismal hole
39  *      it belongs in.
40  *
41  * - Resurrect the larger "config object" code (in config/) so it'll aid the
42  *      GUI config writers, and allow us to do proper validation and default
43  *      value handling.
44  *
45  * - Get rid of WikiNameRegexp and KeywordLinkRegexp as globals by finding
46  *      everywhere that uses them as variables and modify the code to use
47  *      them as constants.  Will involve hacking around
48  *      pcre_fix_posix_classes (probably with redefines()).
49  */
50
51 include_once (dirname(__FILE__)."/config.php");
52 include_once (dirname(__FILE__)."/FileFinder.php");
53
54 function IniConfig($file) {
55     
56     //FindFile("pear/Config.php");
57     //require_once("Config.php");
58  
59     // List of all valid config options to be define()d which take "values" (not
60     // booleans). Needs to be categorised, and generally made a lot tidier. 
61    $_IC_VALID_VALUE = array
62         ('DEBUG', 'WIKI_NAME', 'ADMIN_USER', 'ADMIN_PASSWD',
63          'HTML_DUMP_SUFFIX', 'MAX_UPLOAD_SIZE', 'MINOR_EDIT_TIMEOUT',
64          'ACCESS_LOG', 'CACHE_CONTROL', 'CACHE_CONTROL_MAX_AGE',
65          'PASSWORD_LENGTH_MINIMUM', 'USER_AUTH_POLICY', 'LDAP_AUTH_HOST',
66          'LDAP_BASE_DN', 'LDAP_AUTH_USER', 'LDAP_AUTH_PASSWORD',
67          'LDAP_SEARCH_FIELD', 'IMAP_AUTH_HOST', 'POP3_AUTH_HOST',
68          'AUTH_USER_FILE', 'AUTH_SESS_USER', 'AUTH_SESS_LEVEL', 'GROUP_METHOD',
69          'AUTH_GROUP_FILE', 'EDITING_POLICY', 'THEME', 'CHARSET',
70          'DEFAULT_LANGUAGE', 'WIKI_PGSRC', 'DEFAULT_WIKI_PGSRC',
71          'ALLOWED_PROTOCOLS', 'INLINE_IMAGES', 'SUBPAGE_SEPARATOR',
72          'INTERWIKI_MAP_FILE', 'COPYRIGHTPAGE_TITLE', 'COPYRIGHTPAGE_URL',
73          'AUTHORPAGE_TITLE', 'AUTHORPAGE_URL', 'SERVER_NAME', 'SERVER_PORT',
74          'SCRIPT_NAME', 'DATA_PATH', 'PHPWIKI_DIR', 'VIRTUAL_PATH',
75          'WIKI_NAME_REGEXP');
76
77     // List of all valid config options to be define()d which take booleans.
78     $_IC_VALID_BOOL = array
79         ('ENABLE_USER_NEW', 'ENABLE_EDIT_TOOLBAR', 'JS_SEARCHREPLACE',
80          'ENABLE_REVERSE_DNS', 'ENCRYPTED_PASSWD', 'ZIPDUMP_AUTH', 
81          'ENABLE_RAW_HTML', 'STRICT_MAILABLE_PAGEDUMPS', 'COMPRESS_OUTPUT',
82          'WIKIDB_NOCACHE_MARKUP', 'ALLOW_ANON_USER', 'ALLOW_ANON_EDIT',
83          'ALLOW_BOGO_LOGIN', 'ALLOW_USER_PASSWORDS',
84          'AUTH_USER_FILE_STORABLE', 'ALLOW_HTTP_AUTH_LOGIN',
85          'ALLOW_USER_LOGIN', 'ALLOW_LDAP_LOGIN', 'ALLOW_IMAP_LOGIN',
86          'WARN_NONPUBLIC_INTERWIKIMAP', 'USE_PATH_INFO',
87          'DISABLE_HTTP_REDIRECT');
88
89     if(!file_exists($file)){
90         trigger_error("Datasource file '$file' does not exist", E_USER_ERROR);
91         exit();
92     }
93          
94     $rs = @parse_ini_file($file);
95     $rsdef = @parse_ini_file(dirname(__FILE__)."/../config/config-default.ini");
96     foreach ($rsdef as $k => $v) {
97         if (defined($k))
98             $rs[$k] = constant($k);
99         elseif (!isset($rs[$k]))
100             $rs[$k] = $v;
101     }
102
103     foreach ($_IC_VALID_VALUE as $item) {
104         if (defined($item)) continue;
105         if (array_key_exists($item, $rs)) {
106             define($item, $rs[$item]);
107         //} elseif (array_key_exists($item, $rsdef)) {
108         //    define($item, $rsdef[$item]);
109         // calculate them later:
110         } elseif (in_array($item,array('DATABASE_PREFIX', 'SERVER_NAME', 'SERVER_PORT',
111                 'SCRIPT_NAME', 'DATA_PATH', 'PHPWIKI_DIR', 'VIRTUAL_PATH'))) {
112             ;
113         } else {
114             trigger_error(sprintf("missing config setting for %s",$item));
115         }
116     }
117
118     // Boolean options are slightly special - if they're set to any of
119     // '', 'false', '0', or 'no' (all case-insensitive) then the value will
120     // be a boolean false, otherwise if there is anything set it'll
121     // be true.
122     foreach ($_IC_VALID_BOOL as $item) {
123         if (defined($item)) continue;
124         if (array_key_exists($item, $rs)) {
125             $val = $rs[$item];
126         //} elseif (array_key_exists($item, $rsdef)) {
127         //    $val = $rsdef[$item];
128         } else {
129             $val = false; //trigger_error(sprintf("missing boolean config setting for %s",$item));
130         }
131         
132         // calculate them later: old or dynamic constants
133         if (!array_key_exists($item, $rs) and
134             in_array($item,array('USE_PATH_INFO','USE_DB_SESSION',
135                                  'ALLOW_HTTP_AUTH_LOGIN','ALLOW_LDAP_LOGIN',
136                                  'ALLOW_IMAP_LOGIN','ALLOW_USER_LOGIN',
137                                  'REQUIRE_SIGNIN_BEFORE_EDIT',
138                                  'WIKIDB_NOCACHE_MARKUP')))
139         {
140             ;
141         }
142         elseif (!$val) {
143             define($item, false);
144         }
145         elseif (strtolower($val) == 'false' ||
146                 strtolower($val) == 'no' ||
147                 $val == '' ||
148                 $val == false ||
149                 $val == '0') {
150             define($item, false);
151         }
152         else {
153             define($item, true);
154         }
155     }
156
157     // Special handling for some config options
158     if ($val = @$rs['INCLUDE_PATH']) {
159         ini_set('include_path', $val);
160     }
161
162     if ($val = @$rs['SESSION_SAVE_PATH']) {
163         ini_set('session.save_path', $val);
164     }
165
166     // Database
167     global $DBParams;
168     $DBParams['dbtype'] = @$rs['DATABASE_TYPE'];
169     if (isset($rs['DATABASE_DSN']))
170         $DBParams['dsn'] = $rs['DATABASE_DSN'];
171     if (isset($rs['DATABASE_PREFIX']))
172         $DBParams['prefix'] = $rs['DATABASE_PREFIX'];
173     $DBParams['db_session_table'] = @$rs['DATABASE_SESSION_TABLE'];
174     $DBParams['dba_handler'] = @$rs['DATABASE_DBA_HANDLER'];
175     $DBParams['directory'] = @$rs['DATABASE_DIRECTORY'];
176     $DBParams['timeout'] = @$rs['DATABASE_TIMEOUT'];
177     if (!defined('USE_DB_SESSION') and $DBParams['db_session_table'] and 
178         in_array($DBParams['dbtype'],array('SQL','ADODB'/*,'dba'*/))) {
179         define('USE_DB_SESSION', true);
180     }
181
182     // Expiry stuff
183     global $ExpireParams;
184     $ExpireParams['major'] = array(
185                                    'max_age'  => @$rs['MAJOR_MAX_AGE'],
186                                    'min_age'  => @$rs['MAJOR_MIN_AGE'],
187                                    'min_keep' => @$rs['MAJOR_MIN_KEEP'],
188                                    'keep'     => @$rs['MAJOR_KEEP'],
189                                    'max_keep' => @$rs['MAJOR_MAX_KEEP']
190                                    );
191     $ExpireParams['minor'] = array(
192                                    'max_age'  => @$rs['MINOR_MAX_AGE'],
193                                    'min_age'  => @$rs['MINOR_MIN_AGE'],
194                                    'min_keep' => @$rs['MINOR_MIN_KEEP'],
195                                    'keep'     => @$rs['MINOR_KEEP'],
196                                    'max_keep' => @$rs['MINOR_MAX_KEEP']
197                                    );
198     $ExpireParams['author'] = array(
199                                     'max_age'  => @$rs['AUTHOR_MAX_AGE'],
200                                     'min_age'  => @$rs['AUTHOR_MIN_AGE'],
201                                     'min_keep' => @$rs['AUTHOR_MIN_KEEP'],
202                                     'keep'     => @$rs['AUTHOR_KEEP'],
203                                     'max_keep' => @$rs['AUTHOR_MAX_KEEP']
204                                     );
205
206     // User authentication
207     $GLOBALS['USER_AUTH_ORDER'] = preg_split('/\s*:\s*/', $rs['USER_AUTH_ORDER']);
208
209     // LDAP bind options
210     global $LDAP_SET_OPTION;
211     $optlist = preg_split('/\s*:\s*/', @$rs['LDAP_SET_OPTION']);
212     foreach ($optlist as $opt) {
213         $bits = preg_split('/\s*=\s*/', $opt, 2);
214         if (count($bits) == 2) {
215             $LDAP_SET_OPTION[$bits[0]] = $bits[1];
216         }
217         else {
218             // Possibly throw some sort of error?
219         }
220     }
221
222     // Now it's the external DB authentication stuff's turn
223     if (in_array('Db', $GLOBALS['USER_AUTH_ORDER']) && empty($rs['DBAUTH_AUTH_DSN'])) {
224         $rs['DBAUTH_AUTH_DSN'] = $DBParams['dsn'];
225     }
226     
227     global $DBAuthParams;
228     $DBAP_MAP = array('DBAUTH_AUTH_DSN' => 'auth_dsn',
229                       'DBAUTH_AUTH_CHECK' => 'auth_check',
230                       'DBAUTH_AUTH_USER_EXISTS' => 'auth_user_exists',
231                       'DBAUTH_AUTH_CRYPT_METHOD' => 'auth_crypt_method',
232                       'DBAUTH_AUTH_UPDATE' => 'auth_update',
233                       'DBAUTH_AUTH_CREATE' => 'auth_create',
234                       'DBAUTH_PREF_SELECT' => 'pref_select',
235                       'DBAUTH_PREF_UPDATE' => 'pref_update',
236                       'DBAUTH_IS_MEMBER' => 'is_member',
237                       'DBAUTH_GROUP_MEMBERS' => 'group_members',
238                       'DBAUTH_USER_GROUPS' => 'user_groups'
239                       );
240     foreach ($DBAP_MAP as $rskey => $apkey) {
241         if (isset($rs[$rskey])) {
242             $DBAuthParams[$apkey] = $rs[$rskey];
243         } elseif (isset($rsdef[$rskey])) {
244             $DBAuthParams[$apkey] = $rsdef[$rskey];
245         }
246     }
247
248     // Default Wiki pages to force loading from pgsrc
249     global $GenericPages;
250     $GenericPages = preg_split('/\s*:\s*/', @$rs['DEFAULT_WIKI_PAGES']);
251
252     // Wiki name regexp:  Should be a define(), but might needed to be changed at runtime
253     // (different LC_CHAR need different posix classes)
254     global $WikiNameRegexp;
255     $WikiNameRegexp = constant('WIKI_NAME_REGEXP');
256     if (!trim($WikiNameRegexp))
257        $WikiNameRegexp = '(?<![[:alnum:]])(?:[[:upper:]][[:lower:]]+){2,}(?![[:alnum:]])';
258
259     // Another "too-tricky" redefine
260     global $KeywordLinkRegexp;
261     if (!isset($rs['KEYWORDS'])) $rs['KEYWORDS'] = "Category:Topic";
262     $keywords = preg_split('/\s*:\s*/', $rs['KEYWORDS']);
263     if (empty($keywords)) $keywords = array("Category","Topic");
264     $KeywordLinkRegexp = '(?<=' . implode('|^', $keywords) . ')[[:upper:]].*$';
265         
266     global $DisabledActions;
267     $DisabledActions = preg_split('/\s*:\s*/', @$rs['DISABLED_ACTIONS']);
268     
269     /*global $AllowedProtocols, $InlineImages;
270     $AllowedProtocols = constant("ALLOWED_PROTOCOLS");
271     $InlineImages = constant("INLINE_IMAGES");*/
272
273     fix_configs();
274 }
275
276 // moved from lib/config.php
277 function fix_configs() {
278     global $FieldSeparator, $charset, $WikiNameRegexp, $KeywordLinkRegexp, $AllActionPages;
279     global $DisabledActions, $HTTP_SERVER_VARS, $DBParams, $LANG;
280
281     // "\x80"-"\x9f" (and "\x00" - "\x1f") are non-printing control
282     // chars in iso-8859-*
283     // $FieldSeparator = "\263"; // this is a superscript 3 in ISO-8859-1.
284     // $FieldSeparator = "\xFF"; // this byte should never appear in utf-8
285     // FIXME: get rid of constant. pref is dynamic and language specific
286     $charset = CHARSET;
287     if (isset($LANG) and in_array($LANG,array('ja','zh')))
288         $charset = 'utf-8';
289     if (strtolower($charset) == 'utf-8')
290         $FieldSeparator = "\xFF";
291     else
292         $FieldSeparator = "\x81";
293
294     if (!defined('DEFAULT_LANGUAGE'))
295         define('DEFAULT_LANGUAGE', 'en');
296     update_locale(isset($LANG) ? $LANG : DEFAULT_LANGUAGE);
297
298     // Set up (possibly fake) gettext()
299     //
300     if (!function_exists ('bindtextdomain')) {
301         $locale = array();
302
303         function gettext ($text) { 
304             global $locale;
305             if (!empty ($locale[$text]))
306                 return $locale[$text];
307             return $text;
308         }
309
310         function _ ($text) {
311             return gettext($text);
312         }
313     }
314     else {
315         // Working around really weird gettext problems: (4.3.2, 4.3.6 win)
316         // bindtextdomain() returns the current domain path.
317         // 1. If the script is not index.php but something like "de", on a different path
318         //    then bindtextdomain() fails, but after chdir to the correct path it will work okay.
319         // 2. But the weird error "Undefined variable: bindtextdomain" is generated then.
320         $bindtextdomain_path = FindFile("locale", false, true);
321         if (isWindows())
322             $bindtextdomain_path = str_replace("/","\\",$bindtextdomain_path);
323         $bindtextdomain_real = @bindtextdomain("phpwiki", $bindtextdomain);
324         if ($bindtextdomain_real != $bindtextdomain_path) {
325             // this will happen with virtual_paths. chdir and try again.
326             chdir($bindtextdomain_path);
327             $bindtextdomain_real = @bindtextdomain("phpwiki", $bindtextdomain);
328         }
329         textdomain("phpwiki");
330         if ($bindtextdomain_real != $bindtextdomain_path) { // change back
331             chdir($bindtextdomain_real . (isWindows() ? "\\.." : "/.."));
332         }
333     }
334
335     $WikiNameRegexp = pcre_fix_posix_classes($WikiNameRegexp);
336     $KeywordLinkRegexp = pcre_fix_posix_classes($KeywordLinkRegexp);
337
338     $AllActionPages = explode(':','AllPages:BackLinks:DebugInfo:FindPage:FullRecentChanges:'
339                               .'FullTextSearch:FuzzyPages:InterWikiSearch:LikePages:MostPopular:'
340                               .'OrphanedPages:PageDump:PageHistory:PageInfo:RandomPage:RateIt:'
341                               .'RecentChanges:RecentEdits:RelatedChanges:TitleSearch:TranslateText:'
342                               .'UpLoad:UserPreferences:WantedPages:WhoIsOnline');
343
344     //////////////////////////////////////////////////////////////////
345     // Autodetect URL settings:
346     //
347     if (!defined('SERVER_NAME')) define('SERVER_NAME', $HTTP_SERVER_VARS['SERVER_NAME']);
348     if (!defined('SERVER_PORT')) define('SERVER_PORT', $HTTP_SERVER_VARS['SERVER_PORT']);
349     if (!defined('SERVER_PROTOCOL')) {
350         if (empty($HTTP_SERVER_VARS['HTTPS']) || $HTTP_SERVER_VARS['HTTPS'] == 'off')
351             define('SERVER_PROTOCOL', 'http');
352         else
353             define('SERVER_PROTOCOL', 'https');
354     }
355
356     if (!defined('SCRIPT_NAME'))
357         define('SCRIPT_NAME', deduce_script_name());
358
359     if (!defined('USE_PATH_INFO')) {
360             /*
361              * If SCRIPT_NAME does not look like php source file,
362              * or user cgi we assume that php is getting run by an
363              * action handler in /cgi-bin.  In this case,
364              * I think there is no way to get Apache to pass
365              * useful PATH_INFO to the php script (PATH_INFO
366              * is used to the the php interpreter where the
367              * php script is...)
368              */
369             switch (php_sapi_name()) {
370             case 'apache':
371             case 'apache2handler':
372                 define('USE_PATH_INFO', true);
373                 break;
374             case 'cgi':
375             case 'apache2filter':
376                 define('USE_PATH_INFO', false);
377                 break;
378             default:
379                 define('USE_PATH_INFO', ereg('\.(php3?|cgi)$', SCRIPT_NAME));
380                 break;
381             }
382         }
383      
384     // If user has not defined PHPWIKI_DIR, and we need it
385     if (!defined('PHPWIKI_DIR') and !file_exists("themes/default")) {
386         $themes_dir = FindFile("themes");
387         define('PHPWIKI_DIR', dirname($themes_dir));
388     }
389         
390     if (!defined('VIRTUAL_PATH')) {
391         // We'd like to auto-detect when the cases where apaches
392         // 'Action' directive (or similar means) is used to
393         // redirect page requests to a cgi-handler.
394         //
395         // In cases like this, requests for e.g. /wiki/HomePage
396         // get redirected to a cgi-script called, say,
397         // /path/to/wiki/index.php.  The script gets all
398         // of /wiki/HomePage as it's PATH_INFO.
399         //
400         // The problem is:
401         //   How to detect when this has happened reliably?
402         //   How to pick out the "virtual path" (in this case '/wiki')?
403         //
404         // (Another time an redirect might occur is to a DirectoryIndex
405         // -- the requested URI is '/wikidir/', the request gets
406         // passed to '/wikidir/index.php'.  In this case, the
407         // proper VIRTUAL_PATH is '/wikidir/index.php', since the
408         // pages will appear at e.g. '/wikidir/index.php/HomePage'.
409         //
410
411         $REDIRECT_URL = &$HTTP_SERVER_VARS['REDIRECT_URL'];
412         if (USE_PATH_INFO and isset($REDIRECT_URL)
413             and ! IsProbablyRedirectToIndex()) {
414             // FIXME: This is a hack, and won't work if the requested
415             // pagename has a slash in it.
416             $temp = strtr(dirname($REDIRECT_URL . 'x'),"\\",'/');
417             if ( ($temp == '/') || ($temp == '\\') )
418                 $temp = '';
419             define('VIRTUAL_PATH', $temp);
420         } else {
421             define('VIRTUAL_PATH', SCRIPT_NAME);
422         }
423     }
424
425     // If user has not defined DATA_PATH, we want to use relative URLs.
426     if (!defined('DATA_PATH')) {
427         // fix similar to the one suggested by jkalmbach for 
428         // installations in the webrootdir, like "http://phpwiki.org/HomePage"
429         $temp = dirname(SCRIPT_NAME);
430         if ( ($temp == '/') || ($temp == '\\') )
431             $temp = '';
432         define('DATA_PATH', $temp);
433         /*
434         if (USE_PATH_INFO)
435             define('DATA_PATH', '..');
436         */
437     }
438
439     if (SERVER_PORT
440         && SERVER_PORT != (SERVER_PROTOCOL == 'https' ? 443 : 80)) {
441         define('SERVER_URL',
442                SERVER_PROTOCOL . '://' . SERVER_NAME . ':' . SERVER_PORT);
443     }
444     else {
445         define('SERVER_URL',
446                SERVER_PROTOCOL . '://' . SERVER_NAME);
447     }
448
449     if (VIRTUAL_PATH != SCRIPT_NAME) {
450         // Apache action handlers are used.
451         define('PATH_INFO_PREFIX', VIRTUAL_PATH . '/');
452     }
453     else
454         define('PATH_INFO_PREFIX', '/');
455
456     define('PHPWIKI_BASE_URL',
457            SERVER_URL . (USE_PATH_INFO ? VIRTUAL_PATH . '/' : SCRIPT_NAME));
458
459     // Detect PrettyWiki setup (not loading index.php directly)
460     // $SCRIPT_FILENAME should be the same as __FILE__ in index.php
461     if (!isset($SCRIPT_FILENAME))
462         $SCRIPT_FILENAME = @$HTTP_SERVER_VARS['SCRIPT_FILENAME'];
463     if (!isset($SCRIPT_FILENAME))
464         $SCRIPT_FILENAME = @$HTTP_ENV_VARS['SCRIPT_FILENAME'];
465     if (!isset($SCRIPT_FILENAME))
466         $SCRIPT_FILENAME = dirname(__FILE__.'/../') . '/index.php';
467     if (isWindows())
468         $SCRIPT_FILENAME = strtr($SCRIPT_FILENAME,'/','\\');
469     define('SCRIPT_FILENAME',$SCRIPT_FILENAME);
470
471     //////////////////////////////////////////////////////////////////
472     // Select database
473     //
474     if (empty($DBParams['dbtype']))
475         $DBParams['dbtype'] = 'dba';
476
477     if (!defined('THEME'))
478         define('THEME', 'default');
479
480     if (!defined('WIKI_NAME'))
481         define('WIKI_NAME', _("An unnamed PhpWiki"));
482
483     if (!defined('HOME_PAGE'))
484         define('HOME_PAGE', _("HomePage"));
485
486     // FIXME: delete
487     // Access log
488     if (!defined('ACCESS_LOG'))
489         define('ACCESS_LOG', '');
490
491     // FIXME: delete
492     // Get remote host name, if apache hasn't done it for us
493     if (empty($HTTP_SERVER_VARS['REMOTE_HOST']) && ENABLE_REVERSE_DNS)
494         $HTTP_SERVER_VARS['REMOTE_HOST'] = gethostbyaddr($HTTP_SERVER_VARS['REMOTE_ADDR']);
495
496     // check whether the crypt() function is needed and present
497     if (defined('ENCRYPTED_PASSWD') && !function_exists('crypt')) {
498         $error = sprintf(_("Encrypted passwords cannot be used: %s."),
499                          "'function crypt()' not available in this version of php");
500         trigger_error($error);
501     }
502
503     if (!defined('ADMIN_PASSWD') or ADMIN_PASSWD == '')
504         trigger_error(_("The admin password cannot be empty. Please update your /index.php"));
505
506     if (defined('USE_DB_SESSION') and USE_DB_SESSION) {
507         if (! $DBParams['db_session_table'] ) {
508             trigger_error(_("Empty db_session_table. Turn USE_DB_SESSION off or define the table name."), 
509                           E_USER_ERROR);
510             // this is flawed. constants cannot be changed.
511             define('USE_DB_SESSION',false);
512             $DBParams['db_session_table'] = @$DBParams['prefix'] . 'session';
513         }
514     } else {
515         // default: true (since v1.3.8)
516         if (!defined('USE_DB_SESSION'))
517             define('USE_DB_SESSION',true);
518     }
519     // legacy:
520     if (!defined('ENABLE_USER_NEW')) define('ENABLE_USER_NEW',true);
521     if (!defined('ALLOW_USER_LOGIN'))
522         define('ALLOW_USER_LOGIN', defined('ALLOW_USER_PASSWORDS') && ALLOW_USER_PASSWORDS);
523     if (!defined('ALLOW_ANON_USER')) define('ALLOW_ANON_USER', true); 
524     if (!defined('ALLOW_ANON_EDIT')) define('ALLOW_ANON_EDIT', false); 
525     if (!defined('REQUIRE_SIGNIN_BEFORE_EDIT')) define('REQUIRE_SIGNIN_BEFORE_EDIT', ! ALLOW_ANON_EDIT);
526     if (!defined('ALLOW_BOGO_LOGIN')) define('ALLOW_BOGO_LOGIN', true);
527
528     if (ALLOW_USER_LOGIN and !empty($DBAuthParams) and empty($DBAuthParams['auth_dsn'])) {
529         if (isset($DBParams['dsn']))
530             $DBAuthParams['auth_dsn'] = $DBParams['dsn'];
531     }
532 }
533
534 // $Log: not supported by cvs2svn $
535 // Revision 1.21  2004/05/08 22:55:12  rurban
536 // Fixed longstanding sf.net:demo problem. endless loop, caused by an empty definition of
537 // WIKI_NAME_REGEXP. Exactly this constant wasn't checked for its default setting.
538 //
539 // Revision 1.20  2004/05/08 20:21:00  rurban
540 // remove php tags in Log
541 //
542 // Revision 1.19  2004/05/08 19:55:29  rurban
543 // support <span>inlined plugin-result</span>:
544 //   if the plugin is parsed inside a line, use <span> instead of
545 //   <div tightenable top bottom>
546 //   e.g. for "This is the current Phpwiki <plugin SystemInfo version> version.
547 //
548 // Revision 1.18  2004/05/08 16:58:19  rurban
549 // don't ignore some false config values (e.g. USE_PATH_INFO false was ignored)
550 //
551 // Revision 1.17  2004/05/06 19:26:15  rurban
552 // improve stability, trying to find the InlineParser endless loop on sf.net
553 //
554 // remove end-of-zip comments to fix sf.net bug #777278 and probably #859628
555 //
556 // Revision 1.16  2004/05/02 15:10:05  rurban
557 // new finally reliable way to detect if /index.php is called directly
558 //   and if to include lib/main.php
559 // new global AllActionPages
560 // SetupWiki now loads all mandatory pages: HOME_PAGE, action pages, and warns if not.
561 // WikiTranslation what=buttons for Carsten to create the missing MacOSX buttons
562 // PageGroupTestOne => subpages
563 // renamed PhpWikiRss to PhpWikiRecentChanges
564 // more docs, default configs, ...
565 //
566 // Revision 1.15  2004/05/01 15:59:29  rurban
567 // more php-4.0.6 compatibility: superglobals
568 //
569 // Revision 1.14  2004/04/29 23:25:12  rurban
570 // re-ordered locale init (as in 1.3.9)
571 // fixed loadfile with subpages, and merge/restore anyway
572 //   (sf.net bug #844188)
573 //
574 // Revision 1.13  2004/04/29 21:54:05  rurban
575 // typo
576 //
577 // Revision 1.12  2004/04/27 16:16:27  rurban
578 // more subtle config problems with defaults
579 //
580 // Revision 1.11  2004/04/26 20:44:34  rurban
581 // locking table specific for better databases
582 //
583 // Revision 1.10  2004/04/26 13:22:32  rurban
584 // calculate bool old or dynamic constants later
585 //
586 // Revision 1.9  2004/04/26 12:15:01  rurban
587 // check default config values
588 //
589 // Revision 1.8  2004/04/23 16:55:59  zorloc
590 // If using Db auth and DBAUTH_AUTH_DSN is empty set DBAUTH_AUTH_DSN to $DBParams['dsn']
591 //
592 // Revision 1.7  2004/04/20 22:26:27  zorloc
593 // Removed Pear_Config for parse_ini_file().
594 //
595 // Revision 1.6  2004/04/20 18:10:27  rurban
596 // config refactoring:
597 //   FileFinder is needed for WikiFarm scripts calling index.php
598 //   config run-time calls moved to lib/IniConfig.php:fix_configs()
599 //   added PHPWIKI_DIR smart-detection code (Theme finder)
600 //   moved FileFind to lib/FileFinder.php
601 //   cleaned lib/config.php
602 //
603 // Revision 1.5  2004/04/20 17:21:57  rurban
604 // WikiFarm code: honor predefined constants
605 //
606 // Revision 1.4  2004/04/20 17:08:19  rurban
607 // Some IniConfig fixes: prepend our private lib/pear dir
608 //   switch from " to ' in the auth statements
609 //   use error handling.
610 // WikiUserNew changes for the new "'$variable'" syntax
611 //   in the statements
612 // TODO: optimization to put config vars into the session.
613 //
614
615 // (c-file-style: "gnu")
616 // Local Variables:
617 // mode: php
618 // tab-width: 8
619 // c-basic-offset: 4
620 // c-hanging-comment-ender-p: nil
621 // indent-tabs-mode: nil
622 // End:   
623 ?>