]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/config.php
log
[SourceForge/phpwiki.git] / lib / config.php
1 <?php
2 rcs_id('$Id: config.php,v 1.30 2001-02-12 01:43:10 dairiki Exp $');
3 /*
4  * NOTE: the settings here should probably not need to be changed.
5  *
6  *
7  * (The user-configurable settings have been moved to index.php.)
8  */
9
10 // essential internal stuff
11
12 set_magic_quotes_runtime(0);
13
14 // Some constants.
15
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";
20
21
22 // constants for flags in $pagehash
23 define("FLAG_PAGE_LOCKED", 1);
24
25 //////////////////////////////////////////////////////////////////
26 //
27 // Set up localization
28 //
29 if (!function_exists ('gettext'))
30 {
31    $locale = array();
32
33    function gettext ($text) { 
34       global $locale;
35       if (!empty ($locale[$text]))
36          return $locale[$text];
37       return $text;
38    }
39
40    if ( ($lcfile = SearchPath("LC_MESSAGES/phpwiki.php", 'missing_ok')) )
41    {
42       include($lcfile);
43    }
44 }
45 else
46 {
47    putenv ("LANG=$LANG");
48    bindtextdomain ("phpwiki", "./locale");
49    textdomain ("phpwiki");
50 }
51
52 //////////////////////////////////////////////////////////////////
53 // Autodetect URL settings:
54 //
55 if (!defined('SERVER_NAME')) define('SERVER_NAME', $SERVER_NAME);
56 if (!defined('SERVER_PORT')) define('SERVER_PORT', $SERVER_PORT);
57 if (!defined('SCRIPT_NAME')) define('SCRIPT_NAME', $SCRIPT_NAME);
58 if (!defined('DATA_PATH'))
59    define('DATA_PATH', dirname(SCRIPT_NAME));
60 if (!defined('USE_PATH_INFO'))
61 {
62    /*
63     * If SCRIPT_NAME does not look like php source file,
64     * or user cgi we assume that php is getting run by an
65     * action handler in /cgi-bin.  In this case,
66     * I think there is no way to get Apache to pass
67     * useful PATH_INFO to the php script (PATH_INFO
68     * is used to the the php interpreter where the
69     * php script is...)
70     */
71    define('USE_PATH_INFO', ereg('\.(php3?|cgi)$', $SCRIPT_NAME));
72 }
73 if (!defined('VIRTUAL_PATH'))
74 {
75    if (USE_PATH_INFO and isset($REDIRECT_URL))
76    {
77       // FIXME: This is a hack, and won't work if the requested
78       // pagename has a slash in it.
79       define('VIRTUAL_PATH', dirname($REDIRECT_URL . 'x'));
80    }
81    else
82       define('VIRTUAL_PATH', SCRIPT_NAME);
83 }
84
85 if (SERVER_PORT && SERVER_PORT != 80)
86    define('SERVER_URL',
87           "http://" . SERVER_NAME . ':' . SERVER_PORT);
88 else
89    define('SERVER_URL',
90           "http://" . SERVER_NAME);
91
92 if (VIRTUAL_PATH != SCRIPT_NAME)
93 {
94    // Apache action handlers are used.
95    define('PATH_INFO_PREFIX', VIRTUAL_PATH . "/");
96 }
97 else
98    define("PATH_INFO_PREFIX", '/');
99
100
101 //////////////////////////////////////////////////////////////////
102 // Select database
103 //
104 if (!defined('DBTYPE'))
105 {
106    if ( floor(phpversion()) == 3) {
107       define('DBTYPE', 'dbm');
108    } else {
109       define('DBTYPE', 'dba');
110    }
111 }
112
113 switch (DBTYPE) 
114 {
115    case 'dbm':
116       include 'lib/dbmlib.php';
117       break;
118    case 'dba':
119       include 'lib/dbalib.php';
120       break;
121    case 'mysql':
122       include 'lib/mysql.php';
123       break;
124    case 'pgsql':
125       include 'lib/pgsql.php';
126       break;
127    case 'msql':
128       include 'lib/msql.php';
129       break;
130    case 'file':
131       include "lib/db_filesystem.php";
132       break;
133    default:
134       die(DBTYPE . ": unknown DBTYPE");
135 }
136
137 // InterWiki linking -- wiki-style links to other wikis on the web
138 //
139 if (defined('INTERWIKI_MAP_FILE'))
140 {
141    include ('lib/interwiki.php');
142 }
143
144 // For emacs users
145 // Local Variables:
146 // mode: php
147 // c-file-style: "ellemtel"
148 // End:   
149 ?>