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