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