]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/IniConfig.php
Catch fatals on the four dump calls (as file and zip, as html and mimified)
[SourceForge/phpwiki.git] / lib / IniConfig.php
1 <?php
2 rcs_id('$Id: IniConfig.php,v 1.34 2004-06-13 13:54:25 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          'GOOGLE_LICENSE_KEY','FORTUNE_DIR'
77          );
78
79     // List of all valid config options to be define()d which take booleans.
80     $_IC_VALID_BOOL = array
81         ('ENABLE_USER_NEW', 'ENABLE_PAGEPERM', 'ENABLE_EDIT_TOOLBAR', 'JS_SEARCHREPLACE',
82          'USE_TAGLINES',
83          'ENABLE_REVERSE_DNS', 'ENCRYPTED_PASSWD', 'ZIPDUMP_AUTH', 
84          'ENABLE_RAW_HTML', 'STRICT_MAILABLE_PAGEDUMPS', 'COMPRESS_OUTPUT',
85          'WIKIDB_NOCACHE_MARKUP', 'ALLOW_ANON_USER', 'ALLOW_ANON_EDIT',
86          'ALLOW_BOGO_LOGIN', 'ALLOW_USER_PASSWORDS',
87          'AUTH_USER_FILE_STORABLE', 'ALLOW_HTTP_AUTH_LOGIN',
88          'ALLOW_USER_LOGIN', 'ALLOW_LDAP_LOGIN', 'ALLOW_IMAP_LOGIN',
89          'WARN_NONPUBLIC_INTERWIKIMAP', 'USE_PATH_INFO',
90          'DISABLE_HTTP_REDIRECT');
91
92     if(!file_exists($file)){
93         trigger_error("Datasource file '$file' does not exist", E_USER_ERROR);
94         exit();
95     }
96          
97     $rs = @parse_ini_file($file);
98     $rsdef = @parse_ini_file(dirname(__FILE__)."/../config/config-default.ini");
99     foreach ($rsdef as $k => $v) {
100         if (defined($k))
101             $rs[$k] = constant($k);
102         elseif (!isset($rs[$k]))
103             $rs[$k] = $v;
104     }
105
106     foreach ($_IC_VALID_VALUE as $item) {
107         if (defined($item)) continue;
108         if (array_key_exists($item, $rs)) {
109             define($item, $rs[$item]);
110         //} elseif (array_key_exists($item, $rsdef)) {
111         //    define($item, $rsdef[$item]);
112         // calculate them later or not at all:
113         } elseif (in_array($item,array('DATABASE_PREFIX', 'SERVER_NAME', 'SERVER_PORT',
114                                        'SCRIPT_NAME', 'DATA_PATH', 'PHPWIKI_DIR', 'VIRTUAL_PATH',
115                                        'LDAP_AUTH_HOST','IMAP_AUTH_HOST','POP3_AUTH_HOST'))) 
116         {
117             ;
118         } else {
119             trigger_error(sprintf("missing config setting for %s",$item));
120         }
121     }
122
123     // Boolean options are slightly special - if they're set to any of
124     // '', 'false', '0', or 'no' (all case-insensitive) then the value will
125     // be a boolean false, otherwise if there is anything set it'll
126     // be true.
127     foreach ($_IC_VALID_BOOL as $item) {
128         if (defined($item)) continue;
129         if (array_key_exists($item, $rs)) {
130             $val = $rs[$item];
131         //} elseif (array_key_exists($item, $rsdef)) {
132         //    $val = $rsdef[$item];
133         } else {
134             $val = false; //trigger_error(sprintf("missing boolean config setting for %s",$item));
135         }
136         
137         // calculate them later: old or dynamic constants
138         if (!array_key_exists($item, $rs) and
139             in_array($item,array('USE_PATH_INFO','USE_DB_SESSION',
140                                  'ALLOW_HTTP_AUTH_LOGIN','ALLOW_LDAP_LOGIN',
141                                  'ALLOW_IMAP_LOGIN','ALLOW_USER_LOGIN',
142                                  'REQUIRE_SIGNIN_BEFORE_EDIT',
143                                  'WIKIDB_NOCACHE_MARKUP')))
144         {
145             ;
146         }
147         elseif (!$val) {
148             define($item, false);
149         }
150         elseif (strtolower($val) == 'false' ||
151                 strtolower($val) == 'no' ||
152                 $val == '' ||
153                 $val == false ||
154                 $val == '0') {
155             define($item, false);
156         }
157         else {
158             define($item, true);
159         }
160     }
161
162     // Special handling for some config options
163     if (!empty($rs['INCLUDE_PATH'])) {
164         ini_set('include_path', $rs['INCLUDE_PATH']);
165     }
166     if (!empty($rs['SESSION_SAVE_PATH'])) {
167         ini_set('session.save_path', $rs['SESSION_SAVE_PATH']);
168     }
169
170     // Database
171     global $DBParams;
172     $DBParams['dbtype'] = @$rs['DATABASE_TYPE'];
173     if (isset($rs['DATABASE_DSN']))
174         $DBParams['dsn'] = $rs['DATABASE_DSN'];
175     if (isset($rs['DATABASE_PREFIX']))
176         $DBParams['prefix'] = $rs['DATABASE_PREFIX'];
177     $DBParams['db_session_table'] = @$rs['DATABASE_SESSION_TABLE'];
178     $DBParams['dba_handler'] = @$rs['DATABASE_DBA_HANDLER'];
179     $DBParams['directory'] = @$rs['DATABASE_DIRECTORY'];
180     $DBParams['timeout'] = @$rs['DATABASE_TIMEOUT'];
181     if (!defined('USE_DB_SESSION') and $DBParams['db_session_table'] and 
182         in_array($DBParams['dbtype'],array('SQL','ADODB'/*,'dba'*/))) {
183         define('USE_DB_SESSION', true);
184     }
185
186     // Expiry stuff
187     global $ExpireParams;
188     $ExpireParams['major'] = array(
189                                    'max_age'  => @$rs['MAJOR_MAX_AGE'],
190                                    'min_age'  => @$rs['MAJOR_MIN_AGE'],
191                                    'min_keep' => @$rs['MAJOR_MIN_KEEP'],
192                                    'keep'     => @$rs['MAJOR_KEEP'],
193                                    'max_keep' => @$rs['MAJOR_MAX_KEEP']
194                                    );
195     $ExpireParams['minor'] = array(
196                                    'max_age'  => @$rs['MINOR_MAX_AGE'],
197                                    'min_age'  => @$rs['MINOR_MIN_AGE'],
198                                    'min_keep' => @$rs['MINOR_MIN_KEEP'],
199                                    'keep'     => @$rs['MINOR_KEEP'],
200                                    'max_keep' => @$rs['MINOR_MAX_KEEP']
201                                    );
202     $ExpireParams['author'] = array(
203                                     'max_age'  => @$rs['AUTHOR_MAX_AGE'],
204                                     'min_age'  => @$rs['AUTHOR_MIN_AGE'],
205                                     'min_keep' => @$rs['AUTHOR_MIN_KEEP'],
206                                     'keep'     => @$rs['AUTHOR_KEEP'],
207                                     'max_keep' => @$rs['AUTHOR_MAX_KEEP']
208                                     );
209
210     // User authentication
211     if (!isset($GLOBALS['USER_AUTH_ORDER']))
212         if (isset($rs['USER_AUTH_ORDER']))
213             $GLOBALS['USER_AUTH_ORDER'] = preg_split('/\s*:\s*/', $rs['USER_AUTH_ORDER']);
214         else 
215             $GLOBALS['USER_AUTH_ORDER'] = array("PersonalPage");
216
217     // LDAP bind options
218     global $LDAP_SET_OPTION;
219     if (isset($rs['LDAP_SET_OPTION'])) {
220         $optlist = preg_split('/\s*:\s*/', @$rs['LDAP_SET_OPTION']);
221         foreach ($optlist as $opt) {
222             $bits = preg_split('/\s*=\s*/', $opt, 2);
223             if (count($bits) == 2) {
224                 $LDAP_SET_OPTION[$bits[0]] = $bits[1];
225             }
226             else {
227                 // Possibly throw some sort of error?
228             }
229         }
230     }
231
232     // Now it's the external DB authentication stuff's turn
233     if (in_array('Db', $GLOBALS['USER_AUTH_ORDER']) && empty($rs['DBAUTH_AUTH_DSN'])) {
234         $rs['DBAUTH_AUTH_DSN'] = $DBParams['dsn'];
235     }
236     
237     global $DBAuthParams;
238     $DBAP_MAP = array('DBAUTH_AUTH_DSN' => 'auth_dsn',
239                       'DBAUTH_AUTH_CHECK' => 'auth_check',
240                       'DBAUTH_AUTH_USER_EXISTS' => 'auth_user_exists',
241                       'DBAUTH_AUTH_CRYPT_METHOD' => 'auth_crypt_method',
242                       'DBAUTH_AUTH_UPDATE' => 'auth_update',
243                       'DBAUTH_AUTH_CREATE' => 'auth_create',
244                       'DBAUTH_PREF_SELECT' => 'pref_select',
245                       'DBAUTH_PREF_UPDATE' => 'pref_update',
246                       'DBAUTH_IS_MEMBER' => 'is_member',
247                       'DBAUTH_GROUP_MEMBERS' => 'group_members',
248                       'DBAUTH_USER_GROUPS' => 'user_groups'
249                       );
250     foreach ($DBAP_MAP as $rskey => $apkey) {
251         if (isset($rs[$rskey])) {
252             $DBAuthParams[$apkey] = $rs[$rskey];
253         } elseif (isset($rsdef[$rskey])) {
254             $DBAuthParams[$apkey] = $rsdef[$rskey];
255         }
256     }
257
258     // Default Wiki pages to force loading from pgsrc
259     global $GenericPages;
260     $GenericPages = preg_split('/\s*:\s*/', @$rs['DEFAULT_WIKI_PAGES']);
261
262     // Wiki name regexp:  Should be a define(), but might needed to be changed at runtime
263     // (different LC_CHAR need different posix classes)
264     global $WikiNameRegexp;
265     $WikiNameRegexp = constant('WIKI_NAME_REGEXP');
266     if (!trim($WikiNameRegexp))
267        $WikiNameRegexp = '(?<![[:alnum:]])(?:[[:upper:]][[:lower:]]+){2,}(?![[:alnum:]])';
268
269     // Another "too-tricky" redefine
270     global $KeywordLinkRegexp;
271     if (!isset($rs['KEYWORDS'])) $rs['KEYWORDS'] = "Category:Topic";
272     $keywords = preg_split('/\s*:\s*/', $rs['KEYWORDS']);
273     if (empty($keywords)) $keywords = array("Category","Topic");
274     $KeywordLinkRegexp = '(?<=' . implode('|^', $keywords) . ')[[:upper:]].*$';
275         
276     global $DisabledActions;
277     $DisabledActions = preg_split('/\s*:\s*/', @$rs['DISABLED_ACTIONS']);
278     
279     /*global $AllowedProtocols, $InlineImages;
280     $AllowedProtocols = constant("ALLOWED_PROTOCOLS");
281     $InlineImages = constant("INLINE_IMAGES");*/
282
283     fix_configs();
284 }
285
286 // moved from lib/config.php
287 function fix_configs() {
288     global $FieldSeparator, $charset, $WikiNameRegexp, $KeywordLinkRegexp, $AllActionPages;
289     global $DisabledActions, $HTTP_SERVER_VARS, $DBParams, $LANG;
290
291     // init FileFinder to add proper include paths
292     require_once(dirname(__FILE__)."/FileFinder.php");
293     FindFile("lib/interwiki.map",true);
294     
295     // "\x80"-"\x9f" (and "\x00" - "\x1f") are non-printing control
296     // chars in iso-8859-*
297     // $FieldSeparator = "\263"; // this is a superscript 3 in ISO-8859-1.
298     // $FieldSeparator = "\xFF"; // this byte should never appear in utf-8
299     // FIXME: get rid of constant. pref is dynamic and language specific
300     $charset = CHARSET;
301     if (isset($LANG) and in_array($LANG,array('ja','zh')))
302         $charset = 'utf-8';
303     if (strtolower($charset) == 'utf-8')
304         $FieldSeparator = "\xFF";
305     else
306         $FieldSeparator = "\x81";
307
308     if (!defined('DEFAULT_LANGUAGE'))
309         define('DEFAULT_LANGUAGE', 'en');
310     update_locale(isset($LANG) ? $LANG : DEFAULT_LANGUAGE);
311
312     // Set up (possibly fake) gettext()
313     //
314     if (!function_exists ('bindtextdomain')) {
315         $locale = array();
316
317         function gettext ($text) { 
318             global $locale;
319             if (!empty ($locale[$text]))
320                 return $locale[$text];
321             return $text;
322         }
323
324         function _ ($text) {
325             return gettext($text);
326         }
327     }
328     else {
329         // Working around really weird gettext problems: (4.3.2, 4.3.6 win)
330         // bindtextdomain() returns the current domain path.
331         // 1. If the script is not index.php but something like "de", on a different path
332         //    then bindtextdomain() fails, but after chdir to the correct path it will work okay.
333         // 2. But the weird error "Undefined variable: bindtextdomain" is generated then.
334         $bindtextdomain_path = FindFile("locale", false, true);
335         if (isWindows())
336             $bindtextdomain_path = str_replace("/","\\",$bindtextdomain_path);
337         $bindtextdomain_real = @bindtextdomain("phpwiki", $bindtextdomain);
338         if ($bindtextdomain_real != $bindtextdomain_path) {
339             // this will happen with virtual_paths. chdir and try again.
340             chdir($bindtextdomain_path);
341             $bindtextdomain_real = @bindtextdomain("phpwiki", $bindtextdomain);
342         }
343         textdomain("phpwiki");
344         if ($bindtextdomain_real != $bindtextdomain_path) { // change back
345             chdir($bindtextdomain_real . (isWindows() ? "\\.." : "/.."));
346         }
347     }
348
349     $WikiNameRegexp = pcre_fix_posix_classes($WikiNameRegexp);
350     $KeywordLinkRegexp = pcre_fix_posix_classes($KeywordLinkRegexp);
351
352     $AllActionPages = explode(':','AllPages:BackLinks:DebugInfo:EditMetaData:FindPage:FullRecentChanges:'
353                               .'FullTextSearch:FuzzyPages:InterWikiSearch:LikePages:MostPopular:'
354                               .'OrphanedPages:PageDump:PageHistory:PageInfo:RandomPage:RateIt:'
355                               .'RecentChanges:RecentEdits:RelatedChanges:TitleSearch:TranslateText:'
356                               .'UpLoad:UserPreferences:WantedPages:WhoIsOnline:'
357                               .'PhpWikiAdministration/Remove:'
358                               .'PhpWikiAdministration/Rename:PhpWikiAdministration/Replace:'
359                               .'PhpWikiAdministration/SetAcl:PhpWikiAdministration/Chown'
360                               );
361
362     //////////////////////////////////////////////////////////////////
363     // Autodetect URL settings:
364     //
365     if (!defined('SERVER_NAME')) define('SERVER_NAME', $HTTP_SERVER_VARS['SERVER_NAME']);
366     if (!defined('SERVER_PORT')) define('SERVER_PORT', $HTTP_SERVER_VARS['SERVER_PORT']);
367     if (!defined('SERVER_PROTOCOL')) {
368         if (empty($HTTP_SERVER_VARS['HTTPS']) || $HTTP_SERVER_VARS['HTTPS'] == 'off')
369             define('SERVER_PROTOCOL', 'http');
370         else
371             define('SERVER_PROTOCOL', 'https');
372     }
373
374     if (!defined('SCRIPT_NAME'))
375         define('SCRIPT_NAME', deduce_script_name());
376
377     if (!defined('USE_PATH_INFO')) {
378         if (isCGI())
379             define('USE_PATH_INFO', false);
380         else {
381             /*
382              * If SCRIPT_NAME does not look like php source file,
383              * or user cgi we assume that php is getting run by an
384              * action handler in /cgi-bin.  In this case,
385              * I think there is no way to get Apache to pass
386              * useful PATH_INFO to the php script (PATH_INFO
387              * is used to the the php interpreter where the
388              * php script is...)
389              */
390             switch (php_sapi_name()) {
391             case 'apache':
392             case 'apache2handler':
393                 define('USE_PATH_INFO', true);
394                 break;
395             case 'cgi':
396             case 'apache2filter':
397                 define('USE_PATH_INFO', false);
398                 break;
399             default:
400                 define('USE_PATH_INFO', ereg('\.(php3?|cgi)$', SCRIPT_NAME));
401                 break;
402             }
403         }
404     }
405      
406     // If user has not defined PHPWIKI_DIR, and we need it
407     if (!defined('PHPWIKI_DIR') and !file_exists("themes/default")) {
408         $themes_dir = FindFile("themes");
409         define('PHPWIKI_DIR', dirname($themes_dir));
410     }
411         
412     if (!defined('VIRTUAL_PATH')) {
413         // We'd like to auto-detect when the cases where apaches
414         // 'Action' directive (or similar means) is used to
415         // redirect page requests to a cgi-handler.
416         //
417         // In cases like this, requests for e.g. /wiki/HomePage
418         // get redirected to a cgi-script called, say,
419         // /path/to/wiki/index.php.  The script gets all
420         // of /wiki/HomePage as it's PATH_INFO.
421         //
422         // The problem is:
423         //   How to detect when this has happened reliably?
424         //   How to pick out the "virtual path" (in this case '/wiki')?
425         //
426         // (Another time an redirect might occur is to a DirectoryIndex
427         // -- the requested URI is '/wikidir/', the request gets
428         // passed to '/wikidir/index.php'.  In this case, the
429         // proper VIRTUAL_PATH is '/wikidir/index.php', since the
430         // pages will appear at e.g. '/wikidir/index.php/HomePage'.
431         //
432
433         $REDIRECT_URL = &$HTTP_SERVER_VARS['REDIRECT_URL'];
434         if (USE_PATH_INFO and isset($REDIRECT_URL)
435             and ! IsProbablyRedirectToIndex()) {
436             // FIXME: This is a hack, and won't work if the requested
437             // pagename has a slash in it.
438             $temp = strtr(dirname($REDIRECT_URL . 'x'),"\\",'/');
439             if ( ($temp == '/') || ($temp == '\\') )
440                 $temp = '';
441             define('VIRTUAL_PATH', $temp);
442         } else {
443             define('VIRTUAL_PATH', SCRIPT_NAME);
444         }
445     }
446
447     // If user has not defined DATA_PATH, we want to use relative URLs.
448     if (!defined('DATA_PATH')) {
449         // fix similar to the one suggested by jkalmbach for 
450         // installations in the webrootdir, like "http://phpwiki.org/HomePage"
451         $temp = dirname(SCRIPT_NAME);
452         if ( ($temp == '/') || ($temp == '\\') )
453             $temp = '';
454         define('DATA_PATH', $temp);
455         /*
456         if (USE_PATH_INFO)
457             define('DATA_PATH', '..');
458         */
459     }
460
461     if (SERVER_PORT
462         && SERVER_PORT != (SERVER_PROTOCOL == 'https' ? 443 : 80)) {
463         define('SERVER_URL',
464                SERVER_PROTOCOL . '://' . SERVER_NAME . ':' . SERVER_PORT);
465     }
466     else {
467         define('SERVER_URL',
468                SERVER_PROTOCOL . '://' . SERVER_NAME);
469     }
470
471     if (VIRTUAL_PATH != SCRIPT_NAME) {
472         // Apache action handlers are used.
473         define('PATH_INFO_PREFIX', VIRTUAL_PATH . '/');
474     }
475     else
476         define('PATH_INFO_PREFIX', '/');
477
478     define('PHPWIKI_BASE_URL',
479            SERVER_URL . (USE_PATH_INFO ? VIRTUAL_PATH . '/' : SCRIPT_NAME));
480
481     // Detect PrettyWiki setup (not loading index.php directly)
482     // $SCRIPT_FILENAME should be the same as __FILE__ in index.php
483     if (!isset($SCRIPT_FILENAME))
484         $SCRIPT_FILENAME = @$HTTP_SERVER_VARS['SCRIPT_FILENAME'];
485     if (!isset($SCRIPT_FILENAME))
486         $SCRIPT_FILENAME = @$HTTP_ENV_VARS['SCRIPT_FILENAME'];
487     if (!isset($SCRIPT_FILENAME))
488         $SCRIPT_FILENAME = dirname(__FILE__.'/../') . '/index.php';
489     if (isWindows())
490         $SCRIPT_FILENAME = strtr($SCRIPT_FILENAME,'/','\\');
491     define('SCRIPT_FILENAME',$SCRIPT_FILENAME);
492
493     //////////////////////////////////////////////////////////////////
494     // Select database
495     //
496     if (empty($DBParams['dbtype']))
497         $DBParams['dbtype'] = 'dba';
498
499     if (!defined('THEME'))
500         define('THEME', 'default');
501
502     if (!defined('WIKI_NAME'))
503         define('WIKI_NAME', _("An unnamed PhpWiki"));
504
505     if (!defined('HOME_PAGE'))
506         define('HOME_PAGE', _("HomePage"));
507
508     // FIXME: delete
509     // Access log
510     if (!defined('ACCESS_LOG'))
511         define('ACCESS_LOG', '');
512
513     // FIXME: delete
514     // Get remote host name, if apache hasn't done it for us
515     if (empty($HTTP_SERVER_VARS['REMOTE_HOST']) && ENABLE_REVERSE_DNS)
516         $HTTP_SERVER_VARS['REMOTE_HOST'] = gethostbyaddr($HTTP_SERVER_VARS['REMOTE_ADDR']);
517
518     // check whether the crypt() function is needed and present
519     if (defined('ENCRYPTED_PASSWD') && !function_exists('crypt')) {
520         $error = sprintf(_("Encrypted passwords cannot be used: %s."),
521                          "'function crypt()' not available in this version of php");
522         trigger_error($error);
523     }
524
525     if (!defined('ADMIN_PASSWD') or ADMIN_PASSWD == '')
526         trigger_error(_("The admin password cannot be empty. Please update your config/config.ini"));
527
528     if (defined('USE_DB_SESSION') and USE_DB_SESSION) {
529         if (! $DBParams['db_session_table'] ) {
530             trigger_error(_("Empty db_session_table. Turn USE_DB_SESSION off or define the table name."), 
531                           E_USER_ERROR);
532             // this is flawed. constants cannot be changed.
533             define('USE_DB_SESSION',false);
534             $DBParams['db_session_table'] = @$DBParams['prefix'] . 'session';
535         }
536     } else {
537         // default: true (since v1.3.8)
538         if (!defined('USE_DB_SESSION'))
539             define('USE_DB_SESSION',true);
540     }
541     // legacy:
542     if (!defined('ENABLE_USER_NEW')) define('ENABLE_USER_NEW',true);
543     if (!defined('ALLOW_USER_LOGIN'))
544         define('ALLOW_USER_LOGIN', defined('ALLOW_USER_PASSWORDS') && ALLOW_USER_PASSWORDS);
545     if (!defined('ALLOW_ANON_USER')) define('ALLOW_ANON_USER', true); 
546     if (!defined('ALLOW_ANON_EDIT')) define('ALLOW_ANON_EDIT', false); 
547     if (!defined('REQUIRE_SIGNIN_BEFORE_EDIT')) define('REQUIRE_SIGNIN_BEFORE_EDIT', ! ALLOW_ANON_EDIT);
548     if (!defined('ALLOW_BOGO_LOGIN')) define('ALLOW_BOGO_LOGIN', true);
549     if (!defined('ALLOW_LDAP_LOGIN')) define('ALLOW_LDAP_LOGIN', defined('LDAP_AUTH_HOST'));
550     if (!defined('ALLOW_IMAP_LOGIN')) define('ALLOW_IMAP_LOGIN', defined('IMAP_AUTH_HOST'));
551
552     if (ALLOW_USER_LOGIN and !empty($DBAuthParams) and empty($DBAuthParams['auth_dsn'])) {
553         if (isset($DBParams['dsn']))
554             $DBAuthParams['auth_dsn'] = $DBParams['dsn'];
555     }
556 }
557
558 // $Log: not supported by cvs2svn $
559 // Revision 1.33  2004/06/08 19:48:16  rurban
560 // fixed foreign setup: no ugly skipped msg for the GenericPages, load english actionpages if translated not found
561 //
562 // Revision 1.32  2004/06/08 10:54:46  rurban
563 // better acl dump representation, read back acl and owner
564 //
565 // Revision 1.31  2004/06/06 16:58:51  rurban
566 // added more required ActionPages for foreign languages
567 // install now english ActionPages if no localized are found. (again)
568 // fixed default anon user level to be 0, instead of -1
569 //   (wrong "required administrator to view this page"...)
570 //
571 // Revision 1.30  2004/06/04 12:40:21  rurban
572 // Restrict valid usernames to prevent from attacks against external auth or compromise
573 // possible holes.
574 // Fix various WikiUser old issues with default IMAP,LDAP,POP3 configs. Removed these.
575 // Fxied more warnings
576 //
577 // Revision 1.29  2004/06/04 11:58:38  rurban
578 // added USE_TAGLINES
579 //
580 // Revision 1.28  2004/06/03 20:42:49  rurban
581 // fixed bad warning #964850
582 //
583 // Revision 1.27  2004/06/03 10:18:19  rurban
584 // fix FileUser locking issues, new config ENABLE_PAGEPERM
585 //
586 // Revision 1.26  2004/06/02 18:01:45  rurban
587 // init global FileFinder to add proper include paths at startup
588 //   adds PHPWIKI_DIR if started from another dir, lib/pear also
589 // fix slashify for Windows
590 // fix USER_AUTH_POLICY=old, use only USER_AUTH_ORDER methods (besides HttpAuth)
591 //
592 // Revision 1.25  2004/05/27 17:49:05  rurban
593 // renamed DB_Session to DbSession (in CVS also)
594 // added WikiDB->getParam and WikiDB->getAuthParam method to get rid of globals
595 // remove leading slash in error message
596 // added force_unlock parameter to File_Passwd (no return on stale locks)
597 // fixed adodb session AffectedRows
598 // added FileFinder helpers to unify local filenames and DATA_PATH names
599 // editpage.php: new edit toolbar javascript on ENABLE_EDIT_TOOLBAR
600 //
601 // Revision 1.24  2004/05/18 13:33:13  rurban
602 // we already have a CGI function
603 //
604 // Revision 1.23  2004/05/17 17:43:29  rurban
605 // CGI: no PATH_INFO fix
606 //
607 // Revision 1.22  2004/05/16 22:07:35  rurban
608 // check more config-default and predefined constants
609 // various PagePerm fixes:
610 //   fix default PagePerms, esp. edit and view for Bogo and Password users
611 //   implemented Creator and Owner
612 //   BOGOUSERS renamed to BOGOUSER
613 // fixed syntax errors in signin.tmpl
614 //
615 // Revision 1.21  2004/05/08 22:55:12  rurban
616 // Fixed longstanding sf.net:demo problem. endless loop, caused by an empty definition of
617 // WIKI_NAME_REGEXP. Exactly this constant wasn't checked for its default setting.
618 //
619 // Revision 1.20  2004/05/08 20:21:00  rurban
620 // remove php tags in Log
621 //
622 // Revision 1.19  2004/05/08 19:55:29  rurban
623 // support <span>inlined plugin-result</span>:
624 //   if the plugin is parsed inside a line, use <span> instead of
625 //   <div tightenable top bottom>
626 //   e.g. for "This is the current Phpwiki <plugin SystemInfo version> version.
627 //
628 // Revision 1.18  2004/05/08 16:58:19  rurban
629 // don't ignore some false config values (e.g. USE_PATH_INFO false was ignored)
630 //
631 // Revision 1.17  2004/05/06 19:26:15  rurban
632 // improve stability, trying to find the InlineParser endless loop on sf.net
633 //
634 // remove end-of-zip comments to fix sf.net bug #777278 and probably #859628
635 //
636 // Revision 1.16  2004/05/02 15:10:05  rurban
637 // new finally reliable way to detect if /index.php is called directly
638 //   and if to include lib/main.php
639 // new global AllActionPages
640 // SetupWiki now loads all mandatory pages: HOME_PAGE, action pages, and warns if not.
641 // WikiTranslation what=buttons for Carsten to create the missing MacOSX buttons
642 // PageGroupTestOne => subpages
643 // renamed PhpWikiRss to PhpWikiRecentChanges
644 // more docs, default configs, ...
645 //
646 // Revision 1.15  2004/05/01 15:59:29  rurban
647 // more php-4.0.6 compatibility: superglobals
648 //
649 // Revision 1.14  2004/04/29 23:25:12  rurban
650 // re-ordered locale init (as in 1.3.9)
651 // fixed loadfile with subpages, and merge/restore anyway
652 //   (sf.net bug #844188)
653 //
654 // Revision 1.13  2004/04/29 21:54:05  rurban
655 // typo
656 //
657 // Revision 1.12  2004/04/27 16:16:27  rurban
658 // more subtle config problems with defaults
659 //
660 // Revision 1.11  2004/04/26 20:44:34  rurban
661 // locking table specific for better databases
662 //
663 // Revision 1.10  2004/04/26 13:22:32  rurban
664 // calculate bool old or dynamic constants later
665 //
666 // Revision 1.9  2004/04/26 12:15:01  rurban
667 // check default config values
668 //
669 // Revision 1.8  2004/04/23 16:55:59  zorloc
670 // If using Db auth and DBAUTH_AUTH_DSN is empty set DBAUTH_AUTH_DSN to $DBParams['dsn']
671 //
672 // Revision 1.7  2004/04/20 22:26:27  zorloc
673 // Removed Pear_Config for parse_ini_file().
674 //
675 // Revision 1.6  2004/04/20 18:10:27  rurban
676 // config refactoring:
677 //   FileFinder is needed for WikiFarm scripts calling index.php
678 //   config run-time calls moved to lib/IniConfig.php:fix_configs()
679 //   added PHPWIKI_DIR smart-detection code (Theme finder)
680 //   moved FileFind to lib/FileFinder.php
681 //   cleaned lib/config.php
682 //
683 // Revision 1.5  2004/04/20 17:21:57  rurban
684 // WikiFarm code: honor predefined constants
685 //
686 // Revision 1.4  2004/04/20 17:08:19  rurban
687 // Some IniConfig fixes: prepend our private lib/pear dir
688 //   switch from " to ' in the auth statements
689 //   use error handling.
690 // WikiUserNew changes for the new "'$variable'" syntax
691 //   in the statements
692 // TODO: optimization to put config vars into the session.
693 //
694
695 // (c-file-style: "gnu")
696 // Local Variables:
697 // mode: php
698 // tab-width: 8
699 // c-basic-offset: 4
700 // c-hanging-comment-ender-p: nil
701 // indent-tabs-mode: nil
702 // End:   
703 ?>