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" );
240 include_once( "../maintenance/InitialiseMessages.inc" );
242 $wgTitle = Title
::newFromText( "Installation script" );
245 $wgDatabase = Database
::newFromParams( $wgDBserver, "root", $conf->RootPW
, "", 1 );
247 $wgDatabase = Database
::newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, "", 1 );
249 $wgDatabase->mIgnoreErrors
= true;
251 if ( !$wgDatabase->isOpen() ) {
252 $errs["DBserver"] = "Couldn't connect to database";
256 @$myver = mysql_get_server_info( $wgDatabase->mConn
);
258 print "<li>MySQL error " . ($err = mysql_errno() ) .
259 ": " . htmlspecialchars( mysql_error() );
263 $errs["RootPW"] = "Check password";
265 $errs["DBuser"] = "Check name/pass";
266 $errs["DBpassword"] = "or enter root";
267 $errs["DBpassword2"] = "password below";
268 $errs["RootPW"] = "Got root?";
273 $errs["DBserver"] = "Connection failed";
276 $errs["DBserver"] = "Couldn't connect to database";
280 print "<li>Connected to database... $myver";
281 if( version_compare( $myver, "4.0.0" ) >= 0 ) {
282 print "; enabling MySQL 4 enhancements";
283 $conf->DBmysql4
= true;
284 $local = writeLocalSettings( $conf );
288 @$sel = mysql_select_db( $wgDBname, $wgDatabase->mConn
);
290 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
292 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
294 print "<li>Couldn't create database <tt>" .
295 htmlspecialchars( $wgDBname ) .
296 "</tt>; try with root access or check your username/pass.</li>\n";
297 $errs["RootPW"] = "<- Enter";
300 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
303 $wgDatabase->selectDB( $wgDBname );
305 if( $wgDatabase->tableExists( "cur" ) ) {
306 print "<li>There are already MediaWiki tables in this database. Skipping rest of database setup...</li>\n";
308 # FIXME: Check for errors
309 print "<li>Creating tables...";
310 dbsource( "../maintenance/tables.sql", $wgDatabase );
311 dbsource( "../maintenance/interwiki.sql", $wgDatabase );
312 dbsource( "../maintenance/indexes.sql", $wgDatabase );
313 print " done.</li>\n";
315 print "<li>Initializing data...";
316 $wgDatabase->query( "INSERT INTO site_stats (ss_row_id,ss_total_views," .
317 "ss_total_edits,ss_good_articles) VALUES (1,0,0,0)" );
319 if( $conf->SysopName
) {
320 $u = User
::newFromName( $conf->getSysopName() );
321 if ( 0 == $u->idForName() ) {
323 $u->setPassword( $conf->getSysopPass() );
324 $u->addRight( "sysop" );
325 $u->addRight( "developer" ); /* ?? */
327 print "<li>Created sysop account <tt>" .
328 htmlspecialchars( $conf->SysopName
) . "</tt>.</li>\n";
330 print "<li>Could not create user - already exists!</li>\n";
333 print "<li>Skipped sysop account creation, no name given.</li>\n";
336 # FIXME: Main page, logs
337 # FIXME: Initialize messages
338 print "<li>(NYI: pages)</li>\n";
341 initialiseMessages();
345 # Grant user permissions
346 dbsource( "../maintenance/users.sql", $wgDatabase );
350 /* Write out the config file now that all is well */
351 print "<p>Creating LocalSettings.php...</p>\n\n";
352 $f = fopen( "LocalSettings.php", "xt" );
354 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." );
356 fwrite( $f, "<" . "?php\n$local\n?" . ">" );
359 print "<p>Success! Move the LocalSettings.php file into the parent directory, then follow
360 <a href='{$conf->ScriptPath}/index.php'>this link</a> to your wiki.</p>\n";
370 if( count( $errs ) ) {
371 /* Display options form */
373 if( $conf->posted
) {
374 echo "<p class='error'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
378 <form name
="config" method
="post">
386 aField( $conf, "Sitename", "Site name:" );
390 Your site name should be a relatively short word
. It
'll appear as the namespace
391 name for 'meta
' pages as well as throughout the user interface. Good site names
392 are things like "<a href="http://www.wikipedia.org/">Wikipedia</a>" and
393 "<a href="http://openfacts.berlios.de/">OpenFacts</a>"; avoid punctuation,
394 which may cause problems.
399 aField( $conf, "EmergencyContact", "Contact e-mail" );
403 This will be used as the return address for password reminders and
404 may be displayed in some error conditions so visitors can get in
409 <label for="LanguageCode">Language</label>
410 <select id="LanguageCode" name="LanguageCode">
412 $list = getLanguageList();
413 foreach( $list as $code => $name ) {
414 $sel = ($code == $conf->LanguageCode) ? "selected" : "";
415 echo "\t\t<option value=\"$code\" $sel>$name</option>\n";
421 You may select the language for the user interface of the wiki...
422 Some localizations are less complete than others. This also controls
423 the character encoding; Unicode is more flexible, but Latin-1 may be
424 more compatible with older browsers for some languages. Unicode will
425 be used where not specified otherwise.
429 <?php aField( $conf, "SysopName", "Sysop account name:", "" ) ?>
432 <?php aField( $conf, "SysopPass", "password:", "password" ) ?>
435 <?php aField( $conf, "SysopPass2", "again:", "password" ) ?>
438 A sysop user account can lock or delete pages, block problematic IP
439 addresses from editing, and other maintenance tasks. If creating a new
440 wiki database, a sysop account will be created with the given name
445 <h2>Database config</h2>
449 aField( $conf, "DBserver", "MySQL server" );
452 If your database server isn't on your web server
, enter the name
457 aField( $conf, "DBname", "Database name" );
460 aField( $conf, "DBuser", "DB username" );
463 aField( $conf, "DBpassword", "DB password", "password" );
466 aField( $conf, "DBpassword2", "again", "password" );
469 If you only have a single user account
and database available
,
470 enter those here
. If you have database root
access (see below
)
471 you can specify
new accounts
/databases to be created
.
477 aField( $conf, "RootPW", "DB root password", "password" );
481 You will only need this
if the database
and/or user account
482 above don
't already exist.
483 Do <em>not</em> type in your machine's root password
! MySQL
484 has its own
"root" user with a separate password
. (It might
485 even be blank
, depending on your configuration
.)
489 <label
> 
;</label
>
490 <input type
="submit" value
="Install!" />
500 /* -------------------------------------------------------------------------------------- */
502 function writeAdminSettings( $conf ) {
504 \$wgDBadminuser = \"{$conf->DBadminuser}\";
505 \$wgDBadminpassword = \"{$conf->DBadminpassword}\";
509 function writeLocalSettings( $conf ) {
510 $conf->DBmysql4
= $conf->DBmysql4 ?
'true' : 'false';
511 $conf->UseImageResize
= $conf->UseImageResize ?
'true' : 'false';
512 $conf->DBsqluser
= $conf->DBuser
;
513 $conf->DBsqlpassword
= $conf->DBpassword
;
514 $conf->PasswordSender
= $conf->EmergencyContact
;
515 if( $conf->LanguageCode
== "en-utf8" ) {
516 $conf->LanguageCode
= "en";
517 $conf->Encoding
= "UTF-8";
520 # This file was automatically generated. Don't touch unless you
521 # know what you're doing; see LocalSettings.sample for an edit-
524 \$IP = \"{$conf->IP}\";
525 ini_set( \"include_path\", \"\$IP/includes:\$IP/languages:\" . ini_get(\"include_path\") );
526 include_once( \"DefaultSettings.php\" );
528 if( \$wgCommandLineMode ) {
529 die( \"Can't use command-line utils with in-place install yet, sorry.\" );
532 \$wgSitename = \"{$conf->Sitename}\";
534 \$wgScriptPath = \"{$conf->ScriptPath}\";
535 \$wgScript = \"\$wgScriptPath/index.php\";
536 \$wgRedirectScript = \"\$wgScriptPath/redirect.php\";
538 \$wgArticlePath = \"\$wgScript?title=\$1\";
539 # \$wgArticlePath = \"\$wgScript/\$1\"; # Prettier if you're setup for it
541 \$wgStyleSheetPath = \"\$wgScriptPath/stylesheets\";
542 \$wgStyleSheetDirectory = \"\$IP/stylesheets\";
544 \$wgUploadPath = \"\$wgScriptPath/images\";
545 \$wgUploadDirectory = \"\$IP/images\";
546 \$wgLogo = \"\$wgUploadPath/wiki.png\";
548 \$wgEmergencyContact = \"{$conf->EmergencyContact}\";
549 \$wgPasswordSender = \"{$conf->PasswordSender}\";
551 \$wgDBserver = \"{$conf->DBserver}\";
552 \$wgDBname = \"{$conf->DBname}\";
553 \$wgDBuser = \"{$conf->DBuser}\";
554 \$wgDBpassword = \"{$conf->DBpassword}\";
555 \$wgDBsqluser = \"{$conf->DBsqluser}\";
556 \$wgDBsqlpassword = \"{$conf->DBsqlpassword}\";
558 \$wgDBmysql4 = \$wgEnablePersistentLC = {$conf->DBmysql4};
560 \$wgUseImageResize = {$conf->UseImageResize};
562 ## If you have the appropriate support software installed
563 ## you can enable inline LaTeX equations:
565 # \$wgMathPath = \"{$wgUploadPath}/math\";
566 # \$wgMathDirectory = \"{$wgUploadDirectory}/math\";
567 # \$wgTmpDirectory = \"{$wgUploadDirectory}/tmp\";
569 \$wgLocalInterwiki = \$wgSitename;
571 \$wgLanguageCode = \"{$conf->LanguageCode}\";
572 " . ($conf->Encoding ?
"\$wgInputEncoding = \$wgOutputEncoding = \"{$conf->Encoding}\";" : "" ) . "
577 function dieout( $text ) {
578 die( $text . "\n\n</body>\n</html>" );
581 function importPost( $name, $default = "" ) {
582 if( isset( $_POST[$name] ) ) {
583 return $_POST[$name];
589 function aField( &$conf, $field, $text, $type = "" ) {
590 if( $type != "" ) $type = "type=\"$type\"";
591 echo "\t\t<label for=\"$field\">$text</label>\n";
592 echo "\t\t<input $type name=\"$field\" id=\"$field\" value=\"";
593 echo htmlspecialchars( $conf->$field );
597 if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n";
600 function getLanguageList() {
601 global $wgLanguageNames;
602 if( !isset( $wgLanguageNames ) ) {
603 $wgLanguageCode = "xxx";
604 function wfLocalUrl( $x ) { return $x; }
605 function wfLocalUrlE( $x ) { return $x; }
606 include( "../languages/Language.php" );
610 $latin1 = array( "da", "de", "en", "es", "fr", "nl", "sv" );
612 $d = opendir( "../languages" );
613 while( false !== ($f = readdir( $d ) ) ) {
614 if( preg_match( '/Language([A-Z][a-z]+)\.php$/', $f, $m ) ) {
615 $code = strtolower( $m[1] );
616 $codes[$code] = "$code - " . $wgLanguageNames[$code];
617 if( in_array( $code, $latin1 ) ) {
618 $codes[$code] .= " - Latin-1";
622 $codes["en-utf8"] = "en - English - Unicode";