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