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