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 error_reporting( E_ALL
);
22 header( "Content-type: text/html; charset=utf-8" );
23 @ini_set
( "display_errors", true );
25 ?
><!DOCTYPE HTML
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
26 "http://www.w3.org/TR/html4/loose.dtd">
29 <meta http
-equiv
="Content-type" content
="text/html; charset=utf-8">
30 <meta name
="robots" content
="noindex,nofollow">
31 <title
>MediaWiki installation
</title
>
32 <style type
="text/css">
37 background
-color
: #eee;
39 border
: solid
1px
#444;
47 dl
.setup dd label
.column
{
59 /* margin-right: 200px; */
77 <a href
="http://www.mediawiki.org/"><img
78 src
="../skins/common/images/wiki.png" width
="135" height
="135" alt
="" border
="0" /></a
>
81 <b
><a href
="http://www.mediawiki.org/">MediaWiki
</a
></b
> is
82 Copyright (C
) 2001-2004 by Magnus Manske
, Brion Vibber
, Lee Daniel Crocker
,
83 Tim Starling
, Erik M
ö
;ller
, Gabriel Wicke
, Thomas Gries
and others
.</p
>
86 <li
><a href
="../README">Readme
</a
></li
>
87 <li
><a href
="../RELEASE-NOTES">Release notes
</a
></li
>
88 <li
><a href
="../docs/">doc
/</a
></li
>
89 <li
><a href
="http://meta.wikipedia.org/wiki/MediaWiki_User's_Guide">User
's Guide</a></li>
92 <p>This program is free software; you can redistribute it and/or modify
93 it under the terms of the GNU General Public License as published by
94 the Free Software Foundation; either version 2 of the License, or
95 (at your option) any later version.</p>
97 <p>This program is distributed in the hope that it will be useful,
98 but WITHOUT ANY WARRANTY; without even the implied warranty of
99 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
100 GNU General Public License for more details.</p>
102 <p>You should have received <a href="../COPYING">a copy of the GNU General Public License</a>
103 along with this program; if not, write to the Free Software
104 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
105 or <a href="http://www.gnu.org/copyleft/gpl.html">read it online</a></p>
110 $IP = ".."; # Just to suppress notices, not for anything useful
111 define( "MEDIAWIKI", true );
112 define( "MEDIAWIKI_INSTALL", true );
113 require_once( "../includes/Defines.php" );
114 require_once( "../includes/DefaultSettings.php" );
115 require_once( "../includes/MagicWord.php" );
116 require_once( "../includes/Namespace.php" );
119 <h1>MediaWiki <?php print $wgVersion ?> installation</h1>
124 /* Check for existing configurations and bug out! */
126 if( file_exists( "../LocalSettings.php" ) || file_exists( "../AdminSettings.php" ) ) {
127 dieout( "<h2>Wiki is configured.</h2>
129 <p>Already configured... <a href='../index
.php
'>return to the wiki</a>.</p>
131 <p>(You should probably remove this directory for added security.)</p>" );
134 if( file_exists( "./LocalSettings.php" ) || file_exists( "./AdminSettings.php" ) ) {
135 dieout( "<h2>You're configured
!</h2
>
137 <p
>Please move
<tt
>LocalSettings
.php
</tt
> to the parent directory
, then
138 <a href
='../index.php'>try out your wiki
</a
>.
139 (You should remove this config directory
for added security once you
're done.)</p>" );
142 if( !is_writable( "." ) ) {
143 dieout( "<h2>Can't write config file
, aborting
</h2
>
145 <p
>In order to configure the wiki you have to make the
<tt
>config
</tt
> subdirectory
146 writable by the web server
. Once configuration is done you
'll move the created
147 <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can
148 then remove the <tt>config</tt> subdirectory entirely.</p>
150 <p>To make the directory writable on a Unix/Linux system:</p>
153 cd <i>/path/to/wiki</i>
159 require_once( "../install-utils.inc" );
160 require_once( "../maintenance/updaters.inc" );
161 require_once( "../maintenance/convertLinks.inc" );
162 require_once( "../maintenance/archives/moveCustomMessages.inc" );
165 function getEncoded( $data ) {
169 return utf8_decode( $data ); /* to latin1 wikis */
174 function getSitename() { return $this->getEncoded( $this->Sitename ); }
175 function getSysopName() { return $this->getEncoded( $this->SysopName ); }
176 function getSysopPass() { return $this->getEncoded( $this->SysopPass ); }
181 <p><i>Please include all of the lines below when reporting installation problems.</i></p>
183 <h2>Checking environment...</h2>
188 $wgConfiguring = true;
189 $conf = new ConfigData;
191 install_version_checks();
193 print "<li>PHP " . phpversion() . ": ok</li>\n";
195 if( ini_get( "register_globals" ) ) {
197 <li><b class='error
'>Warning:</b> <b>PHP's
198 <tt
><a href
="http://php.net/register_globals">register_globals
</a
></tt
>
199 option is enabled
.</b
> MediaWiki will work correctly
, but this setting
200 increases your exposure to potential security vulnerabilities in PHP
-based
201 software running on your server
. <b
>You should disable it
if you are able
.</b
></li
>
205 if( ini_get( "safe_mode" ) ) {
207 <li
class='error'><b
>Warning
: PHP
's
208 <a href='http
://www.php.net/features.safe-mode'>safe mode</a> is active!</b>
209 You will likely have problems caused by this
. You may need to make the
210 'images' subdirectory writable
or specify a TMP environment variable pointing to
211 a writable temporary directory owned by you
, since safe mode breaks the system
212 temporary directory
.</li
>
216 $sapi = php_sapi_name();
217 $conf->prettyURLs
= true;
218 print "<li>PHP server API is $sapi; ";
221 case "apache2handler":
222 print "ok, using pretty URLs (<tt>index.php/Page_Title</tt>)";
226 case "apache2filter":
227 print "using ugly URLs (<tt>index.php?title=Page_Title</tt>)";
228 $conf->prettyURLs
= false;
231 print "unknown; using pretty URLs (<tt>index.php/Page_Title</tt>), if you have trouble change this in <tt>LocalSettings.php</tt>";
235 $conf->xml
= function_exists( "utf8_encode" );
237 print "<li>Have XML / Latin1-UTF-8 conversion support.</li>\n";
239 dieout( "PHP's XML module is missing; the wiki requires functions in
240 this module and won't work in this configuration.
241 If you're running Mandrake, install the php-xml package." );
244 $memlimit = ini_get( "memory_limit" );
245 $conf->raiseMemory
= false;
246 if( empty( $memlimit ) ) {
247 print "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n";
249 print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars( $memlimit ) . ". <b>If this is too low, installation may fail!</b> ";
250 $n = IntVal( $memlimit );
251 if( preg_match( '/^([0-9]+)[Mm]$/', trim( $memlimit ), $m ) ) {
252 $n = IntVal( $m[1] * (1024*1024) );
254 if( $n < 20*1024*1024 ) {
255 print "Attempting to raise limit to 20M... ";
256 if( false === ini_set( "memory_limit", "20M" ) ) {
259 $conf->raiseMemory
= true;
266 $conf->zlib
= function_exists( "gzencode" );
268 print "<li>Have zlib support; enabling output compression.</li>\n";
270 print "<li>No zlib support.</li>\n";
273 $conf->turck
= function_exists( 'mmcache_get' );
274 if ( $conf->turck
) {
275 print "<li><a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> installed</li>\n";
277 print "<li><a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> not installed, " .
278 "can't use object caching functions</li>\n";
281 $conf->ImageMagick
= false;
282 $imcheck = array( "/usr/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" );
283 foreach( $imcheck as $dir ) {
284 $im = "$dir/convert";
285 if( file_exists( $im ) ) {
286 print "<li>Found ImageMagick: <tt>$im</tt>; image thumbnailing will be enabled if you enable uploads.</li>\n";
287 $conf->ImageMagick
= $im;
292 $conf->HaveGD
= function_exists( "imagejpeg" );
293 if( $conf->HaveGD
) {
294 print "<li>Found GD graphics library built-in";
295 if( !$conf->ImageMagick
) {
296 print ", image thumbnailing will be enabled if you enable uploads";
300 if( !$conf->ImageMagick
) {
301 print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n";
305 $conf->UseImageResize
= $conf->HaveGD ||
$conf->ImageMagick
;
307 # $conf->IP = "/Users/brion/Sites/inplace";
308 $conf->IP
= dirname( dirname( __FILE__
) );
309 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP
) . "</tt></li>\n";
311 # $conf->ScriptPath = "/~brion/inplace";
312 $conf->ScriptPath
= preg_replace( '{^(.*)/config.*$}', '$1', $_SERVER["REQUEST_URI"] );
313 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath
) . "</tt></li>\n";
315 $conf->posted
= ($_SERVER["REQUEST_METHOD"] == "POST");
317 $conf->Sitename
= ucfirst( importPost( "Sitename", "" ) );
318 $conf->EmergencyContact
= importPost( "EmergencyContact", $_SERVER["SERVER_ADMIN"] );
319 $conf->DBserver
= importPost( "DBserver", "localhost" );
320 $conf->DBname
= importPost( "DBname", "wikidb" );
321 $conf->DBuser
= importPost( "DBuser", "wikiuser" );
322 $conf->DBpassword
= importPost( "DBpassword" );
323 $conf->DBpassword2
= importPost( "DBpassword2" );
324 $conf->DBprefix
= importPost( "DBprefix" );
325 $conf->RootPW
= importPost( "RootPW" );
326 $conf->LanguageCode
= importPost( "LanguageCode", "en" );
327 $conf->SysopName
= importPost( "SysopName", "WikiSysop" );
328 $conf->SysopPass
= importPost( "SysopPass" );
329 $conf->SysopPass2
= importPost( "SysopPass2" );
331 /* Check for validity */
334 if( $conf->Sitename
== "" ||
$conf->Sitename
== "MediaWiki" ||
$conf->Sitename
== "Mediawiki" ) {
335 $errs["Sitename"] = "Must not be blank or \"MediaWiki\".";
337 if( $conf->DBuser
== "" ) {
338 $errs["DBuser"] = "Must not be blank";
340 if( $conf->DBpassword
== "" ) {
341 $errs["DBpassword"] = "Must not be blank";
343 if( $conf->DBpassword
!= $conf->DBpassword2
) {
344 $errs["DBpassword2"] = "Passwords don't match!";
346 if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix
) ) {
347 $errs["DBprefix"] = "Invalid table prefix";
350 if( $conf->SysopPass
== "" ) {
351 $errs["SysopPass"] = "Must not be blank";
353 if( $conf->SysopPass
!= $conf->SysopPass2
) {
354 $errs["SysopPass2"] = "Passwords don't match!";
357 $conf->License
= importRequest( "License", "none" );
358 if( $conf->License
== "gfdl" ) {
359 $conf->RightsUrl
= "http://www.gnu.org/copyleft/fdl.html";
360 $conf->RightsText
= "GNU Free Documentation License 1.2";
361 $conf->RightsCode
= "gfdl";
362 $conf->RightsIcon
= '${wgStylePath}/common/images/gnu-fdl.png';
363 } elseif( $conf->License
== "none" ) {
364 $conf->RightsUrl
= $conf->RightsText
= $conf->RightsCode
= $conf->RightsIcon
= "";
366 $conf->RightsUrl
= importRequest( "RightsUrl", "" );
367 $conf->RightsText
= importRequest( "RightsText", "" );
368 $conf->RightsCode
= importRequest( "RightsCode", "" );
369 $conf->RightsIcon
= importRequest( "RightsIcon", "" );
372 $conf->Shm
= importRequest( "Shm", "none" );
373 $conf->MCServers
= importRequest( "MCServers" );
375 /* Test memcached servers */
377 if ( $conf->Shm
== 'memcached' && $conf->MCServers
) {
378 $conf->MCServerArray
= array_map( 'trim', explode( ',', $conf->MCServers
) );
379 foreach ( $conf->MCServerArray
as $server ) {
380 $error = testMemcachedServer( $server );
382 $errs["MCServers"] = $error;
386 } else if ( $conf->Shm
== 'memcached' ) {
387 $errs["MCServers"] = "Please specify at least one server if you wish to use memcached";
390 /* default values for installation */
391 $conf->Email
=importRequest("Email", "email_enabled");
392 $conf->Emailuser
=importRequest("Emailuser", "emailuser_enabled");
393 $conf->Enotif
=importRequest("Enotif", "enotif_allpages");
394 $conf->Eauthent
=importRequest("Eauthent", "eauthent_enabled");
396 if( $conf->posted
&& ( 0 == count( $errs ) ) ) {
397 do { /* So we can 'continue' to end prematurely */
398 $conf->Root
= ($conf->RootPW
!= "");
400 /* Load up the settings and get installin' */
401 $local = writeLocalSettings( $conf );
402 $wgCommandLineMode = false;
405 $wgDBadminuser = "root";
406 $wgDBadminpassword = $conf->RootPW
;
407 $wgDBprefix = $conf->DBprefix
;
408 $wgCommandLineMode = true;
409 $wgUseDatabaseMessages = false; /* FIXME: For database failure */
410 require_once( "includes/Setup.php" );
413 require_once( "../maintenance/InitialiseMessages.inc" );
415 $wgTitle = Title
::newFromText( "Installation script" );
416 $wgDatabase = Database
::newFromParams( $wgDBserver, "root", $conf->RootPW
, "", 1 );
417 $wgDatabase->ignoreErrors(true);
419 @$myver = mysql_get_server_info( $wgDatabase->mConn
);
422 print "<li>Connected as root (automatic)</li>\n";
424 print "<li>MySQL error " . ($err = mysql_errno() ) .
425 ": " . htmlspecialchars( mysql_error() );
431 $errs["RootPW"] = "Check password";
433 print "<li>Trying regular user...\n";
434 /* Try the regular user... */
435 $wgDBadminuser = $wgDBuser;
436 $wgDBadminpassword = $wgDBpassword;
437 $wgDatabase = Database
::newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, "", 1 );
438 $wgDatabase->isOpen();
439 $wgDatabase->ignoreErrors(true);
440 @$myver = mysql_get_server_info( $wgDatabase->mConn
);
442 $errs["DBuser"] = "Check name/pass";
443 $errs["DBpassword"] = "or enter root";
444 $errs["DBpassword2"] = "password below";
445 $errs["RootPW"] = "Got root?";
446 print " need password.</li>\n";
458 $errs["DBserver"] = "Connection failed";
461 $errs["DBserver"] = "Couldn't connect to database";
467 if ( !$wgDatabase->isOpen() ) {
468 $errs["DBserver"] = "Couldn't connect to database";
472 print "<li>Connected to database... $myver";
473 if( version_compare( $myver, "4.0.0" ) >= 0 ) {
474 print "; enabling MySQL 4 enhancements";
475 $conf->DBmysql4
= true;
476 $local = writeLocalSettings( $conf );
480 @$sel = mysql_select_db( $wgDBname, $wgDatabase->mConn
);
482 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
484 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
486 print "<li>Couldn't create database <tt>" .
487 htmlspecialchars( $wgDBname ) .
488 "</tt>; try with root access or check your username/pass.</li>\n";
489 $errs["RootPW"] = "<- Enter";
492 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
495 $wgDatabase->selectDB( $wgDBname );
497 if( $wgDatabase->tableExists( "cur" ) ||
$wgDatabase->tableExists( "revision" ) ) {
498 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n";
500 # Create user if required
502 $conn = Database
::newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
503 if ( $conn->isOpen() ) {
504 print "<li>DB user account ok</li>\n";
507 print "<li>Granting user permissions...</li>\n";
508 dbsource( "../maintenance/users.sql", $wgDatabase );
518 print "<li>Finished update checks.</li>\n";
520 # FIXME: Check for errors
521 print "<li>Creating tables...";
522 dbsource( "../maintenance/tables.sql", $wgDatabase );
523 dbsource( "../maintenance/interwiki.sql", $wgDatabase );
524 dbsource( "../maintenance/archives/patch-userlevels-defaultgroups.sql", $wgDatabase );
525 print " done.</li>\n";
527 print "<li>Initializing data...";
528 $wgDatabase->insert( 'site_stats',
529 array( 'ss_row_id' => 1,
530 'ss_total_views' => 0,
531 'ss_total_edits' => 0,
532 'ss_good_articles' => 0 ) );
533 # setting up the db user
535 print "<li>Granting user permissions...</li>\n";
536 dbsource( "../maintenance/users.sql", $wgDatabase );
539 if( $conf->SysopName
) {
540 $u = User
::newFromName( $conf->getSysopName() );
541 if ( 0 == $u->idForName() ) {
543 $u->setPassword( $conf->getSysopPass() );
544 $u->addRight( "sysop" );
545 $u->addRight( "bureaucrat" );
548 # Set up the new user in the sysop group
549 # This is a bit of an ugly hack
550 global $wgSysopGroupId, $wgBureaucratGroupId;
551 $groups = $u->getGroups();
552 $groups[] = $wgSysopGroupId;
553 $groups[] = $wgBureaucratGroupId;
554 $u->setGroups( $groups );
557 print "<li>Created sysop account <tt>" .
558 htmlspecialchars( $conf->SysopName
) . "</tt>.</li>\n";
560 print "<li>Could not create user - already exists!</li>\n";
563 print "<li>Skipped sysop account creation, no name given.</li>\n";
566 $titleobj = Title
::newFromText( wfMsgNoDB( "mainpage" ) );
567 $now = wfTimestampNow();
569 extract( $wgDatabase->tableNames( 'text', 'page', 'revision' ) );
570 $titleobj = Title
::newFromText( wfMsgNoDB( "mainpage" ) );
571 $title = $titleobj->getDBkey();
572 $sql = "INSERT INTO $text (old_text, old_flags) VALUES ('" .
573 wfStrencode( wfMsg( "mainpagetext" ) . "\n\n" . wfMsg( "mainpagedocfooter" ) ) .
575 $wgDatabase->query( $sql, $fname );
576 $text_id = $wgDatabase->insertID();
578 $sql = "INSERT INTO $page (page_namespace, page_title, page_restrictions, page_counter, page_is_redirect,
579 page_is_new, page_random, page_touched, page_latest) VALUES (
580 0, '{$title}', '', 0, 0, 1, 0.5, '{$now}', {$text_id} )";
581 $wgDatabase->query( $sql, $fname );
582 $page_id = $wgDatabase->insertID();
584 $sql = "INSERT INTO $revision (rev_id, rev_page, rev_comment, rev_user, rev_user_text,
585 rev_timestamp, rev_minor_edit)
586 VALUES ({$text_id}, {$page_id}, '', 0, 'MediaWiki default', '{$now}', 0)";
587 $wgDatabase->query( $sql, $fname );
590 initialiseMessages();
591 print "</pre></li>\n";
594 /* Write out the config file now that all is well */
595 print "<p>Creating LocalSettings.php...</p>\n\n";
596 $localSettings = "<" . "?php$endl$local$endl?" . ">";
598 if( version_compare( phpversion(), "4.3.2" ) >= 0 ) {
599 $xt = "xt"; # Refuse to overwrite an existing file
601 $xt = "wt"; # 'x' is not available prior to PHP 4.3.2. We did check above, but race conditions blah blah
603 $f = fopen( "LocalSettings.php", $xt );
606 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" .
607 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
608 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
610 if(fwrite( $f, $localSettings ) ) {
613 print "<p>Success! Move the config/LocalSettings.php file into the parent directory, then follow
614 <a href='{$conf->ScriptPath}/index.php'>this link</a> to your wiki.</p>\n";
617 die("<p class='error'>An error occured while writing the config/LocalSettings.php file. Check user rights and disk space then try again.</p>\n");
629 if( count( $errs ) ) {
630 /* Display options form */
632 if( $conf->posted
) {
633 echo "<p class='error'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
637 <form name
="config" method
="post">
645 aField( $conf, "Sitename", "Site name:" );
649 Your site name should be a relatively short word
. It
'll appear as the namespace
650 name for 'meta
' pages as well as throughout the user interface. Good site names
651 are things like "<a href="http://www.wikipedia.org/">Wikipedia</a>" and
652 "<a href="http://openfacts.berlios.de/">OpenFacts</a>"; avoid punctuation,
653 which may cause problems.
658 aField( $conf, "EmergencyContact", "Contact e-mail" );
662 This will be used as the return address for password reminders and
663 may be displayed in some error conditions so visitors can get in
664 touch with you. It is also be used as the default sender address of e-mail
665 notifications (enotifs).
669 <label class='column
' for="LanguageCode">Language</label>
670 <select id="LanguageCode" name="LanguageCode">
672 $list = getLanguageList();
673 foreach( $list as $code => $name ) {
674 $sel = ($code == $conf->LanguageCode) ? 'selected
="selected"' : '';
675 echo "\t\t<option value=\"$code\" $sel>$name</option>\n";
681 You may select the language for the user interface of the wiki...
682 Some localizations are less complete than others. This also controls
683 the character encoding; Unicode is more flexible, but Latin-1 may be
684 more compatible with older browsers for some languages. Unicode will
685 be used where not specified otherwise.
689 <label class='column
'>Copyright/license metadata</label>
690 <div>Select one:</div>
693 <li><?php aField( $conf, "License", "no license metadata", "radio", "none" ); ?></li>
694 <li><?php aField( $conf, "License", "GNU Free Documentation License 1.2 (Wikipedia-compatible)", "radio", "gfdl" ); ?></li>
696 aField( $conf, "License", "a Creative Commons license...", "radio", "cc" );
697 $partner = "MediaWiki";
698 $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/index.php?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
699 $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" );
700 $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" );
701 print "<a href=\"$ccApp\">choose</a>";
702 ?> (link will wipe out any other data in this form!)
703 <?php if( $conf->License == "cc" ) { ?>
705 <li><?php aField( $conf, "RightsIcon", "<img src=\"" . htmlspecialchars( $conf->RightsIcon ) . "\" alt='icon
' />", "hidden" ); ?></li>
706 <li><?php aField( $conf, "RightsText", htmlspecialchars( $conf->RightsText ), "hidden" ); ?></li>
707 <li><?php aField( $conf, "RightsCode", "code: " . htmlspecialchars( $conf->RightsCode ), "hidden" ); ?></li>
708 <li><?php aField( $conf, "RightsUrl", "<a href=\"" . htmlspecialchars( $conf->RightsUrl ) . "\">" . htmlspecialchars( $conf->RightsUrl ) . "</a>", "hidden" ); ?></li>
715 MediaWiki can include a basic license notice, icon, and machine-readable
716 copyright metadata if your wiki's content is to be licensed under
717 the GNU FDL
or a Creative Commons license
. If you
're not sure, leave
723 <?php aField( $conf, "SysopName", "Sysop account name:", "" ) ?>
726 <?php aField( $conf, "SysopPass", "password:", "password" ) ?>
729 <?php aField( $conf, "SysopPass2", "again:", "password" ) ?>
732 A sysop user account can lock or delete pages, block problematic IP
733 addresses from editing, and other maintenance tasks. If creating a new
734 wiki database, a sysop account will be created with the given name
739 <label class='column
'>Shared memory caching</label>
740 <div>Select one:</div>
743 <li><?php aField( $conf, "Shm", "no caching", "radio", "none" ); ?></li>
745 if ( $conf->turck ) {
747 aField( $conf, "Shm", "Turck MMCache", "radio", "turck" );
751 <li><?php aField( $conf, "Shm", "Memcached", "radio", "memcached" ); ?></li>
752 <li><?php aField( $conf, "MCServers", "Memcached servers", "" ) ?></li>
756 Using a shared memory system such as Turck MMCache or Memcached will speed
757 up MediaWiki significantly. Memcached is the best solution but needs to be
758 installed. Specify the server addresses and ports in a comma-separted list. Only
759 use Turck shared memory if the wiki will be running on a single Apache server.
762 <h2>E-mail, e-mail notification and authentification setup</h2>
766 <label class='column
'>E-mail (general)</label>
767 <div>Select one:</div>
770 <li><?php aField( $conf, "Email", "enabled", "radio", "email_enabled" ); ?></li>
771 <li><?php aField( $conf, "Email", "disabled", "radio", "email_disabled" ); ?></li>
775 Use this to disable all e-mail functions (send a password reminder, user-to-user e-mail and e-mail notification),
776 if sending e-mails on your server doesn't work
.
779 <label
class='column'>User
-to
-user e
-mail
</label
>
780 <div
>Select one
:</div
>
783 <li
><?php
aField( $conf, "Emailuser", "enabled", "radio", "emailuser_enabled" ); ?
></li
>
784 <li
><?php
aField( $conf, "Emailuser", "disabled", "radio", "emailuser_disabled" ); ?
></li
>
788 Use this to disable only the user
-to
-user e
-mail
function (EmailUser
).
791 <label
class='column'>E
-mail notification
</label
>
792 <div
>Select one
:</div
>
795 <li
><?php
aField( $conf, "Enotif", "disabled", "radio", "enotif_disabled" ); ?
></li
>
796 <li
><?php
aField( $conf, "Enotif", "enabled for changes of watch-listed and user_talk pages (recommended for small wikis; perhaps not suited for large wikis)", "radio", "enotif_allpages" ); ?
></li
>
797 <li
><?php
aField( $conf, "Enotif", "enabled for changes of user_talk pages only (suited for small and large wikis)", "radio", "enotif_usertalk" ); ?
></li
>
802 $ccEnotif = htmlspecialchars( 'http://meta.wikipedia.org/Enotif' );
803 print "<a href=\"$ccEnotif\">E-mail notification</a>";
805 sends a notification e
-mail to a user
, when the user_talk page is changed
806 and/or when watch
-listed pages are changed
, depending on the above settings
.
807 When testing this feature
, be reminded
, that obviously an e
-mail address must be present in your preferences
808 and that your own changes never trigger notifications to be sent to yourself
.</p
>
810 <p
>Users get corresponding options to select
or deselect in their users
' preferences.
811 The user options are not shown on the preference page, if e-mail notification is disabled.</p>
813 <p>There are additional options for fine tuning in /includes/DefaultSettings.php .</p>
817 <label class='column
'>E-mail address authentication</label>
818 <div>Select one:</div>
821 <li><?php aField( $conf, "Eauthent", "disabled", "radio", "eauthent_disabled" ); ?></li>
822 <li><?php aField( $conf, "Eauthent", "enabled", "radio", "eauthent_enabled" ); ?></li>
827 $ccEauthent = htmlspecialchars( 'http
://meta.wikipedia.org/Eauthent' );
828 print "<a href=\"$ccEnotif\">E-mail address authentication</a>";
830 uses a scheme to authenticate e
-mail addresses of the users
. The user who initially enters
or who changes his
/her stored e
-mail address
831 gets a one
-time temporary password mailed to that address
. The user can
use the original password
as long
as wanted
, however
, the stored e
-mail address
832 is only authenticated at the moment when the user logs in with the one
-time temporary password
.<p
>
834 <p
>The e
-mail address stays authenticated
as long
as the user does not change it
; the time of authentication is indicated
835 on the user preference page
.</p
>
837 <p
>If the option is enabled
, only authenticated e
-mail addresses can receive EmailUser mails
and/or
838 e
-mail notification mails
.</p
>
843 <h2
>Database config
</h2
>
847 aField( $conf, "DBserver", "MySQL server" );
850 If your database server isn
't on your web server, enter the name
855 aField( $conf, "DBname", "Database name" );
858 aField( $conf, "DBuser", "DB username" );
861 aField( $conf, "DBpassword", "DB password", "password" );
864 aField( $conf, "DBpassword2", "again", "password" );
867 If you only have a single user account and database available,
868 enter those here. If you have database root access (see below)
869 you can specify new accounts/databases to be created.
873 aField( $conf, "DBprefix", "Database table prefix" );
876 <p>If you need to share one database between multiple wikis, or
877 MediaWiki and another web application, you may choose to
878 add a prefix to all the table names to avoid conflicts.</p>
880 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
885 aField( $conf, "RootPW", "DB root password", "password" );
889 You will only need this if the database and/or user account
890 above don't already exist
.
891 Do <em
>not
</em
> type in your machine
's root password! MySQL
892 has its own "root" user with a separate password. (It might
893 even be blank, depending on your configuration.)
897 <label class='column
'> </label>
898 <input type="submit" value="Install!" />
908 /* -------------------------------------------------------------------------------------- */
910 function writeAdminSettings( $conf ) {
912 \$wgDBadminuser = \"{$conf->DBadminuser}\";
913 \$wgDBadminpassword = \"{$conf->DBadminpassword}\";
917 function escapePhpString( $string ) {
918 return strtr( $string,
929 function writeLocalSettings( $conf ) {
930 $conf->DBmysql4 = @$conf->DBmysql4 ? 'true' : 'false';
931 $conf->UseImageResize = $conf->UseImageResize ? 'true' : 'false';
932 $conf->PasswordSender = $conf->EmergencyContact;
933 if( preg_match( '/^
([a
-z
]+
)-latin1$
/', $conf->LanguageCode, $m ) ) {
934 $conf->LanguageCode = $m[1];
935 $conf->Latin1 = true;
937 $conf->Latin1 = false;
939 $zlib = ($conf->zlib ? "" : "# ");
940 $magic = ($conf->ImageMagick ? "" : "# ");
941 $convert = ($conf->ImageMagick ? $conf->ImageMagick : "/usr/bin/convert" );
942 $pretty = ($conf->prettyURLs ? "" : "# ");
943 $ugly = ($conf->prettyURLs ? "# " : "");
944 $rights = ($conf->RightsUrl) ? "" : "# ";
946 switch ( $conf->Shm ) {
950 $mcservers = var_export( $conf->MCServerArray
, true );
953 $memcached = 'false';
954 $mcservers = 'array()';
958 $memcached = 'false';
959 $mcservers = 'array()';
963 if ( $conf->Email
== 'email_enabled' ) {
964 $enableemail = 'true';
965 $enableuseremail = ( $conf->Emailuser
== 'emailuser_enabled' ) ?
'true' : 'false' ;
966 $eauthent = ( $conf->Eauthent
== 'eauthent_enabled' ) ?
'true' : 'false' ;
967 switch ( $conf->Enotif
) {
968 case 'enotif_usertalk':
969 $enotifusertalk = 'true';
970 $enotifwatchlist = 'false';
972 case 'enotif_allpages':
973 $enotifusertalk = 'true';
974 $enotifwatchlist = 'true';
977 $enotifusertalk = 'false';
978 $enotifwatchlist = 'false';
981 $enableuseremail = 'false';
982 $enableemail = 'false';
984 $enotifusertalk = 'false';
985 $enotifwatchlist = 'false';
988 $file = @fopen
( "/dev/urandom", "r" );
990 $proxyKey = bin2hex( fread( $file, 32 ) );
994 for ( $i=0; $i<8; $i++
) {
995 $proxyKey .= dechex(mt_rand(0, 0x7fffffff));
997 print "<li>Warning: \$wgProxyKey is insecure</li>\n";
1000 # Add slashes to strings for double quoting
1001 $slconf = array_map( "escapePhpString", get_object_vars( $conf ) );
1002 if( $conf->License
== 'gfdl' ) {
1003 # Needs literal string interpolation for the current style path
1004 $slconf['RightsIcon'] = $conf->RightsIcon
;
1007 $sep = (DIRECTORY_SEPARATOR
== "\\") ?
";" : ":";
1009 # This file was automatically generated by the MediaWiki installer.
1010 # If you make manual changes, please keep track in case you need to
1011 # recreate them later.
1013 \$IP = \"{$slconf['IP']}\";
1014 ini_set( \"include_path\", \".$sep\$IP$sep\$IP/includes$sep\$IP/languages\" );
1015 require_once( \"includes/DefaultSettings.php\" );
1017 # If PHP's memory limit is very low, some operations may fail.
1018 " . ($conf->raiseMemory ?
'' : '# ' ) . "ini_set( 'memory_limit', '20M' );" . "
1020 if ( \$wgCommandLineMode ) {
1021 if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
1022 die( \"This script must be run from the command line\\n\" );
1024 } elseif ( empty( \$wgConfiguring ) ) {
1025 ## Compress output if the browser supports it
1026 {$zlib}if( !ini_get( 'zlib.output_compression' ) ) @ob_start( 'ob_gzhandler' );
1029 \$wgSitename = \"{$slconf['Sitename']}\";
1031 \$wgScriptPath = \"{$slconf['ScriptPath']}\";
1032 \$wgScript = \"\$wgScriptPath/index.php\";
1033 \$wgRedirectScript = \"\$wgScriptPath/redirect.php\";
1035 ## If using PHP as a CGI module, use the ugly URLs
1036 {$pretty}\$wgArticlePath = \"\$wgScript/\$1\";
1037 {$ugly}\$wgArticlePath = \"\$wgScript?title=\$1\";
1039 \$wgStylePath = \"\$wgScriptPath/skins\";
1040 \$wgStyleDirectory = \"\$IP/skins\";
1041 \$wgLogo = \"\$wgStylePath/common/images/wiki.png\";
1043 \$wgUploadPath = \"\$wgScriptPath/images\";
1044 \$wgUploadDirectory = \"\$IP/images\";
1046 \$wgEnableEmail = $enableemail;
1047 \$wgEnableUserEmail = $enableuseremail;
1049 \$wgEmergencyContact = \"{$slconf['EmergencyContact']}\";
1050 \$wgPasswordSender = \"{$slconf['PasswordSender']}\";
1052 ## For a detailed description of the following switches see
1053 ## http://meta.wikimedia.org/Enotif and http://meta.wikimedia.org/Eauthent
1054 ## There are many more options for fine tuning available see
1055 ## /includes/DefaultSettings.php
1056 ## UPO means: this is also a user preference option
1057 \$wgEmailNotificationForUserTalkPages = $enotifusertalk; # UPO
1058 \$wgEmailNotificationForWatchlistPages = $enotifwatchlist; # UPO
1059 \$wgEmailAuthentication = $eauthent;
1061 \$wgDBserver = \"{$slconf['DBserver']}\";
1062 \$wgDBname = \"{$slconf['DBname']}\";
1063 \$wgDBuser = \"{$slconf['DBuser']}\";
1064 \$wgDBpassword = \"{$slconf['DBpassword']}\";
1065 \$wgDBprefix = \"{$slconf['DBprefix']}\";
1067 # If you're on MySQL 3.x, this next line must be FALSE:
1068 \$wgDBmysql4 = \$wgEnablePersistentLC = {$conf->DBmysql4};
1070 ## Shared memory settings
1071 \$wgUseMemCached = $memcached;
1072 \$wgMemCachedServers = $mcservers;
1073 {$turck}\$wgUseTurckShm = function_exists( 'mmcache_get' ) && php_sapi_name() == 'apache';
1075 ## To enable image uploads, make sure the 'images' directory
1076 ## is writable, then uncomment this:
1077 # \$wgDisableUploads = false;
1078 \$wgUseImageResize = {$conf->UseImageResize};
1079 {$magic}\$wgUseImageMagick = true;
1080 {$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
1082 ## If you have the appropriate support software installed
1083 ## you can enable inline LaTeX equations:
1084 # \$wgUseTeX = true;
1085 \$wgMathPath = \"{\$wgUploadPath}/math\";
1086 \$wgMathDirectory = \"{\$wgUploadDirectory}/math\";
1087 \$wgTmpDirectory = \"{\$wgUploadDirectory}/tmp\";
1089 \$wgLocalInterwiki = \$wgSitename;
1091 \$wgLanguageCode = \"{$slconf['LanguageCode']}\";
1092 \$wgUseLatin1 = " . ($conf->Latin1 ?
'true' : 'false') . ";\n
1094 \$wgProxyKey = \"$proxyKey\";
1096 ## Default skin: you can change the default skin. Use the internal symbolic
1097 ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook':
1098 # \$wgDefaultSkin = 'monobook';
1100 ## For attaching licensing metadata to pages, and displaying an
1101 ## appropriate copyright notice / icon. GNU Free Documentation
1102 ## License and Creative Commons licenses are supported so far.
1103 {$rights}\$wgEnableCreativeCommonsRdf = true;
1104 \$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright
1105 \$wgRightsUrl = \"{$slconf['RightsUrl']}\";
1106 \$wgRightsText = \"{$slconf['RightsText']}\";
1107 \$wgRightsIcon = \"{$slconf['RightsIcon']}\";
1108 # \$wgRightsCode = \"{$slconf['RightsCode']}\"; # Not yet used
1112 function dieout( $text ) {
1113 die( $text . "\n\n</body>\n</html>" );
1116 function importVar( &$var, $name, $default = "" ) {
1117 if( isset( $var[$name] ) ) {
1118 $retval = $var[$name];
1119 if ( get_magic_quotes_gpc() ) {
1120 $retval = stripslashes( $retval );
1128 function importPost( $name, $default = "" ) {
1129 return importVar( $_POST, $name, $default );
1132 function importRequest( $name, $default = "" ) {
1133 return importVar( $_REQUEST, $name, $default );
1136 function aField( &$conf, $field, $text, $type = "", $value = "" ) {
1138 $xtype = "type=\"$type\"";
1143 if(!(isset($id)) or ($id == "") ) $id = $field;
1144 $nolabel = ($type == "radio") ||
($type == "hidden");
1148 echo "\t\t<label class='column' for=\"$id\">$text</label>\n";
1151 if( $type == "radio" && $value == $conf->$field ) {
1152 $checked = "checked='checked'";
1156 echo "\t\t<input $xtype name=\"$field\" id=\"$id\" $checked value=\"";
1157 if( $type == "radio" ) {
1158 echo htmlspecialchars( $value );
1160 echo htmlspecialchars( $conf->$field );
1164 echo " $text</label>\n";
1168 if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n";
1171 function getLanguageList() {
1172 global $wgLanguageNames;
1173 if( !isset( $wgLanguageNames ) ) {
1174 $wgContLanguageCode = "xxx";
1175 function wfLocalUrl( $x ) { return $x; }
1176 function wfLocalUrlE( $x ) { return $x; }
1177 require_once( "../languages/Names.php" );
1181 $latin1 = array( "da", "de", "en", "es", "fr", "nl", "sv" );
1183 $d = opendir( "../languages" );
1184 while( false !== ($f = readdir( $d ) ) ) {
1185 if( preg_match( '/Language([A-Z][a-z_]+)\.php$/', $f, $m ) ) {
1186 $code = str_replace( '_', '-', strtolower( $m[1] ) );
1187 if( isset( $wgLanguageNames[$code] ) ) {
1188 $name = $code . ' - ' . $wgLanguageNames[$code];
1192 if( in_array( $code, $latin1 ) ) {
1193 $codes[$code] = $name . " - Unicode";
1194 $codes[$code.'-latin1'] = $name . " - Latin-1";
1196 $codes[$code] = $name;
1205 # Test a memcached server
1206 function testMemcachedServer( $server ) {
1207 $hostport = explode(":", $server);
1210 if ( !function_exists( 'fsockopen' ) ) {
1211 $errstr = "Can't connect to memcached, fsockopen() not present";
1213 if ( !$errstr && count( $hostport ) != 2 ) {
1214 $errstr = 'Please specify host and port';
1215 var_dump( $hostport );
1218 list( $host, $port ) = $hostport;
1222 $fp = @fsockopen
( $host, $port, $errno, $fsockerr, 1.0 );
1223 if ( $fp === false ) {
1224 $errstr = "Cannot connect to memcached on $host:$port : $fsockerr";
1228 $command = "version\r\n";
1229 $bytes = fwrite( $fp, $command );
1230 if ( $bytes != strlen( $command ) ) {
1231 $errstr = "Cannot write to memcached socket on $host:$port";
1235 $expected = "VERSION ";
1236 $response = fread( $fp, strlen( $expected ) );
1237 if ( $response != $expected ) {
1238 $errstr = "Didn't get correct memcached response from $host:$port";
1245 echo "<li>Connected to memcached on $host:$port successfully";