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