]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/config.php
Fixed a bug in the loading of dbmlib.php; if the $whichdatabase was
[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
10    if (!function_exists('rcs_id')) {
11       function rcs_id($id) { echo "<!-- $id -->\n"; };
12    }
13    rcs_id('$Id: config.php,v 1.23 2001-01-31 02:18:26 wainstead Exp $');
14    // end essential internal stuff
15
16
17    /////////////////////////////////////////////////////////////////////
18    // Part One:
19    // Constants and settings. Edit the values below for your site.
20    /////////////////////////////////////////////////////////////////////
21
22
23    // URL of index.php e.g. http://yoursite.com/phpwiki/index.php
24    // you can leave this empty - it will be calculated automatically
25    $ScriptUrl = "";
26    // URL of admin.php e.g. http://yoursite.com/phpwiki/admin.php
27    // you can leave this empty - it will be calculated automatically
28    // if you fill in $ScriptUrl you *MUST* fill in $AdminUrl as well!
29    $AdminUrl = "";
30
31    //  Select your language - default language "C": English
32    // other languages available: Dutch "nl", Spanish "es", German "de"
33    $LANG="C";
34
35    /////////////////////////////////////////////////////////////////////
36    // Part Two:
37    // Database section
38    // set your database here and edit the according section below.
39    // For PHP 4.0.4 and later you must use "dba" if you are using 
40    // DBM files for storage. "dbm" uses the older deprecated interface.
41    // The option 'default' will choose either dbm or dba, depending on
42    // the version of PHP you are running.
43    /////////////////////////////////////////////////////////////////////
44
45    $WhichDatabase = 'default'; // use one of "dbm", "dba", "mysql",
46                            // "pgsql", "msql", or "file"
47
48    // DBM and DBA settings (default)
49    if ($WhichDatabase == 'dbm' or $WhichDatabase == 'dba' or
50        $WhichDatabase == 'default') {
51       $DBMdir = "/tmp";
52       $WikiPageStore = "wiki";
53       $ArchivePageStore = "archive";
54       $WikiDB['wiki']      = "$DBMdir/wikipagesdb";
55       $WikiDB['archive']   = "$DBMdir/wikiarchivedb";
56       $WikiDB['wikilinks'] = "$DBMdir/wikilinksdb";
57       $WikiDB['hottopics'] = "$DBMdir/wikihottopicsdb";
58       $WikiDB['hitcount']  = "$DBMdir/wikihitcountdb";
59       // try this many times if the dbm is unavailable
60       define("MAX_DBM_ATTEMPTS", 20);
61
62       // for PHP3 use dbmlib, else use dbalib for PHP4
63       if ($WhichDatabase == 'default') {
64          if ( floor(phpversion()) == 3) {
65             $WhichDatabase = 'dbm';
66          } else {
67             $WhichDatabase = 'dba';
68          }
69       }
70
71       if ($WhichDatabase == 'dbm') {
72           include "lib/dbmlib.php"; 
73       } else {
74           include "lib/dbalib.php";
75       }
76
77    // MySQL settings -- see INSTALL.mysql for details on using MySQL
78    } elseif ($WhichDatabase == 'mysql') {
79       $WikiPageStore = "wiki";
80       $ArchivePageStore = "archive";
81       $WikiLinksStore = "wikilinks";
82       $WikiScoreStore = "wikiscore";
83       $HitCountStore = "hitcount";
84       $mysql_server = 'localhost';
85       $mysql_user = 'root';
86       $mysql_pwd = '';
87       $mysql_db = 'wiki';
88       include "lib/mysql.php";
89
90    // PostgreSQL settings -- see INSTALL.pgsql for more details
91    } elseif ($WhichDatabase == 'pgsql') {
92       $pg_dbhost    = "localhost";
93       $pg_dbport    = "5432";
94       $WikiDataBase  = "wiki"; // name of the database in Postgresql
95       $WikiPageStore = "wiki";
96       $ArchivePageStore = "archive";
97       $WikiLinksPageStore = "wikilinks";
98       $HotTopicsPageStore = "hottopics";
99       $HitCountPageStore = "hitcount";
100       include "lib/pgsql.php";
101
102    // MiniSQL (mSQL) settings -- see INSTALL.msql for details on using mSQL
103    } elseif ($WhichDatabase == 'msql') {
104       $msql_db = "wiki";
105       $WikiPageStore = array();
106       $ArchivePageStore = array();
107       $WikiPageStore['table']         = "wiki";
108       $WikiPageStore['page_table']    = "wikipages";
109       $ArchivePageStore['table']      = "archive";
110       $ArchivePageStore['page_table'] = "archivepages";
111       // should be the same as wikipages.line
112       define("MSQL_MAX_LINE_LENGTH", 128);
113       include "lib/msql.php";
114
115    // Filesystem DB settings
116    } elseif ($WhichDatabase == 'file') {
117       $DBdir = "/tmp/wiki";
118       $WikiPageStore = "wiki";
119       $ArchivePageStore = "archive";
120       $WikiDB['wiki']      = "$DBdir/pages";
121       $WikiDB['archive']   = "$DBdir/archive";
122       $WikiDB['wikilinks'] = "$DBdir/links";
123       $WikiDB['hottopics'] = "$DBdir/hottopics";
124       $WikiDB['hitcount']  = "$DBdir/hitcount";
125       include "lib/db_filesystem.php";
126
127     } else die("Invalid '\$WhichDatabase' in lib/config.php"); 
128
129
130    /////////////////////////////////////////////////////////////////////
131    // Part Three:
132    // Miscellaneous
133    /////////////////////////////////////////////////////////////////////
134
135    // logo image (path relative to index.php)
136    $logo = "images/wikibase.png";
137    // signature image which is shown after saving an edited page
138    $SignatureImg = "images/signature.png";
139
140    // date & time formats used to display modification times, etc.
141    // formats are given as format strings to PHP date() function
142    $datetimeformat = "F j, Y";  // may contain time of day
143    $dateformat = "F j, Y";      // must not contain time
144
145    // this defines how many page names to list when displaying
146    // the MostPopular pages; the default is to show the 20 most popular pages
147    define("MOST_POPULAR_LIST_LENGTH", 20);
148
149    // this defines how many page names to list when displaying related pages
150    define("NUM_RELATED_PAGES", 5);
151
152    // number of user-defined external references, i.e. "[1]"
153    define("NUM_LINKS", 12);
154
155    // allowed protocols for links - be careful not to allow "javascript:"
156    // within a named link [name|uri] one more protocol is defined: phpwiki
157    $AllowedProtocols = "http|https|mailto|ftp|news|gopher";
158
159    // URLs ending with the following extension should be inlined as images
160    $InlineImages = "png|jpg|gif";
161
162    // Perl regexp for WikiNames
163    // (?<!..) & (?!...) used instead of '\b' because \b matches '_' as well
164    $WikiNameRegexp = "(?<![A-Za-z0-9])([A-Z][a-z]+){2,}(?![A-Za-z0-9])";
165
166
167
168    /////////////////////////////////////////////////////////////////////
169    // Part Four:
170    // Original pages and layout
171    /////////////////////////////////////////////////////////////////////
172
173    // need to define localization function first -- skip this
174    if (!function_exists ('gettext')) {
175       $lcfile = "locale/$LANG/LC_MESSAGES/phpwiki.php";
176       if (file_exists($lcfile)) { include($lcfile); }
177       else { $locale = array(); }
178
179       function gettext ($text) { 
180          global $locale;
181          if (!empty ($locale[$text]))
182            return $locale[$text];
183          return $text;
184       }
185    } else {
186       putenv ("LANG=$LANG");
187       bindtextdomain ("phpwiki", "./locale");
188       textdomain ("phpwiki");
189    }
190    // end of localization function
191
192    // Template files (filenames are relative to script position)
193    $templates = array(
194         "BROWSE" =>    gettext("templates/browse.html"),
195         "EDITPAGE" =>  gettext("templates/editpage.html"),
196         "EDITLINKS" => gettext("templates/editlinks.html"),
197         "MESSAGE" =>   gettext("templates/message.html")
198         );
199
200    /* WIKI_PGSRC -- specifies the source for the initial page contents
201     * of the Wiki.  The setting of WIKI_PGSRC only has effect when
202     * the wiki is accessed for the first time (or after clearing the
203     * database.) WIKI_PGSRC can either name a directory or a zip file.
204     * In either case WIKI_PGSRC is scanned for files --- one file per page.
205     *
206     * If the files appear to be MIME formatted messages, they are
207     * scanned for application/x-phpwiki content-types.  Any suitable
208     * content is added to the wiki.
209     * The files can also be plain text files, in which case the page name
210     * is taken from the file name.
211     */
212
213    define('WIKI_PGSRC', gettext("./pgsrc")); // Default (old) behavior.
214    //define('WIKI_PGSRC', './wiki.zip'); // New style.
215
216    // DEFAULT_WIKI_PGSRC is only used when the language is *not*
217    // the default (English) and when reading from a directory:
218    // in that case some English pages are inserted into the wiki as well
219    // DEFAULT_WIKI_PGSRC defines where the English pages reside 
220    define('DEFAULT_WIKI_PGSRC', "./pgsrc");
221
222
223
224    //////////////////////////////////////////////////////////////////////
225    // you shouldn't have to edit anyting below this line
226
227    if (empty($ScriptUrl)) {
228       $port = ($SERVER_PORT == 80) ? '' : ":$SERVER_PORT";
229       $ScriptUrl = "http://$SERVER_NAME$port$SCRIPT_NAME";
230    }
231    if (defined('WIKI_ADMIN') && !empty($AdminUrl))
232       $ScriptUrl = $AdminUrl;
233
234    $LogoImage = "<img src=\"$logo\" border=0 ALT=\"[PhpWiki!]\">";
235    $LogoImage = "<a href=\"$ScriptUrl\">$LogoImage</a>";
236
237    $FieldSeparator = "\263";
238
239    if (isset($PHP_AUTH_USER)) {
240         $remoteuser = $PHP_AUTH_USER;
241    } else {
242
243       // Apache won't show REMOTE_HOST unless the admin configured it
244       // properly. We'll be nice and see if it's there.
245
246       getenv('REMOTE_HOST') ? ($remoteuser = getenv('REMOTE_HOST'))
247                             : ($remoteuser = getenv('REMOTE_ADDR'));
248    }
249
250    // constants used for HTML output. HTML tags may allow nesting
251    // other tags always start at level 0
252    define("ZERO_LEVEL", 0);
253    define("NESTED_LEVEL", 1);
254
255    // constants for flags in $pagehash
256    define("FLAG_PAGE_LOCKED", 1);
257 ?>