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