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