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 if( !defined( 'MEDIAWIKI_INSTALL' ) ) {
23 die( 'Not an entry point.' );
26 error_reporting( E_ALL | E_STRICT
);
27 header( "Content-type: text/html; charset=utf-8" );
28 @ini_set
( "display_errors", true );
30 # In case of errors, let output be clean.
31 $wgRequestTime = microtime( true );
33 // Run version checks before including other files
34 // so people don't see a scary parse error.
35 require_once( "$IP/maintenance/install-utils.inc" );
36 install_version_checks();
38 require_once( "$IP/includes/Defines.php" );
39 require_once( "$IP/includes/DefaultSettings.php" );
40 require_once( "$IP/includes/AutoLoader.php" );
41 require_once( "$IP/includes/MagicWord.php" );
42 require_once( "$IP/includes/Namespace.php" );
43 require_once( "$IP/includes/ProfilerStub.php" );
44 require_once( "$IP/includes/GlobalFunctions.php" );
45 require_once( "$IP/includes/Hooks.php" );
46 require_once( "$IP/includes/Exception.php" );
47 require_once( "$IP/includes/json/Services_JSON.php" );
48 require_once( "$IP/includes/json/FormatJson.php" );
50 # If we get an exception, the user needs to know
52 $wgShowExceptionDetails = true;
53 $wgShowSQLErrors = true;
54 wfInstallExceptionHandler();
55 ## Databases we support:
59 $ourdb['mysql'] = array(
60 'fullname' => 'MySQL',
63 'bgcolor' => '#ffe5a7',
68 $ourdb['postgres'] = array(
69 'fullname' => 'PostgreSQL',
72 'bgcolor' => '#aaccff',
73 'rootuser' => 'postgres',
77 $ourdb['sqlite'] = array(
78 'fullname' => 'SQLite',
80 'compile' => 'pdo_sqlite',
81 'bgcolor' => '#b1ebb1',
86 $ourdb['mssql'] = array(
87 'fullname' => 'MSSQL',
89 'compile' => 'mssql_not_ready', # Change to 'mssql' after includes/DatabaseMssql.php added;
90 'bgcolor' => '#ffc0cb',
91 'rootuser' => 'administrator',
95 $ourdb['ibm_db2'] = array(
98 'compile' => 'ibm_db2',
99 'bgcolor' => '#ffeba1',
100 'rootuser' => 'db2admin',
101 'serverless' => false
104 $ourdb['oracle'] = array(
105 'fullname' => 'Oracle',
108 'bgcolor' => '#ffeba1',
110 'serverless' => false
114 <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
115 <html xmlns
="http://www.w3.org/1999/xhtml" xml
:lang
="en" lang
="en" dir
="ltr">
117 <meta http
-equiv
="Content-type" content
="text/html; charset=utf-8" />
118 <meta name
="robots" content
="noindex,nofollow"/>
119 <title
>MediaWiki
<?php
echo htmlspecialchars( $wgVersion ); ?
> Installation
</title
>
120 <style type
="text/css">
122 @import
"../skins/monobook/main.css";
126 margin
: 1em
0 1em
2.5em
;
133 .config
-section label
.column
{
145 zoom
: 100%
; /* IE hack */
148 .config
-section
.config
-desc
{
150 margin
: 0 0 2em
18em
;
155 .iput
-text
, .iput
-password
{
162 background
-color
: #fff;
170 background
-color
: #FFF0F0;
171 border
: 2px solid red
;
179 list-style
-type
: none
;
180 list-style
-image
: none
;
197 span
.success
-message
{
208 <script type
="text/javascript">
210 <?php
echo 'var databases = ' . FormatJson
::encode( $ourdb ) . ';'; ?
>
212 function show(id
, showOrHide
) {
213 var i
= document
.getElementById(id
);
214 if (i
) i
.style
.display
= showOrHide ?
'block' : 'none';
217 for (db in databases
) {
221 function toggleDBarea(id
, defaultroot
) {
223 var dbarea
= document
.getElementById(id
);
224 if (dbarea
) dbarea
.style
.display
= (dbarea
.style
.display
== 'none') ?
'block' : 'none';
225 var db
= document
.getElementById('RootUser');
226 db
.value
= databases
[id
].rootuser
;
227 show('db-server-settings1', !databases
[id
].serverless
);
228 show('db-server-settings2', !databases
[id
].serverless
);
235 <div id
="globalWrapper">
236 <div id
="column-content">
238 <div id
="bodyContent">
240 <h1
>MediaWiki
<?php
print htmlspecialchars( $wgVersion ) ?
> Installation
</h1
>
243 $mainListOpened = false; # Is the main list (environement checking) opend ? Used by dieout
245 /* Check for existing configurations and bug out! */
247 if( file_exists( "../LocalSettings.php" ) ) {
248 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
249 dieout( "<p><strong>Setup has completed, <a href='../$script'>your wiki</a> is configured.</strong></p>
250 <p>Please delete the /config directory for extra security.</p>" );
253 if( file_exists( "./LocalSettings.php" ) ) {
254 writeSuccessMessage();
258 if( !is_writable( "." ) ) {
259 dieout( "<h2>Can't write config file, aborting</h2>
261 <p>In order to configure the wiki you have to make the <tt>config</tt> subdirectory
262 writable by the web server. Once configuration is done you'll move the created
263 <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can
264 then remove the <tt>config</tt> subdirectory entirely.</p>
266 <p>To make the directory writable on a Unix/Linux system:</p>
269 cd <i>" . htmlspecialchars( dirname( dirname( __FILE__
) ) ) . "</i>
273 <p>Afterwards retry to start the <a href=\"\">setup</a>.</p>" );
277 require_once( "$IP/maintenance/updaters.inc" );
280 function getEncoded( $data ) {
281 # removing latin1 support, no need...
284 function getSitename() { return $this->getEncoded( $this->Sitename
); }
285 function getSysopName() { return $this->getEncoded( $this->SysopName
); }
286 function getSysopPass() { return $this->getEncoded( $this->SysopPass
); }
288 function setSchema( $schema, $engine ) {
289 $this->DBschema
= $schema;
290 if ( !preg_match( '/^\w*$/', $engine ) ){
293 switch ( $this->DBschema
) {
295 $this->DBTableOptions
= "ENGINE=$engine, DEFAULT CHARSET=utf8";
296 $this->DBmysql5
= 'true';
298 case 'mysql5-binary':
299 $this->DBTableOptions
= "ENGINE=$engine, DEFAULT CHARSET=binary";
300 $this->DBmysql5
= 'true';
303 $this->DBTableOptions
= "TYPE=$engine";
304 $this->DBmysql5
= 'false';
306 $this->DBengine
= $engine;
308 # Set the global for use during install
309 global $wgDBTableOptions;
310 $wgDBTableOptions = $this->DBTableOptions
;
318 <b
>Don
't forget security updates!</b> Keep an eye on the
319 <a href="http://lists.wikimedia.org/mailman/listinfo/mediawiki-announce">low-traffic
320 release announcements mailing list</a>.
325 <h2>Checking environment...</h2>
326 <p><em>Please include all of the lines below when reporting installation problems.</em></p>
327 <ul class="env-check">
329 $mainListOpened = true;
333 define( 'MW_NO_OUTPUT_BUFFER
', 1 );
334 $conf = new ConfigData;
336 install_version_checks();
337 $self = 'Installer
'; # Maintenance script name, to please Setup.php
339 print "<li>PHP " . htmlspecialchars( phpversion() ) . " installed</li>\n";
341 error_reporting( 0 );
342 $phpdatabases = array();
343 foreach (array_keys($ourdb) as $db) {
344 $compname = $ourdb[$db]['compile
'];
345 if( extension_loaded( $compname ) || ( mw_have_dl() && dl( "{$compname}." . PHP_SHLIB_SUFFIX ) ) ) {
346 array_push($phpdatabases, $db);
347 $ourdb[$db]['havedriver
'] = 1;
350 error_reporting( E_ALL | E_STRICT );
352 if (!$phpdatabases) {
353 print "Could not find a suitable database driver!<ul>";
354 foreach (array_keys($ourdb) AS $db) {
355 $comp = $ourdb[$db]['compile
'];
356 $full = $ourdb[$db]['fullname
'];
357 print "<li>For <b>$full</b>, compile PHP using <b>--with-$comp</b>, "
358 ."or install the $comp.so module</li>\n";
364 print "<li>Found database drivers for:";
366 foreach (array_keys($ourdb) AS $db) {
367 if ($ourdb[$db]['havedriver
']) {
368 if ( $DefaultDBtype == '' ) {
369 $DefaultDBtype = $db;
371 print " ".$ourdb[$db]['fullname
'];
376 if( wfIniGetBool( "register_globals" ) ) {
379 <div style="font-size:110%">
380 <strong class="error">Warning:</strong>
381 <strong>PHP's
<tt
><a href
="http://php.net/register_globals">register_globals
</a
></tt
> option is enabled
. Disable it
if you can
.</strong
>
383 MediaWiki will work
, but your server is more exposed to PHP
-based security vulnerabilities
.
390 if( wfIniGetBool( "magic_quotes_runtime" ) ) {
392 ?
><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
>
393 This option corrupts data input unpredictably
; you cannot install
or use
394 MediaWiki unless this option is disabled
.</li
>
398 if( wfIniGetBool( "magic_quotes_sybase" ) ) {
400 ?
><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
>
401 This option corrupts data input unpredictably
; you cannot install
or use
402 MediaWiki unless this option is disabled
.</li
>
406 if( wfIniGetBool( "mbstring.func_overload" ) ) {
408 ?
><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
>
409 This option causes errors
and may corrupt data unpredictably
;
410 you cannot install
or use MediaWiki unless this option is disabled
.</li
>
414 if( wfIniGetBool( "zend.ze1_compatibility_mode" ) ) {
416 ?
><li
class="error"><strong
>Fatal
: <a href
="http://www.php.net/manual/en/ini.core.php">zend
.ze1_compatibility_mode
</a
> is active
!</strong
>
417 This option causes horrible bugs with MediaWiki
; you cannot install
or use
418 MediaWiki unless this option is disabled
.</li
>
424 dieout( "Cannot install MediaWiki." );
427 if( wfIniGetBool( "safe_mode" ) ) {
428 $conf->safeMode
= true;
430 <li
><b
class='error'>Warning
:</b
> <strong
>PHP
's
431 <a href='http
://www.php.net/features.safe-mode'>safe mode</a> is active.</strong>
432 You may have problems caused by this
, particularly
if using image uploads
.
436 $conf->safeMode
= false;
439 $sapi = htmlspecialchars( php_sapi_name() );
440 print "<li>PHP server API is $sapi; ";
441 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
442 if( $wgUsePathInfo ) {
443 print "ok, using pretty URLs (<tt>$script/Page_Title</tt>)";
445 print "using ugly URLs (<tt>$script?title=Page_Title</tt>)";
449 $conf->xml
= function_exists( "utf8_encode" );
451 print "<li>Have XML / Latin1-UTF-8 conversion support.</li>\n";
453 dieout( "PHP's XML module is missing; the wiki requires functions in
454 this module and won't work in this configuration.
455 If you're running Mandrake, install the php-xml package." );
458 # Check for session support
459 if( !function_exists( 'session_name' ) )
460 dieout( "PHP's session module is missing. MediaWiki requires session support in order to function." );
462 # session.save_path doesn't *have* to be set, but if it is, and it's
463 # not valid/writable/etc. then it can cause problems
464 $sessionSavePath = mw_get_session_save_path();
465 $ssp = htmlspecialchars( $sessionSavePath );
466 # Warn the user if it's not set, but let them proceed
467 if( !$sessionSavePath ) {
468 print "<li><strong>Warning:</strong> A value for <tt>session.save_path</tt>
469 has not been set in PHP.ini. If the default value causes problems with
470 saving session data, set it to a valid path which is read/write/execute
471 for the user your web server is running under.</li>";
472 } elseif ( is_dir( $sessionSavePath ) && is_writable( $sessionSavePath ) ) {
473 # All good? Let the user know
474 print "<li>Session save path (<tt>{$ssp}</tt>) appears to be valid.</li>";
476 # Something not right? Warn the user, but let them proceed
477 print "<li><strong>Warning:</strong> Your <tt>session.save_path</tt> value (<tt>{$ssp}</tt>)
478 appears to be invalid or is not writable. PHP needs to be able to save data to
479 this location for correct session operation.</li>";
482 # Check for PCRE support
483 if( !function_exists( 'preg_match' ) )
484 dieout( "The PCRE support module appears to be missing. MediaWiki requires the
485 Perl-compatible regular expression functions." );
487 # The installer can take a while, and we really don't want it to time out
488 wfSuppressWarnings();
492 $memlimit = ini_get( "memory_limit" );
493 if( $memlimit == -1 ) {
494 print "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n";
496 print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars( $memlimit ). " bytes. ";
497 $newlimit = wfMemoryLimit();
498 $memlimit = wfShorthandToInteger( $memlimit );
499 if( $newlimit < $memlimit ) {
500 print "<b>Failed raising limit, installation may fail.</b>";
501 } elseif ( $newlimit > $memlimit ) {
502 print "Raised <tt>memory_limit</tt> to " . htmlspecialchars( $newlimit ) . " bytes. ";
507 $conf->turck
= function_exists( 'mmcache_get' );
508 if ( $conf->turck
) {
509 print "<li><a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> installed</li>\n";
512 $conf->xcache
= function_exists( 'xcache_get' );
514 print "<li><a href=\"http://trac.lighttpd.net/xcache/\">XCache</a> installed</li>\n";
516 $conf->apc
= function_exists('apc_fetch');
518 print "<li><a href=\"http://www.php.net/apc\">APC</a> installed</li>\n";
521 $conf->eaccel
= function_exists( 'eaccelerator_get' );
522 if ( $conf->eaccel
) {
523 $conf->turck
= 'eaccelerator';
524 print "<li><a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> installed</li>\n";
527 $conf->dba
= function_exists( 'dba_open' );
529 if( !( $conf->turck ||
$conf->eaccel ||
$conf->apc ||
$conf->xcache
) ) {
530 echo( '<li>Couldn\'t find <a href="http://turck-mmcache.sourceforge.net">Turck MMCache</a>,
531 <a href="http://eaccelerator.sourceforge.net">eAccelerator</a>,
532 <a href="http://www.php.net/apc">APC</a> or <a href="http://trac.lighttpd.net/xcache/">XCache</a>;
533 cannot use these for object caching.</li>' );
536 $conf->phpCliPath
= false;
537 $phpClilocations = array_merge(
544 explode( PATH_SEPARATOR
, getenv( "PATH" ) ) );
545 $phpClinames = array( "php", "php.exe" );
546 foreach ($phpClilocations as $loc) {
547 $exe = locate_executable($loc, $phpClinames);
548 if ($exe !== false) {
549 $conf->phpCliPath
= $exe;
554 $conf->diff3
= false;
555 $diff3locations = array_merge(
562 explode( PATH_SEPARATOR
, getenv( "PATH" ) ) );
563 $diff3names = array( "gdiff3", "diff3", "diff3.exe" );
565 $diff3versioninfo = array( '$1 --version 2>&1', 'diff3 (GNU diffutils)' );
566 foreach ($diff3locations as $loc) {
567 $exe = locate_executable($loc, $diff3names, $diff3versioninfo);
568 if ($exe !== false) {
575 print "<li>Found GNU diff3: <tt>$conf->diff3</tt>.</li>";
577 print "<li>GNU diff3 not found.</li>";
579 $conf->ImageMagick
= false;
580 $imcheck = array( "/usr/bin", "/opt/csw/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" );
581 foreach( $imcheck as $dir ) {
582 $im = "$dir/convert";
583 if( @file_exists
( $im ) ) {
584 print "<li>Found ImageMagick: <tt>$im</tt>; image thumbnailing will be enabled if you enable uploads.</li>\n";
585 $conf->ImageMagick
= $im;
590 $conf->HaveGD
= function_exists( "imagejpeg" );
591 if( $conf->HaveGD
) {
592 print "<li>Found GD graphics library built-in";
593 if( !$conf->ImageMagick
) {
594 print ", image thumbnailing will be enabled if you enable uploads";
598 if( !$conf->ImageMagick
) {
599 print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n";
603 $conf->IP
= dirname( dirname( __FILE__
) );
604 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP
) . "</tt></li>\n";
607 // PHP_SELF isn't available sometimes, such as when PHP is CGI but
608 // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
609 // to get the path to the current script... hopefully it's reliable. SIGH
610 $path = ($_SERVER["PHP_SELF"] === '')
611 ?
$_SERVER["SCRIPT_NAME"]
612 : $_SERVER["PHP_SELF"];
614 $conf->ScriptPath
= preg_replace( '{^(.*)/config.*$}', '$1', $path );
615 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath
) . "</tt></li>\n";
619 // We may be installing from *.php5 extension file, if so, print message
620 $conf->ScriptExtension
= '.php';
621 if (defined('MW_INSTALL_PHP5_EXT')) {
622 $conf->ScriptExtension
= '.php5';
623 print "<li>Installing MediaWiki with <tt>php5</tt> file extensions</li>\n";
625 print "<li>Installing MediaWiki with <tt>php</tt> file extensions</li>\n";
629 print "<li style='font-weight:bold;color:green;font-size:110%'>Environment checked. You can install MediaWiki.</li>\n";
630 $conf->posted
= ($_SERVER["REQUEST_METHOD"] == "POST");
632 $conf->Sitename
= ucfirst( importPost( "Sitename", "" ) );
633 $defaultEmail = empty( $_SERVER["SERVER_ADMIN"] )
635 : $_SERVER["SERVER_ADMIN"];
636 $conf->EmergencyContact
= importPost( "EmergencyContact", $defaultEmail );
637 $conf->DBtype
= importPost( "DBtype", $DefaultDBtype );
638 if ( !isset( $ourdb[$conf->DBtype
] ) ) {
639 $conf->DBtype
= $DefaultDBtype;
642 $conf->DBserver
= importPost( "DBserver", "localhost" );
643 $conf->DBname
= importPost( "DBname", "wikidb" );
644 $conf->DBuser
= importPost( "DBuser", "wikiuser" );
645 $conf->DBpassword
= importPost( "DBpassword" );
646 $conf->DBpassword2
= importPost( "DBpassword2" );
647 $conf->SysopName
= importPost( "SysopName", "WikiSysop" );
648 $conf->SysopPass
= importPost( "SysopPass" );
649 $conf->SysopPass2
= importPost( "SysopPass2" );
650 $conf->RootUser
= importPost( "RootUser", "root" );
651 $conf->RootPW
= importPost( "RootPW", "" );
652 $useRoot = importCheck( 'useroot', false );
653 $conf->LanguageCode
= importPost( "LanguageCode", "en" );
655 $conf->DBprefix
= importPost( "DBprefix" );
657 importPost( "DBschema", "mysql5-binary" ),
658 importPost( "DBengine", "InnoDB" ) );
660 ## Postgres specific:
661 $conf->DBport
= importPost( "DBport", "5432" );
662 $conf->DBts2schema
= importPost( "DBts2schema", "public" );
663 $conf->DBpgschema
= importPost( "DBpgschema", "mediawiki" );
666 $conf->SQLiteDataDir
= importPost( "SQLiteDataDir", "" );
669 // We need a second field so it doesn't overwrite the MySQL one
670 $conf->DBprefix2
= importPost( "DBprefix2" );
673 // New variable in order to have a different default port number
674 $conf->DBport_db2
= importPost( "DBport_db2", "50000" );
675 $conf->DBcataloged
= importPost( "DBcataloged", "cataloged" );
676 $conf->DBdb2schema
= importPost( "DBdb2schema", "mediawiki" );
679 $conf->DBprefix_ora
= importPost( "DBprefix_ora" );
680 $conf->DBdefTS_ora
= importPost( "DBdefTS_ora", "USERS" );
681 $conf->DBtempTS_ora
= importPost( "DBtempTS_ora", "TEMP" );
683 $conf->ShellLocale
= getShellLocale( $conf->LanguageCode
);
685 /* Check for validity */
688 if( preg_match( '/^$|^mediawiki$|#/i', $conf->Sitename
) ) {
689 $errs["Sitename"] = "Must not be blank or \"MediaWiki\" and may not contain \"#\"";
691 if( !$ourdb[$conf->DBtype
]['serverless'] ) {
692 if( $conf->DBuser
== "" ) {
693 $errs["DBuser"] = "Must not be blank";
695 if( ($conf->DBtype
== 'mysql') && (strlen($conf->DBuser
) > 16) ) {
696 $errs["DBuser"] = "Username too long";
698 if( $conf->DBpassword
== "" && $conf->DBtype
!= "postgres" ) {
699 $errs["DBpassword"] = "Must not be blank";
701 if( $conf->DBpassword
!= $conf->DBpassword2
) {
702 $errs["DBpassword2"] = "Passwords don't match!";
705 if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix
) ) {
706 $errs["DBprefix"] = "Invalid table prefix";
708 untaint( $conf->DBprefix
, TC_MYSQL
);
710 if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix_ora
) ) {
711 $errs["DBprefix_ora"] = "Invalid table prefix";
714 error_reporting( E_ALL | E_STRICT
);
717 * Initialise $wgLang and $wgContLang to something so we can
718 * call case-folding methods. Per Brion, this is English for
719 * now, although we could be clever and initialise to the
720 * user-selected language.
722 $wgContLang = Language
::factory( 'en' );
723 $wgLang = $wgContLang;
726 * We're messing about with users, so we need a stub
727 * authentication plugin...
729 $wgAuth = new AuthPlugin();
732 * Validate the initial administrator account; username,
733 * password checks, etc.
735 if( $conf->SysopName
) {
736 # Check that the user can be created
737 $u = User
::newFromName( $conf->SysopName
);
738 if( $u instanceof User
) {
739 # Various password checks
740 if( $conf->SysopPass
!= '' ) {
741 if( $conf->SysopPass
== $conf->SysopPass2
) {
742 if( !$u->isValidPassword( $conf->SysopPass
) ) {
743 $errs['SysopPass'] = "Bad password";
746 $errs['SysopPass2'] = "Passwords don't match";
749 $errs['SysopPass'] = "Cannot be blank";
753 $errs['SysopName'] = "Bad username";
757 $conf->License
= importRequest( "License", "none" );
758 if( $conf->License
== "gfdl1_2" ) {
759 $conf->RightsUrl
= "http://www.gnu.org/licenses/old-licenses/fdl-1.2.txt";
760 $conf->RightsText
= "GNU Free Documentation License 1.2";
761 $conf->RightsCode
= "gfdl1_2";
762 $conf->RightsIcon
= '${wgScriptPath}/skins/common/images/gnu-fdl.png';
763 } elseif( $conf->License
== "gfdl1_3" ) {
764 $conf->RightsUrl
= "http://www.gnu.org/copyleft/fdl.html";
765 $conf->RightsText
= "GNU Free Documentation License 1.3";
766 $conf->RightsCode
= "gfdl1_3";
767 $conf->RightsIcon
= '${wgScriptPath}/skins/common/images/gnu-fdl.png';
768 } elseif( $conf->License
== "none" ) {
769 $conf->RightsUrl
= $conf->RightsText
= $conf->RightsCode
= $conf->RightsIcon
= "";
770 } elseif( $conf->License
== "pd" ) {
771 $conf->RightsUrl
= "http://creativecommons.org/licenses/publicdomain/";
772 $conf->RightsText
= "Public Domain";
773 $conf->RightsCode
= "pd";
774 $conf->RightsIcon
= '${wgScriptPath}/skins/common/images/public-domain.png';
776 $conf->RightsUrl
= importRequest( "RightsUrl", "" );
777 $conf->RightsText
= importRequest( "RightsText", "" );
778 $conf->RightsCode
= importRequest( "RightsCode", "" );
779 $conf->RightsIcon
= importRequest( "RightsIcon", "" );
782 $conf->Shm
= importRequest( "Shm", "none" );
783 $conf->MCServers
= importRequest( "MCServers" );
785 /* Test memcached servers */
787 if ( $conf->Shm
== 'memcached' && $conf->MCServers
) {
788 $conf->MCServerArray
= wfArrayMap( 'trim', explode( ',', $conf->MCServers
) );
789 foreach ( $conf->MCServerArray
as $server ) {
790 $error = testMemcachedServer( $server );
792 $errs["MCServers"] = $error;
796 } else if ( $conf->Shm
== 'memcached' ) {
797 $errs["MCServers"] = "Please specify at least one server if you wish to use memcached";
800 /* default values for installation */
801 $conf->Email
= importRequest("Email", "email_enabled");
802 $conf->Emailuser
= importRequest("Emailuser", "emailuser_enabled");
803 $conf->Enotif
= importRequest("Enotif", "enotif_allpages");
804 $conf->Eauthent
= importRequest("Eauthent", "eauthent_enabled");
806 if( $conf->posted
&& ( 0 == count( $errs ) ) ) {
807 do { /* So we can 'continue' to end prematurely */
808 $conf->Root
= ($conf->RootPW
!= "");
810 /* Load up the settings and get installin' */
811 $local = writeLocalSettings( $conf );
812 echo "<li style=\"list-style: none\">\n";
813 echo "<p><b>Generating configuration file...</b></p>\n";
816 $wgCommandLineMode = false;
818 $ok = eval( $local );
819 if( $ok === false ) {
820 dieout( "<p>Errors in generated configuration; " .
821 "most likely due to a bug in the installer... " .
822 "Config file was: </p>" .
824 htmlspecialchars( $local ) .
827 $conf->DBtypename
= '';
828 foreach (array_keys($ourdb) as $db) {
829 if ($conf->DBtype
=== $db)
830 $conf->DBtypename
= $ourdb[$db]['fullname'];
832 if ( ! strlen($conf->DBtype
)) {
833 $errs["DBpicktype"] = "Please choose a database type";
837 if (! $conf->DBtypename
) {
838 $errs["DBtype"] = "Unknown database type '$conf->DBtype'";
841 print "<li>Database type: " . htmlspecialchars( $conf->DBtypename
) . "</li>\n";
842 $dbclass = 'Database'.ucfirst($conf->DBtype
);
843 $wgDBtype = $conf->DBtype
;
844 $wgDBadminuser = "root";
845 $wgDBadminpassword = $conf->RootPW
;
848 $wgDBprefix = $conf->DBprefix
;
850 ## Postgres specific:
851 $wgDBport = $conf->DBport
;
852 $wgDBts2schema = $conf->DBts2schema
;
854 if( $wgDBtype == 'postgres' ) {
855 $wgDBmwschema = $conf->DBpgschema
;
856 } elseif ( $wgDBtype == 'ibm_db2' ) {
857 $wgDBmwschema = $conf->DBdb2schema
;
860 if( $conf->DBprefix2
!= '' ) {
862 $wgDBprefix = $conf->DBprefix2
;
863 } elseif( $conf->DBprefix_ora
!= '' ) {
865 $wgDBprefix = $conf->DBprefix_ora
;
869 $wgDBcataloged = $conf->DBcataloged
;
871 $wgCommandLineMode = true;
872 if (! defined ( 'STDERR' ) )
873 define( 'STDERR', fopen("php://stderr", "wb"));
874 $wgUseDatabaseMessages = false; /* FIXME: For database failure */
875 require_once( "$IP/includes/Setup.php" );
876 Language
::getLocalisationCache()->disableBackend();
880 $wgTitle = Title
::newFromText( "Installation script" );
881 error_reporting( E_ALL | E_STRICT
);
882 print "<li>Loading class: " . htmlspecialchars( $dbclass ) . "</li>\n";
883 if ( $conf->DBtype
!= 'sqlite' ) {
887 if( $conf->DBtype
== 'mysql' ) {
888 $mysqlOldClient = version_compare( mysql_get_client_info(), "4.1.0", "lt" );
889 if( $mysqlOldClient ) {
890 print "<li><b>PHP is linked with old MySQL client libraries. If you are
891 using a MySQL 4.1 server and have problems connecting to the database,
892 see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
893 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b></li>\n";
895 $ok = true; # Let's be optimistic
897 # Decide if we're going to use the superuser or the regular database user
898 $conf->Root
= $useRoot;
900 $db_user = $conf->RootUser
;
901 $db_pass = $conf->RootPW
;
903 $db_user = $wgDBuser;
904 $db_pass = $wgDBpassword;
908 echo( "<li>Attempting to connect to database server as " . htmlspecialchars( $db_user ) . "..." );
909 $wgDatabase = Database
::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 );
911 # Check the connection and respond to errors
912 if( $wgDatabase->isOpen() ) {
915 $wgDBadminuser = $db_user;
916 $wgDBadminpassword = $db_pass;
917 echo( "success.</li>\n" );
918 $wgDatabase->ignoreErrors( true );
919 $myver = $wgDatabase->getServerVersion();
921 # There were errors, report them and back out
923 $errno = mysql_errno();
924 $errtx = htmlspecialchars( mysql_error() );
928 echo( "failed due to authentication errors. Check passwords.</li>" );
930 # The superuser details are wrong
931 $errs["RootUser"] = "Check username";
932 $errs["RootPW"] = "and password";
934 # The regular user details are wrong
935 $errs["DBuser"] = "Check username";
936 $errs["DBpassword"] = "and password";
942 # General connection problem
943 echo( htmlspecialchars( "failed with error [$errno] $errtx." ) . "</li>\n" );
944 $errs["DBserver"] = "Connection failed";
949 if( !$ok ) { continue; }
951 else if( $conf->DBtype
== 'ibm_db2' ) {
953 $db_user = $conf->RootUser
;
954 $db_pass = $conf->RootPW
;
956 $db_user = $wgDBuser;
957 $db_pass = $wgDBpassword;
960 echo( "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) .
961 "\" as \"" . htmlspecialchars( $db_user ) . "\"..." );
962 $wgDatabase = $dbc->newFromParams($wgDBserver, $db_user, $db_pass, $wgDBname, 1);
963 // enable extra debug messages
964 $dbc->setMode(DatabaseIbm_db2
::INSTALL_MODE
);
965 $wgDatabase->setMode(DatabaseIbm_db2
::INSTALL_MODE
);
967 if (!$wgDatabase->isOpen()) {
968 print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
970 $myver = $wgDatabase->getServerVersion();
972 if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname);
974 } elseif ( $conf->DBtype
== 'sqlite' ) {
975 if ("$wgSQLiteDataDir" == '') {
976 $wgSQLiteDataDir = dirname($_SERVER['DOCUMENT_ROOT']).'/data';
978 echo "<li>Attempting to connect to SQLite database at \"" .
979 htmlspecialchars( $wgSQLiteDataDir ) . "\"";
980 if ( !is_dir( $wgSQLiteDataDir ) ) {
981 if ( is_writable( dirname( $wgSQLiteDataDir ) ) ) {
982 $ok = wfMkdirParents( $wgSQLiteDataDir, $wgSQLiteDataDirMode );
987 echo ": cannot create data directory</li>";
988 $errs['SQLiteDataDir'] = 'Enter a valid data directory';
992 if ( !is_writable( $wgSQLiteDataDir ) ) {
993 echo ": data directory not writable</li>";
994 $errs['SQLiteDataDir'] = 'Enter a writable data directory';
997 $dataFile = "$wgSQLiteDataDir/$wgDBname.sqlite";
998 if ( file_exists( $dataFile ) && !is_writable( $dataFile ) ) {
999 echo ": data file not writable</li>";
1000 $errs['SQLiteDataDir'] = "$wgDBname.sqlite is not writable";
1003 $wgDatabase = new DatabaseSqlite( false, false, false, $wgDBname, 1 );
1004 if (!$wgDatabase->isOpen()) {
1005 print ": error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
1006 $errs['SQLiteDataDir'] = 'Could not connect to database';
1009 $myver = $wgDatabase->getServerVersion();
1011 if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname);
1013 } elseif ( $conf->DBtype
== 'oracle' ) {
1014 echo "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) ."\"</li>";
1015 $wgDatabase = $dbc->newFromParams('DUMMY', $wgDBuser, $wgDBpassword, $wgDBname, 1);
1016 if (!$wgDatabase->isOpen()) {
1018 echo "<li>Connect failed.</li>";
1020 if (ini_get('oci8.privileged_connect') === false) {
1021 echo "<li>Privileged connect disabled, please set oci8.privileged_connect or run maintenance/ora/user.sql script manually prior to continuing.</li>";
1024 $wgDBadminuser = $conf->RootUser
;
1025 $wgDBadminpassword = $conf->RootPW
;
1026 echo "<li>Attempting to create DB user.</li>";
1027 $wgDatabase = $dbc->newFromParams('DUMMY', $wgDBadminuser, $wgDBadminpassword, $wgDBname, 1, 64);
1028 if ($wgDatabase->isOpen()) {
1029 $wgDBOracleDefTS = $conf->DBdefTS_ora
;
1030 $wgDBOracleTempTS = $conf->DBtempTS_ora
;
1031 $wgDatabase->sourceFile( "../maintenance/ora/user.sql" );
1033 echo "<li>Invalid database superuser, please supply a valid superuser account.</li>";
1034 echo "<li>ERR: ".print_r(oci_error(), true)."</li>";
1039 echo "<li>Database superuser missing, please supply a valid superuser account.</li>";
1043 $errs["RootUser"] = "Check username";
1044 $errs["RootPW"] = "and password";
1046 echo "<li>Attempting to connect to database with new user \"" . htmlspecialchars( $wgDBname ) ."\"</li>";
1047 $wgDatabase = $dbc->newFromParams('DUMMY', $wgDBuser, $wgDBpassword, $wgDBname, 1);
1051 $myver = $wgDatabase->getServerVersion();
1053 } else { # not mysql
1054 error_reporting( E_ALL | E_STRICT
);
1056 ## Possible connect as a superuser
1057 // Changed !mysql to postgres check since it seems to only apply to postgres
1058 if( $useRoot && $conf->DBtype
== 'postgres' ) {
1059 $wgDBsuperuser = $conf->RootUser
;
1060 echo( "<li>Attempting to connect to database \"postgres\" as superuser \"" .
1061 htmlspecialchars( $wgDBsuperuser ) . "\"..." );
1062 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBsuperuser, $conf->RootPW
, "postgres", 1);
1063 if (!$wgDatabase->isOpen()) {
1064 print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
1065 $errs["DBserver"] = "Could not connect to database as superuser";
1066 $errs["RootUser"] = "Check username";
1067 $errs["RootPW"] = "and password";
1070 $wgDatabase->initial_setup($conf->RootPW
, 'postgres');
1072 echo( "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) .
1073 "\" as \"" . htmlspecialchars( $wgDBuser ) . "\"..." );
1074 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1);
1075 if (!$wgDatabase->isOpen()) {
1076 print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
1077 $errs["DBserver"] = "Could not connect to database as user";
1078 $errs["DBuser"] = "Check username";
1079 $errs["DBpassword"] = "and password";
1082 $myver = $wgDatabase->getServerVersion();
1084 if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname);
1087 if ( !$wgDatabase->isOpen() ) {
1088 $errs["DBserver"] = "Couldn't connect to database";
1092 print "<li>Connected to " . htmlspecialchars( "{$conf->DBtype} $myver" );
1093 if ($conf->DBtype
== 'mysql') {
1094 if( version_compare( $myver, "4.0.14" ) < 0 ) {
1096 dieout( "-- mysql 4.0.14 or later required. Aborting." );
1098 $mysqlNewAuth = version_compare( $myver, "4.1.0", "ge" );
1099 if( $mysqlNewAuth && $mysqlOldClient ) {
1100 print "; <b class='error'>You are using MySQL 4.1 server, but PHP is linked
1101 to old client libraries; if you have trouble with authentication, see
1102 <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
1103 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>";
1106 if( $mysqlNewAuth ) {
1107 print "; enabling MySQL 4.1/5.0 charset mode";
1109 print "; <b class='error'>MySQL 4.1/5.0 charset mode enabled,
1110 but older version detected; will likely fail.</b>";
1115 @$sel = $wgDatabase->selectDB( $wgDBname );
1117 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
1119 $err = mysql_errno();
1120 $databaseSafe = htmlspecialchars( $wgDBname );
1121 if( $err == 1102 /* Invalid database name */ ) {
1122 print "<ul><li><strong>{$databaseSafe}</strong> is not a valid database name.</li></ul>";
1124 } elseif( $err != 1049 /* Database doesn't exist */ ) {
1125 print "<ul><li>Error selecting database <strong>{$databaseSafe}</strong>: {$err} ";
1126 print htmlspecialchars( mysql_error() ) . "</li></ul>";
1129 print "<li>Attempting to create database...</li>";
1130 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
1132 print "<li>Couldn't create database <tt>" .
1133 htmlspecialchars( $wgDBname ) .
1134 "</tt>; try with root access or check your username/pass.</li>\n";
1135 $errs["RootPW"] = "<- Enter";
1138 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
1140 $wgDatabase->selectDB( $wgDBname );
1142 else if ($conf->DBtype
== 'postgres') {
1143 if( version_compare( $myver, "8.0" ) < 0 ) {
1144 dieout( "<b>Postgres 8.0 or later is required</b>. Aborting." );
1148 if( $wgDatabase->tableExists( "cur" ) ||
$wgDatabase->tableExists( "revision" ) ) {
1149 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n";
1151 if ( $conf->DBtype
== 'mysql') {
1152 # Determine existing default character set
1153 if ( $wgDatabase->tableExists( "revision" ) ) {
1154 $revision = $wgDatabase->escapeLike( $conf->DBprefix
. 'revision' );
1155 $res = $wgDatabase->query( "SHOW TABLE STATUS LIKE '$revision'" );
1156 $row = $wgDatabase->fetchObject( $res );
1158 echo "<li>SHOW TABLE STATUS query failed!</li>\n";
1159 $existingSchema = false;
1160 $existingEngine = false;
1162 if ( preg_match( '/^latin1/', $row->Collation
) ) {
1163 $existingSchema = 'mysql4';
1164 } elseif ( preg_match( '/^utf8/', $row->Collation
) ) {
1165 $existingSchema = 'mysql5';
1166 } elseif ( preg_match( '/^binary/', $row->Collation
) ) {
1167 $existingSchema = 'mysql5-binary';
1169 $existingSchema = false;
1170 echo "<li><strong>Warning:</strong> Unrecognised existing collation</li>\n";
1172 if ( isset( $row->Engine
) ) {
1173 $existingEngine = $row->Engine
;
1175 $existingEngine = $row->Type
;
1178 if ( $existingSchema && $existingSchema != $conf->DBschema
) {
1179 $encExisting = htmlspecialchars( $existingSchema );
1180 $encRequested = htmlspecialchars( $conf->DBschema
);
1181 print "<li><strong>Warning:</strong> you requested the $encRequested schema, " .
1182 "but the existing database has the $encExisting schema. This upgrade script ".
1183 "can't convert it, so it will remain $encExisting.</li>\n";
1184 $conf->setSchema( $existingSchema, $conf->DBengine
);
1186 if ( $existingEngine && $existingEngine != $conf->DBengine
) {
1187 $encExisting = htmlspecialchars( $existingEngine );
1188 $encRequested = htmlspecialchars( $conf->DBengine
);
1189 print "<li><strong>Warning:</strong> you requested the $encRequested storage " .
1190 "engine, but the existing database uses the $encExisting engine. This upgrade " .
1191 "script can't convert it, so it will remain $encExisting.</li>\n";
1192 $conf->setSchema( $conf->DBschema
, $existingEngine );
1196 # Create user if required
1197 if ( $conf->Root
) {
1198 $conn = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
1199 if ( $conn->isOpen() ) {
1200 print "<li>DB user account ok</li>\n";
1203 print "<li>Granting user permissions...";
1204 if( $mysqlOldClient && $mysqlNewAuth ) {
1205 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>";
1208 $wgDatabase->sourceFile( "../maintenance/users.sql" );
1212 print "</ul><pre>\n";
1218 print "<ul><li>Finished update checks.</li>\n";
1219 // if tables don't yet exist
1221 # Determine available storage engines if possible
1222 if ( $conf->DBtype
== 'mysql' && version_compare( $myver, "4.1.2", "ge" ) ) {
1223 $res = $wgDatabase->query( 'SHOW ENGINES' );
1225 while ( $row = $wgDatabase->fetchObject( $res ) ) {
1226 if ( $row->Engine
== $conf->DBengine
&& ( $row->Support
== 'YES' ||
$row->Support
== 'DEFAULT' ) ) {
1231 $wgDatabase->freeResult( $res );
1232 if ( !$found && $conf->DBengine
!= 'MyISAM' ) {
1233 echo "<li><strong>Warning:</strong> " . htmlspecialchars( $conf->DBengine
) .
1234 " storage engine not available, " .
1235 "using MyISAM instead</li>\n";
1236 $conf->setSchema( $conf->DBschema
, 'MyISAM' );
1240 # FIXME: Check for errors
1241 print "<li>Creating tables...";
1242 if ($conf->DBtype
== 'mysql') {
1243 $wgDatabase->sourceFile( "../maintenance/tables.sql" );
1244 $wgDatabase->sourceFile( "../maintenance/interwiki.sql" );
1245 } elseif (is_callable(array($wgDatabase, 'setup_database'))) {
1246 $wgDatabase->setup_database();
1249 $errs["DBtype"] = "Do not know how to handle database type '$conf->DBtype'";
1253 print " done.</li>\n";
1256 if ($conf->DBtype
== 'ibm_db2') {
1257 // Now that table creation is done, make sure everything is committed
1258 // Do this before doing inserts through API
1259 if ($wgDatabase->lastError()) {
1260 print "<li>Errors encountered during table creation -- rolled back</li>\n";
1261 $wgDatabase->rollback();
1264 print "<li>MediaWiki tables successfully created</li>\n";
1265 $wgDatabase->commit();
1269 print "<li>Initializing statistics...</li>\n";
1270 $wgDatabase->insert( 'site_stats',
1271 array ( 'ss_row_id' => 1,
1272 'ss_total_views' => 0,
1273 'ss_total_edits' => 1, # Main page first edit
1274 'ss_good_articles' => 0, # Main page is not a good article - no internal link
1275 'ss_total_pages' => 1, # Main page
1276 'ss_users' => $conf->SysopName ?
1 : 0, # Sysop account, if created
1277 'ss_admins' => $conf->SysopName ?
1 : 0, # Sysop account, if created
1278 'ss_images' => 0 ) );
1280 # Set up the "regular user" account *if we can, and if we need to*
1281 if( $conf->Root
and $conf->DBtype
== 'mysql') {
1283 $wgDatabase2 = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
1284 if( $wgDatabase2->isOpen() ) {
1285 # Nope, just close the test connection and continue
1286 $wgDatabase2->close();
1287 echo( "<li>User " . htmlspecialchars( $wgDBuser ) . " exists. Skipping grants.</li>\n" );
1289 # Yes, so run the grants
1290 echo( "<li>" . htmlspecialchars( "Granting user permissions to $wgDBuser on $wgDBname..." ) );
1291 $wgDatabase->sourceFile( "../maintenance/users.sql" );
1292 echo( "success.</li>\n" );
1296 if( $conf->SysopName
) {
1297 $u = User
::newFromName( $conf->getSysopName() );
1299 print "<li><strong class=\"error\">Warning:</strong> Skipped sysop account creation - invalid username!</li>\n";
1301 else if ( 0 == $u->idForName() ) {
1302 $u->addToDatabase();
1303 $u->setPassword( $conf->getSysopPass() );
1306 $u->addGroup( "sysop" );
1307 $u->addGroup( "bureaucrat" );
1309 print "<li>Created sysop account <tt>" .
1310 htmlspecialchars( $conf->SysopName
) . "</tt>.</li>\n";
1312 print "<li>Could not create user - already exists!</li>\n";
1315 print "<li>Skipped sysop account creation, no name given.</li>\n";
1318 $titleobj = Title
::newFromText( wfMsgNoDB( "mainpage" ) );
1319 $article = new Article( $titleobj );
1320 $newid = $article->insertOn( $wgDatabase );
1321 $revision = new Revision( array(
1323 'text' => wfMsg( 'mainpagetext' ) . "\n\n" . wfMsgNoTrans( 'mainpagedocfooter' ),
1326 'user_text' => 'MediaWiki default',
1328 $revid = $revision->insertOn( $wgDatabase );
1329 $article->updateRevisionOn( $wgDatabase, $revision );
1332 /* Write out the config file now that all is well */
1333 print "<li style=\"list-style: none\">\n";
1334 print "<p>Creating LocalSettings.php...</p>\n\n";
1335 $localSettings = "<" . "?php$endl$local";
1336 // Fix up a common line-ending problem (due to CVS on Windows)
1337 $localSettings = str_replace( "\r\n", "\n", $localSettings );
1338 $f = fopen( "LocalSettings.php", 'xt' );
1342 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" .
1343 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
1344 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
1346 if(fwrite( $f, $localSettings ) ) {
1349 writeSuccessMessage();
1353 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" );
1360 $mainListOpened = false;
1362 if( count( $errs ) ) {
1363 /* Display options form */
1365 if( $conf->posted
) {
1366 echo "<p class='error-top'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
1370 <form action
="<?php echo defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php'; ?>" name
="config" method
="post">
1372 <h2
>Site config
</h2
>
1374 <div
class="config-section">
1375 <div
class="config-input">
1376 <?php
aField( $conf, "Sitename", "Wiki name:" ); ?
>
1378 <p
class="config-desc">
1379 Preferably a short word without punctuation
, i
.e
. "Wikipedia".<br
/>
1380 Will appear
as the
namespace name
for "meta" pages
, and throughout the
interface.
1382 <div
class="config-input"><?php
aField( $conf, "EmergencyContact", "Contact e-mail:" ); ?
></div
>
1383 <p
class="config-desc">
1384 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
.
1387 <div
class="config-input">
1388 <label
class='column' for="LanguageCode">Language
:</label
>
1389 <select id
="LanguageCode" name
="LanguageCode"><?php
1390 $list = getLanguageList();
1391 foreach( $list as $code => $name ) {
1392 $sel = ($code == $conf->LanguageCode
) ?
'selected="selected"' : '';
1393 $encCode = htmlspecialchars( $code );
1394 $encName = htmlspecialchars( $name );
1395 echo "\n\t\t<option value=\"$encCode\" $sel>$encName</option>";
1401 <p
class="config-desc">
1402 Select the language
for your wiki
's interface. Some localizations aren't fully complete
. Unicode (UTF
-8) is used
for all localizations
.
1405 <div
class="config-input">
1406 <label
class='column'>Copyright
/license
:</label
>
1409 <li
><?php
aField( $conf, "License", "No license metadata", "radio", "none" ); ?
></li
>
1410 <li
><?php
aField( $conf, "License", "Public Domain", "radio", "pd" ); ?
></li
>
1411 <li
><?php
aField( $conf, "License", "GNU Free Documentation License 1.2", "radio", "gfdl1_2" ); ?
></li
>
1412 <li
><?php
aField( $conf, "License", "GNU Free Documentation License 1.3", "radio", "gfdl1_3" ); ?
></li
>
1414 aField( $conf, "License", "A Creative Commons license - ", "radio", "cc" );
1415 $partner = "MediaWiki";
1416 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
1417 $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/$script?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
1418 $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" );
1419 $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" );
1420 print "<a href=\"$ccApp\" target='_blank'>choose</a>";
1421 if( $conf->License
== "cc" ) { ?
>
1423 <li
><?php
aField( $conf, "RightsIcon", "<img src=\"" . htmlspecialchars( $conf->RightsIcon
) . "\" alt='(Creative Commons icon)' />", "hidden" ); ?
></li
>
1424 <li
><?php
aField( $conf, "RightsText", htmlspecialchars( $conf->RightsText
), "hidden" ); ?
></li
>
1425 <li
><?php
aField( $conf, "RightsCode", "code: " . htmlspecialchars( $conf->RightsCode
), "hidden" ); ?
></li
>
1426 <li
><?php
aField( $conf, "RightsUrl", "<a href=\"" . htmlspecialchars( $conf->RightsUrl
) . "\">" . htmlspecialchars( $conf->RightsUrl
) . "</a>", "hidden" ); ?
></li
>
1432 <p
class="config-desc">
1433 A notice
, icon
, and machine
-readable copyright metadata will be displayed
for the license you pick
.
1437 <div
class="config-input">
1438 <?php
aField( $conf, "SysopName", "Admin username:" ) ?
>
1440 <div
class="config-input">
1441 <?php
aField( $conf, "SysopPass", "Password:", "password" ) ?
>
1443 <div
class="config-input">
1444 <?php
aField( $conf, "SysopPass2", "Password confirm:", "password" ) ?
>
1446 <p
class="config-desc">
1447 An admin can lock
/delete pages
, block users from editing
, and do other maintenance tasks
.<br
/>
1448 A
new account will be added only when creating a
new wiki database
.
1450 The password cannot be the same
as the username
.
1453 <div
class="config-input">
1454 <label
class='column'>Object caching
:</label
>
1457 <li
><?php
aField( $conf, "Shm", "No caching", "radio", "none" ); ?
></li
>
1459 if ( $conf->turck
) {
1461 aField( $conf, "Shm", "Turck MMCache", "radio", "turck" );
1464 if( $conf->xcache
) {
1466 aField( $conf, 'Shm', 'XCache', 'radio', 'xcache' );
1471 aField( $conf, "Shm", "APC", "radio", "apc" );
1474 if ( $conf->eaccel
) {
1476 aField( $conf, "Shm", "eAccelerator", "radio", "eaccel" );
1481 aField( $conf, "Shm", "DBA (not recommended)", "radio", "dba" );
1485 <li
><?php
aField( $conf, "Shm", "Memcached", "radio", "memcached" ); ?
></li
>
1487 <div style
="clear:left"><?php
aField( $conf, "MCServers", "Memcached servers:", "text" ) ?
></div
>
1489 <p
class="config-desc">
1490 An
object caching system such
as memcached will provide a significant performance boost
,
1491 but needs to be installed
. Provide the server addresses
and ports in a comma
-separated
list.
1493 MediaWiki can also detect
and support eAccelerator
, Turck MMCache
, APC
, and XCache
, but
1494 these should not be used
if the wiki will be running on multiple application servers
.
1496 DBA (Berkeley
-style DB
) is generally slower than using no cache at all
, and is only
1497 recommended
for testing
.
1501 <h2
>E
-mail
, e
-mail notification
and authentication setup
</h2
>
1503 <div
class="config-section">
1504 <div
class="config-input">
1505 <label
class='column'>E
-mail
features (global):</label
>
1507 <li
><?php
aField( $conf, "Email", "Enabled", "radio", "email_enabled" ); ?
></li
>
1508 <li
><?php
aField( $conf, "Email", "Disabled", "radio", "email_disabled" ); ?
></li
>
1511 <p
class="config-desc">
1512 Use this to disable all e
-mail
functions (password reminders
, user
-to
-user e
-mail
, and e
-mail notifications
)
1513 if sending mail doesn
't work on your server.
1516 <div class="config-input">
1517 <label class='column
'>User-to-user e-mail:</label>
1519 <li><?php aField( $conf, "Emailuser", "Enabled", "radio", "emailuser_enabled" ); ?></li>
1520 <li><?php aField( $conf, "Emailuser", "Disabled", "radio", "emailuser_disabled" ); ?></li>
1523 <p class="config-desc">
1524 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.
1526 <div class="config-input">
1527 <label class='column
'>E-mail notification about changes:</label>
1529 <li><?php aField( $conf, "Enotif", "Disabled", "radio", "enotif_disabled" ); ?></li>
1530 <li><?php aField( $conf, "Enotif", "Enabled for changes to user discussion pages only", "radio", "enotif_usertalk" ); ?></li>
1531 <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>
1534 <div class="config-desc">
1536 For this feature to work, an e-mail address must be present for the user account, and the notification
1537 options in the user's preferences must be enabled
. Also note the
1538 authentication option below
. When testing the feature
, keep in mind that your own changes will never trigger notifications to be sent to yourself
.</p
>
1540 <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
>
1543 <div
class="config-input">
1544 <label
class='column'>E
-mail address authentication
:</label
>
1546 <li
><?php
aField( $conf, "Eauthent", "Disabled", "radio", "eauthent_disabled" ); ?
></li
>
1547 <li
><?php
aField( $conf, "Eauthent", "Enabled", "radio", "eauthent_enabled" ); ?
></li
>
1550 <div
class="config-desc">
1551 <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
1552 change notification mails
. Setting this option is
<b
>recommended
</b
> for public wikis because of potential abuse of the e
-mail features above
.</p
>
1557 <h2
>Database config
</h2
>
1559 <div
class="config-section">
1560 <div
class="config-input">
1561 <label
class='column'>Database type
:</label
>
1563 if (isset($errs['DBpicktype'])) {
1564 print "\t<span class='error'>" . htmlspecialchars( $errs['DBpicktype'] ) . "</span>\n";
1567 <ul
class='plain'><?php
1568 database_picker($conf);
1572 <div id
="db-server-settings1">
1573 <div
class="config-input" style
="clear:left">
1574 <?php
aField( $conf, "DBserver", "Database host:" ); ?
>
1576 <p
class="config-desc">
1577 If your database server isn
't on your web server, enter the name or IP address here.
1581 <div class="config-input"><?php aField( $conf, "DBname", "Database name:" ); ?></div>
1582 <div id="db-server-settings2">
1583 <div class="config-input"><?php aField( $conf, "DBuser", "DB username:" ); ?></div>
1584 <div class="config-input"><?php aField( $conf, "DBpassword", "DB password:", "password" ); ?></div>
1585 <div class="config-input"><?php aField( $conf, "DBpassword2", "DB password confirm:", "password" ); ?></div>
1586 <p class="config-desc">
1587 If you only have a single user account and database available,
1588 enter those here. If you have database root access (see below)
1589 you can specify new accounts/databases to be created. This account
1590 will not be created if it pre-exists. If this is the case, ensure that it
1591 has SELECT, INSERT, UPDATE, and DELETE permissions on the MediaWiki database.
1594 <div class="config-input">
1595 <label class="column">Superuser account:</label>
1596 <input type="checkbox" name="useroot" id="useroot" <?php if( $useRoot ) { ?>checked="checked" <?php } ?> />
1597 <label for="useroot">Use superuser account</label>
1599 <div class="config-input"><?php aField( $conf, "RootUser", "Superuser name:", "text" ); ?></div>
1600 <div class="config-input"><?php aField( $conf, "RootPW", "Superuser password:", "password" ); ?></div>
1602 <p class="config-desc">
1603 If the database user specified above does not exist, or does not have access to create
1604 the database (if needed) or tables within it, please check the box and provide details
1605 of a superuser account, such as <strong>root</strong>, which does.
1609 <?php database_switcher('mysql
'); ?>
1610 <div class="config-input"><?php aField( $conf, "DBprefix", "Database table prefix:" ); ?></div>
1611 <div class="config-desc">
1612 <p>If you need to share one database between multiple wikis, or
1613 between MediaWiki and another web application, you may choose to
1614 add a prefix to all the table names to avoid conflicts.</p>
1616 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
1619 <div class="config-input"><label class="column">Storage Engine</label>
1620 <div>Select one:</div>
1622 <li><?php aField( $conf, "DBengine", "InnoDB", "radio", "InnoDB" ); ?></li>
1623 <li><?php aField( $conf, "DBengine", "MyISAM", "radio", "MyISAM" ); ?></li>
1626 <p class="config-desc">
1627 InnoDB is best for public web installations, since it has good concurrency
1628 support. MyISAM may be faster in single-user installations. MyISAM databases
1629 tend to get corrupted more often than InnoDB databases.
1631 <div class="config-input"><label class="column">Database character set</label>
1632 <div>Select one:</div>
1634 <li><?php aField( $conf, "DBschema", "MySQL 4.1/5.0 binary", "radio", "mysql5-binary" ); ?></li>
1635 <li><?php aField( $conf, "DBschema", "MySQL 4.1/5.0 UTF-8", "radio", "mysql5" ); ?></li>
1636 <li><?php aField( $conf, "DBschema", "MySQL 4.0 backwards-compatible UTF-8", "radio", "mysql4" ); ?></li>
1639 <p class="config-desc">
1640 This option is ignored on upgrade, the same character set will be kept.
1642 <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!.
1644 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>.
1648 <?php database_switcher('postgres
'); ?>
1649 <div class="config-input"><?php aField( $conf, "DBport", "Database port:" ); ?></div>
1650 <div class="config-input"><?php aField( $conf, "DBpgschema", "Schema for mediawiki:" ); ?></div>
1651 <div class="config-input"><?php aField( $conf, "DBts2schema", "Schema for tsearch2:" ); ?></div>
1652 <div class="config-desc">
1653 <p>The username specified above (at "DB username") will have its search path set to the above schemas,
1654 so it is recommended that you create a new user. The above schemas are generally correct:
1655 only change them if you are sure you need to.</p>
1659 <?php database_switcher('sqlite
'); ?>
1660 <div class="config-desc">
1661 <b>NOTE:</b> SQLite only uses the <i>Database name</i> setting above, the user, password and root settings are ignored.
1663 <div class="config-input"><?php
1664 aField( $conf, "SQLiteDataDir", "SQLite data directory:" );
1666 <div class="config-desc">
1667 <p>SQLite stores table data into files in the filesystem.
1668 If you do not provide an explicit path, a "data" directory in
1669 the parent of your document root will be used.</p>
1671 <p>This directory must exist and be writable by the web server.</p>
1675 <?php database_switcher('mssql
'); ?>
1676 <div class="config-input"><?php
1677 aField( $conf, "DBprefix2", "Database table prefix:" );
1679 <div class="config-desc">
1680 <p>If you need to share one database between multiple wikis, or
1681 between MediaWiki and another web application, you may choose to
1682 add a prefix to all the table names to avoid conflicts.</p>
1684 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
1688 <?php database_switcher('ibm_db2
'); ?>
1689 <div class="config-input"><?php
1690 aField( $conf, "DBport_db2", "Database port:" );
1692 <div class="config-input"><?php
1693 aField( $conf, "DBdb2schema", "Schema for mediawiki:" );
1695 <div>Select one:</div>
1697 <li><?php aField( $conf, "DBcataloged", "Cataloged (DB2 installed locally)", "radio", "cataloged" ); ?></li>
1698 <li><?php aField( $conf, "DBcataloged", "Uncataloged (remote DB2 through ODBC)", "radio", "uncataloged" ); ?></li>
1700 <div class="config-desc">
1701 <p>If you need to share one database between multiple wikis, or
1702 between MediaWiki and another web application, you may specify
1703 a different schema to avoid conflicts.</p>
1707 <?php database_switcher('oracle
'); ?>
1708 <div class="config-input"><?php aField( $conf, "DBprefix_ora", "Database table prefix:" ); ?></div>
1709 <div class="config-desc">
1710 <p>If you need to share one database between multiple wikis, or
1711 between MediaWiki and another web application, you may choose to
1712 add a prefix to all the table names to avoid conflicts.</p>
1714 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
1716 <div class="config-input"><?php aField( $conf, "DBdefTS_ora", "Default tablespace:" ); ?></div>
1717 <div class="config-input"><?php aField( $conf, "DBtempTS_ora", "Temporary tablespace:" ); ?></div>
1720 <div class="config-input" style="padding:2em 0 3em">
1721 <label class='column
'> </label>
1722 <input type="submit" value="Install MediaWiki!" class="btn-install" />
1726 <script type="text/javascript">
1727 window.onload = toggleDBarea( <?php echo Xml::encodeJsVar( $conf->DBtype ); ?>,
1729 ## If they passed in a root user name, don't populate it on page load
1730 echo strlen(importPost('RootUser', '')) ?
0 : 1;
1736 /* -------------------------------------------------------------------------------------- */
1737 function writeSuccessMessage() {
1738 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
1739 if ( wfIniGetBool( 'safe_mode' ) && !ini_get( 'open_basedir' ) ) {
1741 <div class="success-box">
1742 <p>Installation successful!</p>
1743 <p>To complete the installation, please do the following:
1745 <li>Download config/LocalSettings.php with your FTP client or file manager</li>
1746 <li>Upload it to the parent directory</li>
1747 <li>Delete config/LocalSettings.php</li>
1748 <li>Start using <a href='../$script'>your wiki</a>!
1750 <p>If you are in a shared hosting environment, do <strong>not</strong> just move LocalSettings.php
1751 remotely. LocalSettings.php is currently owned by the user your webserver is running under,
1752 which means that anyone on the same server can read your database password! Downloading
1753 it and uploading it again will hopefully change the ownership to a user ID specific to you.</p>
1758 <div class="success-box">
1760 <span class="success-message">Installation successful!</span>
1761 Move the <tt>config/LocalSettings.php</tt> file to the parent directory, then follow
1762 <a href="../$script"> this link</a> to your wiki.</p>
1763 <p>You should change file permissions for <tt>LocalSettings.php</tt> as required to
1764 prevent other users on the server reading passwords and altering configuration data.</p>
1771 function escapePhpString( $string ) {
1772 if ( is_array( $string ) ||
is_object( $string ) ) {
1775 return strtr( $string,
1786 function writeLocalSettings( $conf ) {
1787 $conf->PasswordSender
= $conf->EmergencyContact
;
1788 $magic = ($conf->ImageMagick ?
"" : "# ");
1789 $convert = ($conf->ImageMagick ?
$conf->ImageMagick
: "/usr/bin/convert" );
1790 $rights = ($conf->RightsUrl
) ?
"" : "# ";
1791 $hashedUploads = $conf->safeMode ?
'' : '# ';
1793 if ( $conf->ShellLocale
) {
1797 $conf->ShellLocale
= 'en_US.UTF-8';
1800 switch ( $conf->Shm
) {
1802 $cacheType = 'CACHE_MEMCACHED';
1803 $mcservers = var_export( $conf->MCServerArray
, true );
1809 $cacheType = 'CACHE_ACCEL';
1810 $mcservers = 'array()';
1813 $cacheType = 'CACHE_DBA';
1814 $mcservers = 'array()';
1817 $cacheType = 'CACHE_NONE';
1818 $mcservers = 'array()';
1821 if ( $conf->Email
== 'email_enabled' ) {
1822 $enableemail = 'true';
1823 $enableuseremail = ( $conf->Emailuser
== 'emailuser_enabled' ) ?
'true' : 'false' ;
1824 $eauthent = ( $conf->Eauthent
== 'eauthent_enabled' ) ?
'true' : 'false' ;
1825 switch ( $conf->Enotif
) {
1826 case 'enotif_usertalk':
1827 $enotifusertalk = 'true';
1828 $enotifwatchlist = 'false';
1830 case 'enotif_allpages':
1831 $enotifusertalk = 'true';
1832 $enotifwatchlist = 'true';
1835 $enotifusertalk = 'false';
1836 $enotifwatchlist = 'false';
1839 $enableuseremail = 'false';
1840 $enableemail = 'false';
1841 $eauthent = 'false';
1842 $enotifusertalk = 'false';
1843 $enotifwatchlist = 'false';
1846 $file = @fopen
( "/dev/urandom", "r" );
1848 $secretKey = bin2hex( fread( $file, 32 ) );
1852 for ( $i=0; $i<8; $i++
) {
1853 $secretKey .= dechex(mt_rand(0, 0x7fffffff));
1855 print "<li>Warning: \$wgSecretKey key is insecure, generated with mt_rand(). Consider changing it manually.</li>\n";
1858 # Add slashes to strings for double quoting
1859 $slconf = wfArrayMap( "escapePhpString", get_object_vars( $conf ) );
1860 if( $conf->License
== 'gfdl1_2' ||
$conf->License
== 'pd' ||
$conf->License
== 'gfdl1_3' ) {
1861 # Needs literal string interpolation for the current style path
1862 $slconf['RightsIcon'] = $conf->RightsIcon
;
1865 if( $conf->DBtype
== 'mysql' ) {
1867 "# MySQL specific settings
1868 \$wgDBprefix = \"{$slconf['DBprefix']}\";
1870 # MySQL table options to use during installation or update
1871 \$wgDBTableOptions = \"{$slconf['DBTableOptions']}\";
1873 # Experimental charset support for MySQL 4.1/5.0.
1874 \$wgDBmysql5 = {$conf->DBmysql5};";
1875 } elseif( $conf->DBtype
== 'postgres' ) {
1877 "# Postgres specific settings
1878 \$wgDBport = \"{$slconf['DBport']}\";
1879 \$wgDBmwschema = \"{$slconf['DBpgschema']}\";
1880 \$wgDBts2schema = \"{$slconf['DBts2schema']}\";";
1881 } elseif( $conf->DBtype
== 'sqlite' ) {
1883 "# SQLite-specific settings
1884 \$wgSQLiteDataDir = \"{$slconf['SQLiteDataDir']}\";";
1885 } elseif( $conf->DBtype
== 'mssql' ) {
1887 "# MSSQL specific settings
1888 \$wgDBprefix = \"{$slconf['DBprefix2']}\";";
1889 } elseif( $conf->DBtype
== 'ibm_db2' ) {
1891 "# DB2 specific settings
1892 \$wgDBport_db2 = \"{$slconf['DBport_db2']}\";
1893 \$wgDBmwschema = \"{$slconf['DBdb2schema']}\";
1894 \$wgDBcataloged = \"{$slconf['DBcataloged']}\";";
1895 } elseif( $conf->DBtype
== 'oracle' ) {
1897 "# Oracle specific settings
1898 \$wgDBprefix = \"{$slconf['DBprefix']}\";";
1906 # This file was automatically generated by the MediaWiki installer.
1907 # If you make manual changes, please keep track in case you need to
1908 # recreate them later.
1910 # See includes/DefaultSettings.php for all configurable settings
1911 # and their default values, but don't forget to make changes in _this_
1914 # Further documentation for configuration settings may be found at:
1915 # http://www.mediawiki.org/wiki/Manual:Configuration_settings
1917 # If you customize your file layout, set \$IP to the directory that contains
1918 # the other MediaWiki files. It will be used as a base to locate files.
1919 if( defined( 'MW_INSTALL_PATH' ) ) {
1920 \$IP = MW_INSTALL_PATH;
1922 \$IP = dirname( __FILE__ );
1925 \$path = array( \$IP, \"\$IP/includes\", \"\$IP/languages\" );
1926 set_include_path( implode( PATH_SEPARATOR, \$path ) . PATH_SEPARATOR . get_include_path() );
1928 require_once( \"\$IP/includes/DefaultSettings.php\" );
1930 if ( \$wgCommandLineMode ) {
1931 if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
1932 die( \"This script must be run from the command line\\n\" );
1935 ## Uncomment this to disable output compression
1936 # \$wgDisableOutputCompression = true;
1938 \$wgSitename = \"{$slconf['Sitename']}\";
1940 ## The URL base path to the directory containing the wiki;
1941 ## defaults for all runtime URL paths are based off of this.
1942 ## For more information on customizing the URLs please see:
1943 ## http://www.mediawiki.org/wiki/Manual:Short_URL
1944 \$wgScriptPath = \"{$slconf['ScriptPath']}\";
1945 \$wgScriptExtension = \"{$slconf['ScriptExtension']}\";
1947 ## UPO means: this is also a user preference option
1949 \$wgEnableEmail = $enableemail;
1950 \$wgEnableUserEmail = $enableuseremail; # UPO
1952 \$wgEmergencyContact = \"{$slconf['EmergencyContact']}\";
1953 \$wgPasswordSender = \"{$slconf['PasswordSender']}\";
1955 \$wgEnotifUserTalk = $enotifusertalk; # UPO
1956 \$wgEnotifWatchlist = $enotifwatchlist; # UPO
1957 \$wgEmailAuthentication = $eauthent;
1959 ## Database settings
1960 \$wgDBtype = \"{$slconf['DBtype']}\";
1961 \$wgDBserver = \"{$slconf['DBserver']}\";
1962 \$wgDBname = \"{$slconf['DBname']}\";
1963 \$wgDBuser = \"{$slconf['DBuser']}\";
1964 \$wgDBpassword = \"{$slconf['DBpassword']}\";
1968 ## Shared memory settings
1969 \$wgMainCacheType = $cacheType;
1970 \$wgMemCachedServers = $mcservers;
1972 ## To enable image uploads, make sure the 'images' directory
1973 ## is writable, then set this to true:
1974 \$wgEnableUploads = false;
1975 {$magic}\$wgUseImageMagick = true;
1976 {$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
1978 ## If you use ImageMagick (or any other shell command) on a
1979 ## Linux server, this will need to be set to the name of an
1980 ## available UTF-8 locale
1981 {$locale}\$wgShellLocale = \"{$slconf['ShellLocale']}\";
1983 ## If you want to use image uploads under safe mode,
1984 ## create the directories images/archive, images/thumb and
1985 ## images/temp, and make them all writable. Then uncomment
1986 ## this, if it's not already uncommented:
1987 {$hashedUploads}\$wgHashedUploadDirectory = false;
1989 ## If you have the appropriate support software installed
1990 ## you can enable inline LaTeX equations:
1993 ## Set \$wgCacheDirectory to a writable directory on the web server
1994 ## to make your wiki go slightly faster. The directory should not
1995 ## be publically accessible from the web.
1996 #\$wgCacheDirectory = \"\$IP/cache\";
1998 \$wgLocalInterwiki = strtolower( \$wgSitename );
2000 \$wgLanguageCode = \"{$slconf['LanguageCode']}\";
2002 \$wgSecretKey = \"$secretKey\";
2004 ## Default skin: you can change the default skin. Use the internal symbolic
2005 ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook':
2006 \$wgDefaultSkin = 'monobook';
2008 ## For attaching licensing metadata to pages, and displaying an
2009 ## appropriate copyright notice / icon. GNU Free Documentation
2010 ## License and Creative Commons licenses are supported so far.
2011 {$rights}\$wgEnableCreativeCommonsRdf = true;
2012 \$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright
2013 \$wgRightsUrl = \"{$slconf['RightsUrl']}\";
2014 \$wgRightsText = \"{$slconf['RightsText']}\";
2015 \$wgRightsIcon = \"{$slconf['RightsIcon']}\";
2016 # \$wgRightsCode = \"{$slconf['RightsCode']}\"; # Not yet used
2018 \$wgDiff3 = \"{$slconf['diff3']}\";
2020 \$wgPhpCliPath = \"{$slconf['phpCliPath']}\";
2022 # When you make changes to this configuration file, this will make
2023 # sure that cached pages are cleared.
2024 \$wgCacheEpoch = max( \$wgCacheEpoch, gmdate( 'YmdHis', @filemtime( __FILE__ ) ) );
2025 "; ## End of setting the $localsettings string
2027 // Keep things in Unix line endings internally;
2028 // the system will write out as local text type.
2029 return str_replace( "\r\n", "\n", $localsettings );
2032 function dieout( $text ) {
2033 global $mainListOpened;
2034 if( $mainListOpened ) echo( "</ul>" );
2035 if( $text != '' && substr( $text, 0, 2 ) != '<p' && substr( $text, 0, 2 ) != '<h' ){
2036 echo "<p>$text</p>\n";
2040 die( "\n\n</div>\n</div>\n</div>\n</div>\n</body>\n</html>" );
2043 function importVar( &$var, $name, $default = "" ) {
2044 if( isset( $var[$name] ) ) {
2045 $retval = $var[$name];
2046 if ( get_magic_quotes_gpc() ) {
2047 $retval = stripslashes( $retval );
2056 function importPost( $name, $default = "" ) {
2057 return importVar( $_POST, $name, $default );
2060 function importCheck( $name ) {
2061 return isset( $_POST[$name] );
2064 function importRequest( $name, $default = "" ) {
2065 return importVar( $_REQUEST, $name, $default );
2068 function aField( &$conf, $field, $text, $type = "text", $value = "", $onclick = '' ) {
2069 static $radioCount = 0;
2071 $xtype = "type=\"$type\"";
2077 $nolabel = ($type == "radio") ||
($type == "hidden");
2079 if ($type == 'radio')
2080 $id .= $radioCount++
;
2083 echo "<label class='column' for=\"$id\">$text</label>";
2086 if( $type == "radio" && $value == $conf->$field ) {
2087 $checked = "checked='checked'";
2091 echo "<input $xtype name=\"$field\" id=\"$id\" class=\"iput-$type\" $checked ";
2093 echo " onclick='toggleDBarea(\"$value\",1)' " ;
2096 if( $type == "radio" ) {
2097 echo htmlspecialchars( $value );
2099 echo htmlspecialchars( $conf->$field );
2105 echo "<label for=\"$id\">$text</label>";
2109 if(isset($errs[$field])) {
2110 echo "<span class='error'>" . htmlspecialchars( $errs[$field] ) . "</span>\n";
2114 function getLanguageList() {
2115 global $wgLanguageNames, $IP;
2116 if( !isset( $wgLanguageNames ) ) {
2117 require_once( "$IP/languages/Names.php" );
2122 $d = opendir( "../languages/messages" );
2123 /* In case we are called from the root directory */
2125 $d = opendir( "languages/messages");
2126 while( false !== ($f = readdir( $d ) ) ) {
2128 if( preg_match( '/Messages([A-Z][a-z_]+)\.php$/', $f, $m ) ) {
2129 $code = str_replace( '_', '-', strtolower( $m[1] ) );
2130 if( $code == 'qqq' ) continue;
2131 if( isset( $wgLanguageNames[$code] ) ) {
2132 $name = wfBCP47( $code ) . ' - ' . $wgLanguageNames[$code];
2136 $codes[$code] = $name;
2144 #Check for location of an executable
2145 # @param string $loc single location to check
2146 # @param array $names filenames to check for.
2147 # @param mixed $versioninfo array of details to use when checking version, use false for no version checking
2148 function locate_executable($loc, $names, $versioninfo = false) {
2149 if (!is_array($names))
2150 $names = array($names);
2152 foreach ($names as $name) {
2153 $command = "$loc".DIRECTORY_SEPARATOR
."$name";
2154 if (@file_exists
($command)) {
2158 $file = str_replace('$1', $command, $versioninfo[0]);
2159 if (strstr(`
$file`
, $versioninfo[1]) !== false)
2166 # Test a memcached server
2167 function testMemcachedServer( $server ) {
2168 $hostport = explode(":", $server);
2171 if ( !function_exists( 'fsockopen' ) ) {
2172 $errstr = "Can't connect to memcached, fsockopen() not present";
2174 if ( !$errstr && count( $hostport ) != 2 ) {
2175 $errstr = 'Please specify host and port';
2178 list( $host, $port ) = $hostport;
2182 $fp = @fsockopen
( $host, $port, $errno, $fsockerr, 1.0 );
2183 if ( $fp === false ) {
2184 $errstr = "Cannot connect to memcached on $host:$port : $fsockerr";
2188 $command = "version\r\n";
2189 $bytes = fwrite( $fp, $command );
2190 if ( $bytes != strlen( $command ) ) {
2191 $errstr = "Cannot write to memcached socket on $host:$port";
2195 $expected = "VERSION ";
2196 $response = fread( $fp, strlen( $expected ) );
2197 if ( $response != $expected ) {
2198 $errstr = "Didn't get correct memcached response from $host:$port";
2205 echo "<li>Connected to memcached on " . htmlspecialchars( "$host:$port" ) ." successfully</li>";
2210 function database_picker($conf) {
2213 foreach(array_keys($ourdb) as $db) {
2214 if ($ourdb[$db]['havedriver']) {
2216 aField( $conf, "DBtype", $ourdb[$db]['fullname'], 'radio', $db, 'onclick');
2223 function database_switcher($db) {
2225 $color = $ourdb[$db]['bgcolor'];
2226 $full = $ourdb[$db]['fullname'];
2227 print "<fieldset id='$db' style='clear:both'><legend>$full-specific options</legend>\n";
2230 function printListItem( $item ) {
2231 print "<li>$item</li>";
2234 # Determine a suitable value for $wgShellLocale
2235 function getShellLocale( $wikiLang ) {
2236 # Give up now if we're in safe mode or open_basedir
2237 # It's theoretically possible but tricky to work with
2238 if ( wfIniGetBool( "safe_mode" ) ||
ini_get( 'open_basedir' ) ||
!function_exists('exec') ) {
2242 $os = php_uname( 's' );
2243 $supported = array( 'Linux', 'SunOS', 'HP-UX' ); # Tested these
2244 if ( !in_array( $os, $supported ) ) {
2248 # Get a list of available locales
2249 $lines = $ret = false;
2250 exec( '/usr/bin/locale -a', $lines, $ret );
2255 $lines = wfArrayMap( 'trim', $lines );
2256 $candidatesByLocale = array();
2257 $candidatesByLang = array();
2258 foreach ( $lines as $line ) {
2259 if ( $line === '' ) {
2262 if ( !preg_match( '/^([a-zA-Z]+)(_[a-zA-Z]+|)\.(utf8|UTF-8)(@[a-zA-Z_]*|)$/i', $line, $m ) ) {
2265 list( $all, $lang, $territory, $charset, $modifier ) = $m;
2266 $candidatesByLocale[$m[0]] = $m;
2267 $candidatesByLang[$lang][] = $m;
2270 # Try the current value of LANG
2271 if ( isset( $candidatesByLocale[ getenv( 'LANG' ) ] ) ) {
2272 return getenv( 'LANG' );
2275 # Try the most common ones
2276 $commonLocales = array( 'en_US.UTF-8', 'en_US.utf8', 'de_DE.UTF-8', 'de_DE.utf8' );
2277 foreach ( $commonLocales as $commonLocale ) {
2278 if ( isset( $candidatesByLocale[$commonLocale] ) ) {
2279 return $commonLocale;
2283 # Is there an available locale in the Wiki's language?
2284 if ( isset( $candidatesByLang[$wikiLang] ) ) {
2285 $m = reset( $candidatesByLang[$wikiLang] );
2289 # Are there any at all?
2290 if ( count( $candidatesByLocale ) ) {
2291 $m = reset( $candidatesByLocale );
2299 function wfArrayMap( $function, $input ) {
2300 $ret = array_map( $function, $input );
2301 foreach ( $ret as $key => $value ) {
2302 $taint = istainted( $input[$key] );
2304 taint( $ret[$key], $taint );
2312 <div
class="license">
2314 <p
>This program is free software
; you can redistribute it
and/or modify
2315 it under the terms of the GNU General
Public License
as published by
2316 the Free Software Foundation
; either version
2 of the License
, or
2317 (at your option
) any later version
.</p
>
2319 <p
>This program is distributed in the hope that it will be useful
,
2320 but WITHOUT ANY WARRANTY
; without even the implied warranty of
2321 MERCHANTABILITY
or FITNESS
FOR A PARTICULAR PURPOSE
. See the
2322 GNU General
Public License
for more details
.</p
>
2324 <p
>You should have received
<a href
="../COPYING">a copy of the GNU General
Public License
</a
>
2325 along with this program
; if not
, write to the Free Software
2326 Foundation
, Inc
., 51 Franklin Street
, Fifth Floor
, Boston
, MA
02110-1301, USA
.
2327 or <a href
="http://www.gnu.org/copyleft/gpl.html">read it online
</a
></p
>
2333 <div id
="column-one">
2334 <div
class="portlet" id
="p-logo">
2335 <a style
="background-image: url(../skins/common/images/mediawiki.png);"
2337 title
="Main Page"></a
>
2339 <script type
="text/javascript"> if (window
.isMSIE55
) fixalpha(); </script
>
2340 <div
class='portlet'><div
class='pBody'>
2342 <li
><a href
="../README">Readme
</a
></li
>
2343 <li
><a href
="../RELEASE-NOTES">Release notes
</a
></li
>
2344 <li
><a href
="../docs/">Documentation
</a
></li
>
2345 <li
><a href
="http://www.mediawiki.org/wiki/Help:Contents">User
's Guide</a></li>
2346 <li><a href="http://www.mediawiki.org/wiki/Manual:Contents">Administrator's Guide
</a
></li
>
2347 <li
><a href
="http://www.mediawiki.org/wiki/Manual:FAQ">FAQ
</a
></li
>
2349 <p style
="font-size:90%;margin-top:1em">MediaWiki is Copyright ©
2001-2009 by Magnus Manske
, Brion Vibber
,
2350 Lee Daniel Crocker
, Tim Starling
, Erik Möller
, Gabriel Wicke
, Æ
var Arnfjörð Bjarmason
, Niklas Laxström
,
2351 Domas Mituzas
, Rob Church
, Yuri Astrakhan
, Aryeh Gregor
, Aaron Schulz
and others
.</p
>