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