3 # MediaWiki web-based config/installation
4 # Copyright (C) 2004 Brion Vibber <brion@pobox.com>, 2006 Rob Church <robchur@gmail.com>
5 # http://www.mediawiki.org/
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along
18 # with this program; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 # http://www.gnu.org/copyleft/gpl.html
22 error_reporting( E_ALL
);
23 header( "Content-type: text/html; charset=utf-8" );
24 @ini_set
( "display_errors", true );
26 # In case of errors, let output be clean.
27 $wgRequestTime = microtime( true );
29 # Attempt to set up the include path, to fix problems with relative includes
30 $IP = dirname( dirname( __FILE__
) );
31 define( 'MW_INSTALL_PATH', $IP );
32 $sep = PATH_SEPARATOR
;
33 if( !ini_set( "include_path", ".$sep$IP$sep$IP/includes$sep$IP/languages" ) ) {
34 set_include_path( ".$sep$IP$sep$IP/includes$sep$IP/languages" );
37 # Define an entry point and include some files
38 define( "MEDIAWIKI", true );
39 define( "MEDIAWIKI_INSTALL", true );
41 // Run version checks before including other files
42 // so people don't see a scary parse error.
43 require_once( "install-utils.inc" );
44 install_version_checks();
46 require_once( "includes/Defines.php" );
47 require_once( "includes/DefaultSettings.php" );
48 require_once( "includes/MagicWord.php" );
49 require_once( "includes/Namespace.php" );
50 require_once( "includes/ProfilerStub.php" );
52 ## Databases we support:
55 $ourdb['mysql']['fullname'] = 'MySQL';
56 $ourdb['mysql']['havedriver'] = 0;
57 $ourdb['mysql']['compile'] = 'mysql';
58 $ourdb['mysql']['bgcolor'] = '#ffe5a7';
59 $ourdb['mysql']['rootuser'] = 'root';
61 $ourdb['postgres']['fullname'] = 'PostgreSQL';
62 $ourdb['postgres']['havedriver'] = 0;
63 $ourdb['postgres']['compile'] = 'pgsql';
64 $ourdb['postgres']['bgcolor'] = '#aaccff';
65 $ourdb['postgres']['rootuser'] = 'postgres';
68 <!DOCTYPE HTML
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
71 <meta http
-equiv
="Content-type" content
="text/html; charset=utf-8">
72 <title
>MediaWiki
<?php
echo( $wgVersion ); ?
> Installation
</title
>
73 <style type
="text/css">
75 @import
"../skins/monobook/main.css";
79 margin
: 1em
0 1em
2.5em
;
86 .config
-section label
.column
{
98 zoom
: 100%
; /* IE hack */
101 .config
-section
.config
-desc
{
103 margin
: 0 0 2em
18em
;
108 .iput
-text
, .iput
-password
{
115 background
-color
: #fff;
123 background
-color
: #FFF0F0;
124 border
: 2px solid red
;
132 list-style
-type
: none
;
133 list-style
-image
: none
;
151 <script type
="text/javascript">
154 <?php
foreach (array_keys($ourdb) as $db) {
155 echo "\n document.getElementById('$db').style.display='none';";
160 function toggleDBarea(id
,defaultroot
) {
162 var dbarea
= document
.getElementById(id
).style
;
163 dbarea
.display
= (dbarea
.display
== 'none') ?
'block' : 'none';
164 var db
= document
.getElementById('RootUser');
166 <?php
foreach (array_keys($ourdb) as $db) {
167 echo " if (id == '$db') { db.value = '".$ourdb[$db]['rootuser']."';}\n";
176 <div id
="globalWrapper">
177 <div id
="column-content">
179 <div id
="bodyContent">
181 <h1
>MediaWiki
<?php
print $wgVersion ?
> Installation
</h1
>
185 /* Check for existing configurations and bug out! */
187 if( file_exists( "../LocalSettings.php" ) ) {
188 dieout( "<p><strong>Setup has completed, <a href='../index.php'>your wiki</a> is configured.</strong></p>
190 <p>Please delete the /config directory for extra security.</p></div></div></div></div>" );
193 if( file_exists( "./LocalSettings.php" ) ) {
194 writeSuccessMessage();
199 if( !is_writable( "." ) ) {
200 dieout( "<h2>Can't write config file, aborting</h2>
202 <p>In order to configure the wiki you have to make the <tt>config</tt> subdirectory
203 writable by the web server. Once configuration is done you'll move the created
204 <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can
205 then remove the <tt>config</tt> subdirectory entirely.</p>
207 <p>To make the directory writable on a Unix/Linux system:</p>
210 cd <i>/path/to/wiki</i>
214 <p>Afterwards retry to start the <a href=\"\">setup</a>.</p>" );
218 require_once( "install-utils.inc" );
219 require_once( "maintenance/updaters.inc" );
222 function getEncoded( $data ) {
223 # removing latin1 support, no need...
226 function getSitename() { return $this->getEncoded( $this->Sitename
); }
227 function getSysopName() { return $this->getEncoded( $this->SysopName
); }
228 function getSysopPass() { return $this->getEncoded( $this->SysopPass
); }
230 function setSchema( $schema ) {
231 $this->DBschema
= $schema;
232 switch ( $this->DBschema
) {
234 $this->DBTableOptions
= 'ENGINE=InnoDB, DEFAULT CHARSET=utf8';
235 $this->DBmysql5
= 'true';
237 case 'mysql5-binary':
238 $this->DBTableOptions
= 'ENGINE=InnoDB, DEFAULT CHARSET=binary';
239 $this->DBmysql5
= 'true';
242 $this->DBTableOptions
= 'TYPE=InnoDB';
243 $this->DBmysql5
= 'false';
245 # Set the global for use during install
246 global $wgDBTableOptions;
247 $wgDBTableOptions = $this->DBTableOptions
;
255 <b
>Don
't forget security updates!</b> Keep an eye on the
256 <a href="http://mail.wikimedia.org/mailman/listinfo/mediawiki-announce">low-traffic
257 release announcements mailing list</a>.
262 <h2>Checking environment...</h2>
263 <p><em>Please include all of the lines below when reporting installation problems.</em></p>
264 <ul class="env-check">
268 define( 'MW_NO_OUTPUT_BUFFER
', 1 );
269 $conf = new ConfigData;
271 install_version_checks();
273 print "<li>PHP " . phpversion() . " installed</li>\n";
275 ## Temporarily turn off all errors as we try to discover installed databases
276 $olderrnum = error_reporting(0);
278 $phpdatabases = array();
279 foreach (array_keys($ourdb) as $db) {
280 $compname = $ourdb[$db]['compile
'];
281 if (extension_loaded($compname) or dl($compname . '.' . PHP_SHLIB_SUFFIX)) {
282 array_push($phpdatabases, $db);
283 $ourdb[$db]['havedriver
'] = 1;
287 error_reporting($olderrornum);
289 if (!$phpdatabases) {
290 print "Could not find a suitable database driver!<ul>";
291 foreach (array_keys($ourdb) AS $db) {
292 $comp = $ourdb[$db]['compile
'];
293 $full = $ourdb[$db]['fullname
'];
294 print "<li>For <b>$full</b>, compile PHP using <b>--with-$comp</b>, "
295 ."or install the $comp.so module</li>\n";
297 dieout( "</ul></ul>" );
300 print "<li>Found database drivers for:";
301 foreach (array_keys($ourdb) AS $db) {
302 if ($ourdb[$db]['havedriver
']) {
303 $DefaultDBtype = $db;
304 print " ".$ourdb[$db]['fullname
'];
308 if (count($phpdatabases) != 1)
311 if( ini_get( "register_globals" ) ) {
314 <div style="font-size:110%">
315 <strong class="error">Warning:</strong>
316 <strong>PHP's
<tt
><a href
="http://php.net/register_globals">register_globals
</a
></tt
> option is enabled
. Disable it
if you can
.</strong
>
318 MediaWiki will work
, but your server is more exposed to PHP
-based security vulnerabilities
.
325 if( ini_get( "magic_quotes_runtime" ) ) {
327 ?
><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
>
328 This option corrupts data input unpredictably
; you cannot install
or use
329 MediaWiki unless this option is disabled
.
333 if( ini_get( "magic_quotes_sybase" ) ) {
335 ?
><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
>
336 This option corrupts data input unpredictably
; you cannot install
or use
337 MediaWiki unless this option is disabled
.
341 if( ini_get( "mbstring.func_overload" ) ) {
343 ?
><li
class='error'><strong
>Fatal
: <a href
='http://www.php.net/manual/en/ref.mbstring.php#mbstring.overload'>mbstring
.func_overload
</a
> is active
!</strong
>
344 This option causes errors
and may corrupt data unpredictably
;
345 you cannot install
or use MediaWiki unless this option is disabled
.
349 if( ini_get( "zend.ze1_compatibility_mode" ) ) {
351 ?
><li
class="error"><strong
>Fatal
: <a href
="http://www.php.net/manual/en/ini.core.php">zend
.ze1_compatibility_mode
</a
> is active
!</strong
>
352 This option causes horrible bugs with MediaWiki
; you cannot install
or use
353 MediaWiki unless this option is disabled
.
359 dieout( "</ul><p>Cannot install MediaWiki.</p>" );
362 if( ini_get( "safe_mode" ) ) {
363 $conf->safeMode
= true;
365 <li
><b
class='error'>Warning
:</b
> <strong
>PHP
's
366 <a href='http
://www.php.net/features.safe-mode'>safe mode</a> is active.</strong>
367 You may have problems caused by this
, particularly
if using image uploads
.
371 $conf->safeMode
= false;
374 $sapi = php_sapi_name();
375 print "<li>PHP server API is $sapi; ";
376 if( $wgUsePathInfo ) {
377 print "ok, using pretty URLs (<tt>index.php/Page_Title</tt>)";
379 print "using ugly URLs (<tt>index.php?title=Page_Title</tt>)";
383 $conf->xml
= function_exists( "utf8_encode" );
385 print "<li>Have XML / Latin1-UTF-8 conversion support.</li>\n";
387 dieout( "PHP's XML module is missing; the wiki requires functions in
388 this module and won't work in this configuration.
389 If you're running Mandrake, install the php-xml package." );
392 # Check for session support
393 if( !function_exists( 'session_name' ) )
394 dieout( "PHP's session module is missing. MediaWiki requires session support in order to function." );
396 # session.save_path doesn't *have* to be set, but if it is, and it's
397 # not valid/writable/etc. then it can cause problems
398 $sessionSavePath = ini_get( 'session.save_path' );
399 # Warn the user if it's not set, but let them proceed
400 if( !$sessionSavePath ) {
401 print "<li><strong>Warning:</strong> A value for <tt>session.save_path</tt>
402 has not been set in PHP.ini. If the default value causes problems with
403 saving session data, set it to a valid path which is read/write/execute
404 for the user your web server is running under.</li>";
405 } elseif ( is_dir( $sessionSavePath ) && is_writable( $sessionSavePath ) ) {
406 # All good? Let the user know
407 print "<li>Session save path appears to be valid.</li>";
409 # Something not right? Halt the installation so the user can fix it up
410 dieout( "Your session save path appears to be invalid or is not writable.
411 PHP needs to be able to save data to this location in order for correct
412 session operation. Please check that <tt>session.save_path</tt> in
413 <tt>PHP.ini</tt> points to a valid path, and is read/write/execute for
414 the user your web server is running under." );
417 # Check for PCRE support
418 if( !function_exists( 'preg_match' ) )
419 dieout( "The PCRE support module appears to be missing. MediaWiki requires the
420 Perl-compatible regular expression functions." );
422 $memlimit = ini_get( "memory_limit" );
423 $conf->raiseMemory
= false;
424 if( empty( $memlimit ) ||
$memlimit == -1 ) {
425 print "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n";
427 print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars( $memlimit ) . ". ";
428 $n = intval( $memlimit );
429 if( preg_match( '/^([0-9]+)[Mm]$/', trim( $memlimit ), $m ) ) {
430 $n = intval( $m[1] * (1024*1024) );
432 if( $n < 20*1024*1024 ) {
433 print "Attempting to raise limit to 20M... ";
434 if( false === ini_set( "memory_limit", "20M" ) ) {
435 print "failed.<br /><b>" . htmlspecialchars( $memlimit ) . " seems too low, installation may fail!</b>";
437 $conf->raiseMemory
= true;
444 $conf->turck
= function_exists( 'mmcache_get' );
445 if ( $conf->turck
) {
446 print "<li><a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> installed</li>\n";
449 $conf->apc
= function_exists('apc_fetch');
451 print "<li><a href=\"http://www.php.net/apc\">APC</a> installed</li>";
454 $conf->eaccel
= function_exists( 'eaccelerator_get' );
455 if ( $conf->eaccel
) {
456 $conf->turck
= 'eaccelerator';
457 print "<li><a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> installed</li>\n";
460 if( !$conf->turck
&& !$conf->eaccel
&& !$conf->apc
) {
461 echo( '<li>Couldn\'t find <a href="http://turck-mmcache.sourceforge.net">Turck MMCache</a>,
462 <a href="http://eaccelerator.sourceforge.net">eAccelerator</a>, or
463 <a href="http://www.php.net/apc">APC</a>. Object caching functions cannot be used.</li>' );
466 $conf->diff3
= false;
467 $diff3locations = array_merge(
474 explode( $sep, getenv( "PATH" ) ) );
475 $diff3names = array( "gdiff3", "diff3", "diff3.exe" );
477 $diff3versioninfo = array( '$1 --version 2>&1', 'diff3 (GNU diffutils)' );
478 foreach ($diff3locations as $loc) {
479 $exe = locate_executable($loc, $diff3names, $diff3versioninfo);
480 if ($exe !== false) {
487 print "<li>Found GNU diff3: <tt>$conf->diff3</tt>.</li>";
489 print "<li>GNU diff3 not found.</li>";
491 $conf->ImageMagick
= false;
492 $imcheck = array( "/usr/bin", "/opt/csw/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" );
493 foreach( $imcheck as $dir ) {
494 $im = "$dir/convert";
495 if( file_exists( $im ) ) {
496 print "<li>Found ImageMagick: <tt>$im</tt>; image thumbnailing will be enabled if you enable uploads.</li>\n";
497 $conf->ImageMagick
= $im;
502 $conf->HaveGD
= function_exists( "imagejpeg" );
503 if( $conf->HaveGD
) {
504 print "<li>Found GD graphics library built-in";
505 if( !$conf->ImageMagick
) {
506 print ", image thumbnailing will be enabled if you enable uploads";
510 if( !$conf->ImageMagick
) {
511 print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n";
515 $conf->IP
= dirname( dirname( __FILE__
) );
516 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP
) . "</tt></li>\n";
519 // PHP_SELF isn't available sometimes, such as when PHP is CGI but
520 // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
521 // to get the path to the current script... hopefully it's reliable. SIGH
522 $path = ($_SERVER["PHP_SELF"] === '')
523 ?
$_SERVER["SCRIPT_NAME"]
524 : $_SERVER["PHP_SELF"];
525 $conf->ScriptPath
= preg_replace( '{^(.*)/config.*$}', '$1', $path );
526 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath
) . "</tt></li>\n";
528 print "<li style='font-weight:bold;color:green;font-size:110%'>Environment checked. You can install MediaWiki.</li>\n";
529 $conf->posted
= ($_SERVER["REQUEST_METHOD"] == "POST");
531 $conf->Sitename
= ucfirst( importPost( "Sitename", "" ) );
532 $defaultEmail = empty( $_SERVER["SERVER_ADMIN"] )
534 : $_SERVER["SERVER_ADMIN"];
535 $conf->EmergencyContact
= importPost( "EmergencyContact", $defaultEmail );
536 $conf->DBtype
= importPost( "DBtype", $DefaultDBtype );
540 $conf->DBserver
= importPost( "DBserver", "localhost" );
541 $conf->DBname
= importPost( "DBname", "wikidb" );
542 $conf->DBuser
= importPost( "DBuser", "wikiuser" );
543 $conf->DBpassword
= importPost( "DBpassword" );
544 $conf->DBpassword2
= importPost( "DBpassword2" );
545 $conf->SysopName
= importPost( "SysopName", "WikiSysop" );
546 $conf->SysopPass
= importPost( "SysopPass" );
547 $conf->SysopPass2
= importPost( "SysopPass2" );
548 $conf->RootUser
= importPost( "RootUser", "root" );
549 $conf->RootPW
= importPost( "RootPW", "" );
550 $useRoot = importCheck( 'useroot', false );
553 $conf->DBprefix
= importPost( "DBprefix" );
554 $conf->setSchema( importPost( "DBschema", "mysql4" ) );
555 $conf->LanguageCode
= importPost( "LanguageCode", "en" );
557 ## Postgres specific:
558 $conf->DBport
= importPost( "DBport", "5432" );
559 $conf->DBmwschema
= importPost( "DBmwschema", "mediawiki" );
560 $conf->DBts2schema
= importPost( "DBts2schema", "public" );
562 /* Check for validity */
565 if( $conf->Sitename
== "" ||
$conf->Sitename
== "MediaWiki" ||
$conf->Sitename
== "Mediawiki" ) {
566 $errs["Sitename"] = "Must not be blank or \"MediaWiki\"";
568 if( $conf->DBuser
== "" ) {
569 $errs["DBuser"] = "Must not be blank";
571 if( ($conf->DBtype
== 'mysql') && (strlen($conf->DBuser
) > 16) ) {
572 $errs["DBuser"] = "Username too long";
574 if( $conf->DBpassword
== "" && $conf->DBtype
!= "postgres" ) {
575 $errs["DBpassword"] = "Must not be blank";
577 if( $conf->DBpassword
!= $conf->DBpassword2
) {
578 $errs["DBpassword2"] = "Passwords don't match!";
580 if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix
) ) {
581 $errs["DBprefix"] = "Invalid table prefix";
584 if( $conf->SysopPass
== "" ) {
585 $errs["SysopPass"] = "Must not be blank";
587 if( $conf->SysopPass
!= $conf->SysopPass2
) {
588 $errs["SysopPass2"] = "Passwords don't match!";
591 $conf->License
= importRequest( "License", "none" );
592 if( $conf->License
== "gfdl" ) {
593 $conf->RightsUrl
= "http://www.gnu.org/copyleft/fdl.html";
594 $conf->RightsText
= "GNU Free Documentation License 1.2";
595 $conf->RightsCode
= "gfdl";
596 $conf->RightsIcon
= '${wgScriptPath}/skins/common/images/gnu-fdl.png';
597 } elseif( $conf->License
== "none" ) {
598 $conf->RightsUrl
= $conf->RightsText
= $conf->RightsCode
= $conf->RightsIcon
= "";
600 $conf->RightsUrl
= importRequest( "RightsUrl", "" );
601 $conf->RightsText
= importRequest( "RightsText", "" );
602 $conf->RightsCode
= importRequest( "RightsCode", "" );
603 $conf->RightsIcon
= importRequest( "RightsIcon", "" );
606 $conf->Shm
= importRequest( "Shm", "none" );
607 $conf->MCServers
= importRequest( "MCServers" );
609 /* Test memcached servers */
611 if ( $conf->Shm
== 'memcached' && $conf->MCServers
) {
612 $conf->MCServerArray
= array_map( 'trim', explode( ',', $conf->MCServers
) );
613 foreach ( $conf->MCServerArray
as $server ) {
614 $error = testMemcachedServer( $server );
616 $errs["MCServers"] = $error;
620 } else if ( $conf->Shm
== 'memcached' ) {
621 $errs["MCServers"] = "Please specify at least one server if you wish to use memcached";
624 /* default values for installation */
625 $conf->Email
= importRequest("Email", "email_enabled");
626 $conf->Emailuser
= importRequest("Emailuser", "emailuser_enabled");
627 $conf->Enotif
= importRequest("Enotif", "enotif_allpages");
628 $conf->Eauthent
= importRequest("Eauthent", "eauthent_enabled");
630 if( $conf->posted
&& ( 0 == count( $errs ) ) ) {
631 do { /* So we can 'continue' to end prematurely */
632 $conf->Root
= ($conf->RootPW
!= "");
634 /* Load up the settings and get installin' */
635 $local = writeLocalSettings( $conf );
636 echo "<li style=\"list-style: none\">\n";
637 echo "<p><b>Generating configuration file...</b></p>\n";
640 $wgCommandLineMode = false;
642 $ok = eval( $local );
643 if( $ok === false ) {
644 dieout( "Errors in generated configuration; " .
645 "most likely due to a bug in the installer... " .
646 "Config file was: " .
648 htmlspecialchars( $local ) .
652 $conf->DBtypename
= '';
653 foreach (array_keys($ourdb) as $db) {
654 if ($conf->DBtype
=== $db)
655 $conf->DBtypename
= $ourdb[$db]['fullname'];
657 if ( ! strlen($conf->DBtype
)) {
658 $errs["DBpicktype"] = "Please choose a database type";
662 if (! $conf->DBtypename
) {
663 $errs["DBtype"] = "Unknown database type '$conf->DBtype'";
666 print "<li>Database type: {$conf->DBtypename}</li>\n";
667 $dbclass = 'Database'.ucfirst($conf->DBtype
);
668 $wgDBtype = $conf->DBtype
;
669 $wgDBadminuser = "root";
670 $wgDBadminpassword = $conf->RootPW
;
673 $wgDBprefix = $conf->DBprefix
;
675 ## Postgres specific:
676 $wgDBport = $conf->DBport
;
677 $wgDBmwschema = $conf->DBmwschema
;
678 $wgDBts2schema = $conf->DBts2schema
;
680 $wgCommandLineMode = true;
681 $wgUseDatabaseMessages = false; /* FIXME: For database failure */
682 require_once( "includes/Setup.php" );
685 $wgTitle = Title
::newFromText( "Installation script" );
686 error_reporting( E_ALL
);
687 print "<li>Loading class: $dbclass";
690 if( $conf->DBtype
== 'mysql' ) {
691 $mysqlOldClient = version_compare( mysql_get_client_info(), "4.1.0", "lt" );
692 if( $mysqlOldClient ) {
693 print "<li><b>PHP is linked with old MySQL client libraries. If you are
694 using a MySQL 4.1 server and have problems connecting to the database,
695 see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
696 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b></li>\n";
698 $ok = true; # Let's be optimistic
700 # Decide if we're going to use the superuser or the regular database user
701 $conf->Root
= $useRoot;
703 $db_user = $conf->RootUser
;
704 $db_pass = $conf->RootPW
;
706 $db_user = $wgDBuser;
707 $db_pass = $wgDBpassword;
711 echo( "<li>Attempting to connect to database server as $db_user..." );
712 $wgDatabase = Database
::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 );
714 # Check the connection and respond to errors
715 if( $wgDatabase->isOpen() ) {
718 $wgDBadminuser = $db_user;
719 $wgDBadminpassword = $db_pass;
720 echo( "success.</li>\n" );
721 $wgDatabase->ignoreErrors( true );
722 $myver = $wgDatabase->getServerVersion();
724 # There were errors, report them and back out
726 $errno = mysql_errno();
727 $errtx = htmlspecialchars( mysql_error() );
731 echo( "failed due to authentication errors. Check passwords.</li>" );
733 # The superuser details are wrong
734 $errs["RootUser"] = "Check username";
735 $errs["RootPW"] = "and password";
737 # The regular user details are wrong
738 $errs["DBuser"] = "Check username";
739 $errs["DBpassword"] = "and password";
745 # General connection problem
746 echo( "failed with error [$errno] $errtx.</li>\n" );
747 $errs["DBserver"] = "Connection failed";
752 if( !$ok ) { continue; }
754 } else /* not mysql */ {
755 error_reporting( E_ALL
);
757 ## Possible connect as a superuser
759 $wgDBsuperuser = $conf->RootUser
;
760 echo( "<li>Attempting to connect to database \"postgres\" as superuser \"$wgDBsuperuser\"..." );
761 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBsuperuser, $conf->RootPW
, "postgres", 1);
762 if (!$wgDatabase->isOpen()) {
763 print " error: " . $wgDatabase->lastError() . "</li>\n";
764 $errs["DBserver"] = "Could not connect to database as superuser";
765 $errs["RootUser"] = "Check username";
766 $errs["RootPW"] = "and password";
770 echo( "<li>Attempting to connect to database \"$wgDBname\" as \"$wgDBuser\"..." );
771 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1);
772 if (!$wgDatabase->isOpen()) {
773 print " error: " . $wgDatabase->lastError() . "</li>\n";
775 $myver = $wgDatabase->getServerVersion();
779 if ( !$wgDatabase->isOpen() ) {
780 $errs["DBserver"] = "Couldn't connect to database";
784 print "<li>Connected to $myver";
785 if ($conf->DBtype
== 'mysql') {
786 if( version_compare( $myver, "4.0.14" ) < 0 ) {
787 dieout( " -- mysql 4.0.14 or later required. Aborting." );
789 $mysqlNewAuth = version_compare( $myver, "4.1.0", "ge" );
790 if( $mysqlNewAuth && $mysqlOldClient ) {
791 print "; <b class='error'>You are using MySQL 4.1 server, but PHP is linked
792 to old client libraries; if you have trouble with authentication, see
793 <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
794 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>";
797 if( $mysqlNewAuth ) {
798 print "; enabling MySQL 4.1/5.0 charset mode";
800 print "; <b class='error'>MySQL 4.1/5.0 charset mode enabled,
801 but older version detected; will likely fail.</b>";
806 @$sel = $wgDatabase->selectDB( $wgDBname );
808 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
810 $err = mysql_errno();
811 $databaseSafe = htmlspecialchars( $wgDBname );
812 if( $err == 1102 /* Invalid database name */ ) {
813 print "<ul><li><strong>{$databaseSafe}</strong> is not a valid database name.</li></ul>";
815 } elseif( $err != 1049 /* Database doesn't exist */ ) {
816 print "<ul><li>Error selecting database <strong>{$databaseSafe}</strong>: {$err} ";
817 print htmlspecialchars( mysql_error() ) . "</li></ul>";
820 print "<li>Attempting to create database...</li>";
821 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
823 print "<li>Couldn't create database <tt>" .
824 htmlspecialchars( $wgDBname ) .
825 "</tt>; try with root access or check your username/pass.</li>\n";
826 $errs["RootPW"] = "<- Enter";
829 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
831 $wgDatabase->selectDB( $wgDBname );
833 else if ($conf->DBtype
== 'postgres') {
834 if( version_compare( $myver, "PostgreSQL 8.0" ) < 0 ) {
835 dieout( " <b>Postgres 8.0 or later is required</b>. Aborting.</li></ul>" );
839 if( $wgDatabase->tableExists( "cur" ) ||
$wgDatabase->tableExists( "revision" ) ) {
840 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n";
842 if ( $conf->DBtype
== 'mysql') {
844 # Determine existing default character set
845 if ( $wgDatabase->tableExists( "revision" ) ) {
846 $revision = $wgDatabase->escapeLike( $conf->DBprefix
. 'revision' );
847 $res = $wgDatabase->query( "SHOW TABLE STATUS LIKE '$revision'" );
848 $row = $wgDatabase->fetchObject( $res );
850 echo "<li>SHOW TABLE STATUS query failed!</li>\n";
851 $existingSchema = false;
852 } elseif ( preg_match( '/^latin1/', $row->Collation
) ) {
853 $existingSchema = 'mysql4';
854 } elseif ( preg_match( '/^utf8/', $row->Collation
) ) {
855 $existingSchema = 'mysql5';
856 } elseif ( preg_match( '/^binary/', $row->Collation
) ) {
857 $existingSchema = 'mysql5-binary';
859 $existingSchema = false;
860 echo "<li><strong>Warning:</strong> Unrecognised existing collation</li>\n";
862 if ( $existingSchema && $existingSchema != $conf->DBschema
) {
863 print "<li><strong>Warning:</strong> you requested the {$conf->DBschema} schema, " .
864 "but the existing database has the $existingSchema schema. This upgrade script ".
865 "can't convert it, so it will remain $existingSchema.</li>\n";
866 $conf->setSchema( $existingSchema );
870 # Create user if required
872 $conn = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
873 if ( $conn->isOpen() ) {
874 print "<li>DB user account ok</li>\n";
877 print "<li>Granting user permissions...";
878 if( $mysqlOldClient && $mysqlNewAuth ) {
879 print " <b class='error'>If the next step fails, see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'>http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>";
882 dbsource( "../maintenance/users.sql", $wgDatabase );
886 print "</ul><pre>\n";
892 print "<ul><li>Finished update checks.</li>\n";
894 # FIXME: Check for errors
895 print "<li>Creating tables...";
896 if ($conf->DBtype
== 'mysql') {
897 dbsource( "../maintenance/tables.sql", $wgDatabase );
898 dbsource( "../maintenance/interwiki.sql", $wgDatabase );
899 } else if ($conf->DBtype
== 'postgres') {
900 $wgDatabase->setup_database();
903 $errs["DBtype"] = "Do not know how to handle database type '$conf->DBtype'";
907 print " done.</li>\n";
909 print "<li>Initializing data...</li>\n";
910 $wgDatabase->insert( 'site_stats',
911 array ( 'ss_row_id' => 1,
912 'ss_total_views' => 0,
913 'ss_total_edits' => 0,
914 'ss_good_articles' => 0 ) );
916 # Set up the "regular user" account *if we can, and if we need to*
917 if( $conf->Root
and $conf->DBtype
== 'mysql') {
919 $wgDatabase2 = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
920 if( $wgDatabase2->isOpen() ) {
921 # Nope, just close the test connection and continue
922 $wgDatabase2->close();
923 echo( "<li>User $wgDBuser exists. Skipping grants.</li>\n" );
925 # Yes, so run the grants
926 echo( "<li>Granting user permissions to $wgDBuser on $wgDBname..." );
927 dbsource( "../maintenance/users.sql", $wgDatabase );
928 echo( "success.</li>\n" );
932 if( $conf->SysopName
) {
933 $u = User
::newFromName( $conf->getSysopName() );
935 print "<li><strong class=\"error\">Warning:</strong> Skipped sysop account creation - invalid username!</li>\n";
937 else if ( 0 == $u->idForName() ) {
939 $u->setPassword( $conf->getSysopPass() );
942 $u->addGroup( "sysop" );
943 $u->addGroup( "bureaucrat" );
945 print "<li>Created sysop account <tt>" .
946 htmlspecialchars( $conf->SysopName
) . "</tt>.</li>\n";
948 print "<li>Could not create user - already exists!</li>\n";
951 print "<li>Skipped sysop account creation, no name given.</li>\n";
954 $titleobj = Title
::newFromText( wfMsgNoDB( "mainpage" ) );
955 $article = new Article( $titleobj );
956 $newid = $article->insertOn( $wgDatabase );
957 $revision = new Revision( array(
959 'text' => wfMsg( 'mainpagetext' ) . "\n\n" . wfMsgNoTrans( 'mainpagedocfooter' ),
962 'user_text' => 'MediaWiki default',
964 $revid = $revision->insertOn( $wgDatabase );
965 $article->updateRevisionOn( $wgDatabase, $revision );
968 /* Write out the config file now that all is well */
969 print "<li style=\"list-style: none\">\n";
970 print "<p>Creating LocalSettings.php...</p>\n\n";
971 $localSettings = "<" . "?php$endl$local$endl\r\n";
972 // Fix up a common line-ending problem (due to CVS on Windows)
973 $localSettings = str_replace( "\r\n", "\n", $localSettings );
974 $f = fopen( "LocalSettings.php", 'xt' );
977 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" .
978 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
979 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
981 if(fwrite( $f, $localSettings ) ) {
983 writeSuccessMessage();
986 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");
999 if( count( $errs ) ) {
1000 /* Display options form */
1002 if( $conf->posted
) {
1003 echo "<p class='error-top'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
1007 <form action
="index.php" name
="config" method
="post">
1010 <h2
>Site config
</h2
>
1012 <div
class="config-section">
1013 <div
class="config-input">
1015 aField( $conf, "Sitename", "Wiki name:" );
1018 <p
class="config-desc">
1019 Preferably a short word without punctuation
, i
.e
. "Wikipedia".<br
/>
1020 Will appear
as the
namespace name
for "meta" pages
, and throughout the
interface.
1023 <div
class="config-input">
1025 aField( $conf, "EmergencyContact", "Contact e-mail:" );
1028 <p
class="config-desc">
1029 Displayed to users in some error messages
, used
as the
return address
for password reminders
, and used
as the
default sender address of e
-mail notifications
.
1032 <div
class="config-input">
1033 <label
class='column' for="LanguageCode">Language
:</label
>
1034 <select id
="LanguageCode" name
="LanguageCode">
1037 $list = getLanguageList();
1038 foreach( $list as $code => $name ) {
1039 $sel = ($code == $conf->LanguageCode
) ?
'selected="selected"' : '';
1040 echo "\t\t<option value=\"$code\" $sel>$name</option>\n";
1045 <p
class="config-desc">
1046 Select the language
for your wiki
's interface. Some localizations aren't fully complete
. Unicode (UTF
-8) is used
for all localizations
.
1049 <div
class="config-input">
1050 <label
class='column'>Copyright
/license
:</label
>
1053 <li
><?php
aField( $conf, "License", "No license metadata", "radio", "none" ); ?
></li
>
1054 <li
><?php
aField( $conf, "License", "GNU Free Documentation License 1.2 (Wikipedia-compatible)", "radio", "gfdl" ); ?
></li
>
1056 aField( $conf, "License", "A Creative Commons license - ", "radio", "cc" );
1057 $partner = "MediaWiki";
1058 $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/index.php?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
1059 $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" );
1060 $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" );
1061 print "<a href=\"$ccApp\" target='_blank'>choose</a>";
1063 <?php
if( $conf->License
== "cc" ) { ?
>
1065 <li
><?php
aField( $conf, "RightsIcon", "<img src=\"" . htmlspecialchars( $conf->RightsIcon
) . "\" alt='(Creative Commons icon)' />", "hidden" ); ?
></li
>
1066 <li
><?php
aField( $conf, "RightsText", htmlspecialchars( $conf->RightsText
), "hidden" ); ?
></li
>
1067 <li
><?php
aField( $conf, "RightsCode", "code: " . htmlspecialchars( $conf->RightsCode
), "hidden" ); ?
></li
>
1068 <li
><?php
aField( $conf, "RightsUrl", "<a href=\"" . htmlspecialchars( $conf->RightsUrl
) . "\">" . htmlspecialchars( $conf->RightsUrl
) . "</a>", "hidden" ); ?
></li
>
1074 <p
class="config-desc">
1075 A notice
, icon
, and machine
-readable copyright metadata will be displayed
for the license you pick
.
1079 <div
class="config-input">
1080 <?php
aField( $conf, "SysopName", "Admin username:" ) ?
>
1082 <div
class="config-input">
1083 <?php
aField( $conf, "SysopPass", "Password:", "password" ) ?
>
1085 <div
class="config-input">
1086 <?php
aField( $conf, "SysopPass2", "Password confirm:", "password" ) ?
>
1088 <p
class="config-desc">
1089 An admin can lock
/delete pages
, block users from editing
, and do other maintenance tasks
.<br
/>
1090 A
new account will be added only when creating a
new wiki database
.
1093 <div
class="config-input">
1094 <label
class='column'>Shared memory caching
:</label
>
1097 <li
><?php
aField( $conf, "Shm", "No caching", "radio", "none" ); ?
></li
>
1099 if ( $conf->turck
) {
1101 aField( $conf, "Shm", "Turck MMCache", "radio", "turck" );
1106 aField( $conf, "Shm", "APC", "radio", "apc" );
1109 if ( $conf->eaccel
) {
1111 aField( $conf, "Shm", "eAccelerator", "radio", "eaccel" );
1115 <li
><?php
aField( $conf, "Shm", "Memcached", "radio", "memcached" ); ?
></li
>
1117 <div style
="clear:left"><?php
aField( $conf, "MCServers", "Memcached servers:", "text" ) ?
></div
>
1119 <p
class="config-desc">
1120 Using a shared memory system such
as Turck MMCache
, APC
, eAccelerator
, or Memcached
1121 will speed up MediaWiki significantly
. Memcached is the best solution but needs to be
1122 installed
. Specify the server addresses
and ports in a comma
-separated
list. Only
1123 use Turck shared memory
if the wiki will be running on a single Apache server
.
1127 <h2
>E
-mail
, e
-mail notification
and authentication setup
</h2
>
1129 <div
class="config-section">
1130 <div
class="config-input">
1131 <label
class='column'>E
-mail
features (global):</label
>
1133 <li
><?php
aField( $conf, "Email", "Enabled", "radio", "email_enabled" ); ?
></li
>
1134 <li
><?php
aField( $conf, "Email", "Disabled", "radio", "email_disabled" ); ?
></li
>
1137 <p
class="config-desc">
1138 Use this to disable all e
-mail
functions (password reminders
, user
-to
-user e
-mail
, and e
-mail notifications
)
1139 if sending mail doesn
't work on your server.
1142 <div class="config-input">
1143 <label class='column
'>User-to-user e-mail:</label>
1145 <li><?php aField( $conf, "Emailuser", "Enabled", "radio", "emailuser_enabled" ); ?></li>
1146 <li><?php aField( $conf, "Emailuser", "Disabled", "radio", "emailuser_disabled" ); ?></li>
1149 <p class="config-desc">
1150 The user-to-user e-mail feature (Special:Emailuser) lets the wiki act as a relay to allow users to exchange e-mail without publicly advertising their e-mail address.
1152 <div class="config-input">
1153 <label class='column
'>E-mail notification about changes:</label>
1155 <li><?php aField( $conf, "Enotif", "Disabled", "radio", "enotif_disabled" ); ?></li>
1156 <li><?php aField( $conf, "Enotif", "Enabled for changes to user discussion pages only", "radio", "enotif_usertalk" ); ?></li>
1157 <li><?php aField( $conf, "Enotif", "Enabled for changes to user discussion pages, and to pages on watchlists (not recommended for large wikis)", "radio", "enotif_allpages" ); ?></li>
1160 <div class="config-desc">
1162 For this feature to work, an e-mail address must be present for the user account, and the notification
1163 options in the user's preferences must be enabled
. Also note the
1164 authentication option below
. When testing the feature
, keep in mind that your own changes will never trigger notifications to be sent to yourself
.</p
>
1166 <p
>There are additional options
for fine tuning in
/includes
/DefaultSettings
.php
; copy these to your LocalSettings
.php
and edit them there to change them
.</p
>
1169 <div
class="config-input">
1170 <label
class='column'>E
-mail address authentication
:</label
>
1172 <li
><?php
aField( $conf, "Eauthent", "Disabled", "radio", "eauthent_disabled" ); ?
></li
>
1173 <li
><?php
aField( $conf, "Eauthent", "Enabled", "radio", "eauthent_enabled" ); ?
></li
>
1176 <div
class="config-desc">
1177 <p
>If this option is enabled
, users have to confirm their e
-mail address using a magic link sent to them whenever they set
or change it
, and only authenticated e
-mail addresses can receive mails from other users
and/or
1178 change notification mails
. Setting this option is
<B
>recommended
</B
> for public wikis because of potential abuse of the e
-mail features above
.</p
>
1183 <h2
>Database config
</h2
>
1185 <div
class="config-section">
1186 <div
class="config-input">
1187 <label
class='column'>Database type
:</label
>
1188 <?php
if (isset($errs['DBpicktype'])) print "<span class='error'>$errs[DBpicktype]</span>\n"; ?
>
1189 <ul
class='plain'><?php
database_picker($conf) ?
></ul
>
1192 <div
class="config-input" style
="clear:left"><?php
1193 aField( $conf, "DBserver", "Database host:" );
1195 <p
class="config-desc">
1196 If your database server isn
't on your web server, enter the name or IP address here.
1199 <div class="config-input"><?php
1200 aField( $conf, "DBname", "Database name:" );
1202 <div class="config-input"><?php
1203 aField( $conf, "DBuser", "DB username:" );
1205 <div class="config-input"><?php
1206 aField( $conf, "DBpassword", "DB password:", "password" );
1208 <div class="config-input"><?php
1209 aField( $conf, "DBpassword2", "DB password confirm:", "password" );
1211 <p class="config-desc">
1212 If you only have a single user account and database available,
1213 enter those here. If you have database root access (see below)
1214 you can specify new accounts/databases to be created. This account
1215 will not be created if it pre-exists. If this is the case, ensure that it
1216 has SELECT, INSERT, UPDATE, and DELETE permissions on the MediaWiki database.
1219 <div class="config-input">
1220 <label class="column">Superuser account:</label>
1221 <input type="checkbox" name="useroot" id="useroot" <?php if( $useRoot ) { ?>checked="checked" <?php } ?>/>
1222 <label for="useroot">Use superuser account</label>
1224 <div class="config-input">
1226 aField( $conf, "RootUser", "Superuser name:", "superuser" );
1229 <div class="config-input">
1231 aField( $conf, "RootPW", "Superuser password:", "password" );
1235 <p class="config-desc">
1236 If the database user specified above does not exist, or does not have access to create
1237 the database (if needed) or tables within it, please check the box and provide details
1238 of a superuser account, such as <strong>root</strong>, which does.
1241 <?php database_switcher('mysql
'); ?>
1242 <div class="config-input"><?php
1243 aField( $conf, "DBprefix", "Database table prefix:" );
1245 <div class="config-desc">
1246 <p>If you need to share one database between multiple wikis, or
1247 between MediaWiki and another web application, you may choose to
1248 add a prefix to all the table names to avoid conflicts.</p>
1250 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
1253 <div class="config-input"><label class="column">Database charset</label>
1254 <div>Select one:</div>
1256 <li><?php aField( $conf, "DBschema", "Backwards-compatible UTF-8", "radio", "mysql4" ); ?></li>
1257 <li><?php aField( $conf, "DBschema", "Experimental MySQL 4.1/5.0 UTF-8", "radio", "mysql5" ); ?></li>
1258 <li><?php aField( $conf, "DBschema", "Experimental MySQL 4.1/5.0 binary", "radio", "mysql5-binary" ); ?></li>
1261 <p class="config-desc">
1262 <b>EXPERIMENTAL:</b> You can enable explicit Unicode charset support
1263 for MySQL 4.1 and 5.0 servers. This is not well tested and may
1264 cause things to break. <b>If upgrading an older installation, leave
1265 in backwards-compatible mode.</b>
1269 <?php database_switcher('postgres
'); ?>
1270 <div class="config-input"><?php
1271 aField( $conf, "DBport", "Database port:" );
1273 <div class="config-input"><?php
1274 aField( $conf, "DBmwschema", "Schema for mediawiki:" );
1276 <div class="config-input"><?php
1277 aField( $conf, "DBts2schema", "Schema for tsearch2:" );
1279 <div class="config-desc">
1280 <p>The username specified above (at "DB username") will have its search path set to the above schemas,
1281 so it is recommended that you create a new user. The above schemas are generally correct:
1282 only change them if you are sure you need to.</p>
1286 <div class="config-input" style="padding:2em 0 3em">
1287 <label class='column
'> </label>
1288 <input type="submit" value="Install MediaWiki!" class="btn-install" />
1293 <script type="text/javascript">
1294 window.onload = toggleDBarea('<?php
echo $conf->DBtype
; ?
>',
1296 ## If they passed in a root user name, don't populate it on page load
1297 echo strlen(importPost('RootUser', '')) ?
0 : 1;
1306 /* -------------------------------------------------------------------------------------- */
1307 function writeSuccessMessage() {
1308 if ( ini_get( 'safe_mode' ) && !ini_get( 'open_basedir' ) ) {
1310 <p>Installation successful!</p>
1311 <p>To complete the installation, please do the following:
1313 <li>Download config/LocalSettings.php with your FTP client or file manager</li>
1314 <li>Upload it to the parent directory</li>
1315 <li>Delete config/LocalSettings.php</li>
1316 <li>Start using <a href='../index.php'>your wiki</a>!
1318 <p>If you are in a shared hosting environment, do <strong>not</strong> just move LocalSettings.php
1319 remotely. LocalSettings.php is currently owned by the user your webserver is running under,
1320 which means that anyone on the same server can read your database password! Downloading
1321 it and uploading it again will hopefully change the ownership to a user ID specific to you.</p>
1324 echo "<p><span style='font-weight:bold;color:green;font-size:110%'>Installation successful!</span> Move the <tt>config/LocalSettings.php</tt> file into the parent directory, then follow
1325 <strong><a href='../index.php'>this link</a></strong> to your wiki.</p>\n";
1330 function escapePhpString( $string ) {
1331 return strtr( $string,
1342 function writeLocalSettings( $conf ) {
1343 $conf->PasswordSender
= $conf->EmergencyContact
;
1344 $magic = ($conf->ImageMagick ?
"" : "# ");
1345 $convert = ($conf->ImageMagick ?
$conf->ImageMagick
: "/usr/bin/convert" );
1346 $rights = ($conf->RightsUrl
) ?
"" : "# ";
1347 $hashedUploads = $conf->safeMode ?
'' : '# ';
1349 switch ( $conf->Shm
) {
1351 $cacheType = 'CACHE_MEMCACHED';
1352 $mcservers = var_export( $conf->MCServerArray
, true );
1357 $cacheType = 'CACHE_ACCEL';
1358 $mcservers = 'array()';
1361 $cacheType = 'CACHE_NONE';
1362 $mcservers = 'array()';
1365 if ( $conf->Email
== 'email_enabled' ) {
1366 $enableemail = 'true';
1367 $enableuseremail = ( $conf->Emailuser
== 'emailuser_enabled' ) ?
'true' : 'false' ;
1368 $eauthent = ( $conf->Eauthent
== 'eauthent_enabled' ) ?
'true' : 'false' ;
1369 switch ( $conf->Enotif
) {
1370 case 'enotif_usertalk':
1371 $enotifusertalk = 'true';
1372 $enotifwatchlist = 'false';
1374 case 'enotif_allpages':
1375 $enotifusertalk = 'true';
1376 $enotifwatchlist = 'true';
1379 $enotifusertalk = 'false';
1380 $enotifwatchlist = 'false';
1383 $enableuseremail = 'false';
1384 $enableemail = 'false';
1385 $eauthent = 'false';
1386 $enotifusertalk = 'false';
1387 $enotifwatchlist = 'false';
1390 $file = @fopen
( "/dev/urandom", "r" );
1392 $secretKey = bin2hex( fread( $file, 32 ) );
1396 for ( $i=0; $i<8; $i++
) {
1397 $secretKey .= dechex(mt_rand(0, 0x7fffffff));
1399 print "<li>Warning: \$wgSecretKey key is insecure, generated with mt_rand(). Consider changing it manually.</li>\n";
1402 # Add slashes to strings for double quoting
1403 $slconf = array_map( "escapePhpString", get_object_vars( $conf ) );
1404 if( $conf->License
== 'gfdl' ) {
1405 # Needs literal string interpolation for the current style path
1406 $slconf['RightsIcon'] = $conf->RightsIcon
;
1410 # This file was automatically generated by the MediaWiki installer.
1411 # If you make manual changes, please keep track in case you need to
1412 # recreate them later.
1414 # See includes/DefaultSettings.php for all configurable settings
1415 # and their default values, but don't forget to make changes in _this_
1418 # If you customize your file layout, set \$IP to the directory that contains
1419 # the other MediaWiki files. It will be used as a base to locate files.
1420 if( defined( 'MW_INSTALL_PATH' ) ) {
1421 \$IP = MW_INSTALL_PATH;
1423 \$IP = dirname( __FILE__ );
1426 \$path = array( \$IP, \"\$IP/includes\", \"\$IP/languages\" );
1427 set_include_path( implode( PATH_SEPARATOR, \$path ) . PATH_SEPARATOR . get_include_path() );
1429 require_once( \"includes/DefaultSettings.php\" );
1431 # If PHP's memory limit is very low, some operations may fail.
1432 " . ($conf->raiseMemory ?
'' : '# ' ) . "ini_set( 'memory_limit', '20M' );" . "
1434 if ( \$wgCommandLineMode ) {
1435 if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
1436 die( \"This script must be run from the command line\\n\" );
1439 ## Uncomment this to disable output compression
1440 # \$wgDisableOutputCompression = true;
1442 \$wgSitename = \"{$slconf['Sitename']}\";
1444 ## The URL base path to the directory containing the wiki;
1445 ## defaults for all runtime URL paths are based off of this.
1446 \$wgScriptPath = \"{$slconf['ScriptPath']}\";
1448 ## For more information on customizing the URLs please see:
1449 ## http://www.mediawiki.org/wiki/Manual:Short_URL
1451 \$wgEnableEmail = $enableemail;
1452 \$wgEnableUserEmail = $enableuseremail;
1454 \$wgEmergencyContact = \"{$slconf['EmergencyContact']}\";
1455 \$wgPasswordSender = \"{$slconf['PasswordSender']}\";
1457 ## For a detailed description of the following switches see
1458 ## http://meta.wikimedia.org/Enotif and http://meta.wikimedia.org/Eauthent
1459 ## There are many more options for fine tuning available see
1460 ## /includes/DefaultSettings.php
1461 ## UPO means: this is also a user preference option
1462 \$wgEnotifUserTalk = $enotifusertalk; # UPO
1463 \$wgEnotifWatchlist = $enotifwatchlist; # UPO
1464 \$wgEmailAuthentication = $eauthent;
1466 \$wgDBtype = \"{$slconf['DBtype']}\";
1467 \$wgDBserver = \"{$slconf['DBserver']}\";
1468 \$wgDBname = \"{$slconf['DBname']}\";
1469 \$wgDBuser = \"{$slconf['DBuser']}\";
1470 \$wgDBpassword = \"{$slconf['DBpassword']}\";
1472 # MySQL specific settings
1473 \$wgDBprefix = \"{$slconf['DBprefix']}\";
1475 # MySQL table options to use during installation or update
1476 \$wgDBTableOptions = \"{$slconf['DBTableOptions']}\";
1478 # Experimental charset support for MySQL 4.1/5.0.
1479 \$wgDBmysql5 = {$conf->DBmysql5};
1481 # Postgres specific settings
1482 \$wgDBport = \"{$slconf['DBport']}\";
1483 \$wgDBmwschema = \"{$slconf['DBmwschema']}\";
1484 \$wgDBts2schema = \"{$slconf['DBts2schema']}\";
1486 ## Shared memory settings
1487 \$wgMainCacheType = $cacheType;
1488 \$wgMemCachedServers = $mcservers;
1490 ## To enable image uploads, make sure the 'images' directory
1491 ## is writable, then set this to true:
1492 \$wgEnableUploads = false;
1493 {$magic}\$wgUseImageMagick = true;
1494 {$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
1496 ## If you want to use image uploads under safe mode,
1497 ## create the directories images/archive, images/thumb and
1498 ## images/temp, and make them all writable. Then uncomment
1499 ## this, if it's not already uncommented:
1500 {$hashedUploads}\$wgHashedUploadDirectory = false;
1502 ## If you have the appropriate support software installed
1503 ## you can enable inline LaTeX equations:
1506 \$wgLocalInterwiki = \$wgSitename;
1508 \$wgLanguageCode = \"{$slconf['LanguageCode']}\";
1510 \$wgProxyKey = \"$secretKey\";
1512 ## Default skin: you can change the default skin. Use the internal symbolic
1513 ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook':
1514 \$wgDefaultSkin = 'monobook';
1516 ## For attaching licensing metadata to pages, and displaying an
1517 ## appropriate copyright notice / icon. GNU Free Documentation
1518 ## License and Creative Commons licenses are supported so far.
1519 {$rights}\$wgEnableCreativeCommonsRdf = true;
1520 \$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright
1521 \$wgRightsUrl = \"{$slconf['RightsUrl']}\";
1522 \$wgRightsText = \"{$slconf['RightsText']}\";
1523 \$wgRightsIcon = \"{$slconf['RightsIcon']}\";
1524 # \$wgRightsCode = \"{$slconf['RightsCode']}\"; # Not yet used
1526 \$wgDiff3 = \"{$slconf['diff3']}\";
1528 # When you make changes to this configuration file, this will make
1529 # sure that cached pages are cleared.
1530 \$configdate = gmdate( 'YmdHis', @filemtime( __FILE__ ) );
1531 \$wgCacheEpoch = max( \$wgCacheEpoch, \$configdate );
1532 "; ## End of setting the $localsettings string
1534 // Keep things in Unix line endings internally;
1535 // the system will write out as local text type.
1536 return str_replace( "\r\n", "\n", $localsettings );
1539 function dieout( $text ) {
1540 die( $text . "\n\n</body>\n</html>" );
1543 function importVar( &$var, $name, $default = "" ) {
1544 if( isset( $var[$name] ) ) {
1545 $retval = $var[$name];
1546 if ( get_magic_quotes_gpc() ) {
1547 $retval = stripslashes( $retval );
1555 function importPost( $name, $default = "" ) {
1556 return importVar( $_POST, $name, $default );
1559 function importCheck( $name ) {
1560 return isset( $_POST[$name] );
1563 function importRequest( $name, $default = "" ) {
1564 return importVar( $_REQUEST, $name, $default );
1569 function aField( &$conf, $field, $text, $type = "text", $value = "", $onclick = '' ) {
1572 $xtype = "type=\"$type\"";
1578 $nolabel = ($type == "radio") ||
($type == "hidden");
1580 if ($type == 'radio')
1581 $id .= $radioCount++
;
1586 echo "\t\t<label class='column' for=\"$id\">$text</label>\n";
1589 if( $type == "radio" && $value == $conf->$field ) {
1590 $checked = "checked='checked'";
1594 echo "\t\t<input $xtype name=\"$field\" id=\"$id\" class=\"iput-$type\" $checked ";
1596 echo " onclick='toggleDBarea(\"$value\",1)' " ;
1599 if( $type == "radio" ) {
1600 echo htmlspecialchars( $value );
1602 echo htmlspecialchars( $conf->$field );
1608 echo " $text</label>\n";
1612 if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n";
1615 function getLanguageList() {
1616 global $wgLanguageNames;
1617 if( !isset( $wgLanguageNames ) ) {
1618 require_once( "languages/Names.php" );
1623 $d = opendir( "../languages/messages" );
1624 /* In case we are called from the root directory */
1626 $d = opendir( "languages/messages");
1627 while( false !== ($f = readdir( $d ) ) ) {
1629 if( preg_match( '/Messages([A-Z][a-z_]+)\.php$/', $f, $m ) ) {
1630 $code = str_replace( '_', '-', strtolower( $m[1] ) );
1631 if( isset( $wgLanguageNames[$code] ) ) {
1632 $name = $code . ' - ' . $wgLanguageNames[$code];
1636 $codes[$code] = $name;
1644 #Check for location of an executable
1645 # @param string $loc single location to check
1646 # @param array $names filenames to check for.
1647 # @param mixed $versioninfo array of details to use when checking version, use false for no version checking
1648 function locate_executable($loc, $names, $versioninfo = false) {
1649 if (!is_array($names))
1650 $names = array($names);
1652 foreach ($names as $name) {
1653 $command = "$loc".DIRECTORY_SEPARATOR
."$name";
1654 if (file_exists($command)) {
1658 $file = str_replace('$1', $command, $versioninfo[0]);
1659 if (strstr(`
$file`
, $versioninfo[1]) !== false)
1666 # Test a memcached server
1667 function testMemcachedServer( $server ) {
1668 $hostport = explode(":", $server);
1671 if ( !function_exists( 'fsockopen' ) ) {
1672 $errstr = "Can't connect to memcached, fsockopen() not present";
1674 if ( !$errstr && count( $hostport ) != 2 ) {
1675 $errstr = 'Please specify host and port';
1676 var_dump( $hostport );
1679 list( $host, $port ) = $hostport;
1683 $fp = @fsockopen
( $host, $port, $errno, $fsockerr, 1.0 );
1684 if ( $fp === false ) {
1685 $errstr = "Cannot connect to memcached on $host:$port : $fsockerr";
1689 $command = "version\r\n";
1690 $bytes = fwrite( $fp, $command );
1691 if ( $bytes != strlen( $command ) ) {
1692 $errstr = "Cannot write to memcached socket on $host:$port";
1696 $expected = "VERSION ";
1697 $response = fread( $fp, strlen( $expected ) );
1698 if ( $response != $expected ) {
1699 $errstr = "Didn't get correct memcached response from $host:$port";
1706 echo "<li>Connected to memcached on $host:$port successfully";
1711 function database_picker($conf) {
1714 foreach(array_keys($ourdb) as $db) {
1715 if ($ourdb[$db]['havedriver']) {
1717 aField( $conf, "DBtype", $ourdb[$db]['fullname'], 'radio', $db, 'onclick');
1724 function database_switcher($db) {
1726 $color = $ourdb[$db]['bgcolor'];
1727 $full = $ourdb[$db]['fullname'];
1728 print "<div id='$db' style='display:none; background: $color'>\n";
1729 print "<h3>$full specific options:</h3>\n";
1732 function printListItem( $item ) {
1733 print "<li>$item</li>";
1738 <div
class="license">
1740 <p
>This program is free software
; you can redistribute it
and/or modify
1741 it under the terms of the GNU General
Public License
as published by
1742 the Free Software Foundation
; either version
2 of the License
, or
1743 (at your option
) any later version
.</p
>
1745 <p
>This program is distributed in the hope that it will be useful
,
1746 but WITHOUT ANY WARRANTY
; without even the implied warranty of
1747 MERCHANTABILITY
or FITNESS
FOR A PARTICULAR PURPOSE
. See the
1748 GNU General
Public License
for more details
.</p
>
1750 <p
>You should have received
<a href
="../COPYING">a copy of the GNU General
Public License
</a
>
1751 along with this program
; if not
, write to the Free Software
1752 Foundation
, Inc
., 51 Franklin Street
, Fifth Floor
, Boston
, MA
02110-1301, USA
.
1753 or <a href
="http://www.gnu.org/copyleft/gpl.html">read it online
</a
></p
>
1759 <div id
="column-one">
1760 <div
class="portlet" id
="p-logo">
1761 <a style
="background-image: url(../skins/common/images/mediawiki.png);"
1762 href
="http://www.mediawiki.org/"
1763 title
="Main Page"></a
>
1765 <script type
="text/javascript"> if (window
.isMSIE55
) fixalpha(); </script
>
1766 <div
class='portlet'><div
class='pBody'>
1768 <li
><strong
><a href
="http://www.mediawiki.org/">MediaWiki home
</a
></strong
></li
>
1769 <li
><a href
="../README">Readme
</a
></li
>
1770 <li
><a href
="../RELEASE-NOTES">Release notes
</a
></li
>
1771 <li
><a href
="../docs/">Documentation
</a
></li
>
1772 <li
><a href
="http://meta.wikipedia.org/wiki/MediaWiki_User's_Guide">User
's Guide</a></li>
1773 <li><a href="http://meta.wikimedia.org/wiki/MediaWiki_FAQ">FAQ</a></li>
1775 <p style="font-size:90%;margin-top:1em">MediaWiki is Copyright © 2001-2007 by Magnus Manske, Brion Vibber, Lee Daniel Crocker, Tim Starling, Erik Möller, Gabriel Wicke and others.</p>