Replace \ with \\ in $IP, for Windows paths
[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 program 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
103 $IP = ".."; # Just to suppress notices, not for anything useful
104 include( "../includes/DefaultSettings.php" );
105 ?>
106
107 <h1>MediaWiki <?php print $wgVersion ?> installation</h1>
108
109
110 <?php
111
112 /* Check for existing configurations and bug out! */
113
114 if( file_exists( "../LocalSettings.php" ) || file_exists( "../AdminSettings.php" ) ) {
115 dieout( "<h2>Wiki is configured.</h2>
116
117 <p>Already configured... <a href='../index.php'>return to the wiki</a>.</p>
118
119 <p>(You should probably remove this directory for added security.)</p>" );
120 }
121
122 if( file_exists( "./LocalSettings.php" ) || file_exists( "./AdminSettings.php" ) ) {
123 dieout( "<h2>You're configured!</h2>
124
125 <p>Please move <tt>LocalSettings.php</tt> to the parent directory, then
126 <a href='../index.php'>try out your wiki</a>.
127 (You should remove this config directory for added security once you're done.)</p>" );
128 }
129
130 if( !is_writable( "." ) ) {
131 dieout( "<h2>Can't write config file, aborting</h2>
132
133 <p>In order to configure the wiki you have to make the <tt>config</tt> subdirectory
134 writable by the web server. Once configuration is done you'll move the created
135 <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can
136 then remove the <tt>config</tt> subdirectory entirely.</p>
137
138 <p>To make the directory writable on a Unix/Linux system:</p>
139
140 <pre>
141 cd <i>/path/to/wiki</i>
142 chmod a+w config
143 </pre>" );
144 }
145
146
147 include( "../install-utils.inc" );
148 include( "../maintenance/updaters.inc" );
149 class ConfigData {
150 function getEncoded( $data ) {
151 # Hackish
152 global $wgInputEncoding;
153 if( strcasecmp( $wgInputEncoding, "utf-8" ) == 0 ) {
154 return $data;
155 } else {
156 return utf8_decode( $data ); /* to latin1 wikis */
157 }
158 }
159 function getSitename() { return $this->getEncoded( $this->Sitename ); }
160 function getSysopName() { return $this->getEncoded( $this->SysopName ); }
161 function getSysopPass() { return $this->getEncoded( $this->SysopPass ); }
162 }
163
164 ?>
165
166
167 <h2>Checking environment...</h2>
168 <ul>
169 <?php
170 $endl = "
171 ";
172 $conf = new ConfigData;
173
174 install_version_checks();
175 print "<li>PHP " . phpversion() . " ok</li>\n";
176
177 $sapi = php_sapi_name();
178 $conf->prettyURLs = true;
179 print "<li>PHP server API is $sapi; ";
180 switch( $sapi ) {
181 case "apache":
182 print "ok, using pretty URLs (<tt>index.php/Page_Title</tt>)";
183 break;
184 case "cgi":
185 case "cgi-fcgi":
186 print "using ugly URLs (<tt>index.php?title=Page_Title</tt>)";
187 $conf->prettyURLs = false;
188 break;
189 default:
190 print "unknown; using pretty URLs (<tt>index.php/Page_Title</tt>), if you have trouble change this in <tt>LocalSettings.php</tt>";
191 }
192 print "</li>\n";
193
194 $conf->zlib = function_exists( "gzencode" );
195 if( $conf->zlib ) {
196 print "<li>Have zlib support; enabling output compression.</li>\n";
197 } else {
198 print "<li>No zlib support.</li>\n";
199 }
200
201 $conf->ImageMagick = false;
202
203 $conf->HaveGD = function_exists( "imagejpeg" );
204 if( $conf->HaveGD ) {
205 print "<li>Found GD graphics library built-in, image thumbnailing will be enabled if you enable uploads.</li>\n";
206 } else {
207 $imcheck = array( "/usr/bin", "/usr/local/bin", "/sw/bin" );
208 foreach( $imcheck as $dir ) {
209 $im = "$dir/convert";
210 if( file_exists( $im ) ) {
211 print "<li>Found ImageMagick: <tt>$im</tt>; image thumbnailing will be enabled if you enable uploads.</li>\n";
212 $conf->ImageMagick = $im;
213 break;
214 }
215 }
216 if( !$conf->ImageMagick ) {
217 print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n";
218 }
219 }
220
221 $conf->UseImageResize = $conf->HaveGD || $conf->ImageMagick;
222
223 # $conf->IP = "/Users/brion/Sites/inplace";
224 chdir( ".." );
225 $conf->IP = getcwd();
226 $conf->IP = preg_replace( "/\\\\/","\\\\\\\\",$conf->IP ); // For Windows, \ -> \\
227 chdir( "config" );
228 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP ) . "</tt></li>\n";
229
230 # $conf->ScriptPath = "/~brion/inplace";
231 $conf->ScriptPath = preg_replace( '{^(.*)/config.*$}', '$1', $_SERVER["REQUEST_URI"] );
232 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath ) . "</tt></li>\n";
233
234 $conf->posted = ($_SERVER["REQUEST_METHOD"] == "POST");
235
236 $conf->Sitename = ucfirst( importPost( "Sitename", "" ) );
237 $conf->EmergencyContact = importPost( "EmergencyContact", $_SERVER["SERVER_ADMIN"] );
238 $conf->DBserver = importPost( "DBserver", "localhost" );
239 $conf->DBname = importPost( "DBname", "wikidb" );
240 $conf->DBuser = importPost( "DBuser", "wikiuser" );
241 $conf->DBpassword = importPost( "DBpassword" );
242 $conf->DBpassword2 = importPost( "DBpassword2" );
243 $conf->RootPW = importPost( "RootPW" );
244 $conf->LanguageCode = importPost( "LanguageCode", "en-utf8" );
245 $conf->SysopName = importPost( "SysopName", "WikiSysop" );
246 $conf->SysopPass = importPost( "SysopPass" );
247 $conf->SysopPass2 = importPost( "SysopPass2" );
248
249 /* Check for validity */
250 $errs = array();
251
252 if( $conf->Sitename == "" || $conf->Sitename == "MediaWiki" || $conf->Sitename == "Mediawiki" ) {
253 $errs["Sitename"] = "Must not be blank or \"MediaWiki\".";
254 }
255 if( $conf->DBpassword == "" ) {
256 $errs["DBpassword"] = "Must not be blank";
257 }
258 if( $conf->DBpassword != $conf->DBpassword2 ) {
259 $errs["DBpassword2"] = "Passwords don't match!";
260 }
261
262 if( $conf->SysopPass == "" ) {
263 $errs["SysopPass"] = "Must not be blank";
264 }
265 if( $conf->SysopPass != $conf->SysopPass2 ) {
266 $errs["SysopPass2"] = "Passwords don't match!";
267 }
268
269 if( $conf->posted && ( 0 == count( $errs ) ) ) {
270 do { /* So we can 'continue' to end prematurely */
271 $conf->Root = ($conf->RootPW != "");
272
273 /* Load up the settings and get installin' */
274 $local = writeLocalSettings( $conf );
275 $wgCommandLineMode = false;
276 eval($local);
277
278 $wgDBadminuser = $wgDBuser;
279 $wgDBadminpassword = $wgDBpassword;
280 $wgCommandLineMode = true;
281 $wgUseDatabaseMessages = false; /* FIXME: For database failure */
282 include_once( "Setup.php" );
283 include_once( "../maintenance/InitialiseMessages.inc" );
284
285 $wgTitle = Title::newFromText( "Installation script" );
286 $wgDatabase = Database::newFromParams( $wgDBserver, "root", $conf->RootPW, "", 1 );
287 $wgDatabase->mIgnoreErrors = true;
288
289 @$myver = mysql_get_server_info( $wgDatabase->mConn );
290 if( !$myver ) {
291 print "<li>MySQL error " . ($err = mysql_errno() ) .
292 ": " . htmlspecialchars( mysql_error() );
293 $ok = false;
294 switch( $err ) {
295 case 1045:
296 if( $conf->Root ) {
297 $errs["RootPW"] = "Check password";
298 } else {
299 print "<li>Trying regular user...\n";
300 /* Try the regular user... */
301 $wgDatabase = Database::newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, "", 1 );
302 $wgDatabase->isOpen();
303 $wgDatabase->mIgnoreErrors = true;
304 @$myver = mysql_get_server_info( $wgDatabase->mConn );
305 if( !$myver ) {
306 $errs["DBuser"] = "Check name/pass";
307 $errs["DBpassword"] = "or enter root";
308 $errs["DBpassword2"] = "password below";
309 $errs["RootPW"] = "Got root?";
310 print " need password.</li>\n";
311 } else {
312 $conf->Root = false;
313 $conf->RootPW = "";
314 print " ok.</li>\n";
315 # And keep going...
316 $ok = true;
317 }
318 break;
319 }
320 case 2002:
321 case 2003:
322 $errs["DBserver"] = "Connection failed";
323 break;
324 default:
325 $errs["DBserver"] = "Couldn't connect to database";
326 break;
327 }
328 if( !$ok ) continue;
329 }
330
331 if ( !$wgDatabase->isOpen() ) {
332 $errs["DBserver"] = "Couldn't connect to database";
333 continue;
334 }
335
336 print "<li>Connected to database... $myver";
337 if( version_compare( $myver, "4.0.0" ) >= 0 ) {
338 print "; enabling MySQL 4 enhancements";
339 $conf->DBmysql4 = true;
340 $local = writeLocalSettings( $conf );
341 }
342 print "</li>\n";
343
344 @$sel = mysql_select_db( $wgDBname, $wgDatabase->mConn );
345 if( $sel ) {
346 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
347 } else {
348 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
349 if( !$res ) {
350 print "<li>Couldn't create database <tt>" .
351 htmlspecialchars( $wgDBname ) .
352 "</tt>; try with root access or check your username/pass.</li>\n";
353 $errs["RootPW"] = "&lt;- Enter";
354 continue;
355 }
356 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
357 }
358
359 $wgDatabase->selectDB( $wgDBname );
360
361 if( $wgDatabase->tableExists( "cur" ) ) {
362 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n<pre>";
363
364 chdir( ".." );
365 flush();
366 do_ipblocks_update(); flush();
367 do_interwiki_update(); flush();
368 do_index_update(); flush();
369 do_linkscc_update(); flush();
370 do_hitcounter_update(); flush();
371 do_recentchanges_update(); flush();
372 initialiseMessages(); flush();
373 chdir( "config" );
374
375 print "</pre>\n";
376 print "<li>Finished update checks.</li>\n";
377 } else {
378 # FIXME: Check for errors
379 print "<li>Creating tables...";
380 dbsource( "../maintenance/tables.sql", $wgDatabase );
381 dbsource( "../maintenance/interwiki.sql", $wgDatabase );
382 dbsource( "../maintenance/indexes.sql", $wgDatabase );
383 print " done.</li>\n";
384
385 print "<li>Initializing data...";
386 $wgDatabase->query( "INSERT INTO site_stats (ss_row_id,ss_total_views," .
387 "ss_total_edits,ss_good_articles) VALUES (1,0,0,0)" );
388
389 if( $conf->SysopName ) {
390 $u = User::newFromName( $conf->getSysopName() );
391 if ( 0 == $u->idForName() ) {
392 $u->addToDatabase();
393 $u->setPassword( $conf->getSysopPass() );
394 $u->addRight( "sysop" );
395 $u->addRight( "bureaucrat" );
396 $u->saveSettings();
397 print "<li>Created sysop account <tt>" .
398 htmlspecialchars( $conf->SysopName ) . "</tt>.</li>\n";
399 } else {
400 print "<li>Could not create user - already exists!</li>\n";
401 }
402 } else {
403 print "<li>Skipped sysop account creation, no name given.</li>\n";
404 }
405
406 print "<li>Initialising log pages...";
407 $logs = array(
408 "uploadlogpage" => "uploadlogpagetext",
409 "dellogpage" => "dellogpagetext",
410 "protectlogpage" => "protectlogtext",
411 "blocklogpage" => "blocklogtext"
412 );
413 $metaNamespace = Namespace::getWikipedia();
414 $now = wfTimestampNow();
415 $won = wfInvertTimestamp( $now );
416 foreach( $logs as $page => $text ) {
417 $logTitle = wfStrencode( $wgLang->ucfirst( str_replace( " ", "_", wfMsgNoDB( $page ) ) ) );
418 $logText = wfStrencode( wfMsgNoDB( $text ) );
419 $wgDatabase->query( "INSERT INTO cur (cur_namespace,cur_title,cur_text," .
420 "cur_restrictions,cur_timestamp,inverse_timestamp,cur_touched) " .
421 "VALUES ($metaNamespace,'$logTitle','$logText','sysop','$now','$won','$now')" );
422 }
423 print "</li>\n";
424
425 $titleobj = Title::newFromText( wfMsgNoDB( "mainpage" ) );
426 $title = $titleobj->getDBkey();
427 $sql = "INSERT INTO cur (cur_namespace,cur_title,cur_text,cur_timestamp,inverse_timestamp,cur_touched) " .
428 "VALUES (0,'$title','" .
429 wfStrencode( wfMsg( "mainpagetext" ) ) . "','$now','$won','$now')";
430 $wgDatabase->query( $sql, $fname );
431
432 print "<li><pre>";
433 initialiseMessages();
434 print "</pre></li>\n";
435
436 if( $conf->Root ) {
437 # Grant user permissions
438 dbsource( "../maintenance/users.sql", $wgDatabase );
439 }
440 }
441
442 /* Write out the config file now that all is well */
443 print "<p>Creating LocalSettings.php...</p>\n\n";
444 $localSettings = "<" . "?php$endl$local$endl?" . ">";
445
446 if( version_compare( phpversion(), "4.3.2" ) >= 0 ) {
447 $xt = "xt"; # Refuse to overwrite an existing file
448 } else {
449 $xt = "wt"; # 'x' is not available prior to PHP 4.3.2. We did check above, but race conditions blah blah
450 }
451 $f = fopen( "LocalSettings.php", $xt );
452
453 if( $f == false ) {
454 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" .
455 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
456 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
457 }
458 fwrite( $f, $localSettings );
459 fclose( $f );
460
461 print "<p>Success! Move the LocalSettings.php file into the parent directory, then follow
462 <a href='{$conf->ScriptPath}/index.php'>this link</a> to your wiki.</p>\n";
463
464 } while( false );
465 }
466 ?>
467 </ul>
468
469
470 <?php
471
472 if( count( $errs ) ) {
473 /* Display options form */
474
475 if( $conf->posted ) {
476 echo "<p class='error'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
477 }
478 ?>
479
480 <form name="config" method="post">
481
482
483 <h2>Site config</h2>
484
485 <dl class="setup">
486 <dd>
487 <?php
488 aField( $conf, "Sitename", "Site name:" );
489 ?>
490 </dd>
491 <dt>
492 Your site name should be a relatively short word. It'll appear as the namespace
493 name for 'meta' pages as well as throughout the user interface. Good site names
494 are things like "<a href="http://www.wikipedia.org/">Wikipedia</a>" and
495 "<a href="http://openfacts.berlios.de/">OpenFacts</a>"; avoid punctuation,
496 which may cause problems.
497 </dt>
498
499 <dd>
500 <?php
501 aField( $conf, "EmergencyContact", "Contact e-mail" );
502 ?>
503 </dd>
504 <dt>
505 This will be used as the return address for password reminders and
506 may be displayed in some error conditions so visitors can get in
507 touch with you.
508 </dt>
509
510 <dd>
511 <label for="LanguageCode">Language</label>
512 <select id="LanguageCode" name="LanguageCode">
513 <?php
514 $list = getLanguageList();
515 foreach( $list as $code => $name ) {
516 $sel = ($code == $conf->LanguageCode) ? "selected" : "";
517 echo "\t\t<option value=\"$code\" $sel>$name</option>\n";
518 }
519 ?>
520 </select>
521 </dd>
522 <dt>
523 You may select the language for the user interface of the wiki...
524 Some localizations are less complete than others. This also controls
525 the character encoding; Unicode is more flexible, but Latin-1 may be
526 more compatible with older browsers for some languages. Unicode will
527 be used where not specified otherwise.
528 </dt>
529
530 <dd>
531 <?php aField( $conf, "SysopName", "Sysop account name:", "" ) ?>
532 </dd>
533 <dd>
534 <?php aField( $conf, "SysopPass", "password:", "password" ) ?>
535 </dd>
536 <dd>
537 <?php aField( $conf, "SysopPass2", "again:", "password" ) ?>
538 </dd>
539 <dt>
540 A sysop user account can lock or delete pages, block problematic IP
541 addresses from editing, and other maintenance tasks. If creating a new
542 wiki database, a sysop account will be created with the given name
543 and password.
544 </dt>
545 </dl>
546
547 <h2>Database config</h2>
548
549 <dl class="setup">
550 <dd><?php
551 aField( $conf, "DBserver", "MySQL server" );
552 ?></dd>
553 <dt>
554 If your database server isn't on your web server, enter the name
555 or IP address here.
556 </dt>
557
558 <dd><?php
559 aField( $conf, "DBname", "Database name" );
560 ?></dd>
561 <dd><?php
562 aField( $conf, "DBuser", "DB username" );
563 ?></dd>
564 <dd><?php
565 aField( $conf, "DBpassword", "DB password", "password" );
566 ?></dd>
567 <dd><?php
568 aField( $conf, "DBpassword2", "again", "password" );
569 ?></dd>
570 <dt>
571 If you only have a single user account and database available,
572 enter those here. If you have database root access (see below)
573 you can specify new accounts/databases to be created.
574 </dt>
575
576
577 <dd>
578 <?php
579 aField( $conf, "RootPW", "DB root password", "password" );
580 ?>
581 </dd>
582 <dt>
583 You will only need this if the database and/or user account
584 above don't already exist.
585 Do <em>not</em> type in your machine's root password! MySQL
586 has its own "root" user with a separate password. (It might
587 even be blank, depending on your configuration.)
588 </dt>
589
590 <dd>
591 <label>&nbsp;</label>
592 <input type="submit" value="Install!" />
593 </dd>
594 </dl>
595
596
597 </form>
598
599 <?php
600 }
601
602 /* -------------------------------------------------------------------------------------- */
603
604 function writeAdminSettings( $conf ) {
605 return "
606 \$wgDBadminuser = \"{$conf->DBadminuser}\";
607 \$wgDBadminpassword = \"{$conf->DBadminpassword}\";
608 ";
609 }
610
611 function writeLocalSettings( $conf ) {
612 $conf->DBmysql4 = @$conf->DBmysql4 ? 'true' : 'false';
613 $conf->UseImageResize = $conf->UseImageResize ? 'true' : 'false';
614 $conf->PasswordSender = $conf->EmergencyContact;
615 if( $conf->LanguageCode == "en-utf8" ) {
616 $conf->LanguageCode = "en";
617 $conf->Encoding = "UTF-8";
618 }
619 $zlib = ($conf->zlib ? "" : "# ");
620 $magic = ($conf->ImageMagick ? "" : "# ");
621 $convert = ($conf->ImageMagick ? $conf->ImageMagick : "/usr/bin/convert" );
622 $pretty = ($conf->prettyURLs ? "" : "# ");
623 $ugly = ($conf->prettyURLs ? "# " : "");
624 $proxyKey = Parser::getRandomString() . Parser::getRandomString();
625
626 $sep = (DIRECTORY_SEPARATOR == "\\") ? ";" : ":";
627 return "
628 # This file was automatically generated by the MediaWiki installer.
629 # If you make manual changes, please keep track in case you need to
630 # recreate them later.
631
632 \$IP = \"{$conf->IP}\";
633 ini_set( \"include_path\", \"\$IP/includes$sep\$IP/languages$sep\" . ini_get(\"include_path\") );
634 include_once( \"DefaultSettings.php\" );
635
636 if( \$wgCommandLineMode ) {
637 die( \"Can't use command-line utils with in-place install yet, sorry.\" );
638 } else {
639 ## Compress output if the browser supports it
640 {$zlib}if( !ini_get( 'zlib.output_compression' ) ) ob_start( 'ob_gzhandler' );
641 }
642
643 \$wgSitename = \"{$conf->Sitename}\";
644
645 \$wgScriptPath = \"{$conf->ScriptPath}\";
646 \$wgScript = \"\$wgScriptPath/index.php\";
647 \$wgRedirectScript = \"\$wgScriptPath/redirect.php\";
648
649 ## If using PHP as a CGI module, use the ugly URLs
650 {$pretty}\$wgArticlePath = \"\$wgScript/\$1\";
651 {$ugly}\$wgArticlePath = \"\$wgScript?title=\$1\";
652
653 \$wgStyleSheetPath = \"\$wgScriptPath/stylesheets\";
654 \$wgStyleSheetDirectory = \"\$IP/stylesheets\";
655
656 \$wgUploadPath = \"\$wgScriptPath/images\";
657 \$wgUploadDirectory = \"\$IP/images\";
658 \$wgLogo = \"\$wgUploadPath/wiki.png\";
659
660 \$wgEmergencyContact = \"{$conf->EmergencyContact}\";
661 \$wgPasswordSender = \"{$conf->PasswordSender}\";
662
663 \$wgDBserver = \"{$conf->DBserver}\";
664 \$wgDBname = \"{$conf->DBname}\";
665 \$wgDBuser = \"{$conf->DBuser}\";
666 \$wgDBpassword = \"{$conf->DBpassword}\";
667
668 ## To allow SQL queries through the wiki's Special:Askaql page,
669 ## uncomment the next lines. THIS IS VERY INSECURE. If you want
670 ## to allow semipublic read-only SQL access for your sysops,
671 ## you should define a MySQL user with limited privileges.
672 ## See MySQL docs: http://www.mysql.com/doc/en/GRANT.html
673 #
674 # \$wgAllowSysopQueries = true;
675 # \$wgDBsqluser = \"sqluser\";
676 # \$wgDBsqlpassword = \"sqlpass\";
677
678 \$wgDBmysql4 = \$wgEnablePersistentLC = {$conf->DBmysql4};
679
680 ## To enable image uploads, make sure the 'images' directory
681 ## is writable, then uncomment this:
682 # \$wgDisableUploads = false;
683 \$wgUseImageResize = {$conf->UseImageResize};
684 {$magic}\$wgUseImageMagick = true;
685 {$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
686
687 ## If you have the appropriate support software installed
688 ## you can enable inline LaTeX equations:
689 # \$wgUseTeX = true;
690 \$wgMathPath = \"{\$wgUploadPath}/math\";
691 \$wgMathDirectory = \"{\$wgUploadDirectory}/math\";
692 \$wgTmpDirectory = \"{\$wgUploadDirectory}/tmp\";
693
694 ## Experimental layout template subsystems
695 \$wgUsePHPTal = false;
696 \$wgUseSmarty = false;
697 if ( \$wgUsePHPTal ) {
698 ini_set( \"include_path\", \"\$IP/PHPTAL-NP-0.7.0/libs$sep\" . ini_get(\"include_path\") );
699 }
700 if ( \$wgUseSmarty ) {
701 ini_set( \"include_path\", \"\$IP/Smarty-2.6.2/libs$sep\" . ini_get(\"include_path\") );
702 }
703
704 \$wgLocalInterwiki = \$wgSitename;
705
706 \$wgLanguageCode = \"{$conf->LanguageCode}\";
707 " . ($conf->Encoding ? "\$wgInputEncoding = \$wgOutputEncoding = \"{$conf->Encoding}\";" : "" ) . "
708 \$wgProxyKey = $proxyKey;
709
710 ";
711 }
712
713 function dieout( $text ) {
714 die( $text . "\n\n</body>\n</html>" );
715 }
716
717 function importPost( $name, $default = "" ) {
718 if( isset( $_POST[$name] ) ) {
719 return $_POST[$name];
720 } else {
721 return $default;
722 }
723 }
724
725 function aField( &$conf, $field, $text, $type = "" ) {
726 if( $type != "" ) $type = "type=\"$type\"";
727 echo "\t\t<label for=\"$field\">$text</label>\n";
728 echo "\t\t<input $type name=\"$field\" id=\"$field\" value=\"";
729 echo htmlspecialchars( $conf->$field );
730 echo "\" />\n";
731
732 global $errs;
733 if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n";
734 }
735
736 function getLanguageList() {
737 global $wgLanguageNames;
738 if( !isset( $wgLanguageNames ) ) {
739 $wgLanguageCode = "xxx";
740 function wfLocalUrl( $x ) { return $x; }
741 function wfLocalUrlE( $x ) { return $x; }
742 include( "../languages/Language.php" );
743 }
744
745 $codes = array();
746 $latin1 = array( "da", "de", "en", "es", "nl", "sv" );
747
748 $d = opendir( "../languages" );
749 while( false !== ($f = readdir( $d ) ) ) {
750 if( preg_match( '/Language([A-Z][a-z]+)\.php$/', $f, $m ) ) {
751 $code = strtolower( $m[1] );
752 $codes[$code] = "$code - " . $wgLanguageNames[$code];
753 if( in_array( $code, $latin1 ) ) {
754 $codes[$code] .= " - Latin-1";
755 }
756 }
757 }
758 $codes["en-utf8"] = "en - English - Unicode";
759 closedir( $d );
760 ksort( $codes );
761 return $codes;
762 }
763
764 ?>
765
766 </body>
767 </html>