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