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 );
33 # Define an entry point and include some files
34 define( "MEDIAWIKI", true );
35 define( "MEDIAWIKI_INSTALL", true );
37 // Run version checks before including other files
38 // so people don't see a scary parse error.
39 require_once( "$IP/install-utils.inc" );
40 install_version_checks();
42 require_once( "$IP/includes/Defines.php" );
43 require_once( "$IP/includes/DefaultSettings.php" );
44 require_once( "$IP/includes/AutoLoader.php" );
45 require_once( "$IP/includes/MagicWord.php" );
46 require_once( "$IP/includes/Namespace.php" );
47 require_once( "$IP/includes/ProfilerStub.php" );
48 require_once( "$IP/includes/GlobalFunctions.php" );
49 require_once( "$IP/includes/Hooks.php" );
51 # If we get an exception, the user needs to know
53 $wgShowExceptionDetails = true;
55 ## Databases we support:
58 $ourdb['mysql']['fullname'] = 'MySQL';
59 $ourdb['mysql']['havedriver'] = 0;
60 $ourdb['mysql']['compile'] = 'mysql';
61 $ourdb['mysql']['bgcolor'] = '#ffe5a7';
62 $ourdb['mysql']['rootuser'] = 'root';
64 $ourdb['postgres']['fullname'] = 'PostgreSQL';
65 $ourdb['postgres']['havedriver'] = 0;
66 $ourdb['postgres']['compile'] = 'pgsql';
67 $ourdb['postgres']['bgcolor'] = '#aaccff';
68 $ourdb['postgres']['rootuser'] = 'postgres';
70 $ourdb['sqlite']['fullname'] = 'SQLite';
71 $ourdb['sqlite']['havedriver'] = 0;
72 $ourdb['sqlite']['compile'] = 'pdo_sqlite';
73 $ourdb['sqlite']['bgcolor'] = '#b1ebb1';
74 $ourdb['sqlite']['rootuser'] = '';
76 $ourdb['mssql']['fullname'] = 'MSSQL';
77 $ourdb['mssql']['havedriver'] = 0;
78 $ourdb['mssql']['compile'] = 'mssql not ready'; # Change to 'mssql' after includes/DatabaseMssql.php added;
79 $ourdb['mssql']['bgcolor'] = '#ffc0cb';
80 $ourdb['mssql']['rootuser'] = 'administrator';
83 <!DOCTYPE HTML
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
86 <meta http
-equiv
="Content-type" content
="text/html; charset=utf-8">
87 <title
>MediaWiki
<?php
echo( $wgVersion ); ?
> Installation
</title
>
88 <style type
="text/css">
90 @import
"../skins/monobook/main.css";
94 margin
: 1em
0 1em
2.5em
;
101 .config
-section label
.column
{
113 zoom
: 100%
; /* IE hack */
116 .config
-section
.config
-desc
{
118 margin
: 0 0 2em
18em
;
123 .iput
-text
, .iput
-password
{
130 background
-color
: #fff;
138 background
-color
: #FFF0F0;
139 border
: 2px solid red
;
147 list-style
-type
: none
;
148 list-style
-image
: none
;
165 span
.success
-message
{
175 <script type
="text/javascript">
178 <?php
foreach (array_keys($ourdb) as $db) {
179 echo "\n var i = document.getElementById('$db'); if (i) i.style.display='none';";
184 function toggleDBarea(id
,defaultroot
) {
186 var dbarea
= document
.getElementById(id
);
187 if (dbarea
) dbarea
.style
.display
= (dbarea
.style
.display
== 'none') ?
'block' : 'none';
188 var db
= document
.getElementById('RootUser');
190 <?php
foreach (array_keys($ourdb) as $db) {
191 echo " if (id == '$db') { db.value = '".$ourdb[$db]['rootuser']."';}\n";
200 <div id
="globalWrapper">
201 <div id
="column-content">
203 <div id
="bodyContent">
205 <h1
>MediaWiki
<?php
print $wgVersion ?
> Installation
</h1
>
209 /* Check for existing configurations and bug out! */
211 if( file_exists( "../LocalSettings.php" ) ) {
212 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
213 dieout( "<p><strong>Setup has completed, <a href='../$script'>your wiki</a> is configured.</strong></p>
215 <p>Please delete the /config directory for extra security.</p></div></div></div></div>" );
218 if( file_exists( "./LocalSettings.php" ) ) {
219 writeSuccessMessage();
224 if( !is_writable( "." ) ) {
225 dieout( "<h2>Can't write config file, aborting</h2>
227 <p>In order to configure the wiki you have to make the <tt>config</tt> subdirectory
228 writable by the web server. Once configuration is done you'll move the created
229 <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can
230 then remove the <tt>config</tt> subdirectory entirely.</p>
232 <p>To make the directory writable on a Unix/Linux system:</p>
235 cd <i>/path/to/wiki</i>
239 <p>Afterwards retry to start the <a href=\"\">setup</a>.</p>" );
243 require_once( "$IP/install-utils.inc" );
244 require_once( "$IP/maintenance/updaters.inc" );
247 function getEncoded( $data ) {
248 # removing latin1 support, no need...
251 function getSitename() { return $this->getEncoded( $this->Sitename
); }
252 function getSysopName() { return $this->getEncoded( $this->SysopName
); }
253 function getSysopPass() { return $this->getEncoded( $this->SysopPass
); }
255 function setSchema( $schema, $engine ) {
256 $this->DBschema
= $schema;
257 if ( !preg_match( '/^\w*$/', $engine ) ){
260 switch ( $this->DBschema
) {
262 $this->DBTableOptions
= "ENGINE=$engine, DEFAULT CHARSET=utf8";
263 $this->DBmysql5
= 'true';
265 case 'mysql5-binary':
266 $this->DBTableOptions
= "ENGINE=$engine, DEFAULT CHARSET=binary";
267 $this->DBmysql5
= 'true';
270 $this->DBTableOptions
= "TYPE=$engine";
271 $this->DBmysql5
= 'false';
273 $this->DBengine
= $engine;
275 # Set the global for use during install
276 global $wgDBTableOptions;
277 $wgDBTableOptions = $this->DBTableOptions
;
285 <b
>Don
't forget security updates!</b> Keep an eye on the
286 <a href="http://lists.wikimedia.org/mailman/listinfo/mediawiki-announce">low-traffic
287 release announcements mailing list</a>.
292 <h2>Checking environment...</h2>
293 <p><em>Please include all of the lines below when reporting installation problems.</em></p>
294 <ul class="env-check">
298 define( 'MW_NO_OUTPUT_BUFFER
', 1 );
299 $conf = new ConfigData;
301 install_version_checks();
302 $self = 'Installer
'; # Maintenance script name, to please Setup.php
304 print "<li>PHP " . phpversion() . " installed</li>\n";
306 error_reporting( 0 );
307 $phpdatabases = array();
308 foreach (array_keys($ourdb) as $db) {
309 $compname = $ourdb[$db]['compile
'];
310 if( extension_loaded( $compname ) || ( mw_have_dl() && dl( "{$compname}." . PHP_SHLIB_SUFFIX ) ) ) {
311 array_push($phpdatabases, $db);
312 $ourdb[$db]['havedriver
'] = 1;
315 error_reporting( E_ALL );
317 if (!$phpdatabases) {
318 print "Could not find a suitable database driver!<ul>";
319 foreach (array_keys($ourdb) AS $db) {
320 $comp = $ourdb[$db]['compile
'];
321 $full = $ourdb[$db]['fullname
'];
322 print "<li>For <b>$full</b>, compile PHP using <b>--with-$comp</b>, "
323 ."or install the $comp.so module</li>\n";
325 dieout( "</ul></ul>" );
328 print "<li>Found database drivers for:";
330 foreach (array_keys($ourdb) AS $db) {
331 if ($ourdb[$db]['havedriver
']) {
332 if ( $DefaultDBtype == '' ) {
333 $DefaultDBtype = $db;
335 print " ".$ourdb[$db]['fullname
'];
340 if( wfIniGetBool( "register_globals" ) ) {
343 <div style="font-size:110%">
344 <strong class="error">Warning:</strong>
345 <strong>PHP's
<tt
><a href
="http://php.net/register_globals">register_globals
</a
></tt
> option is enabled
. Disable it
if you can
.</strong
>
347 MediaWiki will work
, but your server is more exposed to PHP
-based security vulnerabilities
.
354 if( wfIniGetBool( "magic_quotes_runtime" ) ) {
356 ?
><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
>
357 This option corrupts data input unpredictably
; you cannot install
or use
358 MediaWiki unless this option is disabled
.
362 if( wfIniGetBool( "magic_quotes_sybase" ) ) {
364 ?
><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
>
365 This option corrupts data input unpredictably
; you cannot install
or use
366 MediaWiki unless this option is disabled
.
370 if( wfIniGetBool( "mbstring.func_overload" ) ) {
372 ?
><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
>
373 This option causes errors
and may corrupt data unpredictably
;
374 you cannot install
or use MediaWiki unless this option is disabled
.
378 if( wfIniGetBool( "zend.ze1_compatibility_mode" ) ) {
380 ?
><li
class="error"><strong
>Fatal
: <a href
="http://www.php.net/manual/en/ini.core.php">zend
.ze1_compatibility_mode
</a
> is active
!</strong
>
381 This option causes horrible bugs with MediaWiki
; you cannot install
or use
382 MediaWiki unless this option is disabled
.
388 dieout( "</ul><p>Cannot install MediaWiki.</p>" );
391 if( wfIniGetBool( "safe_mode" ) ) {
392 $conf->safeMode
= true;
394 <li
><b
class='error'>Warning
:</b
> <strong
>PHP
's
395 <a href='http
://www.php.net/features.safe-mode'>safe mode</a> is active.</strong>
396 You may have problems caused by this
, particularly
if using image uploads
.
400 $conf->safeMode
= false;
403 $sapi = php_sapi_name();
404 print "<li>PHP server API is $sapi; ";
405 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
406 if( $wgUsePathInfo ) {
407 print "ok, using pretty URLs (<tt>$script/Page_Title</tt>)";
409 print "using ugly URLs (<tt>$script?title=Page_Title</tt>)";
413 $conf->xml
= function_exists( "utf8_encode" );
415 print "<li>Have XML / Latin1-UTF-8 conversion support.</li>\n";
417 dieout( "PHP's XML module is missing; the wiki requires functions in
418 this module and won't work in this configuration.
419 If you're running Mandrake, install the php-xml package." );
422 # Check for session support
423 if( !function_exists( 'session_name' ) )
424 dieout( "PHP's session module is missing. MediaWiki requires session support in order to function." );
426 # session.save_path doesn't *have* to be set, but if it is, and it's
427 # not valid/writable/etc. then it can cause problems
428 $sessionSavePath = mw_get_session_save_path();
429 $ssp = htmlspecialchars( $sessionSavePath );
430 # Warn the user if it's not set, but let them proceed
431 if( !$sessionSavePath ) {
432 print "<li><strong>Warning:</strong> A value for <tt>session.save_path</tt>
433 has not been set in PHP.ini. If the default value causes problems with
434 saving session data, set it to a valid path which is read/write/execute
435 for the user your web server is running under.</li>";
436 } elseif ( is_dir( $sessionSavePath ) && is_writable( $sessionSavePath ) ) {
437 # All good? Let the user know
438 print "<li>Session save path (<tt>{$ssp}</tt>) appears to be valid.</li>";
440 # Something not right? Warn the user, but let them proceed
441 print "<li><strong>Warning:</strong> Your <tt>session.save_path</tt> value (<tt>{$ssp}</tt>)
442 appears to be invalid or is not writable. PHP needs to be able to save data to
443 this location for correct session operation.</li>";
446 # Check for PCRE support
447 if( !function_exists( 'preg_match' ) )
448 dieout( "The PCRE support module appears to be missing. MediaWiki requires the
449 Perl-compatible regular expression functions." );
451 $memlimit = ini_get( "memory_limit" );
452 $conf->raiseMemory
= false;
453 if( empty( $memlimit ) ||
$memlimit == -1 ) {
454 print "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n";
456 print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars( $memlimit ) . ". ";
457 $n = intval( $memlimit );
458 if( preg_match( '/^([0-9]+)[Mm]$/', trim( $memlimit ), $m ) ) {
459 $n = intval( $m[1] * (1024*1024) );
461 if( $n < 20*1024*1024 ) {
462 print "Attempting to raise limit to 20M... ";
463 if( false === ini_set( "memory_limit", "20M" ) ) {
464 print "failed.<br /><b>" . htmlspecialchars( $memlimit ) . " seems too low, installation may fail!</b>";
466 $conf->raiseMemory
= true;
473 $conf->turck
= function_exists( 'mmcache_get' );
474 if ( $conf->turck
) {
475 print "<li><a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> installed</li>\n";
478 $conf->xcache
= function_exists( 'xcache_get' );
480 print "<li><a href=\"http://trac.lighttpd.net/xcache/\">XCache</a> installed</li>";
482 $conf->apc
= function_exists('apc_fetch');
484 print "<li><a href=\"http://www.php.net/apc\">APC</a> installed</li>";
487 $conf->eaccel
= function_exists( 'eaccelerator_get' );
488 if ( $conf->eaccel
) {
489 $conf->turck
= 'eaccelerator';
490 print "<li><a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> installed</li>\n";
493 $conf->dba
= function_exists( 'dba_open' );
495 if( !( $conf->turck ||
$conf->eaccel ||
$conf->apc ||
$conf->xcache
) ) {
496 echo( '<li>Couldn\'t find <a href="http://turck-mmcache.sourceforge.net">Turck MMCache</a>,
497 <a href="http://eaccelerator.sourceforge.net">eAccelerator</a>,
498 <a href="http://www.php.net/apc">APC</a> or <a href="http://trac.lighttpd.net/xcache/">XCache</a>;
499 cannot use these for object caching.</li>' );
502 $conf->diff3
= false;
503 $diff3locations = array_merge(
510 explode( PATH_SEPARATOR
, getenv( "PATH" ) ) );
511 $diff3names = array( "gdiff3", "diff3", "diff3.exe" );
513 $diff3versioninfo = array( '$1 --version 2>&1', 'diff3 (GNU diffutils)' );
514 foreach ($diff3locations as $loc) {
515 $exe = locate_executable($loc, $diff3names, $diff3versioninfo);
516 if ($exe !== false) {
523 print "<li>Found GNU diff3: <tt>$conf->diff3</tt>.</li>";
525 print "<li>GNU diff3 not found.</li>";
527 $conf->ImageMagick
= false;
528 $imcheck = array( "/usr/bin", "/opt/csw/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" );
529 foreach( $imcheck as $dir ) {
530 $im = "$dir/convert";
531 if( @file_exists
( $im ) ) {
532 print "<li>Found ImageMagick: <tt>$im</tt>; image thumbnailing will be enabled if you enable uploads.</li>\n";
533 $conf->ImageMagick
= $im;
538 $conf->HaveGD
= function_exists( "imagejpeg" );
539 if( $conf->HaveGD
) {
540 print "<li>Found GD graphics library built-in";
541 if( !$conf->ImageMagick
) {
542 print ", image thumbnailing will be enabled if you enable uploads";
546 if( !$conf->ImageMagick
) {
547 print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n";
551 $conf->IP
= dirname( dirname( __FILE__
) );
552 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP
) . "</tt></li>\n";
555 // PHP_SELF isn't available sometimes, such as when PHP is CGI but
556 // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
557 // to get the path to the current script... hopefully it's reliable. SIGH
558 $path = ($_SERVER["PHP_SELF"] === '')
559 ?
$_SERVER["SCRIPT_NAME"]
560 : $_SERVER["PHP_SELF"];
562 $conf->ScriptPath
= preg_replace( '{^(.*)/config.*$}', '$1', $path );
563 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath
) . "</tt></li>\n";
567 // We may be installing from *.php5 extension file, if so, print message
568 $conf->ScriptExtension
= '.php';
569 if (defined('MW_INSTALL_PHP5_EXT')) {
570 $conf->ScriptExtension
= '.php5';
571 print "<li>Installing MediaWiki with <tt>php5</tt> file extensions</li>\n";
573 print "<li>Installing MediaWiki with <tt>php</tt> file extensions</li>\n";
577 print "<li style='font-weight:bold;color:green;font-size:110%'>Environment checked. You can install MediaWiki.</li>\n";
578 $conf->posted
= ($_SERVER["REQUEST_METHOD"] == "POST");
580 $conf->Sitename
= ucfirst( importPost( "Sitename", "" ) );
581 $defaultEmail = empty( $_SERVER["SERVER_ADMIN"] )
583 : $_SERVER["SERVER_ADMIN"];
584 $conf->EmergencyContact
= importPost( "EmergencyContact", $defaultEmail );
585 $conf->DBtype
= importPost( "DBtype", $DefaultDBtype );
589 $conf->DBserver
= importPost( "DBserver", "localhost" );
590 $conf->DBname
= importPost( "DBname", "wikidb" );
591 $conf->DBuser
= importPost( "DBuser", "wikiuser" );
592 $conf->DBpassword
= importPost( "DBpassword" );
593 $conf->DBpassword2
= importPost( "DBpassword2" );
594 $conf->SysopName
= importPost( "SysopName", "WikiSysop" );
595 $conf->SysopPass
= importPost( "SysopPass" );
596 $conf->SysopPass2
= importPost( "SysopPass2" );
597 $conf->RootUser
= importPost( "RootUser", "root" );
598 $conf->RootPW
= importPost( "RootPW", "" );
599 $useRoot = importCheck( 'useroot', false );
600 $conf->LanguageCode
= importPost( "LanguageCode", "en" );
603 $conf->DBprefix
= importPost( "DBprefix" );
605 importPost( "DBschema", "mysql5-binary" ),
606 importPost( "DBengine", "InnoDB" ) );
608 ## Postgres specific:
609 $conf->DBport
= importPost( "DBport", "5432" );
610 $conf->DBmwschema
= importPost( "DBmwschema", "mediawiki" );
611 $conf->DBts2schema
= importPost( "DBts2schema", "public" );
614 $conf->SQLiteDataDir
= importPost( "SQLiteDataDir", "" );
617 // We need a second field so it doesn't overwrite the MySQL one
618 $conf->DBprefix2
= importPost( "DBprefix2" );
621 /* Check for validity */
624 if( preg_match( '/^$|^mediawiki$|#/i', $conf->Sitename
) ) {
625 $errs["Sitename"] = "Must not be blank or \"MediaWiki\" and may not contain \"#\"";
627 if( $conf->DBuser
== "" ) {
628 $errs["DBuser"] = "Must not be blank";
630 if( ($conf->DBtype
== 'mysql') && (strlen($conf->DBuser
) > 16) ) {
631 $errs["DBuser"] = "Username too long";
633 if( $conf->DBpassword
== "" && $conf->DBtype
!= "postgres" ) {
634 $errs["DBpassword"] = "Must not be blank";
636 if( $conf->DBpassword
!= $conf->DBpassword2
) {
637 $errs["DBpassword2"] = "Passwords don't match!";
639 if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix
) ) {
640 $errs["DBprefix"] = "Invalid table prefix";
643 error_reporting( E_ALL
);
646 * Initialise $wgLang and $wgContLang to something so we can
647 * call case-folding methods. Per Brion, this is English for
648 * now, although we could be clever and initialise to the
649 * user-selected language.
651 $wgContLang = Language
::factory( 'en' );
652 $wgLang = $wgContLang;
655 * We're messing about with users, so we need a stub
656 * authentication plugin...
658 $wgAuth = new AuthPlugin();
661 * Validate the initial administrator account; username,
662 * password checks, etc.
664 if( $conf->SysopName
) {
665 # Check that the user can be created
666 $u = User
::newFromName( $conf->SysopName
);
667 if( is_a($u, 'User') ) { // please do not use instanceof, it breaks PHP4
668 # Various password checks
669 if( $conf->SysopPass
!= '' ) {
670 if( $conf->SysopPass
== $conf->SysopPass2
) {
671 if( !$u->isValidPassword( $conf->SysopPass
) ) {
672 $errs['SysopPass'] = "Bad password";
675 $errs['SysopPass2'] = "Passwords don't match";
678 $errs['SysopPass'] = "Cannot be blank";
682 $errs['SysopName'] = "Bad username";
686 $conf->License
= importRequest( "License", "none" );
687 if( $conf->License
== "gfdl" ) {
688 $conf->RightsUrl
= "http://www.gnu.org/copyleft/fdl.html";
689 $conf->RightsText
= "GNU Free Documentation License 1.2";
690 $conf->RightsCode
= "gfdl";
691 $conf->RightsIcon
= '${wgScriptPath}/skins/common/images/gnu-fdl.png';
692 } elseif( $conf->License
== "none" ) {
693 $conf->RightsUrl
= $conf->RightsText
= $conf->RightsCode
= $conf->RightsIcon
= "";
695 $conf->RightsUrl
= importRequest( "RightsUrl", "" );
696 $conf->RightsText
= importRequest( "RightsText", "" );
697 $conf->RightsCode
= importRequest( "RightsCode", "" );
698 $conf->RightsIcon
= importRequest( "RightsIcon", "" );
701 $conf->Shm
= importRequest( "Shm", "none" );
702 $conf->MCServers
= importRequest( "MCServers" );
704 /* Test memcached servers */
706 if ( $conf->Shm
== 'memcached' && $conf->MCServers
) {
707 $conf->MCServerArray
= array_map( 'trim', explode( ',', $conf->MCServers
) );
708 foreach ( $conf->MCServerArray
as $server ) {
709 $error = testMemcachedServer( $server );
711 $errs["MCServers"] = $error;
715 } else if ( $conf->Shm
== 'memcached' ) {
716 $errs["MCServers"] = "Please specify at least one server if you wish to use memcached";
719 /* default values for installation */
720 $conf->Email
= importRequest("Email", "email_enabled");
721 $conf->Emailuser
= importRequest("Emailuser", "emailuser_enabled");
722 $conf->Enotif
= importRequest("Enotif", "enotif_allpages");
723 $conf->Eauthent
= importRequest("Eauthent", "eauthent_enabled");
725 if( $conf->posted
&& ( 0 == count( $errs ) ) ) {
726 do { /* So we can 'continue' to end prematurely */
727 $conf->Root
= ($conf->RootPW
!= "");
729 /* Load up the settings and get installin' */
730 $local = writeLocalSettings( $conf );
731 echo "<li style=\"list-style: none\">\n";
732 echo "<p><b>Generating configuration file...</b></p>\n";
735 $wgCommandLineMode = false;
737 $ok = eval( $local );
738 if( $ok === false ) {
739 dieout( "Errors in generated configuration; " .
740 "most likely due to a bug in the installer... " .
741 "Config file was: " .
743 htmlspecialchars( $local ) .
747 $conf->DBtypename
= '';
748 foreach (array_keys($ourdb) as $db) {
749 if ($conf->DBtype
=== $db)
750 $conf->DBtypename
= $ourdb[$db]['fullname'];
752 if ( ! strlen($conf->DBtype
)) {
753 $errs["DBpicktype"] = "Please choose a database type";
757 if (! $conf->DBtypename
) {
758 $errs["DBtype"] = "Unknown database type '$conf->DBtype'";
761 print "<li>Database type: {$conf->DBtypename}</li>\n";
762 $dbclass = 'Database'.ucfirst($conf->DBtype
);
763 $wgDBtype = $conf->DBtype
;
764 $wgDBadminuser = "root";
765 $wgDBadminpassword = $conf->RootPW
;
768 $wgDBprefix = $conf->DBprefix
;
770 ## Postgres specific:
771 $wgDBport = $conf->DBport
;
772 $wgDBmwschema = $conf->DBmwschema
;
773 $wgDBts2schema = $conf->DBts2schema
;
775 if( $conf->DBprefix2
!= '' ) {
777 $wgDBprefix = $conf->DBprefix2
;
780 $wgCommandLineMode = true;
781 if (! defined ( 'STDERR' ) )
782 define( 'STDERR', fopen("php://stderr", "wb"));
783 $wgUseDatabaseMessages = false; /* FIXME: For database failure */
784 require_once( "$IP/includes/Setup.php" );
787 $wgTitle = Title
::newFromText( "Installation script" );
788 error_reporting( E_ALL
);
789 print "<li>Loading class: $dbclass";
792 if( $conf->DBtype
== 'mysql' ) {
793 $mysqlOldClient = version_compare( mysql_get_client_info(), "4.1.0", "lt" );
794 if( $mysqlOldClient ) {
795 print "<li><b>PHP is linked with old MySQL client libraries. If you are
796 using a MySQL 4.1 server and have problems connecting to the database,
797 see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
798 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b></li>\n";
800 $ok = true; # Let's be optimistic
802 # Decide if we're going to use the superuser or the regular database user
803 $conf->Root
= $useRoot;
805 $db_user = $conf->RootUser
;
806 $db_pass = $conf->RootPW
;
808 $db_user = $wgDBuser;
809 $db_pass = $wgDBpassword;
813 echo( "<li>Attempting to connect to database server as $db_user..." );
814 $wgDatabase = Database
::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 );
816 # Check the connection and respond to errors
817 if( $wgDatabase->isOpen() ) {
820 $wgDBadminuser = $db_user;
821 $wgDBadminpassword = $db_pass;
822 echo( "success.</li>\n" );
823 $wgDatabase->ignoreErrors( true );
824 $myver = $wgDatabase->getServerVersion();
826 # There were errors, report them and back out
828 $errno = mysql_errno();
829 $errtx = htmlspecialchars( mysql_error() );
833 echo( "failed due to authentication errors. Check passwords.</li>" );
835 # The superuser details are wrong
836 $errs["RootUser"] = "Check username";
837 $errs["RootPW"] = "and password";
839 # The regular user details are wrong
840 $errs["DBuser"] = "Check username";
841 $errs["DBpassword"] = "and password";
847 # General connection problem
848 echo( "failed with error [$errno] $errtx.</li>\n" );
849 $errs["DBserver"] = "Connection failed";
854 if( !$ok ) { continue; }
857 error_reporting( E_ALL
);
859 ## Possible connect as a superuser
860 if( $useRoot && $conf->DBtype
!= 'sqlite' ) {
861 $wgDBsuperuser = $conf->RootUser
;
862 echo( "<li>Attempting to connect to database \"postgres\" as superuser \"$wgDBsuperuser\"..." );
863 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBsuperuser, $conf->RootPW
, "postgres", 1);
864 if (!$wgDatabase->isOpen()) {
865 print " error: " . $wgDatabase->lastError() . "</li>\n";
866 $errs["DBserver"] = "Could not connect to database as superuser";
867 $errs["RootUser"] = "Check username";
868 $errs["RootPW"] = "and password";
871 $wgDatabase->initial_setup($conf->RootPW
, 'postgres');
873 echo( "<li>Attempting to connect to database \"$wgDBname\" as \"$wgDBuser\"..." );
874 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1);
875 if (!$wgDatabase->isOpen()) {
876 print " error: " . $wgDatabase->lastError() . "</li>\n";
878 $myver = $wgDatabase->getServerVersion();
880 if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname);
883 if ( !$wgDatabase->isOpen() ) {
884 $errs["DBserver"] = "Couldn't connect to database";
888 print "<li>Connected to $myver";
889 if ($conf->DBtype
== 'mysql') {
890 if( version_compare( $myver, "4.0.14" ) < 0 ) {
891 dieout( " -- mysql 4.0.14 or later required. Aborting." );
893 $mysqlNewAuth = version_compare( $myver, "4.1.0", "ge" );
894 if( $mysqlNewAuth && $mysqlOldClient ) {
895 print "; <b class='error'>You are using MySQL 4.1 server, but PHP is linked
896 to old client libraries; if you have trouble with authentication, see
897 <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
898 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>";
901 if( $mysqlNewAuth ) {
902 print "; enabling MySQL 4.1/5.0 charset mode";
904 print "; <b class='error'>MySQL 4.1/5.0 charset mode enabled,
905 but older version detected; will likely fail.</b>";
910 @$sel = $wgDatabase->selectDB( $wgDBname );
912 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
914 $err = mysql_errno();
915 $databaseSafe = htmlspecialchars( $wgDBname );
916 if( $err == 1102 /* Invalid database name */ ) {
917 print "<ul><li><strong>{$databaseSafe}</strong> is not a valid database name.</li></ul>";
919 } elseif( $err != 1049 /* Database doesn't exist */ ) {
920 print "<ul><li>Error selecting database <strong>{$databaseSafe}</strong>: {$err} ";
921 print htmlspecialchars( mysql_error() ) . "</li></ul>";
924 print "<li>Attempting to create database...</li>";
925 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
927 print "<li>Couldn't create database <tt>" .
928 htmlspecialchars( $wgDBname ) .
929 "</tt>; try with root access or check your username/pass.</li>\n";
930 $errs["RootPW"] = "<- Enter";
933 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
935 $wgDatabase->selectDB( $wgDBname );
937 else if ($conf->DBtype
== 'postgres') {
938 if( version_compare( $myver, "PostgreSQL 8.0" ) < 0 ) {
939 dieout( " <b>Postgres 8.0 or later is required</b>. Aborting.</li></ul>" );
943 if( $wgDatabase->tableExists( "cur" ) ||
$wgDatabase->tableExists( "revision" ) ) {
944 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n";
946 if ( $conf->DBtype
== 'mysql') {
947 # Determine existing default character set
948 if ( $wgDatabase->tableExists( "revision" ) ) {
949 $revision = $wgDatabase->escapeLike( $conf->DBprefix
. 'revision' );
950 $res = $wgDatabase->query( "SHOW TABLE STATUS LIKE '$revision'" );
951 $row = $wgDatabase->fetchObject( $res );
953 echo "<li>SHOW TABLE STATUS query failed!</li>\n";
954 $existingSchema = false;
955 $existingEngine = false;
957 if ( preg_match( '/^latin1/', $row->Collation
) ) {
958 $existingSchema = 'mysql4';
959 } elseif ( preg_match( '/^utf8/', $row->Collation
) ) {
960 $existingSchema = 'mysql5';
961 } elseif ( preg_match( '/^binary/', $row->Collation
) ) {
962 $existingSchema = 'mysql5-binary';
964 $existingSchema = false;
965 echo "<li><strong>Warning:</strong> Unrecognised existing collation</li>\n";
967 if ( isset( $row->Engine
) ) {
968 $existingEngine = $row->Engine
;
970 $existingEngine = $row->Type
;
973 if ( $existingSchema && $existingSchema != $conf->DBschema
) {
974 print "<li><strong>Warning:</strong> you requested the {$conf->DBschema} schema, " .
975 "but the existing database has the $existingSchema schema. This upgrade script ".
976 "can't convert it, so it will remain $existingSchema.</li>\n";
977 $conf->setSchema( $existingSchema, $conf->DBengine
);
979 if ( $existingEngine && $existingEngine != $conf->DBengine
) {
980 print "<li><strong>Warning:</strong> you requested the {$conf->DBengine} storage " .
981 "engine, but the existing database uses the $existingEngine engine. This upgrade " .
982 "script can't convert it, so it will remain $existingEngine.</li>\n";
983 $conf->setSchema( $conf->DBschema
, $existingEngine );
987 # Create user if required
989 $conn = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
990 if ( $conn->isOpen() ) {
991 print "<li>DB user account ok</li>\n";
994 print "<li>Granting user permissions...";
995 if( $mysqlOldClient && $mysqlNewAuth ) {
996 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>";
999 dbsource( "../maintenance/users.sql", $wgDatabase );
1003 print "</ul><pre>\n";
1009 print "<ul><li>Finished update checks.</li>\n";
1011 # Determine available storage engines if possible
1012 if ( $conf->DBtype
== 'mysql' && version_compare( $myver, "4.1.2", "ge" ) ) {
1013 $res = $wgDatabase->query( 'SHOW ENGINES' );
1015 while ( $row = $wgDatabase->fetchObject( $res ) ) {
1016 if ( $row->Engine
== $conf->DBengine
) {
1021 $wgDatabase->freeResult( $res );
1022 if ( !$found && $conf->DBengine
!= 'MyISAM' ) {
1023 echo "<li><strong>Warning:</strong> {$conf->DBengine} storage engine not available, " .
1024 "using MyISAM instead</li>\n";
1025 $conf->setSchema( $conf->DBschema
, 'MyISAM' );
1029 # FIXME: Check for errors
1030 print "<li>Creating tables...";
1031 if ($conf->DBtype
== 'mysql') {
1032 dbsource( "../maintenance/tables.sql", $wgDatabase );
1033 dbsource( "../maintenance/interwiki.sql", $wgDatabase );
1034 } elseif (is_callable(array($wgDatabase, 'setup_database'))) {
1035 $wgDatabase->setup_database();
1038 $errs["DBtype"] = "Do not know how to handle database type '$conf->DBtype'";
1042 print " done.</li>\n";
1044 print "<li>Initializing statistics...</li>\n";
1045 $wgDatabase->insert( 'site_stats',
1046 array ( 'ss_row_id' => 1,
1047 'ss_total_views' => 0,
1048 'ss_total_edits' => 1, # Main page first edit
1049 'ss_good_articles' => 0, # Main page is not a good article - no internal link
1050 'ss_total_pages' => 1, # Main page
1051 'ss_users' => $conf->SysopName ?
1 : 0, # Sysop account, if created
1052 'ss_admins' => $conf->SysopName ?
1 : 0, # Sysop account, if created
1053 'ss_images' => 0 ) );
1055 # Set up the "regular user" account *if we can, and if we need to*
1056 if( $conf->Root
and $conf->DBtype
== 'mysql') {
1058 $wgDatabase2 = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
1059 if( $wgDatabase2->isOpen() ) {
1060 # Nope, just close the test connection and continue
1061 $wgDatabase2->close();
1062 echo( "<li>User $wgDBuser exists. Skipping grants.</li>\n" );
1064 # Yes, so run the grants
1065 echo( "<li>Granting user permissions to $wgDBuser on $wgDBname..." );
1066 dbsource( "../maintenance/users.sql", $wgDatabase );
1067 echo( "success.</li>\n" );
1071 if( $conf->SysopName
) {
1072 $u = User
::newFromName( $conf->getSysopName() );
1074 print "<li><strong class=\"error\">Warning:</strong> Skipped sysop account creation - invalid username!</li>\n";
1076 else if ( 0 == $u->idForName() ) {
1077 $u->addToDatabase();
1078 $u->setPassword( $conf->getSysopPass() );
1081 $u->addGroup( "sysop" );
1082 $u->addGroup( "bureaucrat" );
1084 print "<li>Created sysop account <tt>" .
1085 htmlspecialchars( $conf->SysopName
) . "</tt>.</li>\n";
1087 print "<li>Could not create user - already exists!</li>\n";
1090 print "<li>Skipped sysop account creation, no name given.</li>\n";
1093 $titleobj = Title
::newFromText( wfMsgNoDB( "mainpage" ) );
1094 $article = new Article( $titleobj );
1095 $newid = $article->insertOn( $wgDatabase );
1096 $revision = new Revision( array(
1098 'text' => wfMsg( 'mainpagetext' ) . "\n\n" . wfMsgNoTrans( 'mainpagedocfooter' ),
1101 'user_text' => 'MediaWiki default',
1103 $revid = $revision->insertOn( $wgDatabase );
1104 $article->updateRevisionOn( $wgDatabase, $revision );
1107 /* Write out the config file now that all is well */
1108 print "<li style=\"list-style: none\">\n";
1109 print "<p>Creating LocalSettings.php...</p>\n\n";
1110 $localSettings = "<" . "?php$endl$local";
1111 // Fix up a common line-ending problem (due to CVS on Windows)
1112 $localSettings = str_replace( "\r\n", "\n", $localSettings );
1113 $f = fopen( "LocalSettings.php", 'xt' );
1116 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" .
1117 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
1118 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
1120 if(fwrite( $f, $localSettings ) ) {
1122 print "</li></ul><hr/>\n";
1123 writeSuccessMessage();
1126 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");
1127 print "</li></ul>\n";
1138 if( count( $errs ) ) {
1139 /* Display options form */
1141 if( $conf->posted
) {
1142 echo "<p class='error-top'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
1146 <form action
="<?php echo defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php'; ?>" name
="config" method
="post">
1149 <h2
>Site config
</h2
>
1151 <div
class="config-section">
1152 <div
class="config-input">
1154 aField( $conf, "Sitename", "Wiki name:" );
1157 <p
class="config-desc">
1158 Preferably a short word without punctuation
, i
.e
. "Wikipedia".<br
/>
1159 Will appear
as the
namespace name
for "meta" pages
, and throughout the
interface.
1162 <div
class="config-input">
1164 aField( $conf, "EmergencyContact", "Contact e-mail:" );
1167 <p
class="config-desc">
1168 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
.
1171 <div
class="config-input">
1172 <label
class='column' for="LanguageCode">Language
:</label
>
1173 <select id
="LanguageCode" name
="LanguageCode">
1176 $list = getLanguageList();
1177 foreach( $list as $code => $name ) {
1178 $sel = ($code == $conf->LanguageCode
) ?
'selected="selected"' : '';
1179 echo "\t\t<option value=\"$code\" $sel>$name</option>\n";
1184 <p
class="config-desc">
1185 Select the language
for your wiki
's interface. Some localizations aren't fully complete
. Unicode (UTF
-8) is used
for all localizations
.
1188 <div
class="config-input">
1189 <label
class='column'>Copyright
/license
:</label
>
1192 <li
><?php
aField( $conf, "License", "No license metadata", "radio", "none" ); ?
></li
>
1193 <li
><?php
aField( $conf, "License", "GNU Free Documentation License 1.2 (Wikipedia-compatible)", "radio", "gfdl" ); ?
></li
>
1195 aField( $conf, "License", "A Creative Commons license - ", "radio", "cc" );
1196 $partner = "MediaWiki";
1197 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
1198 $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/$script?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
1199 $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" );
1200 $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" );
1201 print "<a href=\"$ccApp\" target='_blank'>choose</a>";
1203 <?php
if( $conf->License
== "cc" ) { ?
>
1205 <li
><?php
aField( $conf, "RightsIcon", "<img src=\"" . htmlspecialchars( $conf->RightsIcon
) . "\" alt='(Creative Commons icon)' />", "hidden" ); ?
></li
>
1206 <li
><?php
aField( $conf, "RightsText", htmlspecialchars( $conf->RightsText
), "hidden" ); ?
></li
>
1207 <li
><?php
aField( $conf, "RightsCode", "code: " . htmlspecialchars( $conf->RightsCode
), "hidden" ); ?
></li
>
1208 <li
><?php
aField( $conf, "RightsUrl", "<a href=\"" . htmlspecialchars( $conf->RightsUrl
) . "\">" . htmlspecialchars( $conf->RightsUrl
) . "</a>", "hidden" ); ?
></li
>
1214 <p
class="config-desc">
1215 A notice
, icon
, and machine
-readable copyright metadata will be displayed
for the license you pick
.
1219 <div
class="config-input">
1220 <?php
aField( $conf, "SysopName", "Admin username:" ) ?
>
1222 <div
class="config-input">
1223 <?php
aField( $conf, "SysopPass", "Password:", "password" ) ?
>
1225 <div
class="config-input">
1226 <?php
aField( $conf, "SysopPass2", "Password confirm:", "password" ) ?
>
1228 <p
class="config-desc">
1229 An admin can lock
/delete pages
, block users from editing
, and do other maintenance tasks
.<br
/>
1230 A
new account will be added only when creating a
new wiki database
.
1232 The password cannot be the same
as the username
.
1235 <div
class="config-input">
1236 <label
class='column'>Object caching
:</label
>
1239 <li
><?php
aField( $conf, "Shm", "No caching", "radio", "none" ); ?
></li
>
1241 if ( $conf->turck
) {
1243 aField( $conf, "Shm", "Turck MMCache", "radio", "turck" );
1246 if( $conf->xcache
) {
1248 aField( $conf, 'Shm', 'XCache', 'radio', 'xcache' );
1253 aField( $conf, "Shm", "APC", "radio", "apc" );
1256 if ( $conf->eaccel
) {
1258 aField( $conf, "Shm", "eAccelerator", "radio", "eaccel" );
1263 aField( $conf, "Shm", "DBA (not recommended)", "radio", "dba" );
1267 <li
><?php
aField( $conf, "Shm", "Memcached", "radio", "memcached" ); ?
></li
>
1269 <div style
="clear:left"><?php
aField( $conf, "MCServers", "Memcached servers:", "text" ) ?
></div
>
1271 <p
class="config-desc">
1272 An
object caching system such
as memcached will provide a significant performance boost
,
1273 but needs to be installed
. Provide the server addresses
and ports in a comma
-separated
list.
1275 MediaWiki can also detect
and support eAccelerator
, Turck MMCache
, APC
, and XCache
, but
1276 these should not be used
if the wiki will be running on multiple application servers
.
1278 DBA (Berkeley
-style DB
) is generally slower than using no cache at all
, and is only
1279 recommended
for testing
.
1283 <h2
>E
-mail
, e
-mail notification
and authentication setup
</h2
>
1285 <div
class="config-section">
1286 <div
class="config-input">
1287 <label
class='column'>E
-mail
features (global):</label
>
1289 <li
><?php
aField( $conf, "Email", "Enabled", "radio", "email_enabled" ); ?
></li
>
1290 <li
><?php
aField( $conf, "Email", "Disabled", "radio", "email_disabled" ); ?
></li
>
1293 <p
class="config-desc">
1294 Use this to disable all e
-mail
functions (password reminders
, user
-to
-user e
-mail
, and e
-mail notifications
)
1295 if sending mail doesn
't work on your server.
1298 <div class="config-input">
1299 <label class='column
'>User-to-user e-mail:</label>
1301 <li><?php aField( $conf, "Emailuser", "Enabled", "radio", "emailuser_enabled" ); ?></li>
1302 <li><?php aField( $conf, "Emailuser", "Disabled", "radio", "emailuser_disabled" ); ?></li>
1305 <p class="config-desc">
1306 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.
1308 <div class="config-input">
1309 <label class='column
'>E-mail notification about changes:</label>
1311 <li><?php aField( $conf, "Enotif", "Disabled", "radio", "enotif_disabled" ); ?></li>
1312 <li><?php aField( $conf, "Enotif", "Enabled for changes to user discussion pages only", "radio", "enotif_usertalk" ); ?></li>
1313 <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>
1316 <div class="config-desc">
1318 For this feature to work, an e-mail address must be present for the user account, and the notification
1319 options in the user's preferences must be enabled
. Also note the
1320 authentication option below
. When testing the feature
, keep in mind that your own changes will never trigger notifications to be sent to yourself
.</p
>
1322 <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
>
1325 <div
class="config-input">
1326 <label
class='column'>E
-mail address authentication
:</label
>
1328 <li
><?php
aField( $conf, "Eauthent", "Disabled", "radio", "eauthent_disabled" ); ?
></li
>
1329 <li
><?php
aField( $conf, "Eauthent", "Enabled", "radio", "eauthent_enabled" ); ?
></li
>
1332 <div
class="config-desc">
1333 <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
1334 change notification mails
. Setting this option is
<B
>recommended
</B
> for public wikis because of potential abuse of the e
-mail features above
.</p
>
1339 <h2
>Database config
</h2
>
1341 <div
class="config-section">
1342 <div
class="config-input">
1343 <label
class='column'>Database type
:</label
>
1344 <?php
if (isset($errs['DBpicktype'])) print "<span class='error'>$errs[DBpicktype]</span>\n"; ?
>
1345 <ul
class='plain'><?php
database_picker($conf) ?
></ul
>
1348 <div
class="config-input" style
="clear:left"><?php
1349 aField( $conf, "DBserver", "Database host:" );
1351 <p
class="config-desc">
1352 If your database server isn
't on your web server, enter the name or IP address here.
1355 <div class="config-input"><?php
1356 aField( $conf, "DBname", "Database name:" );
1358 <div class="config-input"><?php
1359 aField( $conf, "DBuser", "DB username:" );
1361 <div class="config-input"><?php
1362 aField( $conf, "DBpassword", "DB password:", "password" );
1364 <div class="config-input"><?php
1365 aField( $conf, "DBpassword2", "DB password confirm:", "password" );
1367 <p class="config-desc">
1368 If you only have a single user account and database available,
1369 enter those here. If you have database root access (see below)
1370 you can specify new accounts/databases to be created. This account
1371 will not be created if it pre-exists. If this is the case, ensure that it
1372 has SELECT, INSERT, UPDATE, and DELETE permissions on the MediaWiki database.
1375 <div class="config-input">
1376 <label class="column">Superuser account:</label>
1377 <input type="checkbox" name="useroot" id="useroot" <?php if( $useRoot ) { ?>checked="checked" <?php } ?>/>
1378 <label for="useroot">Use superuser account</label>
1380 <div class="config-input">
1382 aField( $conf, "RootUser", "Superuser name:", "superuser" );
1385 <div class="config-input">
1387 aField( $conf, "RootPW", "Superuser password:", "password" );
1391 <p class="config-desc">
1392 If the database user specified above does not exist, or does not have access to create
1393 the database (if needed) or tables within it, please check the box and provide details
1394 of a superuser account, such as <strong>root</strong>, which does.
1397 <?php database_switcher('mysql
'); ?>
1398 <div class="config-input"><?php
1399 aField( $conf, "DBprefix", "Database table prefix:" );
1401 <div class="config-desc">
1402 <p>If you need to share one database between multiple wikis, or
1403 between MediaWiki and another web application, you may choose to
1404 add a prefix to all the table names to avoid conflicts.</p>
1406 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
1409 <div class="config-input"><label class="column">Storage Engine</label>
1410 <div>Select one:</div>
1412 <li><?php aField( $conf, "DBengine", "InnoDB", "radio", "InnoDB" ); ?></li>
1413 <li><?php aField( $conf, "DBengine", "MyISAM", "radio", "MyISAM" ); ?></li>
1416 <p class="config-desc">
1417 InnoDB is best for public web installations, since it has good concurrency
1418 support. MyISAM may be faster in single-user installations. MyISAM databases
1419 tend to get corrupted more often than InnoDB databases.
1421 <div class="config-input"><label class="column">Database character set</label>
1422 <div>Select one:</div>
1424 <li><?php aField( $conf, "DBschema", "MySQL 4.1/5.0 binary", "radio", "mysql5-binary" ); ?></li>
1425 <li><?php aField( $conf, "DBschema", "MySQL 4.1/5.0 UTF-8", "radio", "mysql5" ); ?></li>
1426 <li><?php aField( $conf, "DBschema", "MySQL 4.0 backwards-compatible UTF-8", "radio", "mysql4" ); ?></li>
1429 <p class="config-desc">
1430 This option is ignored on upgrade, the same character set will be kept.
1432 <b>WARNING:</b> If you use <b>backwards-compatible UTF-8</b> on MySQL 4.1+, and subsequently back up the database with <tt>mysqldump</tt>, it may destroy all non-ASCII characters, irreversibly corrupting your backups!.
1434 In <b>binary mode</b>, MediaWiki stores UTF-8 text to the database in binary fields. This is more efficient than MySQL's UTF
-8 mode
, and allows you to
use the full range of Unicode characters
. In
<b
>UTF
-8 mode
</b
>, MySQL will know what character set your data is in
, and can present
and convert it appropriately
, but it won
't let you store characters above the <a target="_blank" href="http://en.wikipedia.org/wiki/Mapping_of_Unicode_character_planes">Basic Multilingual Plane</a>.
1438 <?php database_switcher('postgres
'); ?>
1439 <div class="config-input"><?php
1440 aField( $conf, "DBport", "Database port:" );
1442 <div class="config-input"><?php
1443 aField( $conf, "DBmwschema", "Schema for mediawiki:" );
1445 <div class="config-input"><?php
1446 aField( $conf, "DBts2schema", "Schema for tsearch2:" );
1448 <div class="config-desc">
1449 <p>The username specified above (at "DB username") will have its search path set to the above schemas,
1450 so it is recommended that you create a new user. The above schemas are generally correct:
1451 only change them if you are sure you need to.</p>
1455 <?php database_switcher('sqlite
'); ?>
1456 <div class="config-desc">
1457 <b>NOTE:</b> SQLite only uses the <i>Database name</i> setting above, the user, password and root settings are ignored.
1459 <div class="config-input"><?php
1460 aField( $conf, "SQLiteDataDir", "SQLite data directory:" );
1462 <div class="config-desc">
1463 <p>SQLite stores table data into files in the filesystem.
1464 If you do not provide an explicit path, a "data" directory in
1465 the parent of your document root will be used.</p>
1467 <p>This directory must exist and be writable by the web server.</p>
1471 <?php database_switcher('mssql
'); ?>
1472 <div class="config-input"><?php
1473 aField( $conf, "DBprefix2", "Database table prefix:" );
1475 <div class="config-desc">
1476 <p>If you need to share one database between multiple wikis, or
1477 between MediaWiki and another web application, you may choose to
1478 add a prefix to all the table names to avoid conflicts.</p>
1480 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
1484 <div class="config-input" style="padding:2em 0 3em">
1485 <label class='column
'> </label>
1486 <input type="submit" value="Install MediaWiki!" class="btn-install" />
1491 <script type="text/javascript">
1492 window.onload = toggleDBarea('<?php
echo $conf->DBtype
; ?
>',
1494 ## If they passed in a root user name, don't populate it on page load
1495 echo strlen(importPost('RootUser', '')) ?
0 : 1;
1504 /* -------------------------------------------------------------------------------------- */
1505 function writeSuccessMessage() {
1506 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
1507 if ( wfIniGetBool( 'safe_mode' ) && !ini_get( 'open_basedir' ) ) {
1509 <div class="success-box">
1510 <p>Installation successful!</p>
1511 <p>To complete the installation, please do the following:
1513 <li>Download config/LocalSettings.php with your FTP client or file manager</li>
1514 <li>Upload it to the parent directory</li>
1515 <li>Delete config/LocalSettings.php</li>
1516 <li>Start using <a href='../$script'>your wiki</a>!
1518 <p>If you are in a shared hosting environment, do <strong>not</strong> just move LocalSettings.php
1519 remotely. LocalSettings.php is currently owned by the user your webserver is running under,
1520 which means that anyone on the same server can read your database password! Downloading
1521 it and uploading it again will hopefully change the ownership to a user ID specific to you.</p>
1526 <div class="success-box">
1528 <span class="success-message">Installation successful!</span>
1529 Move the <tt>config/LocalSettings.php</tt> file to the parent directory, then follow
1530 <a href="../$script"> this link</a> to your wiki.</p>
1531 <p>You should change file permissions for <tt>LocalSettings.php</tt> as required to
1532 prevent other users on the server reading passwords and altering configuration data.</p>
1539 function escapePhpString( $string ) {
1540 if ( is_array( $string ) ||
is_object( $string ) ) {
1543 return strtr( $string,
1554 function writeLocalSettings( $conf ) {
1555 $conf->PasswordSender
= $conf->EmergencyContact
;
1556 $magic = ($conf->ImageMagick ?
"" : "# ");
1557 $convert = ($conf->ImageMagick ?
$conf->ImageMagick
: "/usr/bin/convert" );
1558 $rights = ($conf->RightsUrl
) ?
"" : "# ";
1559 $hashedUploads = $conf->safeMode ?
'' : '# ';
1561 switch ( $conf->Shm
) {
1563 $cacheType = 'CACHE_MEMCACHED';
1564 $mcservers = var_export( $conf->MCServerArray
, true );
1570 $cacheType = 'CACHE_ACCEL';
1571 $mcservers = 'array()';
1574 $cacheType = 'CACHE_DBA';
1575 $mcservers = 'array()';
1578 $cacheType = 'CACHE_NONE';
1579 $mcservers = 'array()';
1582 if ( $conf->Email
== 'email_enabled' ) {
1583 $enableemail = 'true';
1584 $enableuseremail = ( $conf->Emailuser
== 'emailuser_enabled' ) ?
'true' : 'false' ;
1585 $eauthent = ( $conf->Eauthent
== 'eauthent_enabled' ) ?
'true' : 'false' ;
1586 switch ( $conf->Enotif
) {
1587 case 'enotif_usertalk':
1588 $enotifusertalk = 'true';
1589 $enotifwatchlist = 'false';
1591 case 'enotif_allpages':
1592 $enotifusertalk = 'true';
1593 $enotifwatchlist = 'true';
1596 $enotifusertalk = 'false';
1597 $enotifwatchlist = 'false';
1600 $enableuseremail = 'false';
1601 $enableemail = 'false';
1602 $eauthent = 'false';
1603 $enotifusertalk = 'false';
1604 $enotifwatchlist = 'false';
1607 $file = @fopen
( "/dev/urandom", "r" );
1609 $secretKey = bin2hex( fread( $file, 32 ) );
1613 for ( $i=0; $i<8; $i++
) {
1614 $secretKey .= dechex(mt_rand(0, 0x7fffffff));
1616 print "<li>Warning: \$wgSecretKey key is insecure, generated with mt_rand(). Consider changing it manually.</li>\n";
1619 # Add slashes to strings for double quoting
1620 $slconf = array_map( "escapePhpString", get_object_vars( $conf ) );
1621 if( $conf->License
== 'gfdl' ) {
1622 # Needs literal string interpolation for the current style path
1623 $slconf['RightsIcon'] = $conf->RightsIcon
;
1626 if( $conf->DBtype
== 'mysql' ) {
1628 "# MySQL specific settings
1629 \$wgDBprefix = \"{$slconf['DBprefix']}\";
1631 # MySQL table options to use during installation or update
1632 \$wgDBTableOptions = \"{$slconf['DBTableOptions']}\";
1634 # Experimental charset support for MySQL 4.1/5.0.
1635 \$wgDBmysql5 = {$conf->DBmysql5};";
1636 } elseif( $conf->DBtype
== 'postgres' ) {
1638 "# Postgres specific settings
1639 \$wgDBport = \"{$slconf['DBport']}\";
1640 \$wgDBmwschema = \"{$slconf['DBmwschema']}\";
1641 \$wgDBts2schema = \"{$slconf['DBts2schema']}\";";
1642 } elseif( $conf->DBtype
== 'sqlite' ) {
1644 "# SQLite-specific settings
1645 \$wgSQLiteDataDir = \"{$slconf['SQLiteDataDir']}\";";
1646 } elseif( $conf->DBtype
== 'mssql' ) {
1648 "# MSSQL specific settings
1649 \$wgDBprefix = \"{$slconf['DBprefix2']}\";";
1657 # This file was automatically generated by the MediaWiki installer.
1658 # If you make manual changes, please keep track in case you need to
1659 # recreate them later.
1661 # See includes/DefaultSettings.php for all configurable settings
1662 # and their default values, but don't forget to make changes in _this_
1665 # Further documentation for configuration settings may be found at:
1666 # http://www.mediawiki.org/wiki/Manual:Configuration_settings
1668 # If you customize your file layout, set \$IP to the directory that contains
1669 # the other MediaWiki files. It will be used as a base to locate files.
1670 if( defined( 'MW_INSTALL_PATH' ) ) {
1671 \$IP = MW_INSTALL_PATH;
1673 \$IP = dirname( __FILE__ );
1676 \$path = array( \$IP, \"\$IP/includes\", \"\$IP/languages\" );
1677 set_include_path( implode( PATH_SEPARATOR, \$path ) . PATH_SEPARATOR . get_include_path() );
1679 require_once( \"\$IP/includes/DefaultSettings.php\" );
1681 # If PHP's memory limit is very low, some operations may fail.
1682 " . ($conf->raiseMemory ?
'' : '# ' ) . "ini_set( 'memory_limit', '20M' );" . "
1684 if ( \$wgCommandLineMode ) {
1685 if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
1686 die( \"This script must be run from the command line\\n\" );
1689 ## Uncomment this to disable output compression
1690 # \$wgDisableOutputCompression = true;
1692 \$wgSitename = \"{$slconf['Sitename']}\";
1694 ## The URL base path to the directory containing the wiki;
1695 ## defaults for all runtime URL paths are based off of this.
1696 \$wgScriptPath = \"{$slconf['ScriptPath']}\";
1697 \$wgScriptExtension = \"{$slconf['ScriptExtension']}\";
1699 ## For more information on customizing the URLs please see:
1700 ## http://www.mediawiki.org/wiki/Manual:Short_URL
1702 \$wgEnableEmail = $enableemail;
1703 \$wgEnableUserEmail = $enableuseremail;
1705 \$wgEmergencyContact = \"{$slconf['EmergencyContact']}\";
1706 \$wgPasswordSender = \"{$slconf['PasswordSender']}\";
1708 ## UPO means: this is also a user preference option
1709 \$wgEnotifUserTalk = $enotifusertalk; # UPO
1710 \$wgEnotifWatchlist = $enotifwatchlist; # UPO
1711 \$wgEmailAuthentication = $eauthent;
1713 \$wgDBtype = \"{$slconf['DBtype']}\";
1714 \$wgDBserver = \"{$slconf['DBserver']}\";
1715 \$wgDBname = \"{$slconf['DBname']}\";
1716 \$wgDBuser = \"{$slconf['DBuser']}\";
1717 \$wgDBpassword = \"{$slconf['DBpassword']}\";
1721 ## Shared memory settings
1722 \$wgMainCacheType = $cacheType;
1723 \$wgMemCachedServers = $mcservers;
1725 ## To enable image uploads, make sure the 'images' directory
1726 ## is writable, then set this to true:
1727 \$wgEnableUploads = false;
1728 {$magic}\$wgUseImageMagick = true;
1729 {$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
1731 ## If you want to use image uploads under safe mode,
1732 ## create the directories images/archive, images/thumb and
1733 ## images/temp, and make them all writable. Then uncomment
1734 ## this, if it's not already uncommented:
1735 {$hashedUploads}\$wgHashedUploadDirectory = false;
1737 ## If you have the appropriate support software installed
1738 ## you can enable inline LaTeX equations:
1741 \$wgLocalInterwiki = \$wgSitename;
1743 \$wgLanguageCode = \"{$slconf['LanguageCode']}\";
1745 \$wgProxyKey = \"$secretKey\";
1747 ## Default skin: you can change the default skin. Use the internal symbolic
1748 ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook':
1749 \$wgDefaultSkin = 'monobook';
1751 ## For attaching licensing metadata to pages, and displaying an
1752 ## appropriate copyright notice / icon. GNU Free Documentation
1753 ## License and Creative Commons licenses are supported so far.
1754 {$rights}\$wgEnableCreativeCommonsRdf = true;
1755 \$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright
1756 \$wgRightsUrl = \"{$slconf['RightsUrl']}\";
1757 \$wgRightsText = \"{$slconf['RightsText']}\";
1758 \$wgRightsIcon = \"{$slconf['RightsIcon']}\";
1759 # \$wgRightsCode = \"{$slconf['RightsCode']}\"; # Not yet used
1761 \$wgDiff3 = \"{$slconf['diff3']}\";
1763 # When you make changes to this configuration file, this will make
1764 # sure that cached pages are cleared.
1765 \$wgCacheEpoch = max( \$wgCacheEpoch, gmdate( 'YmdHis', @filemtime( __FILE__ ) ) );
1766 "; ## End of setting the $localsettings string
1768 // Keep things in Unix line endings internally;
1769 // the system will write out as local text type.
1770 return str_replace( "\r\n", "\n", $localsettings );
1773 function dieout( $text ) {
1774 die( $text . "\n\n</body>\n</html>" );
1777 function importVar( &$var, $name, $default = "" ) {
1778 if( isset( $var[$name] ) ) {
1779 $retval = $var[$name];
1780 if ( get_magic_quotes_gpc() ) {
1781 $retval = stripslashes( $retval );
1789 function importPost( $name, $default = "" ) {
1790 return importVar( $_POST, $name, $default );
1793 function importCheck( $name ) {
1794 return isset( $_POST[$name] );
1797 function importRequest( $name, $default = "" ) {
1798 return importVar( $_REQUEST, $name, $default );
1803 function aField( &$conf, $field, $text, $type = "text", $value = "", $onclick = '' ) {
1806 $xtype = "type=\"$type\"";
1812 $nolabel = ($type == "radio") ||
($type == "hidden");
1814 if ($type == 'radio')
1815 $id .= $radioCount++
;
1820 echo "\t\t<label class='column' for=\"$id\">$text</label>\n";
1823 if( $type == "radio" && $value == $conf->$field ) {
1824 $checked = "checked='checked'";
1828 echo "\t\t<input $xtype name=\"$field\" id=\"$id\" class=\"iput-$type\" $checked ";
1830 echo " onclick='toggleDBarea(\"$value\",1)' " ;
1833 if( $type == "radio" ) {
1834 echo htmlspecialchars( $value );
1836 echo htmlspecialchars( $conf->$field );
1842 echo " $text</label>\n";
1846 if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n";
1849 function getLanguageList() {
1850 global $wgLanguageNames, $IP;
1851 if( !isset( $wgLanguageNames ) ) {
1852 require_once( "$IP/languages/Names.php" );
1857 $d = opendir( "../languages/messages" );
1858 /* In case we are called from the root directory */
1860 $d = opendir( "languages/messages");
1861 while( false !== ($f = readdir( $d ) ) ) {
1863 if( preg_match( '/Messages([A-Z][a-z_]+)\.php$/', $f, $m ) ) {
1864 $code = str_replace( '_', '-', strtolower( $m[1] ) );
1865 if( isset( $wgLanguageNames[$code] ) ) {
1866 $name = $code . ' - ' . $wgLanguageNames[$code];
1870 $codes[$code] = $name;
1878 #Check for location of an executable
1879 # @param string $loc single location to check
1880 # @param array $names filenames to check for.
1881 # @param mixed $versioninfo array of details to use when checking version, use false for no version checking
1882 function locate_executable($loc, $names, $versioninfo = false) {
1883 if (!is_array($names))
1884 $names = array($names);
1886 foreach ($names as $name) {
1887 $command = "$loc".DIRECTORY_SEPARATOR
."$name";
1888 if (@file_exists
($command)) {
1892 $file = str_replace('$1', $command, $versioninfo[0]);
1893 if (strstr(`
$file`
, $versioninfo[1]) !== false)
1900 # Test a memcached server
1901 function testMemcachedServer( $server ) {
1902 $hostport = explode(":", $server);
1905 if ( !function_exists( 'fsockopen' ) ) {
1906 $errstr = "Can't connect to memcached, fsockopen() not present";
1908 if ( !$errstr && count( $hostport ) != 2 ) {
1909 $errstr = 'Please specify host and port';
1912 list( $host, $port ) = $hostport;
1916 $fp = @fsockopen
( $host, $port, $errno, $fsockerr, 1.0 );
1917 if ( $fp === false ) {
1918 $errstr = "Cannot connect to memcached on $host:$port : $fsockerr";
1922 $command = "version\r\n";
1923 $bytes = fwrite( $fp, $command );
1924 if ( $bytes != strlen( $command ) ) {
1925 $errstr = "Cannot write to memcached socket on $host:$port";
1929 $expected = "VERSION ";
1930 $response = fread( $fp, strlen( $expected ) );
1931 if ( $response != $expected ) {
1932 $errstr = "Didn't get correct memcached response from $host:$port";
1939 echo "<li>Connected to memcached on $host:$port successfully";
1944 function database_picker($conf) {
1947 foreach(array_keys($ourdb) as $db) {
1948 if ($ourdb[$db]['havedriver']) {
1950 aField( $conf, "DBtype", $ourdb[$db]['fullname'], 'radio', $db, 'onclick');
1957 function database_switcher($db) {
1959 $color = $ourdb[$db]['bgcolor'];
1960 $full = $ourdb[$db]['fullname'];
1961 print "<fieldset id='$db'><legend>$full specific options</legend>\n";
1964 function printListItem( $item ) {
1965 print "<li>$item</li>";
1970 <div
class="license">
1972 <p
>This program is free software
; you can redistribute it
and/or modify
1973 it under the terms of the GNU General
Public License
as published by
1974 the Free Software Foundation
; either version
2 of the License
, or
1975 (at your option
) any later version
.</p
>
1977 <p
>This program is distributed in the hope that it will be useful
,
1978 but WITHOUT ANY WARRANTY
; without even the implied warranty of
1979 MERCHANTABILITY
or FITNESS
FOR A PARTICULAR PURPOSE
. See the
1980 GNU General
Public License
for more details
.</p
>
1982 <p
>You should have received
<a href
="../COPYING">a copy of the GNU General
Public License
</a
>
1983 along with this program
; if not
, write to the Free Software
1984 Foundation
, Inc
., 51 Franklin Street
, Fifth Floor
, Boston
, MA
02110-1301, USA
.
1985 or <a href
="http://www.gnu.org/copyleft/gpl.html">read it online
</a
></p
>
1991 <div id
="column-one">
1992 <div
class="portlet" id
="p-logo">
1993 <a style
="background-image: url(../skins/common/images/mediawiki.png);"
1994 href
="http://www.mediawiki.org/"
1995 title
="Main Page"></a
>
1997 <script type
="text/javascript"> if (window
.isMSIE55
) fixalpha(); </script
>
1998 <div
class='portlet'><div
class='pBody'>
2000 <li
><strong
><a href
="http://www.mediawiki.org/">MediaWiki home
</a
></strong
></li
>
2001 <li
><a href
="../README">Readme
</a
></li
>
2002 <li
><a href
="../RELEASE-NOTES">Release notes
</a
></li
>
2003 <li
><a href
="../docs/">Documentation
</a
></li
>
2004 <li
><a href
="http://meta.wikipedia.org/wiki/MediaWiki_User's_Guide">User
's Guide</a></li>
2005 <li><a href="http://www.mediawiki.org/wiki/Manual:FAQ">FAQ</a></li>
2007 <p style="font-size:90%;margin-top:1em">MediaWiki is Copyright © 2001-2008 by Magnus Manske, Brion Vibber, Lee Daniel Crocker, Tim Starling, Erik Möller, Gabriel Wicke and others.</p>