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