2 # MediaWiki web-based config/installation
3 # Copyright (C) 2004 Brion Vibber <brion@pobox.com>
4 # http://www.mediawiki.org/
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">
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">
35 background
-color
: #eee;
37 border
: solid
1px
#444;
57 /* margin-right: 200px; */
70 <a href
="http://www.mediawiki.org/"><img
71 src
="../images/wiki.png" width
="135" height
="135" alt
="" border
="0" /></a
>
74 <b
><a href
="http://www.mediawiki.org/">MediaWiki
</a
></b
> is
75 Copyright (C
) 2001-2004 by Magnus Manske
, Brion Vibber
, Lee Daniel Crocker
,
76 Tim Starling
, Erik M
ö
;ller
, and others
.</p
>
79 <li
><a href
="../README">Readme
</a
></li
>
80 <li
><a href
="../RELEASE-NOTES">Release notes
</a
></li
>
81 <li
><a href
="../docs/">doc
/</a
></li
>
82 <li
><a href
="http://meta.wikipedia.org/wiki/MediaWiki_User's_Guide">User
's Guide</a></li>
85 <p>This program is free software; you can redistribute it and/or modify
86 it under the terms of the GNU General Public License as published by
87 the Free Software Foundation; either version 2 of the License, or
88 (at your option) any later version.</p>
90 <p>This progarm is distributed in the hope that it will be useful,
91 but WITHOUT ANY WARRANTY; without even the implied warranty of
92 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
93 GNU General Public License for more details.</p>
95 <p>You should have received <a href="../COPYING">a copy of the GNU General Public License</a>
96 along with this program; if not, write to the Free Software
97 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
98 or <a href="http://www.gnu.org/copyleft/gpl.html">read it online</a></p>
102 include( "../includes/DefaultSettings.php" );
105 <h1>MediaWiki <?php print $wgVersion ?> installation</h1>
110 /* Check for existing configurations and bug out! */
112 if( file_exists( "../LocalSettings.php" ) || file_exists( "../AdminSettings.php" ) ) {
113 dieout( "<h2>Wiki is configured.</h2>
115 <p>Already configured... <a href='../index
.php
'>return to the wiki</a>.</p>
117 <p>(You should probably remove this directory for added security.)</p>" );
120 if( file_exists( "./LocalSettings.php" ) || file_exists( "./AdminSettings.php" ) ) {
121 dieout( "<h2>You're configured
!</h2
>
123 <p
>Please move
<tt
>LocalSettings
.php
</tt
> to the parent directory
, then
124 <a href
='../index.php'>try out your wiki
</a
>.
125 (You should remove this config directory
for added security once you
're done.)</p>" );
129 include( "../install-utils.inc" );
131 function getEncoded( $data ) {
133 global $wgInputEncoding;
134 if( strcasecmp( $wgInputEncoding, "utf-8" ) == 0 ) {
137 return utf8_decode( $data ); /* to latin1 wikis */
140 function getSitename() { return $this->getEncoded( $this->Sitename ); }
141 function getSysopName() { return $this->getEncoded( $this->SysopName ); }
142 function getSysopPass() { return $this->getEncoded( $this->SysopPass ); }
148 <h2>Checking environment...</h2>
152 $conf = new ConfigData;
154 install_version_checks();
155 print "<li>PHP " . phpversion() . " ok</li>\n";
158 $conf->zlib = function_exists( "gzencode" );
159 $z = $conf->zlib ? "Have" : "No";
160 print "<li>$z zlib support</li>\n";
162 $conf->gd = function_exists( "imagejpeg" );
164 print "<li>Found GD graphics library built-in</li>\n";
166 print "<li>No built-in GD library</li>\n";
169 if( file_exists( "/usr/bin/convert" ) ) {
170 $conf->ImageMagick = "/usr/bin/convert";
171 print "<li>Found ImageMagick: /usr/bin/convert</li>\n";
172 } elseif( file_exists( "/usr/local/bin/convert" ) ) {
173 $conf->ImageMagick = "/usr/local/bin/convert";
174 print "<li>Found ImageMagick: /usr/local/bin/convert</li>\n";
176 $conf->ImageMagick = false;
177 print "<li>No ImageMagick.</li>\n";
181 # $conf->IP = "/Users/brion/Sites/inplace";
183 $conf->IP = getcwd();
185 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP ) . "</tt></li>\n";
187 # $conf->ScriptPath = "/~brion/inplace";
188 $conf->ScriptPath = preg_replace( '{^
(.*)/config
.*$
}', '$1', $_SERVER["REQUEST_URI"] );
189 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath ) . "</tt></li>\n";
191 $conf->posted = ($_SERVER["REQUEST_METHOD"] == "POST");
193 $conf->Sitename = ucfirst( importPost( "Sitename", "" ) );
194 $conf->EmergencyContact = importPost( "EmergencyContact", $_SERVER["SERVER_ADMIN"] );
195 $conf->DBserver = importPost( "DBserver", "localhost" );
196 $conf->DBname = importPost( "DBname", "wikidb" );
197 $conf->DBuser = importPost( "DBuser", "wikiuser" );
198 $conf->DBpassword = importPost( "DBpassword" );
199 $conf->DBpassword2 = importPost( "DBpassword2" );
200 $conf->RootPW = importPost( "RootPW" );
201 $conf->LanguageCode = importPost( "LanguageCode", "en-utf8" );
202 $conf->SysopName = importPost( "SysopName", "WikiSysop" );
203 $conf->SysopPass = importPost( "SysopPass" );
204 $conf->SysopPass2 = importPost( "SysopPass2" );
206 /* Check for validity */
209 if( $conf->Sitename == "" || $conf->Sitename == "MediaWiki" || $conf->Sitename == "Mediawiki" ) {
210 $errs["Sitename"] = "Must not be blank or \"MediaWiki\".";
212 if( $conf->DBpassword == "" ) {
213 $errs["DBpassword"] = "Must not be blank";
215 if( $conf->DBpassword != $conf->DBpassword2 ) {
216 $errs["DBpassword2"] = "Passwords don't match
!";
219 if( $conf->SysopPass == "" ) {
220 $errs["SysopPass
"] = "Must not be blank
";
222 if( $conf->SysopPass != $conf->SysopPass2 ) {
223 $errs["SysopPass2
"] = "Passwords don
't match!";
226 if( $conf->posted && ( 0 == count( $errs ) ) ) {
227 do { /* So we can 'continue' to end prematurely */
228 $conf->Root = ($conf->RootPW != "");
230 /* Load up the settings and get installin' */
231 $local = writeLocalSettings( $conf );
232 $wgCommandLineMode = false;
235 $wgDBadminuser = $wgDBuser;
236 $wgDBadminpassword = $wgDBpassword;
237 $wgCommandLineMode = true;
238 $wgUseDatabaseMessages = false; /* FIXME: For database failure */
239 include_once( "Setup.php" );
242 $wgDatabase = Database
::newFromParams( $wgDBserver, "root", $conf->RootPW
, "", 1 );
244 $wgDatabase = Database
::newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, "", 1 );
246 $wgDatabase->mIgnoreErrors
= true;
248 if ( !$wgDatabase->isOpen() ) {
249 $errs["DBserver"] = "Couldn't connect to database";
253 @$myver = mysql_get_server_info( $wgDatabase->mConn
);
255 print "<li>MySQL error " . ($err = mysql_errno() ) .
256 ": " . htmlspecialchars( mysql_error() );
260 $errs["RootPW"] = "Check password";
262 $errs["DBuser"] = "Check name/pass";
263 $errs["DBpassword"] = "or enter root";
264 $errs["DBpassword2"] = "password below";
265 $errs["RootPW"] = "Got root?";
270 $errs["DBserver"] = "Connection failed";
273 $errs["DBserver"] = "Couldn't connect to database";
277 print "<li>Connected to database... $myver";
278 if( version_compare( $myver, "4.0.0" ) >= 0 ) {
279 print "; enabling MySQL 4 enhancements";
280 $conf->DBmysql4
= true;
281 $local = writeLocalSettings( $conf );
285 @$sel = mysql_select_db( $wgDBname, $wgDatabase->mConn
);
287 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
289 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
291 print "<li>Couldn't create database <tt>" .
292 htmlspecialchars( $wgDBname ) .
293 "</tt>; try with root access or check your username/pass.</li>\n";
294 $errs["RootPW"] = "<- Enter";
297 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
300 $wgDatabase->selectDB( $wgDBname );
302 if( $wgDatabase->tableExists( "cur" ) ) {
303 print "<li>There are already MediaWiki tables in this database. Skipping rest of database setup...</li>\n";
305 # FIXME: Check for errors
306 print "<li>Creating tables...";
307 dbsource( "../maintenance/tables.sql", $wgDatabase );
308 dbsource( "../maintenance/interwiki.sql", $wgDatabase );
309 dbsource( "../maintenance/indexes.sql", $wgDatabase );
310 print " done.</li>\n";
312 print "<li>Initializing data...";
313 $wgDatabase->query( "INSERT INTO site_stats (ss_row_id,ss_total_views," .
314 "ss_total_edits,ss_good_articles) VALUES (1,0,0,0)" );
316 if( $conf->SysopName
) {
317 $u = User
::newFromName( $conf->getSysopName() );
318 if ( 0 == $u->idForName() ) {
320 $u->setPassword( $conf->getSysopPass() );
321 $u->addRight( "sysop" );
322 $u->addRight( "developer" ); /* ?? */
324 print "<li>Created sysop account <tt>" .
325 htmlspecialchars( $conf->SysopName
) . "</tt>.</li>\n";
327 print "<li>Could not create user - already exists!</li>\n";
330 print "<li>Skipped sysop account creation, no name given.</li>\n";
333 # FIXME: Main page, logs
334 # FIXME: Initialize messages
335 print "<li>(NYI: accounts, pages, messages)</li>\n";
338 # Grant user permissions
339 dbsource( "../maintenance/users.sql", $wgDatabase );
343 /* Write out the config file now that all is well */
344 print "<p>Creating LocalSettings.php...</p>\n\n";
345 $f = fopen( "LocalSettings.php", "xt" );
347 dieout( "Couldn't write out LocalSettings.php. Check that the directory permissions are correct and that there isn't already a fiel of that name here." );
349 fwrite( $f, "<" . "?php\n$local\n?" . ">" );
352 print "<p>Success! Move the LocalSettings.php file into the parent directory, then follow
353 <a href='{$conf->ScriptPath}/index.php'>this link</a> to your wiki.</p>\n";
363 if( count( $errs ) ) {
364 /* Display options form */
366 if( $conf->posted
) {
367 echo "<p class='error'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
371 <form name
="config" method
="post">
379 aField( $conf, "Sitename", "Site name:" );
383 Your site name should be a relatively short word
. It
'll appear as the namespace
384 name for 'meta
' pages as well as throughout the user interface. Good site names
385 are things like "<a href="http://www.wikipedia.org/">Wikipedia</a>" and
386 "<a href="http://openfacts.berlios.de/">OpenFacts</a>"; avoid punctuation,
387 which may cause problems.
392 aField( $conf, "EmergencyContact", "Contact e-mail" );
396 This will be used as the return address for password reminders and
397 may be displayed in some error conditions so visitors can get in
402 <label for="LanguageCode">Language</label>
403 <select id="LanguageCode" name="LanguageCode">
405 $list = getLanguageList();
406 foreach( $list as $code => $name ) {
407 $sel = ($code == $conf->LanguageCode) ? "selected" : "";
408 echo "\t\t<option value=\"$code\" $sel>$name</option>\n";
414 You may select the language for the user interface of the wiki...
415 Some localizations are less complete than others. This also controls
416 the character encoding; Unicode is more flexible, but Latin-1 may be
417 more compatible with older browsers for some languages. Unicode will
418 be used where not specified otherwise.
422 <?php aField( $conf, "SysopName", "Sysop account name:", "" ) ?>
425 <?php aField( $conf, "SysopPass", "password:", "password" ) ?>
428 <?php aField( $conf, "SysopPass2", "again:", "password" ) ?>
431 A sysop user account can lock or delete pages, block problematic IP
432 addresses from editing, and other maintenance tasks. If creating a new
433 wiki database, a sysop account will be created with the given name
438 <h2>Database config</h2>
442 aField( $conf, "DBserver", "MySQL server" );
445 If your database server isn't on your web server
, enter the name
450 aField( $conf, "DBname", "Database name" );
453 aField( $conf, "DBuser", "DB username" );
456 aField( $conf, "DBpassword", "DB password", "password" );
459 aField( $conf, "DBpassword2", "again", "password" );
462 If you only have a single user account
and database available
,
463 enter those here
. If you have database root
access (see below
)
464 you can specify
new accounts
/databases to be created
.
470 aField( $conf, "RootPW", "DB root password", "password" );
474 You will only need this
if the database
and/or user account
475 above don
't already exist.
476 Do <em>not</em> type in your machine's root password
! MySQL
477 has its own
"root" user with a separate password
. (It might
478 even be blank
, depending on your configuration
.)
482 <label
> 
;</label
>
483 <input type
="submit" value
="Install!" />
493 /* -------------------------------------------------------------------------------------- */
495 function writeAdminSettings( $conf ) {
497 \$wgDBadminuser = \"{$conf->DBadminuser}\";
498 \$wgDBadminpassword = \"{$conf->DBadminpassword}\";
502 function writeLocalSettings( $conf ) {
503 $conf->DBmysql4
= $conf->DBmysql4 ?
'true' : 'false';
504 $conf->UseImageResize
= $conf->UseImageResize ?
'true' : 'false';
505 $conf->DBsqluser
= $conf->DBuser
;
506 $conf->DBsqlpassword
= $conf->DBpassword
;
507 $conf->PasswordSender
= $conf->EmergencyContact
;
508 if( $conf->LanguageCode
== "en-utf8" ) {
509 $conf->LanguageCode
= "en";
510 $conf->Encoding
= "UTF-8";
513 # This file was automatically generated. Don't touch unless you
514 # know what you're doing; see LocalSettings.sample for an edit-
517 \$IP = \"{$conf->IP}\";
518 ini_set( \"include_path\", \"\$IP/includes:\$IP/languages:\" . ini_get(\"include_path\") );
519 include_once( \"DefaultSettings.php\" );
521 if( \$wgCommandLineMode ) {
522 die( \"Can't use command-line utils with in-place install yet, sorry.\" );
525 \$wgSitename = \"{$conf->Sitename}\";
527 \$wgScriptPath = \"{$conf->ScriptPath}\";
528 \$wgScript = \"\$wgScriptPath/index.php\";
529 \$wgRedirectScript = \"\$wgScriptPath/redirect.php\";
531 \$wgArticlePath = \"\$wgScript?title=\$1\";
532 # \$wgArticlePath = \"\$wgScript/\$1\"; # Prettier if you're setup for it
534 \$wgStyleSheetPath = \"\$wgScriptPath/stylesheets\";
535 \$wgStyleSheetDirectory = \"\$IP/stylesheets\";
537 \$wgUploadPath = \"\$wgScriptPath/images\";
538 \$wgUploadDirectory = \"\$IP/images\";
539 \$wgLogo = \"\$wgUploadPath/wiki.png\";
541 \$wgEmergencyContact = \"{$conf->EmergencyContact}\";
542 \$wgPasswordSender = \"{$conf->PasswordSender}\";
544 \$wgDBserver = \"{$conf->DBserver}\";
545 \$wgDBname = \"{$conf->DBname}\";
546 \$wgDBuser = \"{$conf->DBuser}\";
547 \$wgDBpassword = \"{$conf->DBpassword}\";
548 \$wgDBsqluser = \"{$conf->DBsqluser}\";
549 \$wgDBsqlpassword = \"{$conf->DBsqlpassword}\";
551 \$wgDBmysql4 = \$wgEnablePersistentLC = {$conf->DBmysql4};
553 \$wgUseImageResize = {$conf->UseImageResize};
555 ## If you have the appropriate support software installed
556 ## you can enable inline LaTeX equations:
558 # \$wgMathPath = \"{$wgUploadPath}/math\";
559 # \$wgMathDirectory = \"{$wgUploadDirectory}/math\";
560 # \$wgTmpDirectory = \"{$wgUploadDirectory}/tmp\";
562 \$wgLocalInterwiki = \$wgSitename;
564 \$wgLanguageCode = \"{$conf->LanguageCode}\";
565 " . ($conf->Encoding ?
"\$wgInputEncoding = \$wgOutputEncoding = \"{$conf->Encoding}\";" : "" ) . "
570 function dieout( $text ) {
571 die( $text . "\n\n</body>\n</html>" );
574 function importPost( $name, $default = "" ) {
575 if( isset( $_POST[$name] ) ) {
576 return $_POST[$name];
582 function aField( &$conf, $field, $text, $type = "" ) {
583 if( $type != "" ) $type = "type=\"$type\"";
584 echo "\t\t<label for=\"$field\">$text</label>\n";
585 echo "\t\t<input $type name=\"$field\" id=\"$field\" value=\"";
586 echo htmlspecialchars( $conf->$field );
590 if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n";
593 function getLanguageList() {
594 global $wgLanguageNames;
595 if( !isset( $wgLanguageNames ) ) {
596 $wgLanguageCode = "xxx";
597 function wfLocalUrl( $x ) { return $x; }
598 function wfLocalUrlE( $x ) { return $x; }
599 include( "../languages/Language.php" );
603 $latin1 = array( "da", "de", "en", "es", "fr", "nl", "sv" );
605 $d = opendir( "../languages" );
606 while( false !== ($f = readdir( $d ) ) ) {
607 if( preg_match( '/Language([A-Z][a-z]+)\.php$/', $f, $m ) ) {
608 $code = strtolower( $m[1] );
609 $codes[$code] = "$code - " . $wgLanguageNames[$code];
610 if( in_array( $code, $latin1 ) ) {
611 $codes[$code] .= " - Latin-1";
615 $codes["en-utf8"] = "en - English - Unicode";