023852fe3db0a33fb74ab2c08c2eeab7946beff9
[lhc/web/wiklou.git] / config / index.php
1 <?php
2 # MediaWiki web-based config/installation
3 # Copyright (C) 2004 Brion Vibber <brion@pobox.com>
4 # http://www.mediawiki.org/
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License along
17 # with this program; if not, write to the Free Software Foundation, Inc.,
18 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 # http://www.gnu.org/copyleft/gpl.html
20
21 header( "Content-type: text/html; charset=utf-8" );
22
23 ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
24 "http://www.w3.org/TR/html4/loose.dtd">
25 <html>
26 <head>
27 <meta http-equiv="Content-type" content="text/html; charset=utf-8">
28 <meta name="robots" content="noindex,nofollow">
29 <title>MediaWiki installation</title>
30 <style type="text/css">
31 #credit {
32 float: right;
33 width: 200px;
34 font-size: 0.7em;
35 background-color: #eee;
36 color: black;
37 border: solid 1px #444;
38 padding: 8px;
39 margin-left: 8px;
40 }
41
42 dl.setup dd {
43 margin-left: 0;
44 }
45 dl.setup dd label {
46 clear: left;
47 font-weight: bold;
48 width: 12em;
49 float: left;
50 text-align: right;
51 padding-right: 1em;
52 }
53 dl.setup dt {
54 clear: left;
55 font-size: 0.8em;
56 margin-left: 10em;
57 /* margin-right: 200px; */
58 margin-bottom: 2em;
59 }
60 .error {
61 color: red;
62 }
63 </style>
64 </head>
65
66 <body>
67
68 <div id="credit">
69 <center>
70 <a href="http://www.mediawiki.org/"><img
71 src="../images/wiki.png" width="135" height="135" alt="" border="0" /></a>
72 </center>
73
74 <b><a href="http://www.mediawiki.org/">MediaWiki</a></b> is
75 Copyright (C) 2001-2004 by Magnus Manske, Brion Vibber, Lee Daniel Crocker,
76 Tim Starling, Erik M&ouml;ller, and others.</p>
77
78 <ul>
79 <li><a href="../README">Readme</a></li>
80 <li><a href="../RELEASE-NOTES">Release notes</a></li>
81 <li><a href="../docs/">doc/</a></li>
82 <li><a href="http://meta.wikipedia.org/wiki/MediaWiki_User's_Guide">User's Guide</a></li>
83 </ul>
84
85 <p>This program is free software; you can redistribute it and/or modify
86 it under the terms of the GNU General Public License as published by
87 the Free Software Foundation; either version 2 of the License, or
88 (at your option) any later version.</p>
89
90 <p>This progarm is distributed in the hope that it will be useful,
91 but WITHOUT ANY WARRANTY; without even the implied warranty of
92 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
93 GNU General Public License for more details.</p>
94
95 <p>You should have received <a href="../COPYING">a copy of the GNU General Public License</a>
96 along with this program; if not, write to the Free Software
97 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
98 or <a href="http://www.gnu.org/copyleft/gpl.html">read it online</a></p>
99 </div>
100
101 <?php
102 include( "../includes/DefaultSettings.php" );
103 ?>
104
105 <h1>MediaWiki <?php print $wgVersion ?> installation</h1>
106
107
108 <?php
109
110 /* Check for existing configurations and bug out! */
111
112 if( file_exists( "../LocalSettings.php" ) || file_exists( "../AdminSettings.php" ) ) {
113 dieout( "<h2>Wiki is configured.</h2>
114
115 <p>Already configured... <a href='../index.php'>return to the wiki</a>.</p>
116
117 <p>(You should probably remove this directory for added security.)</p>" );
118 }
119
120 if( file_exists( "./LocalSettings.php" ) || file_exists( "./AdminSettings.php" ) ) {
121 dieout( "<h2>You're configured!</h2>
122
123 <p>Please move <tt>LocalSettings.php</tt> to the parent directory, then
124 <a href='../index.php'>try out your wiki</a>.
125 (You should remove this config directory for added security once you're done.)</p>" );
126 }
127
128 if( !is_writable( "." ) ) {
129 dieout( "<h2>Can't write config file, aborting</h2>
130
131 <p>In order to configure the wiki you have to make the <tt>config</tt> subdirectory
132 writable by the web server. Once configuration is done you'll move the created
133 <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can
134 then remove the <tt>config</tt> subdirectory entirely.</p>
135
136 <p>To make the directory writable on a Unix/Linux system:</p>
137
138 <pre>
139 cd <i>/path/to/wiki</i>
140 chmod a+w config
141 </pre>" );
142 }
143
144
145 include( "../install-utils.inc" );
146 include( "../maintenance/updaters.inc" );
147 class ConfigData {
148 function getEncoded( $data ) {
149 # Hackish
150 global $wgInputEncoding;
151 if( strcasecmp( $wgInputEncoding, "utf-8" ) == 0 ) {
152 return $data;
153 } else {
154 return utf8_decode( $data ); /* to latin1 wikis */
155 }
156 }
157 function getSitename() { return $this->getEncoded( $this->Sitename ); }
158 function getSysopName() { return $this->getEncoded( $this->SysopName ); }
159 function getSysopPass() { return $this->getEncoded( $this->SysopPass ); }
160 }
161
162 ?>
163
164
165 <h2>Checking environment...</h2>
166 <ul>
167 <?php
168
169 $conf = new ConfigData;
170
171 install_version_checks();
172 print "<li>PHP " . phpversion() . " ok</li>\n";
173
174 /*
175 $conf->zlib = function_exists( "gzencode" );
176 $z = $conf->zlib ? "Have" : "No";
177 print "<li>$z zlib support</li>\n";
178 */
179
180 $conf->HaveGD = function_exists( "imagejpeg" );
181 if( $conf->HaveGD ) {
182 print "<li>Found GD graphics library built-in, image thumbnailing will be enabled if you enable uploads.</li>\n";
183 } else {
184 print "<li>No built-in GD library, image thumbnailing disabled.</li>\n";
185 }
186
187 /*
188 if( file_exists( "/usr/bin/convert" ) ) {
189 $conf->ImageMagick = "/usr/bin/convert";
190 print "<li>Found ImageMagick: /usr/bin/convert</li>\n";
191 } elseif( file_exists( "/usr/local/bin/convert" ) ) {
192 $conf->ImageMagick = "/usr/local/bin/convert";
193 print "<li>Found ImageMagick: /usr/local/bin/convert</li>\n";
194 } else {
195 $conf->ImageMagick = false;
196 print "<li>No ImageMagick.</li>\n";
197 }
198 */
199
200 $conf->UseImageResize = $conf->HaveGD;
201
202 # $conf->IP = "/Users/brion/Sites/inplace";
203 chdir( ".." );
204 $conf->IP = getcwd();
205 chdir( "config" );
206 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP ) . "</tt></li>\n";
207
208 # $conf->ScriptPath = "/~brion/inplace";
209 $conf->ScriptPath = preg_replace( '{^(.*)/config.*$}', '$1', $_SERVER["REQUEST_URI"] );
210 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath ) . "</tt></li>\n";
211
212 $conf->posted = ($_SERVER["REQUEST_METHOD"] == "POST");
213
214 $conf->Sitename = ucfirst( importPost( "Sitename", "" ) );
215 $conf->EmergencyContact = importPost( "EmergencyContact", $_SERVER["SERVER_ADMIN"] );
216 $conf->DBserver = importPost( "DBserver", "localhost" );
217 $conf->DBname = importPost( "DBname", "wikidb" );
218 $conf->DBuser = importPost( "DBuser", "wikiuser" );
219 $conf->DBpassword = importPost( "DBpassword" );
220 $conf->DBpassword2 = importPost( "DBpassword2" );
221 $conf->RootPW = importPost( "RootPW" );
222 $conf->LanguageCode = importPost( "LanguageCode", "en-utf8" );
223 $conf->SysopName = importPost( "SysopName", "WikiSysop" );
224 $conf->SysopPass = importPost( "SysopPass" );
225 $conf->SysopPass2 = importPost( "SysopPass2" );
226
227 /* Check for validity */
228 $errs = array();
229
230 if( $conf->Sitename == "" || $conf->Sitename == "MediaWiki" || $conf->Sitename == "Mediawiki" ) {
231 $errs["Sitename"] = "Must not be blank or \"MediaWiki\".";
232 }
233 if( $conf->DBpassword == "" ) {
234 $errs["DBpassword"] = "Must not be blank";
235 }
236 if( $conf->DBpassword != $conf->DBpassword2 ) {
237 $errs["DBpassword2"] = "Passwords don't match!";
238 }
239
240 if( $conf->SysopPass == "" ) {
241 $errs["SysopPass"] = "Must not be blank";
242 }
243 if( $conf->SysopPass != $conf->SysopPass2 ) {
244 $errs["SysopPass2"] = "Passwords don't match!";
245 }
246
247 if( $conf->posted && ( 0 == count( $errs ) ) ) {
248 do { /* So we can 'continue' to end prematurely */
249 $conf->Root = ($conf->RootPW != "");
250
251 /* Load up the settings and get installin' */
252 $local = writeLocalSettings( $conf );
253 $wgCommandLineMode = false;
254 eval($local);
255
256 $wgDBadminuser = $wgDBuser;
257 $wgDBadminpassword = $wgDBpassword;
258 $wgCommandLineMode = true;
259 $wgUseDatabaseMessages = false; /* FIXME: For database failure */
260 include_once( "Setup.php" );
261 include_once( "../maintenance/InitialiseMessages.inc" );
262
263 $wgTitle = Title::newFromText( "Installation script" );
264
265 if( $conf->Root ) {
266 $wgDatabase = Database::newFromParams( $wgDBserver, "root", $conf->RootPW, "", 1 );
267 } else {
268 $wgDatabase = Database::newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, "", 1 );
269 }
270 $wgDatabase->mIgnoreErrors = true;
271
272 if ( !$wgDatabase->isOpen() ) {
273 $errs["DBserver"] = "Couldn't connect to database";
274 continue;
275 }
276
277 @$myver = mysql_get_server_info( $wgDatabase->mConn );
278 if( !$myver ) {
279 print "<li>MySQL error " . ($err = mysql_errno() ) .
280 ": " . htmlspecialchars( mysql_error() );
281 $ok = false;
282 switch( $err ) {
283 case 1045:
284 if( $conf->Root ) {
285 $errs["RootPW"] = "Check password";
286 } else {
287 print "<li>Trying root...\n";
288 /* Try a blank root password... */
289 $wgDatabase = Database::newFromParams( $wgDBserver, "root", "", "", 1 );
290 $wgDatabase->isOpen();
291 $wgDatabase->mIgnoreErrors = true;
292 @$myver = mysql_get_server_info( $wgDatabase->mConn );
293 if( !$myver ) {
294 $errs["DBuser"] = "Check name/pass";
295 $errs["DBpassword"] = "or enter root";
296 $errs["DBpassword2"] = "password below";
297 $errs["RootPW"] = "Got root?";
298 print " need password.</li>\n";
299 } else {
300 $conf->Root = true;
301 $conf->RootPW = "";
302 print " ok.</li>\n";
303 # And keep going...
304 $ok = true;
305 }
306 break;
307 }
308 case 2002:
309 case 2003:
310 $errs["DBserver"] = "Connection failed";
311 break;
312 default:
313 $errs["DBserver"] = "Couldn't connect to database";
314 break;
315 }
316 if( !$ok ) continue;
317 }
318 print "<li>Connected to database... $myver";
319 if( version_compare( $myver, "4.0.0" ) >= 0 ) {
320 print "; enabling MySQL 4 enhancements";
321 $conf->DBmysql4 = true;
322 $local = writeLocalSettings( $conf );
323 }
324 print "</li>\n";
325
326 @$sel = mysql_select_db( $wgDBname, $wgDatabase->mConn );
327 if( $sel ) {
328 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
329 } else {
330 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
331 if( !$res ) {
332 print "<li>Couldn't create database <tt>" .
333 htmlspecialchars( $wgDBname ) .
334 "</tt>; try with root access or check your username/pass.</li>\n";
335 $errs["RootPW"] = "&lt;- Enter";
336 continue;
337 }
338 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
339 }
340
341 $wgDatabase->selectDB( $wgDBname );
342
343 if( $wgDatabase->tableExists( "cur" ) ) {
344 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n<pre>";
345
346 chdir( ".." );
347 flush();
348 do_ipblocks_update(); flush();
349 do_interwiki_update(); flush();
350 do_index_update(); flush();
351 do_linkscc_update(); flush();
352 do_hitcounter_update(); flush();
353 do_recentchanges_update(); flush();
354 initialiseMessages(); flush();
355 chdir( "config" );
356
357 print "</pre>\n";
358 print "<li>Finished update checks.</li>\n";
359 } else {
360 # FIXME: Check for errors
361 print "<li>Creating tables...";
362 dbsource( "../maintenance/tables.sql", $wgDatabase );
363 dbsource( "../maintenance/interwiki.sql", $wgDatabase );
364 dbsource( "../maintenance/indexes.sql", $wgDatabase );
365 print " done.</li>\n";
366
367 print "<li>Initializing data...";
368 $wgDatabase->query( "INSERT INTO site_stats (ss_row_id,ss_total_views," .
369 "ss_total_edits,ss_good_articles) VALUES (1,0,0,0)" );
370
371 if( $conf->SysopName ) {
372 $u = User::newFromName( $conf->getSysopName() );
373 if ( 0 == $u->idForName() ) {
374 $u->addToDatabase();
375 $u->setPassword( $conf->getSysopPass() );
376 $u->addRight( "sysop" );
377 $u->addRight( "developer" ); /* ?? */
378 $u->saveSettings();
379 print "<li>Created sysop account <tt>" .
380 htmlspecialchars( $conf->SysopName ) . "</tt>.</li>\n";
381 } else {
382 print "<li>Could not create user - already exists!</li>\n";
383 }
384 } else {
385 print "<li>Skipped sysop account creation, no name given.</li>\n";
386 }
387
388 print "<li>Initialising log pages...";
389 $logs = array(
390 "uploadlogpage" => "uploadlogpagetext",
391 "dellogpage" => "dellogpagetext",
392 "protectlogpage" => "protectlogtext",
393 "blocklogpage" => "bloglogtext"
394 );
395 $metaNamespace = Namespace::getWikipedia();
396 $now = wfTimestampNow();
397 $won = wfInvertTimestamp( $now );
398 foreach( $logs as $page => $text ) {
399 $logTitle = wfStrencode( $wgLang->ucfirst( str_replace( " ", "_", wfMsgNoDB( $page ) ) ) );
400 $logText = wfStrencode( wfMsgNoDB( $text ) );
401 $wgDatabase->query( "INSERT INTO cur (cur_namespace,cur_title,cur_text," .
402 "cur_restrictions,cur_timestamp,inverse_timestamp,cur_touched) " .
403 "VALUES ($metaNamespace,'$logTitle','$logText','sysop','$now','$won','$now')" );
404 }
405 print "</li>\n";
406
407 $titleobj = Title::newFromText( wfMsgNoDB( "mainpage" ) );
408 $title = $titleobj->getDBkey();
409 $sql = "INSERT INTO cur (cur_namespace,cur_title,cur_text,cur_timestamp,inverse_timestamp,cur_touched) " .
410 "VALUES (0,'$title','" .
411 wfStrencode( wfMsg( "mainpagetext" ) ) . "','$now','$won','$now')";
412 $wgDatabase->query( $sql, $fname );
413
414 print "<li>";
415 initialiseMessages();
416 print "</li>\n";
417
418 if( $conf->Root ) {
419 # Grant user permissions
420 dbsource( "../maintenance/users.sql", $wgDatabase );
421 }
422 }
423
424 /* Write out the config file now that all is well */
425 print "<p>Creating LocalSettings.php...</p>\n\n";
426 $localSettings = "<" . "?php\n$local\n?" . ">";
427
428 if( version_compare( phpversion(), "4.3.2" ) >= 0 ) {
429 $xt = "xt"; # Refuse to overwrite an existing file
430 } else {
431 $xt = "wt"; # 'x' is not available prior to PHP 4.3.2. We did check above, but race conditions blah blah
432 }
433 $f = fopen( "LocalSettings.php", $xt );
434
435 if( $f == false ) {
436 dieout( "Couldn't write out LocalSettings.php. Check that the directory permissions are correct and that there isn't already a file of that name here...</p>\n" .
437 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
438 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
439 }
440 fwrite( $f, $localSettings );
441 fclose( $f );
442
443 print "<p>Success! Move the LocalSettings.php file into the parent directory, then follow
444 <a href='{$conf->ScriptPath}/index.php'>this link</a> to your wiki.</p>\n";
445
446 } while( false );
447 }
448 ?>
449 </ul>
450
451
452 <?php
453
454 if( count( $errs ) ) {
455 /* Display options form */
456
457 if( $conf->posted ) {
458 echo "<p class='error'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
459 }
460 ?>
461
462 <form name="config" method="post">
463
464
465 <h2>Site config</h2>
466
467 <dl class="setup">
468 <dd>
469 <?php
470 aField( $conf, "Sitename", "Site name:" );
471 ?>
472 </dd>
473 <dt>
474 Your site name should be a relatively short word. It'll appear as the namespace
475 name for 'meta' pages as well as throughout the user interface. Good site names
476 are things like "<a href="http://www.wikipedia.org/">Wikipedia</a>" and
477 "<a href="http://openfacts.berlios.de/">OpenFacts</a>"; avoid punctuation,
478 which may cause problems.
479 </dt>
480
481 <dd>
482 <?php
483 aField( $conf, "EmergencyContact", "Contact e-mail" );
484 ?>
485 </dd>
486 <dt>
487 This will be used as the return address for password reminders and
488 may be displayed in some error conditions so visitors can get in
489 touch with you.
490 </dt>
491
492 <dd>
493 <label for="LanguageCode">Language</label>
494 <select id="LanguageCode" name="LanguageCode">
495 <?php
496 $list = getLanguageList();
497 foreach( $list as $code => $name ) {
498 $sel = ($code == $conf->LanguageCode) ? "selected" : "";
499 echo "\t\t<option value=\"$code\" $sel>$name</option>\n";
500 }
501 ?>
502 </select>
503 </dd>
504 <dt>
505 You may select the language for the user interface of the wiki...
506 Some localizations are less complete than others. This also controls
507 the character encoding; Unicode is more flexible, but Latin-1 may be
508 more compatible with older browsers for some languages. Unicode will
509 be used where not specified otherwise.
510 </dt>
511
512 <dd>
513 <?php aField( $conf, "SysopName", "Sysop account name:", "" ) ?>
514 </dd>
515 <dd>
516 <?php aField( $conf, "SysopPass", "password:", "password" ) ?>
517 </dd>
518 <dd>
519 <?php aField( $conf, "SysopPass2", "again:", "password" ) ?>
520 </dd>
521 <dt>
522 A sysop user account can lock or delete pages, block problematic IP
523 addresses from editing, and other maintenance tasks. If creating a new
524 wiki database, a sysop account will be created with the given name
525 and password.
526 </dt>
527 </dl>
528
529 <h2>Database config</h2>
530
531 <dl class="setup">
532 <dd><?php
533 aField( $conf, "DBserver", "MySQL server" );
534 ?></dd>
535 <dt>
536 If your database server isn't on your web server, enter the name
537 or IP address here.
538 </dt>
539
540 <dd><?php
541 aField( $conf, "DBname", "Database name" );
542 ?></dd>
543 <dd><?php
544 aField( $conf, "DBuser", "DB username" );
545 ?></dd>
546 <dd><?php
547 aField( $conf, "DBpassword", "DB password", "password" );
548 ?></dd>
549 <dd><?php
550 aField( $conf, "DBpassword2", "again", "password" );
551 ?></dd>
552 <dt>
553 If you only have a single user account and database available,
554 enter those here. If you have database root access (see below)
555 you can specify new accounts/databases to be created.
556 </dt>
557
558
559 <dd>
560 <?php
561 aField( $conf, "RootPW", "DB root password", "password" );
562 ?>
563 </dd>
564 <dt>
565 You will only need this if the database and/or user account
566 above don't already exist.
567 Do <em>not</em> type in your machine's root password! MySQL
568 has its own "root" user with a separate password. (It might
569 even be blank, depending on your configuration.)
570 </dt>
571
572 <dd>
573 <label>&nbsp;</label>
574 <input type="submit" value="Install!" />
575 </dd>
576 </dl>
577
578
579 </form>
580
581 <?php
582 }
583
584 /* -------------------------------------------------------------------------------------- */
585
586 function writeAdminSettings( $conf ) {
587 return "
588 \$wgDBadminuser = \"{$conf->DBadminuser}\";
589 \$wgDBadminpassword = \"{$conf->DBadminpassword}\";
590 ";
591 }
592
593 function writeLocalSettings( $conf ) {
594 $conf->DBmysql4 = $conf->DBmysql4 ? 'true' : 'false';
595 $conf->UseImageResize = $conf->UseImageResize ? 'true' : 'false';
596 $conf->DBsqluser = $conf->DBuser;
597 $conf->DBsqlpassword = $conf->DBpassword;
598 $conf->PasswordSender = $conf->EmergencyContact;
599 if( $conf->LanguageCode == "en-utf8" ) {
600 $conf->LanguageCode = "en";
601 $conf->Encoding = "UTF-8";
602 }
603 $sep = (DIRECTORY_SEPARATOR == "\\") ? ";" : ":";
604 return "
605 # This file was automatically generated. Don't touch unless you
606 # know what you're doing; see LocalSettings.sample for an edit-
607 # friendly file.
608
609 \$IP = \"{$conf->IP}\";
610 ini_set( \"include_path\", \"\$IP/includes$sep\$IP/languages$sep\" . ini_get(\"include_path\") );
611 include_once( \"DefaultSettings.php\" );
612
613 if( \$wgCommandLineMode ) {
614 die( \"Can't use command-line utils with in-place install yet, sorry.\" );
615 }
616
617 \$wgSitename = \"{$conf->Sitename}\";
618
619 \$wgScriptPath = \"{$conf->ScriptPath}\";
620 \$wgScript = \"\$wgScriptPath/index.php\";
621 \$wgRedirectScript = \"\$wgScriptPath/redirect.php\";
622
623 \$wgArticlePath = \"\$wgScript/\$1\";
624
625 \$wgStyleSheetPath = \"\$wgScriptPath/stylesheets\";
626 \$wgStyleSheetDirectory = \"\$IP/stylesheets\";
627
628 \$wgUploadPath = \"\$wgScriptPath/images\";
629 \$wgUploadDirectory = \"\$IP/images\";
630 \$wgLogo = \"\$wgUploadPath/wiki.png\";
631
632 \$wgEmergencyContact = \"{$conf->EmergencyContact}\";
633 \$wgPasswordSender = \"{$conf->PasswordSender}\";
634
635 \$wgDBserver = \"{$conf->DBserver}\";
636 \$wgDBname = \"{$conf->DBname}\";
637 \$wgDBuser = \"{$conf->DBuser}\";
638 \$wgDBpassword = \"{$conf->DBpassword}\";
639 \$wgDBsqluser = \"{$conf->DBsqluser}\";
640 \$wgDBsqlpassword = \"{$conf->DBsqlpassword}\";
641
642 \$wgDBmysql4 = \$wgEnablePersistentLC = {$conf->DBmysql4};
643
644 ## To enable image uploads, make sure the 'images' directory
645 ## is writable, then uncomment this:
646 # \$wgDisableUploads = false;
647 \$wgUseImageResize = {$conf->UseImageResize};
648
649 ## If you have the appropriate support software installed
650 ## you can enable inline LaTeX equations:
651 # \$wgUseTeX = true;
652 # \$wgMathPath = \"{\$wgUploadPath}/math\";
653 # \$wgMathDirectory = \"{\$wgUploadDirectory}/math\";
654 # \$wgTmpDirectory = \"{\$wgUploadDirectory}/tmp\";
655
656 \$wgLocalInterwiki = \$wgSitename;
657
658 \$wgLanguageCode = \"{$conf->LanguageCode}\";
659 " . ($conf->Encoding ? "\$wgInputEncoding = \$wgOutputEncoding = \"{$conf->Encoding}\";" : "" ) . "
660
661 \$wgUsePHPTAL = false;
662 if ( \$wgUsePHPTAL ) {
663 ini_set( \"include_path\", \"\$IP/PHPTAL-NP-0.7.0/libs:\" . ini_get(\"include_path\") );
664 }
665
666 ";
667 }
668
669 function dieout( $text ) {
670 die( $text . "\n\n</body>\n</html>" );
671 }
672
673 function importPost( $name, $default = "" ) {
674 if( isset( $_POST[$name] ) ) {
675 return $_POST[$name];
676 } else {
677 return $default;
678 }
679 }
680
681 function aField( &$conf, $field, $text, $type = "" ) {
682 if( $type != "" ) $type = "type=\"$type\"";
683 echo "\t\t<label for=\"$field\">$text</label>\n";
684 echo "\t\t<input $type name=\"$field\" id=\"$field\" value=\"";
685 echo htmlspecialchars( $conf->$field );
686 echo "\" />\n";
687
688 global $errs;
689 if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n";
690 }
691
692 function getLanguageList() {
693 global $wgLanguageNames;
694 if( !isset( $wgLanguageNames ) ) {
695 $wgLanguageCode = "xxx";
696 function wfLocalUrl( $x ) { return $x; }
697 function wfLocalUrlE( $x ) { return $x; }
698 include( "../languages/Language.php" );
699 }
700
701 $codes = array();
702 $latin1 = array( "da", "de", "en", "es", "nl", "sv" );
703
704 $d = opendir( "../languages" );
705 while( false !== ($f = readdir( $d ) ) ) {
706 if( preg_match( '/Language([A-Z][a-z]+)\.php$/', $f, $m ) ) {
707 $code = strtolower( $m[1] );
708 $codes[$code] = "$code - " . $wgLanguageNames[$code];
709 if( in_array( $code, $latin1 ) ) {
710 $codes[$code] .= " - Latin-1";
711 }
712 }
713 }
714 $codes["en-utf8"] = "en - English - Unicode";
715 closedir( $d );
716 ksort( $codes );
717 return $codes;
718 }
719
720 ?>
721
722 </body>
723 </html>