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" );
50 require_once( "$IP/includes/Exception.php" );
52 # If we get an exception, the user needs to know
54 $wgShowExceptionDetails = true;
55 $wgShowSQLErrors = true;
56 wfInstallExceptionHandler();
57 ## Databases we support:
60 $ourdb['mysql']['fullname'] = 'MySQL';
61 $ourdb['mysql']['havedriver'] = 0;
62 $ourdb['mysql']['compile'] = 'mysql';
63 $ourdb['mysql']['bgcolor'] = '#ffe5a7';
64 $ourdb['mysql']['rootuser'] = 'root';
66 $ourdb['postgres']['fullname'] = 'PostgreSQL';
67 $ourdb['postgres']['havedriver'] = 0;
68 $ourdb['postgres']['compile'] = 'pgsql';
69 $ourdb['postgres']['bgcolor'] = '#aaccff';
70 $ourdb['postgres']['rootuser'] = 'postgres';
72 $ourdb['sqlite']['fullname'] = 'SQLite';
73 $ourdb['sqlite']['havedriver'] = 0;
74 $ourdb['sqlite']['compile'] = 'pdo_sqlite';
75 $ourdb['sqlite']['bgcolor'] = '#b1ebb1';
76 $ourdb['sqlite']['rootuser'] = '';
78 $ourdb['mssql']['fullname'] = 'MSSQL';
79 $ourdb['mssql']['havedriver'] = 0;
80 $ourdb['mssql']['compile'] = 'mssql not ready'; # Change to 'mssql' after includes/DatabaseMssql.php added;
81 $ourdb['mssql']['bgcolor'] = '#ffc0cb';
82 $ourdb['mssql']['rootuser'] = 'administrator';
84 $ourdb['ibm_db2']['fullname'] = 'DB2';
85 $ourdb['ibm_db2']['havedriver'] = 0;
86 $ourdb['ibm_db2']['compile'] = 'ibm_db2';
87 $ourdb['ibm_db2']['bgcolor'] = '#ffeba1';
88 $ourdb['ibm_db2']['rootuser'] = 'db2admin';
90 $ourdb['oracle']['fullname'] = 'Oracle';
91 $ourdb['oracle']['havedriver'] = 0;
92 $ourdb['oracle']['compile'] = 'oci8';
93 $ourdb['oracle']['bgcolor'] = '#ffeba1';
94 $ourdb['oracle']['rootuser'] = '';
97 <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
98 <html xmlns
="http://www.w3.org/1999/xhtml" xml
:lang
="en" lang
="en" dir
="ltr">
100 <meta http
-equiv
="Content-type" content
="text/html; charset=utf-8" />
101 <meta name
="robots" content
="noindex,nofollow"/>
102 <title
>MediaWiki
<?php
echo htmlspecialchars( $wgVersion ); ?
> Installation
</title
>
103 <style type
="text/css">
105 @import
"../skins/monobook/main.css";
109 margin
: 1em
0 1em
2.5em
;
116 .config
-section label
.column
{
128 zoom
: 100%
; /* IE hack */
131 .config
-section
.config
-desc
{
133 margin
: 0 0 2em
18em
;
138 .iput
-text
, .iput
-password
{
145 background
-color
: #fff;
153 background
-color
: #FFF0F0;
154 border
: 2px solid red
;
162 list-style
-type
: none
;
163 list-style
-image
: none
;
180 span
.success
-message
{
190 <script type
="text/javascript">
193 <?php
foreach (array_keys($ourdb) as $db) {
194 echo "\n var i = document.getElementById('$db'); if (i) i.style.display='none';";
199 function toggleDBarea(id
,defaultroot
) {
201 var dbarea
= document
.getElementById(id
);
202 if (dbarea
) dbarea
.style
.display
= (dbarea
.style
.display
== 'none') ?
'block' : 'none';
203 var db
= document
.getElementById('RootUser');
205 <?php
foreach (array_keys($ourdb) as $db) {
206 echo " if (id == '$db') { db.value = '".$ourdb[$db]['rootuser']."';}\n";
215 <div id
="globalWrapper">
216 <div id
="column-content">
218 <div id
="bodyContent">
220 <h1
>MediaWiki
<?php
print htmlspecialchars( $wgVersion ) ?
> Installation
</h1
>
223 $mainListOpened = false; # Is the main list (environement checking) opend ? Used by dieout
225 /* Check for existing configurations and bug out! */
227 if( file_exists( "../LocalSettings.php" ) ) {
228 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
229 dieout( "<p><strong>Setup has completed, <a href='../$script'>your wiki</a> is configured.</strong></p>
230 <p>Please delete the /config directory for extra security.</p>" );
233 if( file_exists( "./LocalSettings.php" ) ) {
234 writeSuccessMessage();
238 if( !is_writable( "." ) ) {
239 dieout( "<h2>Can't write config file, aborting</h2>
241 <p>In order to configure the wiki you have to make the <tt>config</tt> subdirectory
242 writable by the web server. Once configuration is done you'll move the created
243 <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can
244 then remove the <tt>config</tt> subdirectory entirely.</p>
246 <p>To make the directory writable on a Unix/Linux system:</p>
249 cd <i>/path/to/wiki</i>
253 <p>Afterwards retry to start the <a href=\"\">setup</a>.</p>" );
257 require_once( "$IP/install-utils.inc" );
258 require_once( "$IP/maintenance/updaters.inc" );
261 function getEncoded( $data ) {
262 # removing latin1 support, no need...
265 function getSitename() { return $this->getEncoded( $this->Sitename
); }
266 function getSysopName() { return $this->getEncoded( $this->SysopName
); }
267 function getSysopPass() { return $this->getEncoded( $this->SysopPass
); }
269 function setSchema( $schema, $engine ) {
270 $this->DBschema
= $schema;
271 if ( !preg_match( '/^\w*$/', $engine ) ){
274 switch ( $this->DBschema
) {
276 $this->DBTableOptions
= "ENGINE=$engine, DEFAULT CHARSET=utf8";
277 $this->DBmysql5
= 'true';
279 case 'mysql5-binary':
280 $this->DBTableOptions
= "ENGINE=$engine, DEFAULT CHARSET=binary";
281 $this->DBmysql5
= 'true';
284 $this->DBTableOptions
= "TYPE=$engine";
285 $this->DBmysql5
= 'false';
287 $this->DBengine
= $engine;
289 # Set the global for use during install
290 global $wgDBTableOptions;
291 $wgDBTableOptions = $this->DBTableOptions
;
299 <b
>Don
't forget security updates!</b> Keep an eye on the
300 <a href="http://lists.wikimedia.org/mailman/listinfo/mediawiki-announce">low-traffic
301 release announcements mailing list</a>.
306 <h2>Checking environment...</h2>
307 <p><em>Please include all of the lines below when reporting installation problems.</em></p>
308 <ul class="env-check">
310 $mainListOpened = true;
314 define( 'MW_NO_OUTPUT_BUFFER
', 1 );
315 $conf = new ConfigData;
317 install_version_checks();
318 $self = 'Installer
'; # Maintenance script name, to please Setup.php
320 print "<li>PHP " . htmlspecialchars( phpversion() ) . " installed</li>\n";
322 error_reporting( 0 );
323 $phpdatabases = array();
324 foreach (array_keys($ourdb) as $db) {
325 $compname = $ourdb[$db]['compile
'];
326 if( extension_loaded( $compname ) || ( mw_have_dl() && dl( "{$compname}." . PHP_SHLIB_SUFFIX ) ) ) {
327 array_push($phpdatabases, $db);
328 $ourdb[$db]['havedriver
'] = 1;
331 error_reporting( E_ALL );
333 if (!$phpdatabases) {
334 print "Could not find a suitable database driver!<ul>";
335 foreach (array_keys($ourdb) AS $db) {
336 $comp = $ourdb[$db]['compile
'];
337 $full = $ourdb[$db]['fullname
'];
338 print "<li>For <b>$full</b>, compile PHP using <b>--with-$comp</b>, "
339 ."or install the $comp.so module</li>\n";
345 print "<li>Found database drivers for:";
347 foreach (array_keys($ourdb) AS $db) {
348 if ($ourdb[$db]['havedriver
']) {
349 if ( $DefaultDBtype == '' ) {
350 $DefaultDBtype = $db;
352 print " ".$ourdb[$db]['fullname
'];
357 if( wfIniGetBool( "register_globals" ) ) {
360 <div style="font-size:110%">
361 <strong class="error">Warning:</strong>
362 <strong>PHP's
<tt
><a href
="http://php.net/register_globals">register_globals
</a
></tt
> option is enabled
. Disable it
if you can
.</strong
>
364 MediaWiki will work
, but your server is more exposed to PHP
-based security vulnerabilities
.
371 if( wfIniGetBool( "magic_quotes_runtime" ) ) {
373 ?
><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
>
374 This option corrupts data input unpredictably
; you cannot install
or use
375 MediaWiki unless this option is disabled
.</li
>
379 if( wfIniGetBool( "magic_quotes_sybase" ) ) {
381 ?
><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
>
382 This option corrupts data input unpredictably
; you cannot install
or use
383 MediaWiki unless this option is disabled
.</li
>
387 if( wfIniGetBool( "mbstring.func_overload" ) ) {
389 ?
><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
>
390 This option causes errors
and may corrupt data unpredictably
;
391 you cannot install
or use MediaWiki unless this option is disabled
.</li
>
395 if( wfIniGetBool( "zend.ze1_compatibility_mode" ) ) {
397 ?
><li
class="error"><strong
>Fatal
: <a href
="http://www.php.net/manual/en/ini.core.php">zend
.ze1_compatibility_mode
</a
> is active
!</strong
>
398 This option causes horrible bugs with MediaWiki
; you cannot install
or use
399 MediaWiki unless this option is disabled
.</li
>
405 dieout( "Cannot install MediaWiki." );
408 if( wfIniGetBool( "safe_mode" ) ) {
409 $conf->safeMode
= true;
411 <li
><b
class='error'>Warning
:</b
> <strong
>PHP
's
412 <a href='http
://www.php.net/features.safe-mode'>safe mode</a> is active.</strong>
413 You may have problems caused by this
, particularly
if using image uploads
.
417 $conf->safeMode
= false;
420 $sapi = htmlspecialchars( php_sapi_name() );
421 print "<li>PHP server API is $sapi; ";
422 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
423 if( $wgUsePathInfo ) {
424 print "ok, using pretty URLs (<tt>$script/Page_Title</tt>)";
426 print "using ugly URLs (<tt>$script?title=Page_Title</tt>)";
430 $conf->xml
= function_exists( "utf8_encode" );
432 print "<li>Have XML / Latin1-UTF-8 conversion support.</li>\n";
434 dieout( "PHP's XML module is missing; the wiki requires functions in
435 this module and won't work in this configuration.
436 If you're running Mandrake, install the php-xml package." );
439 # Check for session support
440 if( !function_exists( 'session_name' ) )
441 dieout( "PHP's session module is missing. MediaWiki requires session support in order to function." );
443 # session.save_path doesn't *have* to be set, but if it is, and it's
444 # not valid/writable/etc. then it can cause problems
445 $sessionSavePath = mw_get_session_save_path();
446 $ssp = htmlspecialchars( $sessionSavePath );
447 # Warn the user if it's not set, but let them proceed
448 if( !$sessionSavePath ) {
449 print "<li><strong>Warning:</strong> A value for <tt>session.save_path</tt>
450 has not been set in PHP.ini. If the default value causes problems with
451 saving session data, set it to a valid path which is read/write/execute
452 for the user your web server is running under.</li>";
453 } elseif ( is_dir( $sessionSavePath ) && is_writable( $sessionSavePath ) ) {
454 # All good? Let the user know
455 print "<li>Session save path (<tt>{$ssp}</tt>) appears to be valid.</li>";
457 # Something not right? Warn the user, but let them proceed
458 print "<li><strong>Warning:</strong> Your <tt>session.save_path</tt> value (<tt>{$ssp}</tt>)
459 appears to be invalid or is not writable. PHP needs to be able to save data to
460 this location for correct session operation.</li>";
463 # Check for PCRE support
464 if( !function_exists( 'preg_match' ) )
465 dieout( "The PCRE support module appears to be missing. MediaWiki requires the
466 Perl-compatible regular expression functions." );
468 $memlimit = ini_get( "memory_limit" );
469 $conf->raiseMemory
= false;
470 if( empty( $memlimit ) ||
$memlimit == -1 ) {
471 print "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n";
473 print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars( $memlimit ) . ". ";
474 $n = intval( $memlimit );
475 if( preg_match( '/^([0-9]+)[Mm]$/', trim( $memlimit ), $m ) ) {
476 $n = intval( $m[1] * (1024*1024) );
478 if( $n < 20*1024*1024 ) {
479 print "Attempting to raise limit to 20M... ";
480 if( false === ini_set( "memory_limit", "20M" ) ) {
481 print "failed.<br /><b>" . htmlspecialchars( $memlimit ) . " seems too low, installation may fail!</b>";
483 $conf->raiseMemory
= true;
490 $conf->turck
= function_exists( 'mmcache_get' );
491 if ( $conf->turck
) {
492 print "<li><a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> installed</li>\n";
495 $conf->xcache
= function_exists( 'xcache_get' );
497 print "<li><a href=\"http://trac.lighttpd.net/xcache/\">XCache</a> installed</li>\n";
499 $conf->apc
= function_exists('apc_fetch');
501 print "<li><a href=\"http://www.php.net/apc\">APC</a> installed</li>\n";
504 $conf->eaccel
= function_exists( 'eaccelerator_get' );
505 if ( $conf->eaccel
) {
506 $conf->turck
= 'eaccelerator';
507 print "<li><a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> installed</li>\n";
510 $conf->dba
= function_exists( 'dba_open' );
512 if( !( $conf->turck ||
$conf->eaccel ||
$conf->apc ||
$conf->xcache
) ) {
513 echo( '<li>Couldn\'t find <a href="http://turck-mmcache.sourceforge.net">Turck MMCache</a>,
514 <a href="http://eaccelerator.sourceforge.net">eAccelerator</a>,
515 <a href="http://www.php.net/apc">APC</a> or <a href="http://trac.lighttpd.net/xcache/">XCache</a>;
516 cannot use these for object caching.</li>' );
519 $conf->phpCliPath
= false;
520 $phpClilocations = array_merge(
527 explode( PATH_SEPARATOR
, getenv( "PATH" ) ) );
528 $phpClinames = array( "php", "php.exe" );
529 foreach ($phpClilocations as $loc) {
530 $exe = locate_executable($loc, $phpClinames);
531 if ($exe !== false) {
532 $conf->phpCliPath
= $exe;
537 $conf->diff3
= false;
538 $diff3locations = array_merge(
545 explode( PATH_SEPARATOR
, getenv( "PATH" ) ) );
546 $diff3names = array( "gdiff3", "diff3", "diff3.exe" );
548 $diff3versioninfo = array( '$1 --version 2>&1', 'diff3 (GNU diffutils)' );
549 foreach ($diff3locations as $loc) {
550 $exe = locate_executable($loc, $diff3names, $diff3versioninfo);
551 if ($exe !== false) {
558 print "<li>Found GNU diff3: <tt>$conf->diff3</tt>.</li>";
560 print "<li>GNU diff3 not found.</li>";
562 $conf->ImageMagick
= false;
563 $imcheck = array( "/usr/bin", "/opt/csw/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" );
564 foreach( $imcheck as $dir ) {
565 $im = "$dir/convert";
566 if( @file_exists
( $im ) ) {
567 print "<li>Found ImageMagick: <tt>$im</tt>; image thumbnailing will be enabled if you enable uploads.</li>\n";
568 $conf->ImageMagick
= $im;
573 $conf->HaveGD
= function_exists( "imagejpeg" );
574 if( $conf->HaveGD
) {
575 print "<li>Found GD graphics library built-in";
576 if( !$conf->ImageMagick
) {
577 print ", image thumbnailing will be enabled if you enable uploads";
581 if( !$conf->ImageMagick
) {
582 print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n";
586 $conf->IP
= dirname( dirname( __FILE__
) );
587 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP
) . "</tt></li>\n";
590 // PHP_SELF isn't available sometimes, such as when PHP is CGI but
591 // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
592 // to get the path to the current script... hopefully it's reliable. SIGH
593 $path = ($_SERVER["PHP_SELF"] === '')
594 ?
$_SERVER["SCRIPT_NAME"]
595 : $_SERVER["PHP_SELF"];
597 $conf->ScriptPath
= preg_replace( '{^(.*)/config.*$}', '$1', $path );
598 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath
) . "</tt></li>\n";
602 // We may be installing from *.php5 extension file, if so, print message
603 $conf->ScriptExtension
= '.php';
604 if (defined('MW_INSTALL_PHP5_EXT')) {
605 $conf->ScriptExtension
= '.php5';
606 print "<li>Installing MediaWiki with <tt>php5</tt> file extensions</li>\n";
608 print "<li>Installing MediaWiki with <tt>php</tt> file extensions</li>\n";
612 print "<li style='font-weight:bold;color:green;font-size:110%'>Environment checked. You can install MediaWiki.</li>\n";
613 $conf->posted
= ($_SERVER["REQUEST_METHOD"] == "POST");
615 $conf->Sitename
= ucfirst( importPost( "Sitename", "" ) );
616 $defaultEmail = empty( $_SERVER["SERVER_ADMIN"] )
618 : $_SERVER["SERVER_ADMIN"];
619 $conf->EmergencyContact
= importPost( "EmergencyContact", $defaultEmail );
620 $conf->DBtype
= importPost( "DBtype", $DefaultDBtype );
621 if ( !isset( $ourdb[$conf->DBtype
] ) ) {
622 $conf->DBtype
= $DefaultDBtype;
625 $conf->DBserver
= importPost( "DBserver", "localhost" );
626 $conf->DBname
= importPost( "DBname", "wikidb" );
627 $conf->DBuser
= importPost( "DBuser", "wikiuser" );
628 $conf->DBpassword
= importPost( "DBpassword" );
629 $conf->DBpassword2
= importPost( "DBpassword2" );
630 $conf->SysopName
= importPost( "SysopName", "WikiSysop" );
631 $conf->SysopPass
= importPost( "SysopPass" );
632 $conf->SysopPass2
= importPost( "SysopPass2" );
633 $conf->RootUser
= importPost( "RootUser", "root" );
634 $conf->RootPW
= importPost( "RootPW", "" );
635 $useRoot = importCheck( 'useroot', false );
636 $conf->LanguageCode
= importPost( "LanguageCode", "en" );
638 $conf->DBprefix
= importPost( "DBprefix" );
640 importPost( "DBschema", "mysql5-binary" ),
641 importPost( "DBengine", "InnoDB" ) );
643 ## Postgres specific:
644 $conf->DBport
= importPost( "DBport", "5432" );
645 $conf->DBmwschema
= importPost( "DBmwschema", "mediawiki" );
646 $conf->DBts2schema
= importPost( "DBts2schema", "public" );
649 $conf->SQLiteDataDir
= importPost( "SQLiteDataDir", "" );
652 // We need a second field so it doesn't overwrite the MySQL one
653 $conf->DBprefix2
= importPost( "DBprefix2" );
656 // New variable in order to have a different default port number
657 $conf->DBport_db2
= importPost( "DBport_db2", "50000" );
658 $conf->DBmwschema
= importPost( "DBmwschema", "mediawiki" );
659 $conf->DBcataloged
= importPost( "DBcataloged", "cataloged" );
662 $conf->DBprefix_ora
= importPost( "DBprefix_ora" );
663 $conf->DBdefTS_ora
= importPost( "DBdefTS_ora", "USERS" );
664 $conf->DBtempTS_ora
= importPost( "DBtempTS_ora", "TEMP" );
666 $conf->ShellLocale
= getShellLocale( $conf->LanguageCode
);
668 /* Check for validity */
671 if( preg_match( '/^$|^mediawiki$|#/i', $conf->Sitename
) ) {
672 $errs["Sitename"] = "Must not be blank or \"MediaWiki\" and may not contain \"#\"";
674 if( $conf->DBuser
== "" ) {
675 $errs["DBuser"] = "Must not be blank";
677 if( ($conf->DBtype
== 'mysql') && (strlen($conf->DBuser
) > 16) ) {
678 $errs["DBuser"] = "Username too long";
680 if( $conf->DBpassword
== "" && $conf->DBtype
!= "postgres" ) {
681 $errs["DBpassword"] = "Must not be blank";
683 if( $conf->DBpassword
!= $conf->DBpassword2
) {
684 $errs["DBpassword2"] = "Passwords don't match!";
686 if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix
) ) {
687 $errs["DBprefix"] = "Invalid table prefix";
689 untaint( $conf->DBprefix
, TC_MYSQL
);
691 if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix_ora
) ) {
692 $errs["DBprefix_ora"] = "Invalid table prefix";
695 error_reporting( E_ALL
);
698 * Initialise $wgLang and $wgContLang to something so we can
699 * call case-folding methods. Per Brion, this is English for
700 * now, although we could be clever and initialise to the
701 * user-selected language.
703 $wgContLang = Language
::factory( 'en' );
704 $wgLang = $wgContLang;
707 * We're messing about with users, so we need a stub
708 * authentication plugin...
710 $wgAuth = new AuthPlugin();
713 * Validate the initial administrator account; username,
714 * password checks, etc.
716 if( $conf->SysopName
) {
717 # Check that the user can be created
718 $u = User
::newFromName( $conf->SysopName
);
719 if( is_a($u, 'User') ) { // please do not use instanceof, it breaks PHP4
720 # Various password checks
721 if( $conf->SysopPass
!= '' ) {
722 if( $conf->SysopPass
== $conf->SysopPass2
) {
723 if( $u->isValidPassword( $conf->SysopPass
) !== true ) {
724 $errs['SysopPass'] = "Bad password";
727 $errs['SysopPass2'] = "Passwords don't match";
730 $errs['SysopPass'] = "Cannot be blank";
734 $errs['SysopName'] = "Bad username";
738 $conf->License
= importRequest( "License", "none" );
739 if( $conf->License
== "gfdl1_2" ) {
740 $conf->RightsUrl
= "http://www.gnu.org/licenses/old-licenses/fdl-1.2.txt";
741 $conf->RightsText
= "GNU Free Documentation License 1.2";
742 $conf->RightsCode
= "gfdl1_2";
743 $conf->RightsIcon
= '${wgScriptPath}/skins/common/images/gnu-fdl.png';
744 } elseif( $conf->License
== "gfdl1_3" ) {
745 $conf->RightsUrl
= "http://www.gnu.org/copyleft/fdl.html";
746 $conf->RightsText
= "GNU Free Documentation License 1.3";
747 $conf->RightsCode
= "gfdl1_3";
748 $conf->RightsIcon
= '${wgScriptPath}/skins/common/images/gnu-fdl.png';
749 } elseif( $conf->License
== "none" ) {
750 $conf->RightsUrl
= $conf->RightsText
= $conf->RightsCode
= $conf->RightsIcon
= "";
751 } elseif( $conf->License
== "pd" ) {
752 $conf->RightsUrl
= "http://creativecommons.org/licenses/publicdomain/";
753 $conf->RightsText
= "Public Domain";
754 $conf->RightsCode
= "pd";
755 $conf->RightsIcon
= '${wgScriptPath}/skins/common/images/public-domain.png';
757 $conf->RightsUrl
= importRequest( "RightsUrl", "" );
758 $conf->RightsText
= importRequest( "RightsText", "" );
759 $conf->RightsCode
= importRequest( "RightsCode", "" );
760 $conf->RightsIcon
= importRequest( "RightsIcon", "" );
763 $conf->Shm
= importRequest( "Shm", "none" );
764 $conf->MCServers
= importRequest( "MCServers" );
766 /* Test memcached servers */
768 if ( $conf->Shm
== 'memcached' && $conf->MCServers
) {
769 $conf->MCServerArray
= wfArrayMap( 'trim', explode( ',', $conf->MCServers
) );
770 foreach ( $conf->MCServerArray
as $server ) {
771 $error = testMemcachedServer( $server );
773 $errs["MCServers"] = $error;
777 } else if ( $conf->Shm
== 'memcached' ) {
778 $errs["MCServers"] = "Please specify at least one server if you wish to use memcached";
781 /* default values for installation */
782 $conf->Email
= importRequest("Email", "email_enabled");
783 $conf->Emailuser
= importRequest("Emailuser", "emailuser_enabled");
784 $conf->Enotif
= importRequest("Enotif", "enotif_allpages");
785 $conf->Eauthent
= importRequest("Eauthent", "eauthent_enabled");
787 if( $conf->posted
&& ( 0 == count( $errs ) ) ) {
788 do { /* So we can 'continue' to end prematurely */
789 $conf->Root
= ($conf->RootPW
!= "");
791 /* Load up the settings and get installin' */
792 $local = writeLocalSettings( $conf );
793 echo "<li style=\"list-style: none\">\n";
794 echo "<p><b>Generating configuration file...</b></p>\n";
797 $wgCommandLineMode = false;
799 $ok = eval( $local );
800 if( $ok === false ) {
801 dieout( "<p>Errors in generated configuration; " .
802 "most likely due to a bug in the installer... " .
803 "Config file was: </p>" .
805 htmlspecialchars( $local ) .
808 $conf->DBtypename
= '';
809 foreach (array_keys($ourdb) as $db) {
810 if ($conf->DBtype
=== $db)
811 $conf->DBtypename
= $ourdb[$db]['fullname'];
813 if ( ! strlen($conf->DBtype
)) {
814 $errs["DBpicktype"] = "Please choose a database type";
818 if (! $conf->DBtypename
) {
819 $errs["DBtype"] = "Unknown database type '$conf->DBtype'";
822 print "<li>Database type: " . htmlspecialchars( $conf->DBtypename
) . "</li>\n";
823 $dbclass = 'Database'.ucfirst($conf->DBtype
);
824 $wgDBtype = $conf->DBtype
;
825 $wgDBadminuser = "root";
826 $wgDBadminpassword = $conf->RootPW
;
829 $wgDBprefix = $conf->DBprefix
;
831 ## Postgres specific:
832 $wgDBport = $conf->DBport
;
833 $wgDBmwschema = $conf->DBmwschema
;
834 $wgDBts2schema = $conf->DBts2schema
;
836 if( $conf->DBprefix2
!= '' ) {
838 $wgDBprefix = $conf->DBprefix2
;
839 } elseif( $conf->DBprefix_ora
!= '' ) {
841 $wgDBprefix = $conf->DBprefix_ora
;
845 $wgDBcataloged = $conf->DBcataloged
;
847 $wgCommandLineMode = true;
848 if (! defined ( 'STDERR' ) )
849 define( 'STDERR', fopen("php://stderr", "wb"));
850 $wgUseDatabaseMessages = false; /* FIXME: For database failure */
851 require_once( "$IP/includes/Setup.php" );
852 Language
::getLocalisationCache()->disableBackend();
856 $wgTitle = Title
::newFromText( "Installation script" );
857 error_reporting( E_ALL
);
858 print "<li>Loading class: " . htmlspecialchars( $dbclass ) . "</li>\n";
859 if ( $conf->DBtype
!= 'sqlite' ) {
863 if( $conf->DBtype
== 'mysql' ) {
864 $mysqlOldClient = version_compare( mysql_get_client_info(), "4.1.0", "lt" );
865 if( $mysqlOldClient ) {
866 print "<li><b>PHP is linked with old MySQL client libraries. If you are
867 using a MySQL 4.1 server and have problems connecting to the database,
868 see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
869 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b></li>\n";
871 $ok = true; # Let's be optimistic
873 # Decide if we're going to use the superuser or the regular database user
874 $conf->Root
= $useRoot;
876 $db_user = $conf->RootUser
;
877 $db_pass = $conf->RootPW
;
879 $db_user = $wgDBuser;
880 $db_pass = $wgDBpassword;
884 echo( "<li>Attempting to connect to database server as " . htmlspecialchars( $db_user ) . "..." );
885 $wgDatabase = Database
::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 );
887 # Check the connection and respond to errors
888 if( $wgDatabase->isOpen() ) {
891 $wgDBadminuser = $db_user;
892 $wgDBadminpassword = $db_pass;
893 echo( "success.</li>\n" );
894 $wgDatabase->ignoreErrors( true );
895 $myver = $wgDatabase->getServerVersion();
897 # There were errors, report them and back out
899 $errno = mysql_errno();
900 $errtx = htmlspecialchars( mysql_error() );
904 echo( "failed due to authentication errors. Check passwords.</li>" );
906 # The superuser details are wrong
907 $errs["RootUser"] = "Check username";
908 $errs["RootPW"] = "and password";
910 # The regular user details are wrong
911 $errs["DBuser"] = "Check username";
912 $errs["DBpassword"] = "and password";
918 # General connection problem
919 echo( htmlspecialchars( "failed with error [$errno] $errtx." ) . "</li>\n" );
920 $errs["DBserver"] = "Connection failed";
925 if( !$ok ) { continue; }
927 else if( $conf->DBtype
== 'ibm_db2' ) {
929 $db_user = $conf->RootUser
;
930 $db_pass = $conf->RootPW
;
932 $db_user = $wgDBuser;
933 $db_pass = $wgDBpassword;
936 echo( "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) .
937 "\" as \"" . htmlspecialchars( $db_user ) . "\"..." );
938 $wgDatabase = $dbc->newFromParams($wgDBserver, $db_user, $db_pass, $wgDBname, 1);
939 if (!$wgDatabase->isOpen()) {
940 print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
942 $myver = $wgDatabase->getServerVersion();
944 if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname);
946 } elseif ( $conf->DBtype
== 'sqlite' ) {
947 if ("$wgSQLiteDataDir" == '') {
948 $wgSQLiteDataDir = dirname($_SERVER['DOCUMENT_ROOT']).'/data';
950 echo "<li>Attempting to connect to SQLite database at \"" .
951 htmlspecialchars( $wgSQLiteDataDir ) . "\"";
952 if ( !is_dir( $wgSQLiteDataDir ) ) {
953 if ( is_writable( dirname( $wgSQLiteDataDir ) ) ) {
954 $ok = wfMkdirParents( $wgSQLiteDataDir, $wgSQLiteDataDirMode );
959 echo ": cannot create data directory</li>";
960 $errs['SQLiteDataDir'] = 'Enter a valid data directory';
964 if ( !is_writable( $wgSQLiteDataDir ) ) {
965 echo ": data directory not writable</li>";
966 $errs['SQLiteDataDir'] = 'Enter a writable data directory';
969 $dataFile = "$wgSQLiteDataDir/$wgDBname.sqlite";
970 if ( file_exists( $dataFile ) && !is_writable( $dataFile ) ) {
971 echo ": data file not writable</li>";
972 $errs['SQLiteDataDir'] = "$wgDBname.sqlite is not writable";
975 $wgDatabase = new DatabaseSqlite( false, false, false, $wgDBname, 1 );
976 if (!$wgDatabase->isOpen()) {
977 print ": error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
978 $errs['SQLiteDataDir'] = 'Could not connect to database';
981 $myver = $wgDatabase->getServerVersion();
983 if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname);
985 } elseif ( $conf->DBtype
== 'oracle' ) {
986 echo "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) ."\"</li>";
987 $wgDatabase = $dbc->newFromParams('DUMMY', $wgDBuser, $wgDBpassword, $wgDBname, 1);
988 if (!$wgDatabase->isOpen()) {
990 echo "<li>Connect failed.</li>";
992 if (ini_get('oci8.privileged_connect') === false) {
993 echo "<li>Privileged connect disabled, please set oci8.privileged_connect or run maintenance/ora/user.sql script manually prior to continuing.</li>";
996 $wgDBadminuser = $conf->RootUser
;
997 $wgDBadminpassword = $conf->RootPW
;
998 echo "<li>Attempting to create DB user.</li>";
999 $wgDatabase = $dbc->newFromParams('DUMMY', $wgDBadminuser, $wgDBadminpassword, $wgDBname, 1, 64);
1000 if ($wgDatabase->isOpen()) {
1001 $wgDBOracleDefTS = $conf->DBdefTS_ora
;
1002 $wgDBOracleTempTS = $conf->DBtempTS_ora
;
1003 dbsource( "../maintenance/ora/user.sql", $wgDatabase );
1005 echo "<li>Invalid database superuser, please supply a valid superuser account.</li>";
1006 echo "<li>ERR: ".print_r(oci_error(), true)."</li>";
1011 echo "<li>Database superuser missing, please supply a valid superuser account.</li>";
1015 $errs["RootUser"] = "Check username";
1016 $errs["RootPW"] = "and password";
1018 echo "<li>Attempting to connect to database with new user \"" . htmlspecialchars( $wgDBname ) ."\"</li>";
1019 $wgDatabase = $dbc->newFromParams('DUMMY', $wgDBuser, $wgDBpassword, $wgDBname, 1);
1023 $myver = $wgDatabase->getServerVersion();
1025 } else { # not mysql
1026 error_reporting( E_ALL
);
1028 ## Possible connect as a superuser
1029 // Changed !mysql to postgres check since it seems to only apply to postgres
1030 if( $useRoot && $conf->DBtype
== 'postgres' ) {
1031 $wgDBsuperuser = $conf->RootUser
;
1032 echo( "<li>Attempting to connect to database \"postgres\" as superuser \"" .
1033 htmlspecialchars( $wgDBsuperuser ) . "\"..." );
1034 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBsuperuser, $conf->RootPW
, "postgres", 1);
1035 if (!$wgDatabase->isOpen()) {
1036 print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
1037 $errs["DBserver"] = "Could not connect to database as superuser";
1038 $errs["RootUser"] = "Check username";
1039 $errs["RootPW"] = "and password";
1042 $wgDatabase->initial_setup($conf->RootPW
, 'postgres');
1044 echo( "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) .
1045 "\" as \"" . htmlspecialchars( $wgDBuser ) . "\"..." );
1046 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1);
1047 if (!$wgDatabase->isOpen()) {
1048 print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
1050 $myver = $wgDatabase->getServerVersion();
1052 if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname);
1055 if ( !$wgDatabase->isOpen() ) {
1056 $errs["DBserver"] = "Couldn't connect to database";
1060 print "<li>Connected to " . htmlspecialchars( "{$conf->DBtype} $myver" );
1061 if ($conf->DBtype
== 'mysql') {
1062 if( version_compare( $myver, "4.0.14" ) < 0 ) {
1064 dieout( "-- mysql 4.0.14 or later required. Aborting." );
1066 $mysqlNewAuth = version_compare( $myver, "4.1.0", "ge" );
1067 if( $mysqlNewAuth && $mysqlOldClient ) {
1068 print "; <b class='error'>You are using MySQL 4.1 server, but PHP is linked
1069 to old client libraries; if you have trouble with authentication, see
1070 <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
1071 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>";
1074 if( $mysqlNewAuth ) {
1075 print "; enabling MySQL 4.1/5.0 charset mode";
1077 print "; <b class='error'>MySQL 4.1/5.0 charset mode enabled,
1078 but older version detected; will likely fail.</b>";
1083 @$sel = $wgDatabase->selectDB( $wgDBname );
1085 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
1087 $err = mysql_errno();
1088 $databaseSafe = htmlspecialchars( $wgDBname );
1089 if( $err == 1102 /* Invalid database name */ ) {
1090 print "<ul><li><strong>{$databaseSafe}</strong> is not a valid database name.</li></ul>";
1092 } elseif( $err != 1049 /* Database doesn't exist */ ) {
1093 print "<ul><li>Error selecting database <strong>{$databaseSafe}</strong>: {$err} ";
1094 print htmlspecialchars( mysql_error() ) . "</li></ul>";
1097 print "<li>Attempting to create database...</li>";
1098 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
1100 print "<li>Couldn't create database <tt>" .
1101 htmlspecialchars( $wgDBname ) .
1102 "</tt>; try with root access or check your username/pass.</li>\n";
1103 $errs["RootPW"] = "<- Enter";
1106 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
1108 $wgDatabase->selectDB( $wgDBname );
1110 else if ($conf->DBtype
== 'postgres') {
1111 if( version_compare( $myver, "8.0" ) < 0 ) {
1112 dieout( "<b>Postgres 8.0 or later is required</b>. Aborting." );
1116 if( $wgDatabase->tableExists( "cur" ) ||
$wgDatabase->tableExists( "revision" ) ) {
1117 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n";
1119 if ( $conf->DBtype
== 'mysql') {
1120 # Determine existing default character set
1121 if ( $wgDatabase->tableExists( "revision" ) ) {
1122 $revision = $wgDatabase->escapeLike( $conf->DBprefix
. 'revision' );
1123 $res = $wgDatabase->query( "SHOW TABLE STATUS LIKE '$revision'" );
1124 $row = $wgDatabase->fetchObject( $res );
1126 echo "<li>SHOW TABLE STATUS query failed!</li>\n";
1127 $existingSchema = false;
1128 $existingEngine = false;
1130 if ( preg_match( '/^latin1/', $row->Collation
) ) {
1131 $existingSchema = 'mysql4';
1132 } elseif ( preg_match( '/^utf8/', $row->Collation
) ) {
1133 $existingSchema = 'mysql5';
1134 } elseif ( preg_match( '/^binary/', $row->Collation
) ) {
1135 $existingSchema = 'mysql5-binary';
1137 $existingSchema = false;
1138 echo "<li><strong>Warning:</strong> Unrecognised existing collation</li>\n";
1140 if ( isset( $row->Engine
) ) {
1141 $existingEngine = $row->Engine
;
1143 $existingEngine = $row->Type
;
1146 if ( $existingSchema && $existingSchema != $conf->DBschema
) {
1147 $encExisting = htmlspecialchars( $existingSchema );
1148 $encRequested = htmlspecialchars( $conf->DBschema
);
1149 print "<li><strong>Warning:</strong> you requested the $encRequested schema, " .
1150 "but the existing database has the $encExisting schema. This upgrade script ".
1151 "can't convert it, so it will remain $encExisting.</li>\n";
1152 $conf->setSchema( $existingSchema, $conf->DBengine
);
1154 if ( $existingEngine && $existingEngine != $conf->DBengine
) {
1155 $encExisting = htmlspecialchars( $existingEngine );
1156 $encRequested = htmlspecialchars( $conf->DBengine
);
1157 print "<li><strong>Warning:</strong> you requested the $encRequested storage " .
1158 "engine, but the existing database uses the $encExisting engine. This upgrade " .
1159 "script can't convert it, so it will remain $encExisting.</li>\n";
1160 $conf->setSchema( $conf->DBschema
, $existingEngine );
1164 # Create user if required
1165 if ( $conf->Root
) {
1166 $conn = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
1167 if ( $conn->isOpen() ) {
1168 print "<li>DB user account ok</li>\n";
1171 print "<li>Granting user permissions...";
1172 if( $mysqlOldClient && $mysqlNewAuth ) {
1173 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>";
1176 dbsource( "../maintenance/users.sql", $wgDatabase );
1180 print "</ul><pre>\n";
1186 print "<ul><li>Finished update checks.</li>\n";
1188 # Determine available storage engines if possible
1189 if ( $conf->DBtype
== 'mysql' && version_compare( $myver, "4.1.2", "ge" ) ) {
1190 $res = $wgDatabase->query( 'SHOW ENGINES' );
1192 while ( $row = $wgDatabase->fetchObject( $res ) ) {
1193 if ( $row->Engine
== $conf->DBengine
&& ( $row->Support
== 'YES' ||
$row->Support
== 'DEFAULT' ) ) {
1198 $wgDatabase->freeResult( $res );
1199 if ( !$found && $conf->DBengine
!= 'MyISAM' ) {
1200 echo "<li><strong>Warning:</strong> " . htmlspecialchars( $conf->DBengine
) .
1201 " storage engine not available, " .
1202 "using MyISAM instead</li>\n";
1203 $conf->setSchema( $conf->DBschema
, 'MyISAM' );
1207 # FIXME: Check for errors
1208 print "<li>Creating tables...";
1209 if ($conf->DBtype
== 'mysql') {
1210 dbsource( "../maintenance/tables.sql", $wgDatabase );
1211 dbsource( "../maintenance/interwiki.sql", $wgDatabase );
1212 } elseif (is_callable(array($wgDatabase, 'setup_database'))) {
1213 $wgDatabase->setup_database();
1216 $errs["DBtype"] = "Do not know how to handle database type '$conf->DBtype'";
1220 print " done.</li>\n";
1222 print "<li>Initializing statistics...</li>\n";
1223 $wgDatabase->insert( 'site_stats',
1224 array ( 'ss_row_id' => 1,
1225 'ss_total_views' => 0,
1226 'ss_total_edits' => 1, # Main page first edit
1227 'ss_good_articles' => 0, # Main page is not a good article - no internal link
1228 'ss_total_pages' => 1, # Main page
1229 'ss_users' => $conf->SysopName ?
1 : 0, # Sysop account, if created
1230 'ss_admins' => $conf->SysopName ?
1 : 0, # Sysop account, if created
1231 'ss_images' => 0 ) );
1233 # Set up the "regular user" account *if we can, and if we need to*
1234 if( $conf->Root
and $conf->DBtype
== 'mysql') {
1236 $wgDatabase2 = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
1237 if( $wgDatabase2->isOpen() ) {
1238 # Nope, just close the test connection and continue
1239 $wgDatabase2->close();
1240 echo( "<li>User " . htmlspecialchars( $wgDBuser ) . " exists. Skipping grants.</li>\n" );
1242 # Yes, so run the grants
1243 echo( "<li>" . htmlspecialchars( "Granting user permissions to $wgDBuser on $wgDBname..." ) );
1244 dbsource( "../maintenance/users.sql", $wgDatabase );
1245 echo( "success.</li>\n" );
1249 if( $conf->SysopName
) {
1250 $u = User
::newFromName( $conf->getSysopName() );
1252 print "<li><strong class=\"error\">Warning:</strong> Skipped sysop account creation - invalid username!</li>\n";
1254 else if ( 0 == $u->idForName() ) {
1255 $u->addToDatabase();
1256 $u->setPassword( $conf->getSysopPass() );
1259 $u->addGroup( "sysop" );
1260 $u->addGroup( "bureaucrat" );
1262 print "<li>Created sysop account <tt>" .
1263 htmlspecialchars( $conf->SysopName
) . "</tt>.</li>\n";
1265 print "<li>Could not create user - already exists!</li>\n";
1268 print "<li>Skipped sysop account creation, no name given.</li>\n";
1271 $titleobj = Title
::newFromText( wfMsgNoDB( "mainpage" ) );
1272 $article = new Article( $titleobj );
1273 $newid = $article->insertOn( $wgDatabase );
1274 $revision = new Revision( array(
1276 'text' => wfMsg( 'mainpagetext' ) . "\n\n" . wfMsgNoTrans( 'mainpagedocfooter' ),
1279 'user_text' => 'MediaWiki default',
1281 $revid = $revision->insertOn( $wgDatabase );
1282 $article->updateRevisionOn( $wgDatabase, $revision );
1284 // Now that all database work is done, make sure everything is committed
1285 $wgDatabase->commit();
1287 /* Write out the config file now that all is well */
1288 print "<li style=\"list-style: none\">\n";
1289 print "<p>Creating LocalSettings.php...</p>\n\n";
1290 $localSettings = "<" . "?php$endl$local";
1291 // Fix up a common line-ending problem (due to CVS on Windows)
1292 $localSettings = str_replace( "\r\n", "\n", $localSettings );
1293 $f = fopen( "LocalSettings.php", 'xt' );
1297 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" .
1298 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
1299 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
1301 if(fwrite( $f, $localSettings ) ) {
1304 writeSuccessMessage();
1308 dieout( "<p class='error'>An error occured while writing the config/LocalSettings.php file. Check user rights and disk space then try again.</p></li>\n" );
1315 $mainListOpened = false;
1317 if( count( $errs ) ) {
1318 /* Display options form */
1320 if( $conf->posted
) {
1321 echo "<p class='error-top'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
1325 <form action
="<?php echo defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php'; ?>" name
="config" method
="post">
1327 <h2
>Site config
</h2
>
1329 <div
class="config-section">
1330 <div
class="config-input">
1331 <?php
aField( $conf, "Sitename", "Wiki name:" ); ?
>
1333 <p
class="config-desc">
1334 Preferably a short word without punctuation
, i
.e
. "Wikipedia".<br
/>
1335 Will appear
as the
namespace name
for "meta" pages
, and throughout the
interface.
1337 <div
class="config-input"><?php
aField( $conf, "EmergencyContact", "Contact e-mail:" ); ?
></div
>
1338 <p
class="config-desc">
1339 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
.
1342 <div
class="config-input">
1343 <label
class='column' for="LanguageCode">Language
:</label
>
1344 <select id
="LanguageCode" name
="LanguageCode"><?php
1345 $list = getLanguageList();
1346 foreach( $list as $code => $name ) {
1347 $sel = ($code == $conf->LanguageCode
) ?
'selected="selected"' : '';
1348 $encCode = htmlspecialchars( $code );
1349 $encName = htmlspecialchars( $name );
1350 echo "\n\t\t<option value=\"$encCode\" $sel>$encName</option>";
1356 <p
class="config-desc">
1357 Select the language
for your wiki
's interface. Some localizations aren't fully complete
. Unicode (UTF
-8) is used
for all localizations
.
1360 <div
class="config-input">
1361 <label
class='column'>Copyright
/license
:</label
>
1364 <li
><?php
aField( $conf, "License", "No license metadata", "radio", "none" ); ?
></li
>
1365 <li
><?php
aField( $conf, "License", "Public Domain", "radio", "pd" ); ?
></li
>
1366 <li
><?php
aField( $conf, "License", "GNU Free Documentation License 1.2", "radio", "gfdl1_2" ); ?
></li
>
1367 <li
><?php
aField( $conf, "License", "GNU Free Documentation License 1.3", "radio", "gfdl1_3" ); ?
></li
>
1369 aField( $conf, "License", "A Creative Commons license - ", "radio", "cc" );
1370 $partner = "MediaWiki";
1371 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
1372 $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/$script?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
1373 $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" );
1374 $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" );
1375 print "<a href=\"$ccApp\" target='_blank'>choose</a>";
1376 if( $conf->License
== "cc" ) { ?
>
1378 <li
><?php
aField( $conf, "RightsIcon", "<img src=\"" . htmlspecialchars( $conf->RightsIcon
) . "\" alt='(Creative Commons icon)' />", "hidden" ); ?
></li
>
1379 <li
><?php
aField( $conf, "RightsText", htmlspecialchars( $conf->RightsText
), "hidden" ); ?
></li
>
1380 <li
><?php
aField( $conf, "RightsCode", "code: " . htmlspecialchars( $conf->RightsCode
), "hidden" ); ?
></li
>
1381 <li
><?php
aField( $conf, "RightsUrl", "<a href=\"" . htmlspecialchars( $conf->RightsUrl
) . "\">" . htmlspecialchars( $conf->RightsUrl
) . "</a>", "hidden" ); ?
></li
>
1387 <p
class="config-desc">
1388 A notice
, icon
, and machine
-readable copyright metadata will be displayed
for the license you pick
.
1392 <div
class="config-input">
1393 <?php
aField( $conf, "SysopName", "Admin username:" ) ?
>
1395 <div
class="config-input">
1396 <?php
aField( $conf, "SysopPass", "Password:", "password" ) ?
>
1398 <div
class="config-input">
1399 <?php
aField( $conf, "SysopPass2", "Password confirm:", "password" ) ?
>
1401 <p
class="config-desc">
1402 An admin can lock
/delete pages
, block users from editing
, and do other maintenance tasks
.<br
/>
1403 A
new account will be added only when creating a
new wiki database
.
1405 The password cannot be the same
as the username
.
1408 <div
class="config-input">
1409 <label
class='column'>Object caching
:</label
>
1412 <li
><?php
aField( $conf, "Shm", "No caching", "radio", "none" ); ?
></li
>
1414 if ( $conf->turck
) {
1416 aField( $conf, "Shm", "Turck MMCache", "radio", "turck" );
1419 if( $conf->xcache
) {
1421 aField( $conf, 'Shm', 'XCache', 'radio', 'xcache' );
1426 aField( $conf, "Shm", "APC", "radio", "apc" );
1429 if ( $conf->eaccel
) {
1431 aField( $conf, "Shm", "eAccelerator", "radio", "eaccel" );
1436 aField( $conf, "Shm", "DBA (not recommended)", "radio", "dba" );
1440 <li
><?php
aField( $conf, "Shm", "Memcached", "radio", "memcached" ); ?
></li
>
1442 <div style
="clear:left"><?php
aField( $conf, "MCServers", "Memcached servers:", "text" ) ?
></div
>
1444 <p
class="config-desc">
1445 An
object caching system such
as memcached will provide a significant performance boost
,
1446 but needs to be installed
. Provide the server addresses
and ports in a comma
-separated
list.
1448 MediaWiki can also detect
and support eAccelerator
, Turck MMCache
, APC
, and XCache
, but
1449 these should not be used
if the wiki will be running on multiple application servers
.
1451 DBA (Berkeley
-style DB
) is generally slower than using no cache at all
, and is only
1452 recommended
for testing
.
1456 <h2
>E
-mail
, e
-mail notification
and authentication setup
</h2
>
1458 <div
class="config-section">
1459 <div
class="config-input">
1460 <label
class='column'>E
-mail
features (global):</label
>
1462 <li
><?php
aField( $conf, "Email", "Enabled", "radio", "email_enabled" ); ?
></li
>
1463 <li
><?php
aField( $conf, "Email", "Disabled", "radio", "email_disabled" ); ?
></li
>
1466 <p
class="config-desc">
1467 Use this to disable all e
-mail
functions (password reminders
, user
-to
-user e
-mail
, and e
-mail notifications
)
1468 if sending mail doesn
't work on your server.
1471 <div class="config-input">
1472 <label class='column
'>User-to-user e-mail:</label>
1474 <li><?php aField( $conf, "Emailuser", "Enabled", "radio", "emailuser_enabled" ); ?></li>
1475 <li><?php aField( $conf, "Emailuser", "Disabled", "radio", "emailuser_disabled" ); ?></li>
1478 <p class="config-desc">
1479 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.
1481 <div class="config-input">
1482 <label class='column
'>E-mail notification about changes:</label>
1484 <li><?php aField( $conf, "Enotif", "Disabled", "radio", "enotif_disabled" ); ?></li>
1485 <li><?php aField( $conf, "Enotif", "Enabled for changes to user discussion pages only", "radio", "enotif_usertalk" ); ?></li>
1486 <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>
1489 <div class="config-desc">
1491 For this feature to work, an e-mail address must be present for the user account, and the notification
1492 options in the user's preferences must be enabled
. Also note the
1493 authentication option below
. When testing the feature
, keep in mind that your own changes will never trigger notifications to be sent to yourself
.</p
>
1495 <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
>
1498 <div
class="config-input">
1499 <label
class='column'>E
-mail address authentication
:</label
>
1501 <li
><?php
aField( $conf, "Eauthent", "Disabled", "radio", "eauthent_disabled" ); ?
></li
>
1502 <li
><?php
aField( $conf, "Eauthent", "Enabled", "radio", "eauthent_enabled" ); ?
></li
>
1505 <div
class="config-desc">
1506 <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
1507 change notification mails
. Setting this option is
<b
>recommended
</b
> for public wikis because of potential abuse of the e
-mail features above
.</p
>
1512 <h2
>Database config
</h2
>
1514 <div
class="config-section">
1515 <div
class="config-input">
1516 <label
class='column'>Database type
:</label
>
1518 if (isset($errs['DBpicktype'])) {
1519 print "\t<span class='error'>" . htmlspecialchars( $errs['DBpicktype'] ) . "</span>\n";
1522 <ul
class='plain'><?php
1523 database_picker($conf);
1527 <div
class="config-input" style
="clear:left">
1528 <?php
aField( $conf, "DBserver", "Database host:" ); ?
>
1530 <p
class="config-desc">
1531 If your database server isn
't on your web server, enter the name or IP address here.
1534 <div class="config-input"><?php aField( $conf, "DBname", "Database name:" ); ?></div>
1535 <div class="config-input"><?php aField( $conf, "DBuser", "DB username:" ); ?></div>
1536 <div class="config-input"><?php aField( $conf, "DBpassword", "DB password:", "password" ); ?></div>
1537 <div class="config-input"><?php aField( $conf, "DBpassword2", "DB password confirm:", "password" ); ?></div>
1538 <p class="config-desc">
1539 If you only have a single user account and database available,
1540 enter those here. If you have database root access (see below)
1541 you can specify new accounts/databases to be created. This account
1542 will not be created if it pre-exists. If this is the case, ensure that it
1543 has SELECT, INSERT, UPDATE, and DELETE permissions on the MediaWiki database.
1546 <div class="config-input">
1547 <label class="column">Superuser account:</label>
1548 <input type="checkbox" name="useroot" id="useroot" <?php if( $useRoot ) { ?>checked="checked" <?php } ?> />
1549 <label for="useroot">Use superuser account</label>
1551 <div class="config-input"><?php aField( $conf, "RootUser", "Superuser name:", "text" ); ?></div>
1552 <div class="config-input"><?php aField( $conf, "RootPW", "Superuser password:", "password" ); ?></div>
1554 <p class="config-desc">
1555 If the database user specified above does not exist, or does not have access to create
1556 the database (if needed) or tables within it, please check the box and provide details
1557 of a superuser account, such as <strong>root</strong>, which does.
1560 <?php database_switcher('mysql
'); ?>
1561 <div class="config-input"><?php aField( $conf, "DBprefix", "Database table prefix:" ); ?></div>
1562 <div class="config-desc">
1563 <p>If you need to share one database between multiple wikis, or
1564 between MediaWiki and another web application, you may choose to
1565 add a prefix to all the table names to avoid conflicts.</p>
1567 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
1570 <div class="config-input"><label class="column">Storage Engine</label>
1571 <div>Select one:</div>
1573 <li><?php aField( $conf, "DBengine", "InnoDB", "radio", "InnoDB" ); ?></li>
1574 <li><?php aField( $conf, "DBengine", "MyISAM", "radio", "MyISAM" ); ?></li>
1577 <p class="config-desc">
1578 InnoDB is best for public web installations, since it has good concurrency
1579 support. MyISAM may be faster in single-user installations. MyISAM databases
1580 tend to get corrupted more often than InnoDB databases.
1582 <div class="config-input"><label class="column">Database character set</label>
1583 <div>Select one:</div>
1585 <li><?php aField( $conf, "DBschema", "MySQL 4.1/5.0 binary", "radio", "mysql5-binary" ); ?></li>
1586 <li><?php aField( $conf, "DBschema", "MySQL 4.1/5.0 UTF-8", "radio", "mysql5" ); ?></li>
1587 <li><?php aField( $conf, "DBschema", "MySQL 4.0 backwards-compatible UTF-8", "radio", "mysql4" ); ?></li>
1590 <p class="config-desc">
1591 This option is ignored on upgrade, the same character set will be kept.
1593 <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!.
1595 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>.
1599 <?php database_switcher('postgres
'); ?>
1600 <div class="config-input"><?php aField( $conf, "DBport", "Database port:" ); ?></div>
1601 <div class="config-input"><?php aField( $conf, "DBmwschema", "Schema for mediawiki:" ); ?></div>
1602 <div class="config-input"><?php aField( $conf, "DBts2schema", "Schema for tsearch2:" ); ?></div>
1603 <div class="config-desc">
1604 <p>The username specified above (at "DB username") will have its search path set to the above schemas,
1605 so it is recommended that you create a new user. The above schemas are generally correct:
1606 only change them if you are sure you need to.</p>
1610 <?php database_switcher('sqlite
'); ?>
1611 <div class="config-desc">
1612 <b>NOTE:</b> SQLite only uses the <i>Database name</i> setting above, the user, password and root settings are ignored.
1614 <div class="config-input"><?php
1615 aField( $conf, "SQLiteDataDir", "SQLite data directory:" );
1617 <div class="config-desc">
1618 <p>SQLite stores table data into files in the filesystem.
1619 If you do not provide an explicit path, a "data" directory in
1620 the parent of your document root will be used.</p>
1622 <p>This directory must exist and be writable by the web server.</p>
1626 <?php database_switcher('mssql
'); ?>
1627 <div class="config-input"><?php
1628 aField( $conf, "DBprefix2", "Database table prefix:" );
1630 <div class="config-desc">
1631 <p>If you need to share one database between multiple wikis, or
1632 between MediaWiki and another web application, you may choose to
1633 add a prefix to all the table names to avoid conflicts.</p>
1635 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
1639 <?php database_switcher('ibm_db2
'); ?>
1640 <div class="config-input"><?php
1641 aField( $conf, "DBport_db2", "Database port:" );
1643 <div class="config-input"><?php
1644 aField( $conf, "DBmwschema", "Schema for mediawiki:" );
1646 <div>Select one:</div>
1648 <li><?php aField( $conf, "DBcataloged", "Cataloged (DB2 installed locally)", "radio", "cataloged" ); ?></li>
1649 <li><?php aField( $conf, "DBcataloged", "Uncataloged (remote DB2 through ODBC)", "radio", "uncataloged" ); ?></li>
1651 <div class="config-desc">
1652 <p>If you need to share one database between multiple wikis, or
1653 between MediaWiki and another web application, you may specify
1654 a different schema to avoid conflicts.</p>
1658 <?php database_switcher('oracle
'); ?>
1659 <div class="config-input"><?php aField( $conf, "DBprefix_ora", "Database table prefix:" ); ?></div>
1660 <div class="config-desc">
1661 <p>If you need to share one database between multiple wikis, or
1662 between MediaWiki and another web application, you may choose to
1663 add a prefix to all the table names to avoid conflicts.</p>
1665 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
1667 <div class="config-input"><?php aField( $conf, "DBdefTS_ora", "Default tablespace:" ); ?></div>
1668 <div class="config-input"><?php aField( $conf, "DBtempTS_ora", "Temporary tablespace:" ); ?></div>
1671 <div class="config-input" style="padding:2em 0 3em">
1672 <label class='column
'> </label>
1673 <input type="submit" value="Install MediaWiki!" class="btn-install" />
1677 <script type="text/javascript">
1678 window.onload = toggleDBarea( <?php echo Xml::encodeJsVar( $conf->DBtype ); ?>,
1680 ## If they passed in a root user name, don't populate it on page load
1681 echo strlen(importPost('RootUser', '')) ?
0 : 1;
1687 /* -------------------------------------------------------------------------------------- */
1688 function writeSuccessMessage() {
1689 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
1690 if ( wfIniGetBool( 'safe_mode' ) && !ini_get( 'open_basedir' ) ) {
1692 <div class="success-box">
1693 <p>Installation successful!</p>
1694 <p>To complete the installation, please do the following:
1696 <li>Download config/LocalSettings.php with your FTP client or file manager</li>
1697 <li>Upload it to the parent directory</li>
1698 <li>Delete config/LocalSettings.php</li>
1699 <li>Start using <a href='../$script'>your wiki</a>!
1701 <p>If you are in a shared hosting environment, do <strong>not</strong> just move LocalSettings.php
1702 remotely. LocalSettings.php is currently owned by the user your webserver is running under,
1703 which means that anyone on the same server can read your database password! Downloading
1704 it and uploading it again will hopefully change the ownership to a user ID specific to you.</p>
1709 <div class="success-box">
1711 <span class="success-message">Installation successful!</span>
1712 Move the <tt>config/LocalSettings.php</tt> file to the parent directory, then follow
1713 <a href="../$script"> this link</a> to your wiki.</p>
1714 <p>You should change file permissions for <tt>LocalSettings.php</tt> as required to
1715 prevent other users on the server reading passwords and altering configuration data.</p>
1722 function escapePhpString( $string ) {
1723 if ( is_array( $string ) ||
is_object( $string ) ) {
1726 return strtr( $string,
1737 function writeLocalSettings( $conf ) {
1738 $conf->PasswordSender
= $conf->EmergencyContact
;
1739 $magic = ($conf->ImageMagick ?
"" : "# ");
1740 $convert = ($conf->ImageMagick ?
$conf->ImageMagick
: "/usr/bin/convert" );
1741 $rights = ($conf->RightsUrl
) ?
"" : "# ";
1742 $hashedUploads = $conf->safeMode ?
'' : '# ';
1744 if ( $conf->ShellLocale
) {
1748 $conf->ShellLocale
= 'en_US.UTF-8';
1751 switch ( $conf->Shm
) {
1753 $cacheType = 'CACHE_MEMCACHED';
1754 $mcservers = var_export( $conf->MCServerArray
, true );
1760 $cacheType = 'CACHE_ACCEL';
1761 $mcservers = 'array()';
1764 $cacheType = 'CACHE_DBA';
1765 $mcservers = 'array()';
1768 $cacheType = 'CACHE_NONE';
1769 $mcservers = 'array()';
1772 if ( $conf->Email
== 'email_enabled' ) {
1773 $enableemail = 'true';
1774 $enableuseremail = ( $conf->Emailuser
== 'emailuser_enabled' ) ?
'true' : 'false' ;
1775 $eauthent = ( $conf->Eauthent
== 'eauthent_enabled' ) ?
'true' : 'false' ;
1776 switch ( $conf->Enotif
) {
1777 case 'enotif_usertalk':
1778 $enotifusertalk = 'true';
1779 $enotifwatchlist = 'false';
1781 case 'enotif_allpages':
1782 $enotifusertalk = 'true';
1783 $enotifwatchlist = 'true';
1786 $enotifusertalk = 'false';
1787 $enotifwatchlist = 'false';
1790 $enableuseremail = 'false';
1791 $enableemail = 'false';
1792 $eauthent = 'false';
1793 $enotifusertalk = 'false';
1794 $enotifwatchlist = 'false';
1797 $file = @fopen
( "/dev/urandom", "r" );
1799 $secretKey = bin2hex( fread( $file, 32 ) );
1803 for ( $i=0; $i<8; $i++
) {
1804 $secretKey .= dechex(mt_rand(0, 0x7fffffff));
1806 print "<li>Warning: \$wgSecretKey key is insecure, generated with mt_rand(). Consider changing it manually.</li>\n";
1809 # Add slashes to strings for double quoting
1810 $slconf = wfArrayMap( "escapePhpString", get_object_vars( $conf ) );
1811 if( $conf->License
== 'gfdl1_2' ||
$conf->License
== 'pd' ||
$conf->License
== 'gfdl1_3' ) {
1812 # Needs literal string interpolation for the current style path
1813 $slconf['RightsIcon'] = $conf->RightsIcon
;
1816 if( $conf->DBtype
== 'mysql' ) {
1818 "# MySQL specific settings
1819 \$wgDBprefix = \"{$slconf['DBprefix']}\";
1821 # MySQL table options to use during installation or update
1822 \$wgDBTableOptions = \"{$slconf['DBTableOptions']}\";
1824 # Experimental charset support for MySQL 4.1/5.0.
1825 \$wgDBmysql5 = {$conf->DBmysql5};";
1826 } elseif( $conf->DBtype
== 'postgres' ) {
1828 "# Postgres specific settings
1829 \$wgDBport = \"{$slconf['DBport']}\";
1830 \$wgDBmwschema = \"{$slconf['DBmwschema']}\";
1831 \$wgDBts2schema = \"{$slconf['DBts2schema']}\";";
1832 } elseif( $conf->DBtype
== 'sqlite' ) {
1834 "# SQLite-specific settings
1835 \$wgSQLiteDataDir = \"{$slconf['SQLiteDataDir']}\";";
1836 } elseif( $conf->DBtype
== 'mssql' ) {
1838 "# MSSQL specific settings
1839 \$wgDBprefix = \"{$slconf['DBprefix2']}\";";
1840 } elseif( $conf->DBtype
== 'ibm_db2' ) {
1842 "# DB2 specific settings
1843 \$wgDBport_db2 = \"{$slconf['DBport_db2']}\";
1844 \$wgDBmwschema = \"{$slconf['DBmwschema']}\";
1845 \$wgDBcataloged = \"{$slconf['DBcataloged']}\";";
1846 } elseif( $conf->DBtype
== 'oracle' ) {
1848 "# Oracle specific settings
1849 \$wgDBprefix = \"{$slconf['DBprefix']}\";";
1857 # This file was automatically generated by the MediaWiki installer.
1858 # If you make manual changes, please keep track in case you need to
1859 # recreate them later.
1861 # See includes/DefaultSettings.php for all configurable settings
1862 # and their default values, but don't forget to make changes in _this_
1865 # Further documentation for configuration settings may be found at:
1866 # http://www.mediawiki.org/wiki/Manual:Configuration_settings
1868 # If you customize your file layout, set \$IP to the directory that contains
1869 # the other MediaWiki files. It will be used as a base to locate files.
1870 if( defined( 'MW_INSTALL_PATH' ) ) {
1871 \$IP = MW_INSTALL_PATH;
1873 \$IP = dirname( __FILE__ );
1876 \$path = array( \$IP, \"\$IP/includes\", \"\$IP/languages\" );
1877 set_include_path( implode( PATH_SEPARATOR, \$path ) . PATH_SEPARATOR . get_include_path() );
1879 require_once( \"\$IP/includes/DefaultSettings.php\" );
1881 # If PHP's memory limit is very low, some operations may fail.
1882 " . ($conf->raiseMemory ?
'' : '# ' ) . "ini_set( 'memory_limit', '20M' );" . "
1884 if ( \$wgCommandLineMode ) {
1885 if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
1886 die( \"This script must be run from the command line\\n\" );
1889 ## Uncomment this to disable output compression
1890 # \$wgDisableOutputCompression = true;
1892 \$wgSitename = \"{$slconf['Sitename']}\";
1894 ## The URL base path to the directory containing the wiki;
1895 ## defaults for all runtime URL paths are based off of this.
1896 ## For more information on customizing the URLs please see:
1897 ## http://www.mediawiki.org/wiki/Manual:Short_URL
1898 \$wgScriptPath = \"{$slconf['ScriptPath']}\";
1899 \$wgScriptExtension = \"{$slconf['ScriptExtension']}\";
1901 ## UPO means: this is also a user preference option
1903 \$wgEnableEmail = $enableemail;
1904 \$wgEnableUserEmail = $enableuseremail; # UPO
1906 \$wgEmergencyContact = \"{$slconf['EmergencyContact']}\";
1907 \$wgPasswordSender = \"{$slconf['PasswordSender']}\";
1909 \$wgEnotifUserTalk = $enotifusertalk; # UPO
1910 \$wgEnotifWatchlist = $enotifwatchlist; # UPO
1911 \$wgEmailAuthentication = $eauthent;
1913 ## Database settings
1914 \$wgDBtype = \"{$slconf['DBtype']}\";
1915 \$wgDBserver = \"{$slconf['DBserver']}\";
1916 \$wgDBname = \"{$slconf['DBname']}\";
1917 \$wgDBuser = \"{$slconf['DBuser']}\";
1918 \$wgDBpassword = \"{$slconf['DBpassword']}\";
1922 ## Shared memory settings
1923 \$wgMainCacheType = $cacheType;
1924 \$wgMemCachedServers = $mcservers;
1926 ## To enable image uploads, make sure the 'images' directory
1927 ## is writable, then set this to true:
1928 \$wgEnableUploads = false;
1929 {$magic}\$wgUseImageMagick = true;
1930 {$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
1932 ## If you use ImageMagick (or any other shell command) on a
1933 ## Linux server, this will need to be set to the name of an
1934 ## available UTF-8 locale
1935 {$locale}\$wgShellLocale = \"{$slconf['ShellLocale']}\";
1937 ## If you want to use image uploads under safe mode,
1938 ## create the directories images/archive, images/thumb and
1939 ## images/temp, and make them all writable. Then uncomment
1940 ## this, if it's not already uncommented:
1941 {$hashedUploads}\$wgHashedUploadDirectory = false;
1943 ## If you have the appropriate support software installed
1944 ## you can enable inline LaTeX equations:
1947 ## Set \$wgCacheDirectory to a writable directory on the web server
1948 ## to make your wiki go slightly faster. The directory should not
1949 ## be publically accessible from the web.
1950 #\$wgCacheDirectory = \"\$IP/cache\";
1952 \$wgLocalInterwiki = strtolower( \$wgSitename );
1954 \$wgLanguageCode = \"{$slconf['LanguageCode']}\";
1956 \$wgSecretKey = \"$secretKey\";
1958 ## Default skin: you can change the default skin. Use the internal symbolic
1959 ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook':
1960 \$wgDefaultSkin = 'monobook';
1962 ## For attaching licensing metadata to pages, and displaying an
1963 ## appropriate copyright notice / icon. GNU Free Documentation
1964 ## License and Creative Commons licenses are supported so far.
1965 {$rights}\$wgEnableCreativeCommonsRdf = true;
1966 \$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright
1967 \$wgRightsUrl = \"{$slconf['RightsUrl']}\";
1968 \$wgRightsText = \"{$slconf['RightsText']}\";
1969 \$wgRightsIcon = \"{$slconf['RightsIcon']}\";
1970 # \$wgRightsCode = \"{$slconf['RightsCode']}\"; # Not yet used
1972 \$wgDiff3 = \"{$slconf['diff3']}\";
1974 \$wgPhpCliPath = \"{$slconf['phpCliPath']}\";
1976 # When you make changes to this configuration file, this will make
1977 # sure that cached pages are cleared.
1978 \$wgCacheEpoch = max( \$wgCacheEpoch, gmdate( 'YmdHis', @filemtime( __FILE__ ) ) );
1979 "; ## End of setting the $localsettings string
1981 // Keep things in Unix line endings internally;
1982 // the system will write out as local text type.
1983 return str_replace( "\r\n", "\n", $localsettings );
1986 function dieout( $text ) {
1987 global $mainListOpened;
1988 if( $mainListOpened ) echo( "</ul>" );
1989 if( $text != '' && substr( $text, 0, 2 ) != '<p' && substr( $text, 0, 2 ) != '<h' ){
1990 echo "<p>$text</p>\n";
1994 die( "\n\n</div>\n</div>\n</div>\n</div>\n</body>\n</html>" );
1997 function importVar( &$var, $name, $default = "" ) {
1998 if( isset( $var[$name] ) ) {
1999 $retval = $var[$name];
2000 if ( get_magic_quotes_gpc() ) {
2001 $retval = stripslashes( $retval );
2010 function importPost( $name, $default = "" ) {
2011 return importVar( $_POST, $name, $default );
2014 function importCheck( $name ) {
2015 return isset( $_POST[$name] );
2018 function importRequest( $name, $default = "" ) {
2019 return importVar( $_REQUEST, $name, $default );
2022 function aField( &$conf, $field, $text, $type = "text", $value = "", $onclick = '' ) {
2023 static $radioCount = 0;
2025 $xtype = "type=\"$type\"";
2031 $nolabel = ($type == "radio") ||
($type == "hidden");
2033 if ($type == 'radio')
2034 $id .= $radioCount++
;
2037 echo "<label class='column' for=\"$id\">$text</label>";
2040 if( $type == "radio" && $value == $conf->$field ) {
2041 $checked = "checked='checked'";
2045 echo "<input $xtype name=\"$field\" id=\"$id\" class=\"iput-$type\" $checked ";
2047 echo " onclick='toggleDBarea(\"$value\",1)' " ;
2050 if( $type == "radio" ) {
2051 echo htmlspecialchars( $value );
2053 echo htmlspecialchars( $conf->$field );
2059 echo "<label for=\"$id\">$text</label>";
2063 if(isset($errs[$field])) {
2064 echo "<span class='error'>" . htmlspecialchars( $errs[$field] ) . "</span>\n";
2068 function getLanguageList() {
2069 global $wgLanguageNames, $IP;
2070 if( !isset( $wgLanguageNames ) ) {
2071 require_once( "$IP/languages/Names.php" );
2076 $d = opendir( "../languages/messages" );
2077 /* In case we are called from the root directory */
2079 $d = opendir( "languages/messages");
2080 while( false !== ($f = readdir( $d ) ) ) {
2082 if( preg_match( '/Messages([A-Z][a-z_]+)\.php$/', $f, $m ) ) {
2083 $code = str_replace( '_', '-', strtolower( $m[1] ) );
2084 if( isset( $wgLanguageNames[$code] ) ) {
2085 $name = $code . ' - ' . $wgLanguageNames[$code];
2089 $codes[$code] = $name;
2097 #Check for location of an executable
2098 # @param string $loc single location to check
2099 # @param array $names filenames to check for.
2100 # @param mixed $versioninfo array of details to use when checking version, use false for no version checking
2101 function locate_executable($loc, $names, $versioninfo = false) {
2102 if (!is_array($names))
2103 $names = array($names);
2105 foreach ($names as $name) {
2106 $command = "$loc".DIRECTORY_SEPARATOR
."$name";
2107 if (@file_exists
($command)) {
2111 $file = str_replace('$1', $command, $versioninfo[0]);
2112 if (strstr(`
$file`
, $versioninfo[1]) !== false)
2119 # Test a memcached server
2120 function testMemcachedServer( $server ) {
2121 $hostport = explode(":", $server);
2124 if ( !function_exists( 'fsockopen' ) ) {
2125 $errstr = "Can't connect to memcached, fsockopen() not present";
2127 if ( !$errstr && count( $hostport ) != 2 ) {
2128 $errstr = 'Please specify host and port';
2131 list( $host, $port ) = $hostport;
2135 $fp = @fsockopen
( $host, $port, $errno, $fsockerr, 1.0 );
2136 if ( $fp === false ) {
2137 $errstr = "Cannot connect to memcached on $host:$port : $fsockerr";
2141 $command = "version\r\n";
2142 $bytes = fwrite( $fp, $command );
2143 if ( $bytes != strlen( $command ) ) {
2144 $errstr = "Cannot write to memcached socket on $host:$port";
2148 $expected = "VERSION ";
2149 $response = fread( $fp, strlen( $expected ) );
2150 if ( $response != $expected ) {
2151 $errstr = "Didn't get correct memcached response from $host:$port";
2158 echo "<li>Connected to memcached on " . htmlspecialchars( "$host:$port" ) ." successfully</li>";
2163 function database_picker($conf) {
2166 foreach(array_keys($ourdb) as $db) {
2167 if ($ourdb[$db]['havedriver']) {
2169 aField( $conf, "DBtype", $ourdb[$db]['fullname'], 'radio', $db, 'onclick');
2176 function database_switcher($db) {
2178 $color = $ourdb[$db]['bgcolor'];
2179 $full = $ourdb[$db]['fullname'];
2180 print "<fieldset id='$db'><legend>$full specific options</legend>\n";
2183 function printListItem( $item ) {
2184 print "<li>$item</li>";
2187 # Determine a suitable value for $wgShellLocale
2188 function getShellLocale( $wikiLang ) {
2189 # Give up now if we're in safe mode or open_basedir
2190 # It's theoretically possible but tricky to work with
2191 if ( wfIniGetBool( "safe_mode" ) ||
ini_get( 'open_basedir' ) ) {
2195 $os = php_uname( 's' );
2196 $supported = array( 'Linux', 'SunOS', 'HP-UX' ); # Tested these
2197 if ( !in_array( $os, $supported ) ) {
2201 # Get a list of available locales
2202 $lines = $ret = false;
2203 exec( '/usr/bin/locale -a', $lines, $ret );
2208 $lines = wfArrayMap( 'trim', $lines );
2209 $candidatesByLocale = array();
2210 $candidatesByLang = array();
2211 foreach ( $lines as $line ) {
2212 if ( $line === '' ) {
2215 if ( !preg_match( '/^([a-zA-Z]+)(_[a-zA-Z]+|)\.(utf8|UTF-8)(@[a-zA-Z_]*|)$/i', $line, $m ) ) {
2218 list( $all, $lang, $territory, $charset, $modifier ) = $m;
2219 $candidatesByLocale[$m[0]] = $m;
2220 $candidatesByLang[$lang][] = $m;
2223 # Try the current value of LANG
2224 if ( isset( $candidatesByLocale[ getenv( 'LANG' ) ] ) ) {
2225 return getenv( 'LANG' );
2228 # Try the most common ones
2229 $commonLocales = array( 'en_US.UTF-8', 'en_US.utf8', 'de_DE.UTF-8', 'de_DE.utf8' );
2230 foreach ( $commonLocales as $commonLocale ) {
2231 if ( isset( $candidatesByLocale[$commonLocale] ) ) {
2232 return $commonLocale;
2236 # Is there an available locale in the Wiki's language?
2237 if ( isset( $candidatesByLang[$wikiLang] ) ) {
2238 $m = reset( $candidatesByLang[$wikiLang] );
2242 # Are there any at all?
2243 if ( count( $candidatesByLocale ) ) {
2244 $m = reset( $candidatesByLocale );
2252 function wfArrayMap( $function, $input ) {
2253 $ret = array_map( $function, $input );
2254 foreach ( $ret as $key => $value ) {
2255 $taint = istainted( $input[$key] );
2257 taint( $ret[$key], $taint );
2265 <div
class="license">
2267 <p
>This program is free software
; you can redistribute it
and/or modify
2268 it under the terms of the GNU General
Public License
as published by
2269 the Free Software Foundation
; either version
2 of the License
, or
2270 (at your option
) any later version
.</p
>
2272 <p
>This program is distributed in the hope that it will be useful
,
2273 but WITHOUT ANY WARRANTY
; without even the implied warranty of
2274 MERCHANTABILITY
or FITNESS
FOR A PARTICULAR PURPOSE
. See the
2275 GNU General
Public License
for more details
.</p
>
2277 <p
>You should have received
<a href
="../COPYING">a copy of the GNU General
Public License
</a
>
2278 along with this program
; if not
, write to the Free Software
2279 Foundation
, Inc
., 51 Franklin Street
, Fifth Floor
, Boston
, MA
02110-1301, USA
.
2280 or <a href
="http://www.gnu.org/copyleft/gpl.html">read it online
</a
></p
>
2286 <div id
="column-one">
2287 <div
class="portlet" id
="p-logo">
2288 <a style
="background-image: url(../skins/common/images/mediawiki.png);"
2290 title
="Main Page"></a
>
2292 <script type
="text/javascript"> if (window
.isMSIE55
) fixalpha(); </script
>
2293 <div
class='portlet'><div
class='pBody'>
2295 <li
><a href
="../README">Readme
</a
></li
>
2296 <li
><a href
="../RELEASE-NOTES">Release notes
</a
></li
>
2297 <li
><a href
="../docs/">Documentation
</a
></li
>
2298 <li
><a href
="http://www.mediawiki.org/wiki/Help:Contents">User
's Guide</a></li>
2299 <li><a href="http://www.mediawiki.org/wiki/Manual:Contents">Administrator's Guide
</a
></li
>
2300 <li
><a href
="http://www.mediawiki.org/wiki/Manual:FAQ">FAQ
</a
></li
>
2302 <p style
="font-size:90%;margin-top:1em">MediaWiki is Copyright ©
2001-2009 by Magnus Manske
, Brion Vibber
,
2303 Lee Daniel Crocker
, Tim Starling
, Erik Möller
, Gabriel Wicke
, Æ
var Arnfjörð Bjarmason
, Niklas Laxström
,
2304 Domas Mituzas
, Rob Church
, Yuri Astrakhan
, Aryeh Gregor
, Aaron Schulz
and others
.</p
>