]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/config.php
2004-11-28 19:19 rurban
[SourceForge/phpwiki.git] / lib / config.php
1 <?php
2
3    // essential internal stuff -- skip it. Go down to Part One. There
4    // are four parts to this file that interest you, all labeled Part
5    // One, Two, Three and Four.
6
7    set_magic_quotes_runtime(0);
8    error_reporting(E_ALL ^ E_NOTICE);
9    if (!ini_get('register_globals')) {
10        extract($HTTP_SERVER_VARS);
11    }
12
13    if (!function_exists('rcs_id')) {
14       function rcs_id($id) { echo "<!-- $id -->\n"; };
15    }
16    rcs_id('$Id: config.php,v 1.24.2.13.2.2 2005-01-07 13:59:58 rurban Exp $'); 
17    // end essential internal stuff
18
19
20    /////////////////////////////////////////////////////////////////////
21    // Part One:
22    // Constants and settings. Edit the values below for your site.
23    /////////////////////////////////////////////////////////////////////
24
25
26    // URL of index.php e.g. http://yoursite.com/phpwiki/index.php
27    // you can leave this empty - it will be calculated automatically
28    $ScriptUrl = "";
29    // URL of admin.php e.g. http://yoursite.com/phpwiki/admin.php
30    // you can leave this empty - it will be calculated automatically
31    // if you fill in $ScriptUrl you *MUST* fill in $AdminUrl as well!
32    $AdminUrl = "";
33
34    // Select your language - default language "C": English
35    // other languages available: Dutch "nl", Spanish "es", German "de",
36    // and Swedish "sv"
37    $LANG="C";
38
39    /////////////////////////////////////////////////////////////////////
40    // Part Two:
41    // Database section
42    // set your database here and edit the according section below.
43    // For PHP 4.0.4 and later you must use "dba" if you are using 
44    // DBM files for storage. "dbm" uses the older deprecated interface.
45    // The option 'default' will choose either dbm or dba, depending on
46    // the version of PHP you are running.
47    /////////////////////////////////////////////////////////////////////
48
49    $WhichDatabase = 'default'; // use one of "dbm", "dba", "mysql",
50                            // "pgsql", "msql", "mssql", or "file"
51
52    // DBM and DBA settings (default)
53    if ($WhichDatabase == 'dbm' or $WhichDatabase == 'dba' or
54        $WhichDatabase == 'default') {
55       $DBMdir = "/tmp";
56       $WikiPageStore = "wiki";
57       $ArchivePageStore = "archive";
58       $WikiDB['wiki']      = "$DBMdir/wikipagesdb";
59       $WikiDB['archive']   = "$DBMdir/wikiarchivedb";
60       $WikiDB['wikilinks'] = "$DBMdir/wikilinksdb";
61       $WikiDB['hottopics'] = "$DBMdir/wikihottopicsdb";
62       $WikiDB['hitcount']  = "$DBMdir/wikihitcountdb";
63
64       // this is the type of DBM file on your system. For most Linuxen
65       // 'gdbm' is fine; 'db2' is another common type. 'ndbm' appears
66       // on Solaris but won't work because it won't store pages larger
67       // than 1000 bytes.
68       define("DBM_FILE_TYPE", 'gdbm');
69
70       // try this many times if the dbm is unavailable
71       define("MAX_DBM_ATTEMPTS", 20);
72
73       // for PHP3 use dbmlib, else use dbalib for PHP4
74       if ($WhichDatabase == 'default') {
75          if ( floor(phpversion()) == 3) {
76             $WhichDatabase = 'dbm';
77          } else {
78             $WhichDatabase = 'dba';
79          }
80       }
81
82       if ($WhichDatabase == 'dbm') {
83           include "lib/dbmlib.php"; 
84       } else {
85           include "lib/dbalib.php";
86       }
87
88    // MySQL settings -- see INSTALL.mysql for details on using MySQL
89    } elseif ($WhichDatabase == 'mysql') {
90       // MySQL server host:
91       $mysql_server = 'localhost';
92
93       // username as used in step 2 of INSTALL.mysql:
94       $mysql_user = 'wikiuser';
95
96       // password of above user (or leave blank if none):
97       $mysql_pwd = '';
98
99       // name of the mysql database
100       //  (this used to default to 'wiki' prior to phpwiki-1.2.2)
101       $mysql_db = 'phpwiki';
102
103       // Names of the tables.
104       // You probably don't need to change these.  If you do change
105       // them you will also have to make corresponding changes in
106       // schemas/schema.mysql before you initialize the database.
107       $WikiPageStore = "wiki";
108       $ArchivePageStore = "archive";
109       $WikiLinksStore = "wikilinks";
110       $WikiScoreStore = "wikiscore";
111       $HitCountStore = "hitcount";
112
113       include "lib/mysql.php";
114
115    // PostgreSQL settings -- see INSTALL.pgsql for more details
116    } elseif ($WhichDatabase == 'pgsql') {
117       $pg_dbhost    = "localhost";
118       $pg_dbport    = "5432";
119       $pg_dbuser    = "";      // username as used in step 2 of INSTALL.mysql
120       $pg_dbpass    = "";      // password of above user (or leave blank if none)       
121       $WikiDataBase  = "wiki"; // name of the database in Postgresql
122       $WikiPageStore = "wiki";
123       $ArchivePageStore = "archive";
124       $WikiLinksPageStore = "wikilinks";
125       $HotTopicsPageStore = "hottopics";
126       $HitCountPageStore = "hitcount";
127       include "lib/pgsql.php";
128
129    // MiniSQL (mSQL) settings -- see INSTALL.msql for details on using mSQL
130    } elseif ($WhichDatabase == 'msql') {
131       $msql_db = "wiki";
132       $WikiPageStore = array();
133       $ArchivePageStore = array();
134       $WikiPageStore['table']         = "wiki";
135       $WikiPageStore['page_table']    = "wikipages";
136       $ArchivePageStore['table']      = "archive";
137       $ArchivePageStore['page_table'] = "archivepages";
138       // should be the same as wikipages.line
139       define("MSQL_MAX_LINE_LENGTH", 128);
140       include "lib/msql.php";
141
142    // Filesystem DB settings
143    } elseif ($WhichDatabase == 'file') {
144       $DBdir = "/tmp/wiki";
145       $WikiPageStore = "wiki";
146       $ArchivePageStore = "archive";
147       $WikiDB['wiki']      = "$DBdir/pages";
148       $WikiDB['archive']   = "$DBdir/archive";
149       $WikiDB['wikilinks'] = "$DBdir/links";
150       $WikiDB['hottopics'] = "$DBdir/hottopics";
151       $WikiDB['hitcount']  = "$DBdir/hitcount";
152       include "lib/db_filesystem.php";
153
154    // MS SQLServer settings
155    } elseif ($WhichDatabase == 'mssql') {
156       $WikiPageStore = "wiki";
157       $ArchivePageStore = "archive";
158       $WikiLinksStore = "wikilinks";
159       $WikiScoreStore = "wikiscore";
160       $HitCountStore = "hitcount";
161       $mssql_server = 'servername';
162       $mssql_user = '';
163       $mssql_pwd = '';
164       $mssql_db = '';
165       include "lib/mssql.php";
166
167    } else die("Invalid '\$WhichDatabase' in lib/config.php"); 
168
169
170    /////////////////////////////////////////////////////////////////////
171    // Part Three:
172    // Miscellaneous
173    /////////////////////////////////////////////////////////////////////
174
175    // logo image (path relative to index.php)
176    $logo = "images/wikibase.png";
177
178    // Signature image which is shown after saving an edited page
179    // If this is left blank (or unset), the signature will be omitted.
180    $SignatureImg = "images/signature.png";
181
182    // date & time formats used to display modification times, etc.
183    // formats are given as format strings to PHP date() function
184    $datetimeformat = "F j, Y";  // may contain time of day
185    $dateformat = "F j, Y";      // must not contain time
186
187    // this defines how many page names to list when displaying
188    // the MostPopular pages; the default is to show the 20 most popular pages
189    define("MOST_POPULAR_LIST_LENGTH", 20);
190
191    // this defines how many page names to list when displaying related pages
192    define("NUM_RELATED_PAGES", 5);
193
194    // number of user-defined external references, i.e. "[1]"
195    define("NUM_LINKS", 12);
196
197    // allowed protocols for links - be careful not to allow "javascript:"
198    // within a named link [name|uri] one more protocol is defined: phpwiki
199    $AllowedProtocols = "http|https|mailto|ftp|news|gopher";
200
201    // URLs ending with the following extension should be inlined as images
202    $InlineImages = "png|jpg|gif";
203
204    // Perl regexp for WikiNames
205    // (?<!..) & (?!...) used instead of '\b' because \b matches '_' as well
206    $WikiNameRegexp = "(?<![A-Za-z0-9])([A-Z][a-z]+){2,}(?![A-Za-z0-9])";
207
208
209
210    /////////////////////////////////////////////////////////////////////
211    // Part Four:
212    // Original pages and layout
213    /////////////////////////////////////////////////////////////////////
214
215    // need to define localization function first -- skip this
216    if (!function_exists ('gettext')) {
217       $lcfile = "locale/$LANG/LC_MESSAGES/phpwiki.php";
218       if (file_exists($lcfile)) { include($lcfile); }
219       else { $locale = array(); }
220
221       function gettext ($text) { 
222          global $locale;
223          if (!empty ($locale[$text]))
224            return $locale[$text];
225          return $text;
226       }
227    } else {
228       // This putenv() fails when safe_mode is on.
229       // I think it is unnecessary. 
230       //putenv ("LANG=$LANG");
231       bindtextdomain ("phpwiki", "./locale");
232       textdomain ("phpwiki");
233       if (!defined("LC_ALL")) {
234          // Backwards compatibility (for PHP < 4.0.5)
235          define("LC_ALL", "LC_ALL");
236       }   
237       setlocale(LC_ALL, "$LANG");
238    }
239    // end of localization function
240
241    // Template files (filenames are relative to script position)
242    $templates = array(
243         "BROWSE" =>    gettext("templates/browse.html"),
244         "EDITPAGE" =>  gettext("templates/editpage.html"),
245         "EDITLINKS" => gettext("templates/editlinks.html"),
246         "MESSAGE" =>   gettext("templates/message.html")
247         );
248
249    /* WIKI_PGSRC -- specifies the source for the initial page contents
250     * of the Wiki.  The setting of WIKI_PGSRC only has effect when
251     * the wiki is accessed for the first time (or after clearing the
252     * database.) WIKI_PGSRC can either name a directory or a zip file.
253     * In either case WIKI_PGSRC is scanned for files --- one file per page.
254     *
255     * If the files appear to be MIME formatted messages, they are
256     * scanned for application/x-phpwiki content-types.  Any suitable
257     * content is added to the wiki.
258     * The files can also be plain text files, in which case the page name
259     * is taken from the file name.
260     */
261
262    define('WIKI_PGSRC', gettext("./pgsrc")); // Default (old) behavior.
263    //define('WIKI_PGSRC', './wiki.zip'); // New style.
264
265    // DEFAULT_WIKI_PGSRC is only used when the language is *not*
266    // the default (English) and when reading from a directory:
267    // in that case some English pages are inserted into the wiki as well
268    // DEFAULT_WIKI_PGSRC defines where the English pages reside 
269    define('DEFAULT_WIKI_PGSRC', "./pgsrc");
270
271
272
273    //////////////////////////////////////////////////////////////////////
274    // you shouldn't have to edit anyting below this line
275    function compute_default_scripturl() {
276       global $HTTP_SERVER_VARS, $SERVER_PORT, $SERVER_NAME, $SCRIPT_NAME, $HTTPS;
277       if (!ini_get('register_globals')) {
278           extract($HTTP_SERVER_VARS);
279       }
280       
281       if (!empty($HTTPS) && $HTTPS != 'off') {
282          $proto = 'https';
283          $dflt_port = 443;
284       }
285       else {
286          $proto = 'http';
287          $dflt_port = 80;
288       }
289       $port = ($SERVER_PORT == $dflt_port) ? '' : ":$SERVER_PORT";
290       return $proto . '://' . $SERVER_NAME . $port . $SCRIPT_NAME;
291    }
292
293    if (empty($ScriptUrl)) {
294       $ScriptUrl = compute_default_scripturl();
295    }
296    if (defined('WIKI_ADMIN') && !empty($AdminUrl))
297       $ScriptUrl = $AdminUrl;
298
299    $FieldSeparator = "\263";
300
301    if (isset($PHP_AUTH_USER)) {
302         $remoteuser = $PHP_AUTH_USER;
303    } else {
304
305       // Apache won't show REMOTE_HOST unless the admin configured it
306       // properly. We'll be nice and see if it's there.
307
308       getenv('REMOTE_HOST') ? ($remoteuser = getenv('REMOTE_HOST'))
309                             : ($remoteuser = getenv('REMOTE_ADDR'));
310    }
311
312    // constants used for HTML output. HTML tags may allow nesting
313    // other tags always start at level 0
314    define("ZERO_LEVEL", 0);
315    define("NESTED_LEVEL", 1);
316
317    // constants for flags in $pagehash
318    define("FLAG_PAGE_LOCKED", 1);
319 ?>