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/">
78 <img src
="../skins/common/images/wiki.png" width
="135" height
="135" alt
="" border
="0" />
82 <strong
><a href
="http://www.mediawiki.org/">MediaWiki
</a
></strong
> is
83 Copyright (C
) 2001-<?
=date('Y')?
> by Magnus Manske
, Brion Vibber
, Lee Daniel Crocker
,
84 Tim Starling
, Erik M
ö
;ller
, Gabriel Wicke
, Thomas Gries
and others
.</p
>
87 <li
><a href
="../README">Readme
</a
></li
>
88 <li
><a href
="../RELEASE-NOTES">Release notes
</a
></li
>
89 <li
><a href
="../docs/">doc
/</a
></li
>
90 <li
><a href
="http://meta.wikipedia.org/wiki/MediaWiki_User's_Guide">User
's Guide</a></li>
93 <p>This program is free software; you can redistribute it and/or modify
94 it under the terms of the GNU General Public License as published by
95 the Free Software Foundation; either version 2 of the License, or
96 (at your option) any later version.</p>
98 <p>This program is distributed in the hope that it will be useful,
99 but WITHOUT ANY WARRANTY; without even the implied warranty of
100 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
101 GNU General Public License for more details.</p>
103 <p>You should have received <a href="../COPYING">a copy of the GNU General Public License</a>
104 along with this program; if not, write to the Free Software
105 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
106 or <a href="http://www.gnu.org/copyleft/gpl.html">read it online</a></p>
111 $IP = ".."; # Just to suppress notices, not for anything useful
112 define( "MEDIAWIKI", true );
113 define( "MEDIAWIKI_INSTALL", true );
114 require_once( "../includes/Defines.php" );
115 require_once( "../includes/DefaultSettings.php" );
116 require_once( "../includes/MagicWord.php" );
117 require_once( "../includes/Namespace.php" );
120 <h1>MediaWiki <?php print $wgVersion ?> installation</h1>
125 /* Check for existing configurations and bug out! */
127 if( file_exists( "../LocalSettings.php" ) ) {
128 dieout( "<h2>Wiki is configured.</h2>
130 <p>Already configured... <a href='../index
.php
'>return to the wiki</a>.</p>
132 <p>(You should probably remove this directory for added security.)</p>" );
135 if( file_exists( "./LocalSettings.php" ) ) {
136 dieout( "<h2>You're configured
!</h2
>
138 <p
>Please move
<tt
>LocalSettings
.php
</tt
> to the parent directory
, then
139 <a href
='../index.php'>try out your wiki
</a
>.
140 (You should remove this config directory
for added security once you
're done.)</p>" );
143 if( !is_writable( "." ) ) {
144 dieout( "<h2>Can't write config file
, aborting
</h2
>
146 <p
>In order to configure the wiki you have to make the
<tt
>config
</tt
> subdirectory
147 writable by the web server
. Once configuration is done you
'll move the created
148 <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can
149 then remove the <tt>config</tt> subdirectory entirely.</p>
151 <p>To make the directory writable on a Unix/Linux system:</p>
154 <tt>cd /path/to/wiki</tt><br>
155 <tt>chmod a+w config</tt>
160 require_once( "../install-utils.inc" );
161 require_once( "../maintenance/updaters.inc" );
162 require_once( "../maintenance/convertLinks.inc" );
163 require_once( "../maintenance/archives/moveCustomMessages.inc" );
166 function getEncoded( $data ) {
167 # removing latin1 support, no need...
170 function getSitename() { return $this->getEncoded( $this->Sitename ); }
171 function getSysopName() { return $this->getEncoded( $this->SysopName ); }
172 function getSysopPass() { return $this->getEncoded( $this->SysopPass ); }
177 <p><em>Please include all of the lines below when reporting installation problems.</em></p>
179 <h2>Checking environment...</h2>
184 $wgConfiguring = true;
185 $conf = new ConfigData;
187 install_version_checks();
189 print "<li>PHP " . phpversion() . ": ok</li>\n";
191 if( ini_get( "register_globals" ) ) {
193 <li><b class='error
'>Warning:</strong> <strong>PHP's
194 <tt
><a href
="http://php.net/register_globals">register_globals
</a
></tt
>
195 option is enabled
.</strong
> MediaWiki will work correctly
, but this setting
196 increases your exposure to potential security vulnerabilities in PHP
-based
197 software running on your server
. <strong
>You should disable it
if you are able
.</strong
></li
>
201 if( ini_get( "safe_mode" ) ) {
203 <li
class='error'><strong
>Warning
: PHP
's
204 <a href='http
://www.php.net/features.safe-mode'>safe mode</a> is active!</strong>
205 You may have problems caused by this
, particularly
if using image uploads
.
212 if( ini_get( "magic_quotes_runtime" ) ) {
214 ?
><li
class='error'><strong
>Fatal
: <a href
='http://www.php.net/manual/en/ref.info.php#ini.magic-quotes-runtime'>magic_quotes_runtime
</a
> is active
!</strong
>
215 This option corrupts data input unpredictably
; you cannot install
or use
216 MediaWiki unless this option is disabled
.
220 if( ini_get( "magic_quotes_sybase" ) ) {
222 ?
><li
class='error'><strong
>Fatal
: <a href
='http://www.php.net/manual/en/ref.sybase.php#ini.magic-quotes-sybase'>magic_quotes_sybase
</a
> is active
!</strong
>
223 This option corrupts data input unpredictably
; you cannot install
or use
224 MediaWiki unless this option is disabled
.
229 dieout( "</ul><p>Cannot install wiki.</p>" );
232 $sapi = php_sapi_name();
233 $conf->prettyURLs
= true;
234 print "<li>PHP server API is $sapi; ";
237 case "apache2handler":
238 print "ok, using pretty URLs (<tt>index.php/Page_Title</tt>)";
242 case "apache2filter":
243 print "using ugly URLs (<tt>index.php?title=Page_Title</tt>)";
244 $conf->prettyURLs
= false;
247 print "unknown; using pretty URLs (<tt>index.php/Page_Title</tt>), if you have trouble change this in <tt>LocalSettings.php</tt>";
251 $conf->xml
= function_exists( "utf8_encode" );
253 print "<li>Have XML / Latin1-UTF-8 conversion support.</li>\n";
255 dieout( "PHP's XML module is missing; the wiki requires functions in
256 this module and won't work in this configuration.
257 If you're running Mandrake, install the php-xml package." );
260 $memlimit = ini_get( "memory_limit" );
261 $conf->raiseMemory
= false;
262 if( empty( $memlimit ) ) {
263 print "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n";
265 print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars( $memlimit ) . ". <strong>If this is too low, installation may fail!</strong> ";
266 $n = IntVal( $memlimit );
267 if( preg_match( '/^([0-9]+)[Mm]$/', trim( $memlimit ), $m ) ) {
268 $n = IntVal( $m[1] * (1024*1024) );
270 if( $n < 20*1024*1024 ) {
271 print "Attempting to raise limit to 20M... ";
272 if( false === ini_set( "memory_limit", "20M" ) ) {
275 $conf->raiseMemory
= true;
282 $conf->zlib
= function_exists( "gzencode" );
284 print "<li>Have zlib support; enabling output compression.</li>\n";
286 print "<li>No zlib support.</li>\n";
289 $conf->turck
= function_exists( 'mmcache_get' );
290 if ( $conf->turck
) {
291 print "<li><a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> installed</li>\n";
293 $conf->eaccel
= function_exists( 'eaccelerator_get' );
294 if ( $conf->eaccel
) {
295 $conf->turck
= 'eaccelerator';
296 print "<li><a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> installed</li>\n";
298 if (!$conf->turck
&& !$conf->eaccel
) {
299 print "<li>Neither <a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> nor <a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> are installed, " .
300 "can't use object caching functions</li>\n";
303 $conf->ImageMagick
= false;
304 $imcheck = array( "/usr/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" );
305 foreach( $imcheck as $dir ) {
306 $im = "$dir/convert";
307 if( file_exists( $im ) ) {
308 print "<li>Found ImageMagick: <tt>$im</tt>; image thumbnailing will be enabled if you enable uploads.</li>\n";
309 $conf->ImageMagick
= $im;
314 $conf->HaveGD
= function_exists( "imagejpeg" );
315 if( $conf->HaveGD
) {
316 print "<li>Found GD graphics library built-in";
317 if( !$conf->ImageMagick
) {
318 print ", image thumbnailing will be enabled if you enable uploads";
322 if( !$conf->ImageMagick
) {
323 print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n";
327 $conf->UseImageResize
= $conf->HaveGD ||
$conf->ImageMagick
;
329 # $conf->IP = "/Users/brion/Sites/inplace";
330 $conf->IP
= dirname( dirname( __FILE__
) );
331 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP
) . "</tt></li>\n";
333 # $conf->ScriptPath = "/~brion/inplace";
334 $conf->ScriptPath
= preg_replace( '{^(.*)/config.*$}', '$1', $_SERVER["PHP_SELF"] ); # was SCRIPT_NAME
335 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath
) . "</tt></li>\n";
337 $conf->posted
= ($_SERVER["REQUEST_METHOD"] == "POST");
339 $conf->Sitename
= ucfirst( importPost( "Sitename", "" ) );
340 $defaultEmail = empty( $_SERVER["SERVER_ADMIN"] )
342 : $_SERVER["SERVER_ADMIN"];
343 $conf->EmergencyContact
= importPost( "EmergencyContact", $defaultEmail );
344 $conf->DBserver
= importPost( "DBserver", "localhost" );
345 $conf->DBname
= importPost( "DBname", "wikidb" );
346 $conf->DBuser
= importPost( "DBuser", "wikiuser" );
347 $conf->DBpassword
= importPost( "DBpassword" );
348 $conf->DBpassword2
= importPost( "DBpassword2" );
349 $conf->DBprefix
= importPost( "DBprefix" );
350 $conf->RootPW
= importPost( "RootPW" );
351 $conf->LanguageCode
= importPost( "LanguageCode", "en" );
352 $conf->SysopName
= importPost( "SysopName", "WikiSysop" );
353 $conf->SysopPass
= importPost( "SysopPass" );
354 $conf->SysopPass2
= importPost( "SysopPass2" );
356 /* Check for validity */
359 if( $conf->Sitename
== "" ||
$conf->Sitename
== "MediaWiki" ||
$conf->Sitename
== "Mediawiki" ) {
360 $errs["Sitename"] = "Must not be blank or \"MediaWiki\".";
362 if( $conf->DBuser
== "" ) {
363 $errs["DBuser"] = "Must not be blank";
365 if( $conf->DBpassword
== "" ) {
366 $errs["DBpassword"] = "Must not be blank";
368 if( $conf->DBpassword
!= $conf->DBpassword2
) {
369 $errs["DBpassword2"] = "Passwords don't match!";
371 if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix
) ) {
372 $errs["DBprefix"] = "Invalid table prefix";
375 if( $conf->SysopPass
== "" ) {
376 $errs["SysopPass"] = "Must not be blank";
378 if( $conf->SysopPass
!= $conf->SysopPass2
) {
379 $errs["SysopPass2"] = "Passwords don't match!";
382 $conf->License
= importRequest( "License", "none" );
383 if( $conf->License
== "gfdl" ) {
384 $conf->RightsUrl
= "http://www.gnu.org/copyleft/fdl.html";
385 $conf->RightsText
= "GNU Free Documentation License 1.2";
386 $conf->RightsCode
= "gfdl";
387 $conf->RightsIcon
= '${wgStylePath}/common/images/gnu-fdl.png';
388 } elseif( $conf->License
== "none" ) {
389 $conf->RightsUrl
= $conf->RightsText
= $conf->RightsCode
= $conf->RightsIcon
= "";
391 $conf->RightsUrl
= importRequest( "RightsUrl", "" );
392 $conf->RightsText
= importRequest( "RightsText", "" );
393 $conf->RightsCode
= importRequest( "RightsCode", "" );
394 $conf->RightsIcon
= importRequest( "RightsIcon", "" );
397 $conf->Shm
= importRequest( "Shm", "none" );
398 $conf->MCServers
= importRequest( "MCServers" );
400 /* Test memcached servers */
402 if ( $conf->Shm
== 'memcached' && $conf->MCServers
) {
403 $conf->MCServerArray
= array_map( 'trim', explode( ',', $conf->MCServers
) );
404 foreach ( $conf->MCServerArray
as $server ) {
405 $error = testMemcachedServer( $server );
407 $errs["MCServers"] = $error;
411 } else if ( $conf->Shm
== 'memcached' ) {
412 $errs["MCServers"] = "Please specify at least one server if you wish to use memcached";
415 /* default values for installation */
416 $conf->Email
=importRequest("Email", "email_enabled");
417 $conf->Emailuser
=importRequest("Emailuser", "emailuser_enabled");
418 $conf->Enotif
=importRequest("Enotif", "enotif_allpages");
419 $conf->Eauthent
=importRequest("Eauthent", "eauthent_enabled");
421 if( $conf->posted
&& ( 0 == count( $errs ) ) ) {
422 do { /* So we can 'continue' to end prematurely */
423 $conf->Root
= ($conf->RootPW
!= "");
425 /* Load up the settings and get installin' */
426 $local = writeLocalSettings( $conf );
427 $wgCommandLineMode = false;
430 $wgDBadminuser = "root";
431 $wgDBadminpassword = $conf->RootPW
;
432 $wgDBprefix = $conf->DBprefix
;
433 $wgCommandLineMode = true;
434 $wgUseDatabaseMessages = false; /* FIXME: For database failure */
435 require_once( "includes/Setup.php" );
438 require_once( "../maintenance/InitialiseMessages.inc" );
440 $wgTitle = Title
::newFromText( "Installation script" );
441 $wgDatabase = Database
::newFromParams( $wgDBserver, "root", $conf->RootPW
, "", 1 );
442 $wgDatabase->ignoreErrors(true);
444 @$myver = mysql_get_server_info( $wgDatabase->mConn
);
447 print "<li>Connected as root (automatic)</li>\n";
449 print "<li>MySQL error " . ($err = mysql_errno() ) .
450 ": " . htmlspecialchars( mysql_error() );
456 $errs["RootPW"] = "Check password";
458 print "<li>Trying regular user...\n";
459 /* Try the regular user... */
460 $wgDBadminuser = $wgDBuser;
461 $wgDBadminpassword = $wgDBpassword;
462 $wgDatabase = Database
::newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, "", 1 );
463 $wgDatabase->isOpen();
464 $wgDatabase->ignoreErrors(true);
465 @$myver = mysql_get_server_info( $wgDatabase->mConn
);
467 $errs["DBuser"] = "Check name/pass";
468 $errs["DBpassword"] = "or enter root";
469 $errs["DBpassword2"] = "password below";
470 $errs["RootPW"] = "Got root?";
471 print " need password.</li>\n";
483 $errs["DBserver"] = "Connection failed";
486 $errs["DBserver"] = "Couldn't connect to database";
492 if ( !$wgDatabase->isOpen() ) {
493 $errs["DBserver"] = "Couldn't connect to database";
497 print "<li>Connected to database... $myver";
498 if( version_compare( $myver, "4.0.0" ) >= 0 ) {
499 print "; enabling MySQL 4 enhancements";
500 $conf->DBmysql4
= true;
501 $local = writeLocalSettings( $conf );
505 @$sel = mysql_select_db( $wgDBname, $wgDatabase->mConn
);
507 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
509 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
511 print "<li>Couldn't create database <tt>" .
512 htmlspecialchars( $wgDBname ) .
513 "</tt>; try with root access or check your username/pass.</li>\n";
514 $errs["RootPW"] = "<- Enter";
517 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
520 $wgDatabase->selectDB( $wgDBname );
522 if( $wgDatabase->tableExists( "cur" ) ||
$wgDatabase->tableExists( "revision" ) ) {
523 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n";
525 # Create user if required
527 $conn = Database
::newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
528 if ( $conn->isOpen() ) {
529 print "<li>DB user account ok</li>\n";
532 print "<li>Granting user permissions...</li>\n";
533 dbsource( "../maintenance/users.sql", $wgDatabase );
543 print "<li>Finished update checks.</li>\n";
545 # FIXME: Check for errors
546 print "<li>Creating tables...";
547 dbsource( "../maintenance/tables.sql", $wgDatabase );
548 dbsource( "../maintenance/interwiki.sql", $wgDatabase );
549 dbsource( "../maintenance/archives/patch-userlevels-defaultgroups.sql", $wgDatabase );
550 print " done.</li>\n";
552 print "<li>Initializing data...";
553 $wgDatabase->insert( 'site_stats',
554 array( 'ss_row_id' => 1,
555 'ss_total_views' => 0,
556 'ss_total_edits' => 0,
557 'ss_good_articles' => 0 ) );
558 # setting up the db user
560 print "<li>Granting user permissions...</li>\n";
561 dbsource( "../maintenance/users.sql", $wgDatabase );
564 if( $conf->SysopName
) {
565 $u = User
::newFromName( $conf->getSysopName() );
566 if ( 0 == $u->idForName() ) {
568 $u->setPassword( $conf->getSysopPass() );
569 $u->addRight( "sysop" );
570 $u->addRight( "bureaucrat" );
573 # Set up the new user in the sysop group
574 # This is a bit of an ugly hack
575 global $wgSysopGroupId, $wgBureaucratGroupId;
576 $groups = $u->getGroups();
577 $groups[] = $wgSysopGroupId;
578 $groups[] = $wgBureaucratGroupId;
579 $u->setGroups( $groups );
582 print "<li>Created sysop account <tt>" .
583 htmlspecialchars( $conf->SysopName
) . "</tt>.</li>\n";
585 print "<li>Could not create user - already exists!</li>\n";
588 print "<li>Skipped sysop account creation, no name given.</li>\n";
591 $titleobj = Title
::newFromText( wfMsgNoDB( "mainpage" ) );
592 $article = new Article( $titleobj );
593 $newid = $article->insertOn( $wgDatabase );
594 $revision = new Revision( array(
596 'text' => wfMsg( 'mainpagetext' ) . "\n\n" . wfMsg( 'mainpagedocfooter' ),
599 'user_text' => 'MediaWiki default',
601 $revid = $revision->insertOn( $wgDatabase );
602 $article->updateRevisionOn( $wgDatabase, $revision );
605 initialiseMessages();
606 print "</pre></li>\n";
609 /* Write out the config file now that all is well */
610 print "<p>Creating LocalSettings.php...</p>\n\n";
611 $localSettings = "<" . "?php$endl$local$endl?" . ">";
613 if( version_compare( phpversion(), "4.3.2" ) >= 0 ) {
614 $xt = "xt"; # Refuse to overwrite an existing file
616 $xt = "wt"; # 'x' is not available prior to PHP 4.3.2. We did check above, but race conditions blah blah
618 $f = fopen( "LocalSettings.php", $xt );
621 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" .
622 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
623 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
625 if(fwrite( $f, $localSettings ) ) {
628 print "<p>Success! Move the config/LocalSettings.php file into the parent directory, then follow
629 <a href='{$conf->ScriptPath}/index.php'>this link</a> to your wiki.</p>\n";
632 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");
644 if( count( $errs ) ) {
645 /* Display options form */
647 if( $conf->posted
) {
648 echo "<p class='error'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
652 <form name
="config" method
="post">
660 aField( $conf, "Sitename", "Site name:" );
664 Your site name should be a relatively short word
. It
'll appear as the namespace
665 name for 'meta
' pages as well as throughout the user interface. Good site names
666 are things like "<a href="http://www.wikipedia.org/">Wikipedia</a>" and
667 "<a href="http://openfacts.berlios.de/">OpenFacts</a>"; avoid punctuation,
668 which may cause problems.
673 aField( $conf, "EmergencyContact", "Contact e-mail" );
677 This will be used as the return address for password reminders and
678 may be displayed in some error conditions so visitors can get in
679 touch with you. It is also be used as the default sender address of e-mail
680 notifications (enotifs).
684 <label class='column
' for="LanguageCode">Language</label>
685 <select id="LanguageCode" name="LanguageCode">
688 $list = getLanguageList();
689 foreach( $list as $code => $name ) {
690 $sel = ($code == $conf->LanguageCode) ? 'selected
="selected"' : '';
691 echo "\t\t<option value=\"$code\" $sel>$name</option>\n";
697 You may select the language for the user interface of the wiki...
698 Some localizations are less complete than others. Unicode (UTF-8 encoding)
699 is used for all localizations.
703 <label class='column
'>Copyright/license metadata</label>
704 <div>Select one:</div>
707 <li><?php aField( $conf, "License", "no license metadata", "radio", "none" ); ?></li>
708 <li><?php aField( $conf, "License", "GNU Free Documentation License 1.2 (Wikipedia-compatible)", "radio", "gfdl" ); ?></li>
710 aField( $conf, "License", "a Creative Commons license...", "radio", "cc" );
711 $partner = "MediaWiki";
712 $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/index.php?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
713 $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" );
714 $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" );
715 print "<a href=\"$ccApp\">choose</a>";
716 ?> (link will wipe out any other data in this form!)
717 <?php if( $conf->License == "cc" ) { ?>
719 <li><?php aField( $conf, "RightsIcon", "<img src=\"" . htmlspecialchars( $conf->RightsIcon ) . "\" alt='icon
' />", "hidden" ); ?></li>
720 <li><?php aField( $conf, "RightsText", htmlspecialchars( $conf->RightsText ), "hidden" ); ?></li>
721 <li><?php aField( $conf, "RightsCode", "code: " . htmlspecialchars( $conf->RightsCode ), "hidden" ); ?></li>
722 <li><?php aField( $conf, "RightsUrl", "<a href=\"" . htmlspecialchars( $conf->RightsUrl ) . "\">" . htmlspecialchars( $conf->RightsUrl ) . "</a>", "hidden" ); ?></li>
729 MediaWiki can include a basic license notice, icon, and machine-readable
730 copyright metadata if your wiki's content is to be licensed under
731 the GNU FDL
or a Creative Commons license
. If you
're not sure, leave
737 <?php aField( $conf, "SysopName", "Sysop account name:", "" ) ?>
740 <?php aField( $conf, "SysopPass", "password:", "password" ) ?>
743 <?php aField( $conf, "SysopPass2", "again:", "password" ) ?>
746 A sysop user account can lock or delete pages, block problematic IP
747 addresses from editing, and other maintenance tasks. If creating a new
748 wiki database, a sysop account will be created with the given name
753 <label class='column
'>Shared memory caching</label>
754 <div>Select one:</div>
757 <li><?php aField( $conf, "Shm", "no caching", "radio", "none" ); ?></li>
759 if ( $conf->turck ) {
761 aField( $conf, "Shm", "Turck MMCache", "radio", "turck" );
766 if ( $conf->eaccel ) {
768 aField( $conf, "Shm", "eAccelerator", "radio", "eaccel" );
772 <li><?php aField( $conf, "Shm", "Memcached", "radio", "memcached" ); ?></li>
773 <li><?php aField( $conf, "MCServers", "Memcached servers", "" ) ?></li>
777 Using a shared memory system such as Turck MMCache, eAccelerator, or Memcached will speed
778 up MediaWiki significantly. Memcached is the best solution but needs to be
779 installed. Specify the server addresses and ports in a comma-separted list. Only
780 use Turck shared memory if the wiki will be running on a single Apache server.
783 <h2>E-mail, e-mail notification and authentification setup</h2>
787 <label class='column
'>E-mail (general)</label>
788 <div>Select one:</div>
791 <li><?php aField( $conf, "Email", "enabled", "radio", "email_enabled" ); ?></li>
792 <li><?php aField( $conf, "Email", "disabled", "radio", "email_disabled" ); ?></li>
796 Use this to disable all e-mail functions (send a password reminder, user-to-user e-mail and e-mail notification),
797 if sending e-mails on your server doesn't work
.
800 <label
class='column'>User
-to
-user e
-mail
</label
>
801 <div
>Select one
:</div
>
804 <li
><?php
aField( $conf, "Emailuser", "enabled", "radio", "emailuser_enabled" ); ?
></li
>
805 <li
><?php
aField( $conf, "Emailuser", "disabled", "radio", "emailuser_disabled" ); ?
></li
>
809 Use this to disable only the user
-to
-user e
-mail
function (EmailUser
).
812 <label
class='column'>E
-mail notification
</label
>
813 <div
>Select one
:</div
>
816 <li
><?php
aField( $conf, "Enotif", "disabled", "radio", "enotif_disabled" ); ?
></li
>
817 <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
>
818 <li
><?php
aField( $conf, "Enotif", "enabled for changes of user_talk pages only (suited for small and large wikis)", "radio", "enotif_usertalk" ); ?
></li
>
823 $ccEnotif = htmlspecialchars( 'http://meta.wikipedia.org/Enotif' );
824 print "<a href=\"$ccEnotif\">E-mail notification</a>";
826 sends a notification e
-mail to a user
, when the user_talk page is changed
827 and/or when watch
-listed pages are changed
, depending on the above settings
.
828 When testing this feature
, be reminded
, that obviously an e
-mail address must be present in your preferences
829 and that your own changes never trigger notifications to be sent to yourself
.</p
>
831 <p
>Users get corresponding options to select
or deselect in their users
' preferences.
832 The user options are not shown on the preference page, if e-mail notification is disabled.</p>
834 <p>There are additional options for fine tuning in /includes/DefaultSettings.php .</p>
838 <label class='column
'>E-mail address authentication</label>
839 <div>Select one:</div>
842 <li><?php aField( $conf, "Eauthent", "disabled", "radio", "eauthent_disabled" ); ?></li>
843 <li><?php aField( $conf, "Eauthent", "enabled", "radio", "eauthent_enabled" ); ?></li>
848 $ccEauthent = htmlspecialchars( 'http
://meta.wikipedia.org/Eauthent' );
849 print "<a href=\"$ccEnotif\">E-mail address authentication</a>";
851 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
852 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
853 is only authenticated at the moment when the user logs in with the one
-time temporary password
.<p
>
855 <p
>The e
-mail address stays authenticated
as long
as the user does not change it
; the time of authentication is indicated
856 on the user preference page
.</p
>
858 <p
>If the option is enabled
, only authenticated e
-mail addresses can receive EmailUser mails
and/or
859 e
-mail notification mails
.</p
>
864 <h2
>Database config
</h2
>
868 aField( $conf, "DBserver", "MySQL server" );
871 If your database server isn
't on your web server, enter the name
876 aField( $conf, "DBname", "Database name" );
879 aField( $conf, "DBuser", "DB username" );
882 aField( $conf, "DBpassword", "DB password", "password" );
885 aField( $conf, "DBpassword2", "again", "password" );
888 If you only have a single user account and database available,
889 enter those here. If you have database root access (see below)
890 you can specify new accounts/databases to be created.
894 aField( $conf, "DBprefix", "Database table prefix" );
897 <p>If you need to share one database between multiple wikis, or
898 MediaWiki and another web application, you may choose to
899 add a prefix to all the table names to avoid conflicts.</p>
901 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
906 aField( $conf, "RootPW", "DB root password", "password" );
910 You will only need this if the database and/or user account
911 above don't already exist
.
912 Do <em
>not
</em
> type in your machine
's root password! MySQL
913 has its own "root" user with a separate password. (It might
914 even be blank, depending on your configuration.)
918 <label class='column
'> </label>
919 <input type="submit" value="Install!" />
929 /* -------------------------------------------------------------------------------------- */
931 function escapePhpString( $string ) {
932 return strtr( $string,
943 function writeLocalSettings( $conf ) {
944 $conf->DBmysql4 = @$conf->DBmysql4 ? 'true' : 'false';
945 $conf->UseImageResize = $conf->UseImageResize ? 'true' : 'false';
946 $conf->PasswordSender = $conf->EmergencyContact;
947 $zlib = ($conf->zlib ? "" : "# ");
948 $magic = ($conf->ImageMagick ? "" : "# ");
949 $convert = ($conf->ImageMagick ? $conf->ImageMagick : "/usr/bin/convert" );
950 $pretty = ($conf->prettyURLs ? "" : "# ");
951 $ugly = ($conf->prettyURLs ? "# " : "");
952 $rights = ($conf->RightsUrl) ? "" : "# ";
954 switch ( $conf->Shm ) {
958 $mcservers = var_export( $conf->MCServerArray
, true );
962 $memcached = 'false';
963 $mcservers = 'array()';
967 $memcached = 'false';
968 $mcservers = 'array()';
972 if ( $conf->Email
== 'email_enabled' ) {
973 $enableemail = 'true';
974 $enableuseremail = ( $conf->Emailuser
== 'emailuser_enabled' ) ?
'true' : 'false' ;
975 $eauthent = ( $conf->Eauthent
== 'eauthent_enabled' ) ?
'true' : 'false' ;
976 switch ( $conf->Enotif
) {
977 case 'enotif_usertalk':
978 $enotifusertalk = 'true';
979 $enotifwatchlist = 'false';
981 case 'enotif_allpages':
982 $enotifusertalk = 'true';
983 $enotifwatchlist = 'true';
986 $enotifusertalk = 'false';
987 $enotifwatchlist = 'false';
990 $enableuseremail = 'false';
991 $enableemail = 'false';
993 $enotifusertalk = 'false';
994 $enotifwatchlist = 'false';
997 $file = @fopen
( "/dev/urandom", "r" );
999 $secretKey = bin2hex( fread( $file, 32 ) );
1003 for ( $i=0; $i<8; $i++
) {
1004 $secretKey .= dechex(mt_rand(0, 0x7fffffff));
1006 print "<li>Warning: \$wgSecretKey key is insecure, generated with mt_rand(). Consider changing it manually.</li>\n";
1009 # Add slashes to strings for double quoting
1010 $slconf = array_map( "escapePhpString", get_object_vars( $conf ) );
1011 if( $conf->License
== 'gfdl' ) {
1012 # Needs literal string interpolation for the current style path
1013 $slconf['RightsIcon'] = $conf->RightsIcon
;
1016 $sep = (DIRECTORY_SEPARATOR
== "\\") ?
";" : ":";
1018 # This file was automatically generated by the MediaWiki installer.
1019 # If you make manual changes, please keep track in case you need to
1020 # recreate them later.
1022 \$IP = \"{$slconf['IP']}\";
1023 ini_set( \"include_path\", \".$sep\$IP$sep\$IP/includes$sep\$IP/languages\" );
1024 require_once( \"includes/DefaultSettings.php\" );
1026 # If PHP's memory limit is very low, some operations may fail.
1027 " . ($conf->raiseMemory ?
'' : '# ' ) . "ini_set( 'memory_limit', '20M' );" . "
1029 if ( \$wgCommandLineMode ) {
1030 if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
1031 die( \"This script must be run from the command line\\n\" );
1033 } elseif ( empty( \$wgConfiguring ) ) {
1034 ## Compress output if the browser supports it
1035 {$zlib}if( !ini_get( 'zlib.output_compression' ) ) @ob_start( 'ob_gzhandler' );
1038 \$wgSitename = \"{$slconf['Sitename']}\";
1040 \$wgScriptPath = \"{$slconf['ScriptPath']}\";
1041 \$wgScript = \"\$wgScriptPath/index.php\";
1042 \$wgRedirectScript = \"\$wgScriptPath/redirect.php\";
1044 ## If using PHP as a CGI module, use the ugly URLs
1045 {$pretty}\$wgArticlePath = \"\$wgScript/\$1\";
1046 {$ugly}\$wgArticlePath = \"\$wgScript?title=\$1\";
1048 \$wgStylePath = \"\$wgScriptPath/skins\";
1049 \$wgStyleDirectory = \"\$IP/skins\";
1050 \$wgLogo = \"\$wgStylePath/common/images/wiki.png\";
1052 \$wgUploadPath = \"\$wgScriptPath/images\";
1053 \$wgUploadDirectory = \"\$IP/images\";
1055 \$wgEnableEmail = $enableemail;
1056 \$wgEnableUserEmail = $enableuseremail;
1058 \$wgEmergencyContact = \"{$slconf['EmergencyContact']}\";
1059 \$wgPasswordSender = \"{$slconf['PasswordSender']}\";
1061 ## For a detailed description of the following switches see
1062 ## http://meta.wikimedia.org/Enotif and http://meta.wikimedia.org/Eauthent
1063 ## There are many more options for fine tuning available see
1064 ## /includes/DefaultSettings.php
1065 ## UPO means: this is also a user preference option
1066 \$wgEmailNotificationForUserTalkPages = $enotifusertalk; # UPO
1067 \$wgEmailNotificationForWatchlistPages = $enotifwatchlist; # UPO
1068 \$wgEmailAuthentication = $eauthent;
1070 \$wgDBserver = \"{$slconf['DBserver']}\";
1071 \$wgDBname = \"{$slconf['DBname']}\";
1072 \$wgDBuser = \"{$slconf['DBuser']}\";
1073 \$wgDBpassword = \"{$slconf['DBpassword']}\";
1074 \$wgDBprefix = \"{$slconf['DBprefix']}\";
1076 # If you're on MySQL 3.x, this next line must be FALSE:
1077 \$wgDBmysql4 = \$wgEnablePersistentLC = {$conf->DBmysql4};
1079 ## Shared memory settings
1080 \$wgUseMemCached = $memcached;
1081 \$wgMemCachedServers = $mcservers;
1082 {$turck}\$wgUseTurckShm = function_exists( 'mmcache_get' ) && ( php_sapi_name() == 'apache' || php_sapi_name() == 'apache2handler' );
1083 {$turck}\$wgUseEAccelShm = function_exists( 'eaccelerator_get' ) && ( php_sapi_name() == 'apache' || php_sapi_name() == 'apache2handler' );
1085 ## To enable image uploads, make sure the 'images' directory
1086 ## is writable, then uncomment this:
1087 # \$wgEnableUploads = true;
1088 \$wgUseImageResize = {$conf->UseImageResize};
1089 {$magic}\$wgUseImageMagick = true;
1090 {$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
1092 ## If you have the appropriate support software installed
1093 ## you can enable inline LaTeX equations:
1094 # \$wgUseTeX = true;
1095 \$wgMathPath = \"{\$wgUploadPath}/math\";
1096 \$wgMathDirectory = \"{\$wgUploadDirectory}/math\";
1097 \$wgTmpDirectory = \"{\$wgUploadDirectory}/tmp\";
1099 \$wgLocalInterwiki = \$wgSitename;
1101 \$wgLanguageCode = \"{$slconf['LanguageCode']}\";
1103 \$wgProxyKey = \"$secretKey\";
1105 ## Default skin: you can change the default skin. Use the internal symbolic
1106 ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook':
1107 # \$wgDefaultSkin = 'monobook';
1109 ## For attaching licensing metadata to pages, and displaying an
1110 ## appropriate copyright notice / icon. GNU Free Documentation
1111 ## License and Creative Commons licenses are supported so far.
1112 {$rights}\$wgEnableCreativeCommonsRdf = true;
1113 \$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright
1114 \$wgRightsUrl = \"{$slconf['RightsUrl']}\";
1115 \$wgRightsText = \"{$slconf['RightsText']}\";
1116 \$wgRightsIcon = \"{$slconf['RightsIcon']}\";
1117 # \$wgRightsCode = \"{$slconf['RightsCode']}\"; # Not yet used
1121 function dieout( $text ) {
1122 die( $text . "\n\n</body>\n</html>" );
1125 function importVar( &$var, $name, $default = "" ) {
1126 if( isset( $var[$name] ) ) {
1127 $retval = $var[$name];
1128 if ( get_magic_quotes_gpc() ) {
1129 $retval = stripslashes( $retval );
1137 function importPost( $name, $default = "" ) {
1138 return importVar( $_POST, $name, $default );
1141 function importRequest( $name, $default = "" ) {
1142 return importVar( $_REQUEST, $name, $default );
1145 function aField( &$conf, $field, $text, $type = "", $value = "" ) {
1147 $xtype = "type=\"$type\"";
1152 if(!(isset($id)) or ($id == "") ) $id = $field;
1153 $nolabel = ($type == "radio") ||
($type == "hidden");
1157 echo "\t\t<label class='column' for=\"$id\">$text</label>\n";
1160 if( $type == "radio" && $value == $conf->$field ) {
1161 $checked = "checked='checked'";
1165 echo "\t\t<input $xtype name=\"$field\" id=\"$id\" $checked value=\"";
1166 if( $type == "radio" ) {
1167 echo htmlspecialchars( $value );
1169 echo htmlspecialchars( $conf->$field );
1173 echo " $text</label>\n";
1177 if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n";
1180 function getLanguageList() {
1181 global $wgLanguageNames;
1182 if( !isset( $wgLanguageNames ) ) {
1183 $wgContLanguageCode = "xxx";
1184 function wfLocalUrl( $x ) { return $x; }
1185 function wfLocalUrlE( $x ) { return $x; }
1186 require_once( "../languages/Names.php" );
1191 $d = opendir( "../languages" );
1192 while( false !== ($f = readdir( $d ) ) ) {
1193 if( preg_match( '/Language([A-Z][a-z_]+)\.php$/', $f, $m ) ) {
1194 $code = str_replace( '_', '-', strtolower( $m[1] ) );
1195 if( isset( $wgLanguageNames[$code] ) ) {
1196 $name = $code . ' - ' . $wgLanguageNames[$code];
1200 $codes[$code] = $name;
1208 # Test a memcached server
1209 function testMemcachedServer( $server ) {
1210 $hostport = explode(":", $server);
1213 if ( !function_exists( 'fsockopen' ) ) {
1214 $errstr = "Can't connect to memcached, fsockopen() not present";
1216 if ( !$errstr && count( $hostport ) != 2 ) {
1217 $errstr = 'Please specify host and port';
1218 var_dump( $hostport );
1221 list( $host, $port ) = $hostport;
1225 $fp = @fsockopen
( $host, $port, $errno, $fsockerr, 1.0 );
1226 if ( $fp === false ) {
1227 $errstr = "Cannot connect to memcached on $host:$port : $fsockerr";
1231 $command = "version\r\n";
1232 $bytes = fwrite( $fp, $command );
1233 if ( $bytes != strlen( $command ) ) {
1234 $errstr = "Cannot write to memcached socket on $host:$port";
1238 $expected = "VERSION ";
1239 $response = fread( $fp, strlen( $expected ) );
1240 if ( $response != $expected ) {
1241 $errstr = "Didn't get correct memcached response from $host:$port";
1248 echo "<li>Connected to memcached on $host:$port successfully";