* user css/js preview
[mediawiki.git] / config / index.php
bloba883d49db7eca4ab82473eab3dbc7b97b139c62c
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.
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.
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
21 header( "Content-type: text/html; charset=utf-8" );
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;
42 dl.setup dd {
43 margin-left: 0;
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;
53 dl.setup dt {
54 clear: left;
55 font-size: 0.8em;
56 margin-left: 10em;
57 /* margin-right: 200px; */
58 margin-bottom: 2em;
60 .error {
61 color: red;
63 ul.plain {
64 list-style: none;
65 clear: both;
66 margin-left: 12em;
68 </style>
69 </head>
71 <body>
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>
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>
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>
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>
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>
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>
106 <?php
108 $IP = ".."; # Just to suppress notices, not for anything useful
109 define( "MEDIAWIKI", true );
110 define( "MEDIAWIKI_INSTALL", true );
111 require( "../includes/DefaultSettings.php" );
114 <h1>MediaWiki <?php print $wgVersion ?> installation</h1>
117 <?php
119 /* Check for existing configurations and bug out! */
121 if( file_exists( "../LocalSettings.php" ) || file_exists( "../AdminSettings.php" ) ) {
122 dieout( "<h2>Wiki is configured.</h2>
124 <p>Already configured... <a href='../index.php'>return to the wiki</a>.</p>
126 <p>(You should probably remove this directory for added security.)</p>" );
129 if( file_exists( "./LocalSettings.php" ) || file_exists( "./AdminSettings.php" ) ) {
130 dieout( "<h2>You're configured!</h2>
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>" );
137 if( !is_writable( "." ) ) {
138 dieout( "<h2>Can't write config file, aborting</h2>
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>
145 <p>To make the directory writable on a Unix/Linux system:</p>
147 <pre>
148 cd <i>/path/to/wiki</i>
149 chmod a+w config
150 </pre>" );
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 */
166 function getSitename() { return $this->getEncoded( $this->Sitename ); }
167 function getSysopName() { return $this->getEncoded( $this->SysopName ); }
168 function getSysopPass() { return $this->getEncoded( $this->SysopPass ); }
173 <p><i>Please include all of the lines below when reporting installation problems.</i></p>
175 <h2>Checking environment...</h2>
176 <ul>
177 <?php
178 $endl = "
180 $conf = new ConfigData;
182 install_version_checks();
183 print "<li>PHP " . phpversion() . " ok</li>\n";
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>";
202 print "</li>\n";
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";
211 $conf->ImageMagick = false;
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;
226 if( !$conf->ImageMagick ) {
227 print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n";
231 $conf->UseImageResize = $conf->HaveGD || $conf->ImageMagick;
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";
240 @$oldpath = ini_set( "include_path", ini_get( "include_path" ) );
241 if( empty( $oldpath ) ) {
242 print "<li>Can't set <tt>include_path</tt>; new template layout will be disabled.</li>\n";
245 # $conf->ScriptPath = "/~brion/inplace";
246 $conf->ScriptPath = preg_replace( '{^(.*)/config.*$}', '$1', $_SERVER["REQUEST_URI"] );
247 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath ) . "</tt></li>\n";
249 $conf->posted = ($_SERVER["REQUEST_METHOD"] == "POST");
251 $conf->Sitename = ucfirst( importPost( "Sitename", "" ) );
252 $conf->EmergencyContact = importPost( "EmergencyContact", $_SERVER["SERVER_ADMIN"] );
253 $conf->DBserver = importPost( "DBserver", "localhost" );
254 $conf->DBname = importPost( "DBname", "wikidb" );
255 $conf->DBuser = importPost( "DBuser", "wikiuser" );
256 $conf->DBpassword = importPost( "DBpassword" );
257 $conf->DBpassword2 = importPost( "DBpassword2" );
258 $conf->RootPW = importPost( "RootPW" );
259 $conf->LanguageCode = importPost( "LanguageCode", "en-utf8" );
260 $conf->SysopName = importPost( "SysopName", "WikiSysop" );
261 $conf->SysopPass = importPost( "SysopPass" );
262 $conf->SysopPass2 = importPost( "SysopPass2" );
264 /* Check for validity */
265 $errs = array();
267 if( $conf->Sitename == "" || $conf->Sitename == "MediaWiki" || $conf->Sitename == "Mediawiki" ) {
268 $errs["Sitename"] = "Must not be blank or \"MediaWiki\".";
270 if( $conf->DBpassword == "" ) {
271 $errs["DBpassword"] = "Must not be blank";
273 if( $conf->DBpassword != $conf->DBpassword2 ) {
274 $errs["DBpassword2"] = "Passwords don't match!";
277 if( $conf->SysopPass == "" ) {
278 $errs["SysopPass"] = "Must not be blank";
280 if( $conf->SysopPass != $conf->SysopPass2 ) {
281 $errs["SysopPass2"] = "Passwords don't match!";
284 $conf->License = importPost( "License", "none" );
285 if( $conf->License == "gfdl" ) {
286 $conf->RightsUrl = "http://www.gnu.org/copyleft/fdl.html";
287 $conf->RightsText = "GNU Free Documentation License 1.2";
288 $conf->RightsCode = "gfdl";
289 $conf->RightsIcon = "{$conf->ScriptPath}/stylesheets/images/gnu-fdl.png";
290 } elseif( $conf->License == "none" ) {
291 $conf->RightsUrl = $conf->RightsText = $conf->RightsCode = $conf->RightsIcon = "";
292 } else {
293 $conf->RightsUrl = importPost( "RightsUrl", "" );
294 $conf->RightsText = importPost( "RightsText", "" );
295 $conf->RightsCode = importPost( "RightsCode", "" );
296 $conf->RightsIcon = importPost( "RightsIcon", "" );
299 if( $conf->posted && ( 0 == count( $errs ) ) ) {
300 do { /* So we can 'continue' to end prematurely */
301 $conf->Root = ($conf->RootPW != "");
303 /* Load up the settings and get installin' */
304 $local = writeLocalSettings( $conf );
305 $wgCommandLineMode = false;
306 chdir( ".." );
307 eval($local);
308 $wgDBadminuser = $wgDBuser;
309 $wgDBadminpassword = $wgDBpassword;
310 $wgCommandLineMode = true;
311 $wgUseDatabaseMessages = false; /* FIXME: For database failure */
312 require_once( "includes/Setup.php" );
313 chdir( "config" );
315 require_once( "../maintenance/InitialiseMessages.inc" );
317 $wgTitle = Title::newFromText( "Installation script" );
318 $wgDatabase = Database::newFromParams( $wgDBserver, "root", $conf->RootPW, "", 1 );
319 $wgDatabase->mIgnoreErrors = true;
321 @$myver = mysql_get_server_info( $wgDatabase->mConn );
322 if( $myver ) {
323 $conf->Root = true;
324 print "<li>Connected as root (automatic)</li>\n";
325 } else {
326 print "<li>MySQL error " . ($err = mysql_errno() ) .
327 ": " . htmlspecialchars( mysql_error() );
328 $ok = false;
329 switch( $err ) {
330 case 1045:
331 if( $conf->Root ) {
332 $errs["RootPW"] = "Check password";
333 } else {
334 print "<li>Trying regular user...\n";
335 /* Try the regular user... */
336 $wgDatabase = Database::newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, "", 1 );
337 $wgDatabase->isOpen();
338 $wgDatabase->mIgnoreErrors = true;
339 @$myver = mysql_get_server_info( $wgDatabase->mConn );
340 if( !$myver ) {
341 $errs["DBuser"] = "Check name/pass";
342 $errs["DBpassword"] = "or enter root";
343 $errs["DBpassword2"] = "password below";
344 $errs["RootPW"] = "Got root?";
345 print " need password.</li>\n";
346 } else {
347 $conf->Root = false;
348 $conf->RootPW = "";
349 print " ok.</li>\n";
350 # And keep going...
351 $ok = true;
353 break;
355 case 2002:
356 case 2003:
357 $errs["DBserver"] = "Connection failed";
358 break;
359 default:
360 $errs["DBserver"] = "Couldn't connect to database";
361 break;
363 if( !$ok ) continue;
366 if ( !$wgDatabase->isOpen() ) {
367 $errs["DBserver"] = "Couldn't connect to database";
368 continue;
371 print "<li>Connected to database... $myver";
372 if( version_compare( $myver, "4.0.0" ) >= 0 ) {
373 print "; enabling MySQL 4 enhancements";
374 $conf->DBmysql4 = true;
375 $local = writeLocalSettings( $conf );
377 print "</li>\n";
379 @$sel = mysql_select_db( $wgDBname, $wgDatabase->mConn );
380 if( $sel ) {
381 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
382 } else {
383 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
384 if( !$res ) {
385 print "<li>Couldn't create database <tt>" .
386 htmlspecialchars( $wgDBname ) .
387 "</tt>; try with root access or check your username/pass.</li>\n";
388 $errs["RootPW"] = "&lt;- Enter";
389 continue;
391 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
394 $wgDatabase->selectDB( $wgDBname );
396 if( $wgDatabase->tableExists( "cur" ) ) {
397 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n<pre>";
399 chdir( ".." );
400 flush();
401 do_ipblocks_update(); flush();
402 do_interwiki_update(); flush();
403 do_index_update(); flush();
404 do_linkscc_update(); flush();
405 do_hitcounter_update(); flush();
406 do_recentchanges_update(); flush();
407 echo "FIXME: need the link table change here\n";
408 do_user_real_name_update(); flush();
409 do_querycache_update(); flush();
410 do_objectcache_update(); flush();
411 initialiseMessages(); flush();
412 chdir( "config" );
414 print "</pre>\n";
415 print "<li>Finished update checks.</li>\n";
416 } else {
417 # FIXME: Check for errors
418 print "<li>Creating tables...";
419 dbsource( "../maintenance/tables.sql", $wgDatabase );
420 dbsource( "../maintenance/interwiki.sql", $wgDatabase );
421 dbsource( "../maintenance/indexes.sql", $wgDatabase );
422 print " done.</li>\n";
424 print "<li>Initializing data...";
425 $wgDatabase->query( "INSERT INTO site_stats (ss_row_id,ss_total_views," .
426 "ss_total_edits,ss_good_articles) VALUES (1,0,0,0)" );
428 if( $conf->SysopName ) {
429 $u = User::newFromName( $conf->getSysopName() );
430 if ( 0 == $u->idForName() ) {
431 $u->addToDatabase();
432 $u->setPassword( $conf->getSysopPass() );
433 $u->addRight( "sysop" );
434 $u->addRight( "bureaucrat" );
435 $u->saveSettings();
436 print "<li>Created sysop account <tt>" .
437 htmlspecialchars( $conf->SysopName ) . "</tt>.</li>\n";
438 } else {
439 print "<li>Could not create user - already exists!</li>\n";
441 } else {
442 print "<li>Skipped sysop account creation, no name given.</li>\n";
445 print "<li>Initialising log pages...";
446 $logs = array(
447 "uploadlogpage" => "uploadlogpagetext",
448 "dellogpage" => "dellogpagetext",
449 "protectlogpage" => "protectlogtext",
450 "blocklogpage" => "blocklogtext"
452 $metaNamespace = Namespace::getWikipedia();
453 $now = wfTimestampNow();
454 $won = wfInvertTimestamp( $now );
455 foreach( $logs as $page => $text ) {
456 $logTitle = wfStrencode( $wgLang->ucfirst( str_replace( " ", "_", wfMsgNoDB( $page ) ) ) );
457 $logText = wfStrencode( wfMsgNoDB( $text ) );
458 $wgDatabase->query( "INSERT INTO cur (cur_namespace,cur_title,cur_text," .
459 "cur_restrictions,cur_timestamp,inverse_timestamp,cur_touched) " .
460 "VALUES ($metaNamespace,'$logTitle','$logText','sysop','$now','$won','$now')" );
462 print "</li>\n";
464 $titleobj = Title::newFromText( wfMsgNoDB( "mainpage" ) );
465 $title = $titleobj->getDBkey();
466 $sql = "INSERT INTO cur (cur_namespace,cur_title,cur_text,cur_timestamp,inverse_timestamp,cur_touched) " .
467 "VALUES (0,'$title','" .
468 wfStrencode( wfMsg( "mainpagetext" ) . "\n\n" . wfMsg( "mainpagedocfooter" ) ) . "','$now','$won','$now')";
469 $wgDatabase->query( $sql, $fname );
471 print "<li><pre>";
472 initialiseMessages();
473 print "</pre></li>\n";
475 if( $conf->Root ) {
476 print "<li>Granting user permissions...</li>\n";
477 dbsource( "../maintenance/users.sql", $wgDatabase );
481 /* Write out the config file now that all is well */
482 print "<p>Creating LocalSettings.php...</p>\n\n";
483 $localSettings = "<" . "?php$endl$local$endl?" . ">";
485 if( version_compare( phpversion(), "4.3.2" ) >= 0 ) {
486 $xt = "xt"; # Refuse to overwrite an existing file
487 } else {
488 $xt = "wt"; # 'x' is not available prior to PHP 4.3.2. We did check above, but race conditions blah blah
490 $f = fopen( "LocalSettings.php", $xt );
492 if( $f == false ) {
493 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" .
494 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
495 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
497 fwrite( $f, $localSettings );
498 fclose( $f );
500 print "<p>Success! Move the LocalSettings.php file into the parent directory, then follow
501 <a href='{$conf->ScriptPath}/index.php'>this link</a> to your wiki.</p>\n";
503 } while( false );
506 </ul>
509 <?php
511 if( count( $errs ) ) {
512 /* Display options form */
514 if( $conf->posted ) {
515 echo "<p class='error'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
519 <form name="config" method="post">
522 <h2>Site config</h2>
524 <dl class="setup">
525 <dd>
526 <?php
527 aField( $conf, "Sitename", "Site name:" );
529 </dd>
530 <dt>
531 Your site name should be a relatively short word. It'll appear as the namespace
532 name for 'meta' pages as well as throughout the user interface. Good site names
533 are things like "<a href="http://www.wikipedia.org/">Wikipedia</a>" and
534 "<a href="http://openfacts.berlios.de/">OpenFacts</a>"; avoid punctuation,
535 which may cause problems.
536 </dt>
538 <dd>
539 <?php
540 aField( $conf, "EmergencyContact", "Contact e-mail" );
542 </dd>
543 <dt>
544 This will be used as the return address for password reminders and
545 may be displayed in some error conditions so visitors can get in
546 touch with you.
547 </dt>
549 <dd>
550 <label class='column' for="LanguageCode">Language</label>
551 <select id="LanguageCode" name="LanguageCode">
552 <?php
553 $list = getLanguageList();
554 foreach( $list as $code => $name ) {
555 $sel = ($code == $conf->LanguageCode) ? "selected" : "";
556 echo "\t\t<option value=\"$code\" $sel>$name</option>\n";
559 </select>
560 </dd>
561 <dt>
562 You may select the language for the user interface of the wiki...
563 Some localizations are less complete than others. This also controls
564 the character encoding; Unicode is more flexible, but Latin-1 may be
565 more compatible with older browsers for some languages. Unicode will
566 be used where not specified otherwise.
567 </dt>
569 <dd>
570 <label class='column'>Copyright/license metadata</label>
571 <div>Select one:</div>
573 <ul class="plain">
574 <li><?php aField( $conf, "License", "no license metadata", "radio", "none" ); ?></li>
575 <li><?php aField( $conf, "License", "GNU Free Documentation License 1.2 (Wikipedia-compatible)", "radio", "gfdl" ); ?></li>
576 <li><?php
577 aField( $conf, "License", "a Creative Commons license...", "radio", "cc" );
578 $partner = "MediaWiki";
579 $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/index.php?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
580 $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" );
581 $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" );
582 print "<a href=\"$ccApp\">choose</a>";
583 ?></li>
584 <li><?php aField( $conf, "RightsUrl", $conf->RightsUrl, "hidden" ); ?></li>
585 <li><?php aField( $conf, "RightsText", $conf->RightsText, "hidden" ); ?></li>
586 <li><?php aField( $conf, "RightsCode", $conf->RightsCode, "hidden" ); ?></li>
587 <li><?php aField( $conf, "RightsIcon", $conf->RightsIcon, "hidden" ); ?></li>
588 </ul>
589 </dd>
590 <dt>
591 MediaWiki can include a basic license notice, icon, and machine-reable
592 copyright metadata if your wiki's content is to be licensed under
593 the GNU FDL or a Creative Commons license. If you're not sure, leave
594 it at "none".
595 </dt>
598 <dd>
599 <?php aField( $conf, "SysopName", "Sysop account name:", "" ) ?>
600 </dd>
601 <dd>
602 <?php aField( $conf, "SysopPass", "password:", "password" ) ?>
603 </dd>
604 <dd>
605 <?php aField( $conf, "SysopPass2", "again:", "password" ) ?>
606 </dd>
607 <dt>
608 A sysop user account can lock or delete pages, block problematic IP
609 addresses from editing, and other maintenance tasks. If creating a new
610 wiki database, a sysop account will be created with the given name
611 and password.
612 </dt>
613 </dl>
615 <h2>Database config</h2>
617 <dl class="setup">
618 <dd><?php
619 aField( $conf, "DBserver", "MySQL server" );
620 ?></dd>
621 <dt>
622 If your database server isn't on your web server, enter the name
623 or IP address here.
624 </dt>
626 <dd><?php
627 aField( $conf, "DBname", "Database name" );
628 ?></dd>
629 <dd><?php
630 aField( $conf, "DBuser", "DB username" );
631 ?></dd>
632 <dd><?php
633 aField( $conf, "DBpassword", "DB password", "password" );
634 ?></dd>
635 <dd><?php
636 aField( $conf, "DBpassword2", "again", "password" );
637 ?></dd>
638 <dt>
639 If you only have a single user account and database available,
640 enter those here. If you have database root access (see below)
641 you can specify new accounts/databases to be created.
642 </dt>
645 <dd>
646 <?php
647 aField( $conf, "RootPW", "DB root password", "password" );
649 </dd>
650 <dt>
651 You will only need this if the database and/or user account
652 above don't already exist.
653 Do <em>not</em> type in your machine's root password! MySQL
654 has its own "root" user with a separate password. (It might
655 even be blank, depending on your configuration.)
656 </dt>
658 <dd>
659 <label class='column'>&nbsp;</label>
660 <input type="submit" value="Install!" />
661 </dd>
662 </dl>
665 </form>
667 <?php
670 /* -------------------------------------------------------------------------------------- */
672 function writeAdminSettings( $conf ) {
673 return "
674 \$wgDBadminuser = \"{$conf->DBadminuser}\";
675 \$wgDBadminpassword = \"{$conf->DBadminpassword}\";
679 function writeLocalSettings( $conf ) {
680 $conf->DBmysql4 = @$conf->DBmysql4 ? 'true' : 'false';
681 $conf->UseImageResize = $conf->UseImageResize ? 'true' : 'false';
682 $conf->PasswordSender = $conf->EmergencyContact;
683 if( $conf->LanguageCode == "en-utf8" ) {
684 $conf->LanguageCode = "en";
685 $conf->Encoding = "UTF-8";
687 $zlib = ($conf->zlib ? "" : "# ");
688 $magic = ($conf->ImageMagick ? "" : "# ");
689 $convert = ($conf->ImageMagick ? $conf->ImageMagick : "/usr/bin/convert" );
690 $pretty = ($conf->prettyURLs ? "" : "# ");
691 $ugly = ($conf->prettyURLs ? "# " : "");
692 $rights = ($conf->RightsUrl) ? "" : "# ";
694 # $proxyKey = Parser::getRandomString() . Parser::getRandomString();
696 $sep = (DIRECTORY_SEPARATOR == "\\") ? ";" : ":";
697 return "
698 # This file was automatically generated by the MediaWiki installer.
699 # If you make manual changes, please keep track in case you need to
700 # recreate them later.
702 \$IP = \"{$conf->IP}\";
703 require_once( \"includes/DefaultSettings.php\" );
705 if ( \$wgCommandLineMode ) {
706 if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
707 die( \"This script must be run from the command line\\n\" );
709 } else {
710 ## Compress output if the browser supports it
711 {$zlib}if( !ini_get( 'zlib.output_compression' ) ) ob_start( 'ob_gzhandler' );
714 \$wgSitename = \"{$conf->Sitename}\";
716 \$wgScriptPath = \"{$conf->ScriptPath}\";
717 \$wgScript = \"\$wgScriptPath/index.php\";
718 \$wgRedirectScript = \"\$wgScriptPath/redirect.php\";
720 ## If using PHP as a CGI module, use the ugly URLs
721 {$pretty}\$wgArticlePath = \"\$wgScript/\$1\";
722 {$ugly}\$wgArticlePath = \"\$wgScript?title=\$1\";
724 \$wgStylePath = \"\$wgScriptPath/stylesheets\";
725 \$wgStyleDirectory = \"\$IP/stylesheets\";
726 \$wgLogo = \"\$wgStylePath/images/wiki.png\";
728 \$wgUploadPath = \"\$wgScriptPath/images\";
729 \$wgUploadDirectory = \"\$IP/images\";
731 \$wgEmergencyContact = \"{$conf->EmergencyContact}\";
732 \$wgPasswordSender = \"{$conf->PasswordSender}\";
734 \$wgDBserver = \"{$conf->DBserver}\";
735 \$wgDBname = \"{$conf->DBname}\";
736 \$wgDBuser = \"{$conf->DBuser}\";
737 \$wgDBpassword = \"{$conf->DBpassword}\";
739 ## To allow SQL queries through the wiki's Special:Askaql page,
740 ## uncomment the next lines. THIS IS VERY INSECURE. If you want
741 ## to allow semipublic read-only SQL access for your sysops,
742 ## you should define a MySQL user with limited privileges.
743 ## See MySQL docs: http://www.mysql.com/doc/en/GRANT.html
745 # \$wgAllowSysopQueries = true;
746 # \$wgDBsqluser = \"sqluser\";
747 # \$wgDBsqlpassword = \"sqlpass\";
749 \$wgDBmysql4 = \$wgEnablePersistentLC = {$conf->DBmysql4};
751 ## To enable image uploads, make sure the 'images' directory
752 ## is writable, then uncomment this:
753 # \$wgDisableUploads = false;
754 \$wgUseImageResize = {$conf->UseImageResize};
755 {$magic}\$wgUseImageMagick = true;
756 {$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
758 ## If you have the appropriate support software installed
759 ## you can enable inline LaTeX equations:
760 # \$wgUseTeX = true;
761 \$wgMathPath = \"{\$wgUploadPath}/math\";
762 \$wgMathDirectory = \"{\$wgUploadDirectory}/math\";
763 \$wgTmpDirectory = \"{\$wgUploadDirectory}/tmp\";
765 \$wgLocalInterwiki = \$wgSitename;
767 \$wgLanguageCode = \"{$conf->LanguageCode}\";
768 " . ($conf->Encoding ? "\$wgInputEncoding = \$wgOutputEncoding = \"{$conf->Encoding}\";" : "" ) . "
770 ## Default skin: you can change the default skin. Use the internal symbolic
771 ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook':
772 # \$wgDefaultSkin = 'monobook';
774 ## This is incomplete, ignore it:
775 #\$wgProxyKey = $proxyKey;
777 ## For attaching licensing metadata to pages, and displaying an
778 ## appropriate copyright notice / icon. GNU Free Documentation
779 ## License and Creative Commons licenses are supported so far.
780 {$rights}\$wgEnableCreativeCommonsRdf = true;
781 \$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright
782 \$wgRightsUrl = \"{$conf->RightsUrl}\";
783 \$wgRightsText = \"{$conf->RightsText}\";
784 \$wgRightsIcon = \"{$conf->RightsIcon}\";
785 # \$wgRightsCode = \"{$conf->RightsCode}\"; # Not yet used
789 function dieout( $text ) {
790 die( $text . "\n\n</body>\n</html>" );
793 function importPost( $name, $default = "" ) {
794 if( isset( $_REQUEST[$name] ) ) {
795 return $_REQUEST[$name];
796 } else {
797 return $default;
801 function aField( &$conf, $field, $text, $type = "", $value = "" ) {
802 if( $type != "" ) {
803 $xtype = "type=\"$type\"";
804 } else {
805 $xtype = "";
808 if(!(isset($id)) or ($id == "") ) $id = $field;
809 $nolabel = ($type == "radio") || ($type == "hidden");
810 if( $nolabel ) {
811 echo "\t\t<label>";
812 } else {
813 echo "\t\t<label class='column' for=\"$id\">$text</label>\n";
816 if( $type == "radio" && $value == $conf->$field ) {
817 $checked = "checked='checked'";
818 } else {
819 $checked = "";
821 echo "\t\t<input $xtype name=\"$field\" id=\"$id\" $checked value=\"";
822 if( $type == "radio" ) {
823 echo htmlspecialchars( $value );
824 } else {
825 echo htmlspecialchars( $conf->$field );
827 echo "\" />\n";
828 if( $nolabel ) {
829 echo " $text</label>\n";
832 global $errs;
833 if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n";
836 function getLanguageList() {
837 global $wgLanguageNames;
838 if( !isset( $wgLanguageNames ) ) {
839 $wgLanguageCode = "xxx";
840 function wfLocalUrl( $x ) { return $x; }
841 function wfLocalUrlE( $x ) { return $x; }
842 require( "../languages/Language.php" );
845 $codes = array();
846 $latin1 = array( "da", "de", "en", "es", "nl", "sv" );
848 $d = opendir( "../languages" );
849 while( false !== ($f = readdir( $d ) ) ) {
850 if( preg_match( '/Language([A-Z][a-z]+)\.php$/', $f, $m ) ) {
851 $code = strtolower( $m[1] );
852 $codes[$code] = "$code - " . $wgLanguageNames[$code];
853 if( in_array( $code, $latin1 ) ) {
854 $codes[$code] .= " - Latin-1";
858 $codes["en-utf8"] = "en - English - Unicode";
859 closedir( $d );
860 ksort( $codes );
861 return $codes;
866 </body>
867 </html>