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['ibm_db2'] = array(
89 'compile' => 'ibm_db2',
90 'bgcolor' => '#ffeba1',
91 'rootuser' => 'db2admin',
95 $ourdb['oracle'] = array(
96 'fullname' => 'Oracle',
99 'bgcolor' => '#ffeba1',
101 'serverless' => false
105 <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
106 <html xmlns
="http://www.w3.org/1999/xhtml" lang
="en" dir
="ltr">
108 <meta http
-equiv
="Content-type" content
="text/html; charset=utf-8" />
109 <meta name
="robots" content
="noindex,nofollow"/>
110 <title
>MediaWiki
<?php
echo htmlspecialchars( $wgVersion ); ?
> Installation
</title
>
111 <style type
="text/css">
113 @import
"../skins/monobook/main.css";
117 margin
: 1em
0 1em
2.5em
;
124 .config
-section label
.column
{
136 zoom
: 100%
; /* IE hack */
139 .config
-section
.config
-desc
{
141 margin
: 0 0 2em
18em
;
146 .iput
-text
, .iput
-password
{
153 background
-color
: #fff;
161 background
-color
: #FFF0F0;
162 border
: 2px solid red
;
170 list-style
-type
: none
;
171 list-style
-image
: none
;
188 span
.success
-message
{
199 <script type
="text/javascript">
201 <?php
echo 'var databases = ' . FormatJson
::encode( $ourdb ) . ';'; ?
>
203 function show(id
, showOrHide
) {
204 var i
= document
.getElementById(id
);
205 if (i
) i
.style
.display
= showOrHide ?
'block' : 'none';
208 for (db in databases
) {
212 function toggleDBarea(id
, defaultroot
) {
214 var dbarea
= document
.getElementById(id
);
215 if (dbarea
) dbarea
.style
.display
= (dbarea
.style
.display
== 'none') ?
'block' : 'none';
216 var db
= document
.getElementById('RootUser');
217 db
.value
= databases
[id
].rootuser
;
218 show('db-server-settings1', !databases
[id
].serverless
);
219 show('db-server-settings2', !databases
[id
].serverless
);
226 <div id
="globalWrapper">
227 <div id
="column-content">
229 <div id
="bodyContent">
231 <h1
>MediaWiki
<?php
print htmlspecialchars( $wgVersion ) ?
> Installation
</h1
>
234 $mainListOpened = false; # Is the main list (environement checking) opend ? Used by dieout
236 /* Check for existing configurations and bug out! */
238 if( file_exists( "../LocalSettings.php" ) ) {
239 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
240 dieout( "<p><strong>Setup has completed, <a href='../$script'>your wiki</a> is configured.</strong></p>
241 <p>Please delete the /config directory for extra security.</p>" );
244 if( file_exists( "./LocalSettings.php" ) ) {
245 writeSuccessMessage();
249 if( !is_writable( "." ) ) {
250 dieout( "<h2>Can't write config file, aborting</h2>
252 <p>In order to configure the wiki you have to make the <tt>config</tt> subdirectory
253 writable by the web server. Once configuration is done you'll move the created
254 <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can
255 then remove the <tt>config</tt> subdirectory entirely.</p>
257 <p>To make the directory writable on a Unix/Linux system:</p>
260 cd <i>" . htmlspecialchars( dirname( dirname( __FILE__
) ) ) . "</i>
264 <p>Afterwards retry to start the <a href=\"\">setup</a>.</p>" );
268 require_once( "$IP/maintenance/updaters.inc" );
271 function getEncoded( $data ) {
272 # removing latin1 support, no need...
275 function getSitename() { return $this->getEncoded( $this->Sitename
); }
276 function getSysopName() { return $this->getEncoded( $this->SysopName
); }
277 function getSysopPass() { return $this->getEncoded( $this->SysopPass
); }
279 function setSchema( $schema, $engine ) {
280 $this->DBschema
= $schema;
281 if ( !preg_match( '/^\w*$/', $engine ) ){
284 switch ( $this->DBschema
) {
286 $this->DBTableOptions
= "ENGINE=$engine, DEFAULT CHARSET=utf8";
287 $this->DBmysql5
= 'true';
289 case 'mysql5-binary':
290 $this->DBTableOptions
= "ENGINE=$engine, DEFAULT CHARSET=binary";
291 $this->DBmysql5
= 'true';
294 $this->DBTableOptions
= "TYPE=$engine";
295 $this->DBmysql5
= 'false';
297 $this->DBengine
= $engine;
299 # Set the global for use during install
300 global $wgDBTableOptions;
301 $wgDBTableOptions = $this->DBTableOptions
;
309 <b
>Don
't forget security updates!</b> Keep an eye on the
310 <a href="http://lists.wikimedia.org/mailman/listinfo/mediawiki-announce">low-traffic
311 release announcements mailing list</a>.
316 <h2>Checking environment...</h2>
317 <p><em>Please include all of the lines below when reporting installation problems.</em></p>
318 <ul class="env-check">
320 $mainListOpened = true;
324 define( 'MW_NO_OUTPUT_BUFFER
', 1 );
325 $conf = new ConfigData;
327 install_version_checks();
328 $self = 'Installer
'; # Maintenance script name, to please Setup.php
330 print "<li>PHP " . htmlspecialchars( phpversion() ) . " installed</li>\n";
332 error_reporting( 0 );
333 $phpdatabases = array();
334 foreach (array_keys($ourdb) as $db) {
335 $compname = $ourdb[$db]['compile
'];
336 if( wfDl( $compname ) ) {
337 array_push($phpdatabases, $db);
338 $ourdb[$db]['havedriver
'] = 1;
341 error_reporting( E_ALL | E_STRICT );
343 if (!$phpdatabases) {
344 print "Could not find a suitable database driver!<ul>";
345 foreach (array_keys($ourdb) AS $db) {
346 $comp = $ourdb[$db]['compile
'];
347 $full = $ourdb[$db]['fullname
'];
348 print "<li>For <b>$full</b>, compile PHP using <b>--with-$comp</b>, "
349 ."or install the $comp.so module</li>\n";
355 print "<li>Found database drivers for:";
357 foreach (array_keys($ourdb) AS $db) {
358 if ($ourdb[$db]['havedriver
']) {
359 if ( $DefaultDBtype == '' ) {
360 $DefaultDBtype = $db;
362 print " ".$ourdb[$db]['fullname
'];
367 if( wfIniGetBool( "register_globals" ) ) {
370 <div style="font-size:110%">
371 <strong class="error">Warning:</strong>
372 <strong>PHP's
<tt
><a href
="http://php.net/register_globals">register_globals
</a
></tt
> option is enabled
. Disable it
if you can
.</strong
>
374 MediaWiki will work
, but your server is more exposed to PHP
-based security vulnerabilities
.
381 if( wfIniGetBool( "magic_quotes_runtime" ) ) {
383 ?
><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
>
384 This option corrupts data input unpredictably
; you cannot install
or use
385 MediaWiki unless this option is disabled
.</li
>
389 if( wfIniGetBool( "magic_quotes_sybase" ) ) {
391 ?
><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
>
392 This option corrupts data input unpredictably
; you cannot install
or use
393 MediaWiki unless this option is disabled
.</li
>
397 if( wfIniGetBool( "mbstring.func_overload" ) ) {
399 ?
><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
>
400 This option causes errors
and may corrupt data unpredictably
;
401 you cannot install
or use MediaWiki unless this option is disabled
.</li
>
405 if( wfIniGetBool( "zend.ze1_compatibility_mode" ) ) {
407 ?
><li
class="error"><strong
>Fatal
: <a href
="http://www.php.net/manual/en/ini.core.php">zend
.ze1_compatibility_mode
</a
> is active
!</strong
>
408 This option causes horrible bugs with MediaWiki
; you cannot install
or use
409 MediaWiki unless this option is disabled
.</li
>
414 dieout( "Cannot install MediaWiki." );
417 if( wfIniGetBool( "safe_mode" ) ) {
418 $conf->safeMode
= true;
420 <li
><b
class='error'>Warning
:</b
> <strong
>PHP
's
421 <a href='http
://www.php.net/features.safe-mode'>safe mode</a> is active.</strong>
422 You may have problems caused by this
, particularly
if using image uploads
.
426 $conf->safeMode
= false;
429 $sapi = htmlspecialchars( php_sapi_name() );
430 print "<li>PHP server API is $sapi; ";
431 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
432 if( $wgUsePathInfo ) {
433 print "ok, using pretty URLs (<tt>$script/Page_Title</tt>)";
435 print "using ugly URLs (<tt>$script?title=Page_Title</tt>)";
439 $conf->xml
= function_exists( "utf8_encode" );
441 print "<li>Have XML / Latin1-UTF-8 conversion support.</li>\n";
443 dieout( "PHP's XML module is missing; the wiki requires functions in
444 this module and won't work in this configuration.
445 If you're running Mandrake, install the php-xml package." );
448 # Check for session support
449 if( !function_exists( 'session_name' ) )
450 dieout( "PHP's session module is missing. MediaWiki requires session support in order to function." );
452 # session.save_path doesn't *have* to be set, but if it is, and it's
453 # not valid/writable/etc. then it can cause problems
454 $sessionSavePath = mw_get_session_save_path();
455 $ssp = htmlspecialchars( $sessionSavePath );
456 # Warn the user if it's not set, but let them proceed
457 if( !$sessionSavePath ) {
458 print "<li><strong>Warning:</strong> A value for <tt>session.save_path</tt>
459 has not been set in PHP.ini. If the default value causes problems with
460 saving session data, set it to a valid path which is read/write/execute
461 for the user your web server is running under.</li>";
462 } elseif ( is_dir( $sessionSavePath ) && is_writable( $sessionSavePath ) ) {
463 # All good? Let the user know
464 print "<li>Session save path (<tt>{$ssp}</tt>) appears to be valid.</li>";
466 # Something not right? Warn the user, but let them proceed
467 print "<li><strong>Warning:</strong> Your <tt>session.save_path</tt> value (<tt>{$ssp}</tt>)
468 appears to be invalid or is not writable. PHP needs to be able to save data to
469 this location for correct session operation.</li>";
472 # Check for PCRE support
473 if( !function_exists( 'preg_match' ) )
474 dieout( "The PCRE support module appears to be missing. MediaWiki requires the
475 Perl-compatible regular expression functions." );
477 # The installer can take a while, and we really don't want it to time out
478 wfSuppressWarnings();
482 $memlimit = ini_get( "memory_limit" );
483 if( $memlimit == -1 ) {
484 print "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n";
486 print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars( $memlimit ). " bytes. ";
487 $newlimit = wfMemoryLimit();
488 $memlimit = wfShorthandToInteger( $memlimit );
489 if( $newlimit < $memlimit ) {
490 print "<b>Failed raising limit, installation may fail.</b>";
491 } elseif ( $newlimit > $memlimit ) {
492 print "Raised <tt>memory_limit</tt> to " . htmlspecialchars( $newlimit ) . " bytes. ";
497 $conf->xcache
= function_exists( 'xcache_get' );
499 print "<li><a href=\"http://trac.lighttpd.net/xcache/\">XCache</a> installed</li>\n";
501 $conf->apc
= function_exists('apc_fetch');
503 print "<li><a href=\"http://www.php.net/apc\">APC</a> installed</li>\n";
506 $conf->eaccel
= function_exists( 'eaccelerator_get' );
507 if ( $conf->eaccel
) {
508 print "<li><a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> installed</li>\n";
511 $conf->dba
= function_exists( 'dba_open' );
513 if( !( $conf->eaccel ||
$conf->apc ||
$conf->xcache
) ) {
514 echo( '<li>Couldn\'t find <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->diff3
= false;
520 $diff3locations = array_merge(
527 explode( PATH_SEPARATOR
, getenv( "PATH" ) ) );
528 $diff3names = array( "gdiff3", "diff3", "diff3.exe" );
530 $diff3versioninfo = array( '$1 --version 2>&1', 'diff3 (GNU diffutils)' );
531 foreach ($diff3locations as $loc) {
532 $exe = locate_executable($loc, $diff3names, $diff3versioninfo);
533 if ($exe !== false) {
540 print "<li>Found GNU diff3: <tt>$conf->diff3</tt>.</li>";
542 print "<li>GNU diff3 not found.</li>";
544 $conf->ImageMagick
= false;
545 $imcheck = array( "/usr/bin", "/opt/csw/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" );
546 foreach( $imcheck as $dir ) {
547 $im = "$dir/convert";
548 if( @file_exists
( $im ) ) {
549 print "<li>Found ImageMagick: <tt>$im</tt>; image thumbnailing will be enabled if you enable uploads.</li>\n";
550 $conf->ImageMagick
= $im;
555 $conf->HaveGD
= function_exists( "imagejpeg" );
556 if( $conf->HaveGD
) {
557 print "<li>Found GD graphics library built-in";
558 if( !$conf->ImageMagick
) {
559 print ", image thumbnailing will be enabled if you enable uploads";
563 if( !$conf->ImageMagick
) {
564 print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n";
568 $conf->IP
= dirname( dirname( __FILE__
) );
569 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP
) . "</tt></li>\n";
572 // PHP_SELF isn't available sometimes, such as when PHP is CGI but
573 // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
574 // to get the path to the current script... hopefully it's reliable. SIGH
575 $path = ($_SERVER["PHP_SELF"] === '')
576 ?
$_SERVER["SCRIPT_NAME"]
577 : $_SERVER["PHP_SELF"];
579 $conf->ScriptPath
= preg_replace( '{^(.*)/config.*$}', '$1', $path );
580 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath
) . "</tt></li>\n";
584 // We may be installing from *.php5 extension file, if so, print message
585 $conf->ScriptExtension
= '.php';
586 if (defined('MW_INSTALL_PHP5_EXT')) {
587 $conf->ScriptExtension
= '.php5';
588 print "<li>Installing MediaWiki with <tt>php5</tt> file extensions</li>\n";
590 print "<li>Installing MediaWiki with <tt>php</tt> file extensions</li>\n";
594 print "<li style='font-weight:bold;color:green;font-size:110%'>Environment checked. You can install MediaWiki.</li>\n";
595 $conf->posted
= ($_SERVER["REQUEST_METHOD"] == "POST");
597 $conf->Sitename
= ucfirst( importPost( "Sitename", "" ) );
598 $defaultEmail = empty( $_SERVER["SERVER_ADMIN"] )
600 : $_SERVER["SERVER_ADMIN"];
601 $conf->EmergencyContact
= importPost( "EmergencyContact", $defaultEmail );
602 $conf->DBtype
= importPost( "DBtype", $DefaultDBtype );
603 if ( !isset( $ourdb[$conf->DBtype
] ) ) {
604 $conf->DBtype
= $DefaultDBtype;
607 $conf->DBserver
= importPost( "DBserver", $wgDBserver );
608 $conf->DBname
= importPost( "DBname", $wgDBname );
609 $conf->DBuser
= importPost( "DBuser", $wgDBuser );
610 $conf->DBpassword
= importPost( "DBpassword" );
611 $conf->DBpassword2
= importPost( "DBpassword2" );
612 $conf->SysopName
= importPost( "SysopName", "WikiSysop" );
613 $conf->SysopPass
= importPost( "SysopPass" );
614 $conf->SysopPass2
= importPost( "SysopPass2" );
615 $conf->RootUser
= importPost( "RootUser" );
616 $conf->RootPW
= importPost( "RootPW", "" );
617 $useRoot = importCheck( 'useroot', false );
618 $conf->LanguageCode
= importPost( "LanguageCode", "en" );
620 $conf->DBprefix
= importPost( "DBprefix" );
622 importPost( "DBschema", "mysql5-binary" ),
623 importPost( "DBengine", "InnoDB" ) );
625 ## Postgres specific:
626 $conf->DBport
= importPost( "DBport", $wgDBport );
627 $conf->DBts2schema
= importPost( "DBts2schema", "public" );
628 $conf->DBpgschema
= importPost( "DBpgschema", "mediawiki" );
631 $conf->SQLiteDataDir
= importPost( "SQLiteDataDir", "$IP/../data" );
634 // New variable in order to have a different default port number
635 $conf->DBport_db2
= importPost( "DBport_db2", "50000" );
636 $conf->DBcataloged
= importPost( "DBcataloged", "cataloged" );
637 $conf->DBdb2schema
= importPost( "DBdb2schema", "mediawiki" );
640 $conf->DBprefix_ora
= importPost( "DBprefix_ora" );
641 $conf->DBdefTS_ora
= importPost( "DBdefTS_ora", "USERS" );
642 $conf->DBtempTS_ora
= importPost( "DBtempTS_ora", "TEMP" );
644 $conf->ShellLocale
= getShellLocale( $conf->LanguageCode
);
646 /* Check for validity */
649 if( preg_match( '/^$|^mediawiki$|#/i', $conf->Sitename
) ) {
650 $errs["Sitename"] = "Must not be blank or \"MediaWiki\" and may not contain \"#\"";
652 if( !$ourdb[$conf->DBtype
]['serverless'] ) {
653 if( $conf->DBuser
== "" ) {
654 $errs["DBuser"] = "Must not be blank";
656 if( ($conf->DBtype
== 'mysql') && (strlen($conf->DBuser
) > 16) ) {
657 $errs["DBuser"] = "Username too long";
659 if( $conf->DBpassword
== "" && $conf->DBtype
!= "postgres" ) {
660 $errs["DBpassword"] = "Must not be blank";
662 if( $conf->DBpassword
!= $conf->DBpassword2
) {
663 $errs["DBpassword2"] = "Passwords don't match!";
666 if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix
) ) {
667 $errs["DBprefix"] = "Invalid table prefix";
669 untaint( $conf->DBprefix
, TC_MYSQL
);
671 if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix_ora
) ) {
672 $errs["DBprefix_ora"] = "Invalid table prefix";
675 error_reporting( E_ALL | E_STRICT
);
678 * Initialise $wgLang and $wgContLang to something so we can
679 * call case-folding methods. Per Brion, this is English for
680 * now, although we could be clever and initialise to the
681 * user-selected language.
683 $wgContLang = Language
::factory( 'en' );
684 $wgLang = $wgContLang;
687 * We're messing about with users, so we need a stub
688 * authentication plugin...
690 $wgAuth = new AuthPlugin();
693 * Validate the initial administrator account; username,
694 * password checks, etc.
696 if( $conf->SysopName
) {
697 # Check that the user can be created
698 $u = User
::newFromName( $conf->SysopName
);
699 if( $u instanceof User
) {
700 # Various password checks
701 if( $conf->SysopPass
!= '' ) {
702 if( $conf->SysopPass
== $conf->SysopPass2
) {
703 if( !$u->isValidPassword( $conf->SysopPass
) ) {
704 $errs['SysopPass'] = "Bad password";
707 $errs['SysopPass2'] = "Passwords don't match";
710 $errs['SysopPass'] = "Cannot be blank";
714 $errs['SysopName'] = "Bad username";
718 $conf->License
= importRequest( "License", "none" );
719 if( $conf->License
== "gfdl1_2" ) {
720 $conf->RightsUrl
= "http://www.gnu.org/licenses/old-licenses/fdl-1.2.txt";
721 $conf->RightsText
= "GNU Free Documentation License 1.2";
722 $conf->RightsCode
= "gfdl1_2";
723 $conf->RightsIcon
= '${wgScriptPath}/skins/common/images/gnu-fdl.png';
724 } elseif( $conf->License
== "gfdl1_3" ) {
725 $conf->RightsUrl
= "http://www.gnu.org/copyleft/fdl.html";
726 $conf->RightsText
= "GNU Free Documentation License 1.3";
727 $conf->RightsCode
= "gfdl1_3";
728 $conf->RightsIcon
= '${wgScriptPath}/skins/common/images/gnu-fdl.png';
729 } elseif( $conf->License
== "none" ) {
730 $conf->RightsUrl
= $conf->RightsText
= $conf->RightsCode
= $conf->RightsIcon
= "";
731 } elseif( $conf->License
== "pd" ) {
732 $conf->RightsUrl
= "http://creativecommons.org/licenses/publicdomain/";
733 $conf->RightsText
= "Public Domain";
734 $conf->RightsCode
= "pd";
735 $conf->RightsIcon
= '${wgScriptPath}/skins/common/images/public-domain.png';
737 $conf->RightsUrl
= importRequest( "RightsUrl", "" );
738 $conf->RightsText
= importRequest( "RightsText", "" );
739 $conf->RightsCode
= importRequest( "RightsCode", "" );
740 $conf->RightsIcon
= importRequest( "RightsIcon", "" );
743 $conf->Shm
= importRequest( "Shm", "none" );
744 $conf->MCServers
= importRequest( "MCServers" );
746 /* Test memcached servers */
748 if ( $conf->Shm
== 'memcached' && $conf->MCServers
) {
749 $conf->MCServerArray
= wfArrayMap( 'trim', explode( ',', $conf->MCServers
) );
750 foreach ( $conf->MCServerArray
as $server ) {
751 $error = testMemcachedServer( $server );
753 $errs["MCServers"] = $error;
757 } else if ( $conf->Shm
== 'memcached' ) {
758 $errs["MCServers"] = "Please specify at least one server if you wish to use memcached";
761 /* default values for installation */
762 $conf->Email
= importRequest("Email", "email_enabled");
763 $conf->Emailuser
= importRequest("Emailuser", "emailuser_enabled");
764 $conf->Enotif
= importRequest("Enotif", "enotif_allpages");
765 $conf->Eauthent
= importRequest("Eauthent", "eauthent_enabled");
767 if( $conf->posted
&& ( 0 == count( $errs ) ) ) {
768 do { /* So we can 'continue' to end prematurely */
769 $conf->Root
= ($conf->RootPW
!= "");
771 /* Load up the settings and get installin' */
772 $local = writeLocalSettings( $conf );
773 echo "<li style=\"list-style: none\">\n";
774 echo "<p><b>Generating configuration file...</b></p>\n";
777 $wgCommandLineMode = false;
779 $ok = eval( $local );
780 if( $ok === false ) {
781 dieout( "<p>Errors in generated configuration; " .
782 "most likely due to a bug in the installer... " .
783 "Config file was: </p>" .
785 htmlspecialchars( $local ) .
788 $conf->DBtypename
= '';
789 foreach (array_keys($ourdb) as $db) {
790 if ($conf->DBtype
=== $db)
791 $conf->DBtypename
= $ourdb[$db]['fullname'];
793 if ( ! strlen($conf->DBtype
)) {
794 $errs["DBpicktype"] = "Please choose a database type";
798 if (! $conf->DBtypename
) {
799 $errs["DBtype"] = "Unknown database type '$conf->DBtype'";
802 print "<li>Database type: " . htmlspecialchars( $conf->DBtypename
) . "</li>\n";
803 $dbclass = 'Database'.ucfirst($conf->DBtype
);
804 $wgDBtype = $conf->DBtype
;
805 $wgDBadminuser = "root";
806 $wgDBadminpassword = $conf->RootPW
;
809 $wgDBprefix = $conf->DBprefix
;
811 ## Postgres specific:
812 $wgDBport = $conf->DBport
;
813 $wgDBts2schema = $conf->DBts2schema
;
815 if( $wgDBtype == 'postgres' ) {
816 $wgDBmwschema = $conf->DBpgschema
;
817 } elseif ( $wgDBtype == 'ibm_db2' ) {
818 $wgDBmwschema = $conf->DBdb2schema
;
821 if( $conf->DBprefix_ora
!= '' ) {
823 $wgDBprefix = $conf->DBprefix_ora
;
827 $wgDBcataloged = $conf->DBcataloged
;
829 $wgCommandLineMode = true;
830 if (! defined ( 'STDERR' ) )
831 define( 'STDERR', fopen("php://stderr", "wb"));
832 $wgUseDatabaseMessages = false; /* FIXME: For database failure */
833 require_once( "$IP/includes/Setup.php" );
834 Language
::getLocalisationCache()->disableBackend();
838 $wgTitle = Title
::newFromText( "Installation script" );
839 error_reporting( E_ALL | E_STRICT
);
840 print "<li>Loading class: " . htmlspecialchars( $dbclass ) . "</li>\n";
841 if ( $conf->DBtype
!= 'sqlite' ) {
845 if( $conf->DBtype
== 'mysql' ) {
846 $mysqlOldClient = version_compare( mysql_get_client_info(), "4.1.0", "lt" );
847 if( $mysqlOldClient ) {
848 print "<li><b>PHP is linked with old MySQL client libraries. If you are
849 using a MySQL 4.1 server and have problems connecting to the database,
850 see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
851 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b></li>\n";
853 $ok = true; # Let's be optimistic
855 # Decide if we're going to use the superuser or the regular database user
856 $conf->Root
= $useRoot;
858 $db_user = $conf->RootUser
;
859 $db_pass = $conf->RootPW
;
861 $db_user = $wgDBuser;
862 $db_pass = $wgDBpassword;
866 echo( "<li>Attempting to connect to database server as " . htmlspecialchars( $db_user ) . "..." );
867 $wgDatabase = Database
::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 );
869 # Check the connection and respond to errors
870 if( $wgDatabase->isOpen() ) {
873 $wgDBadminuser = $db_user;
874 $wgDBadminpassword = $db_pass;
875 echo( "success.</li>\n" );
876 $wgDatabase->ignoreErrors( true );
877 $myver = $wgDatabase->getServerVersion();
879 # There were errors, report them and back out
881 $errno = mysql_errno();
882 $errtx = htmlspecialchars( mysql_error() );
886 echo( "failed due to authentication errors. Check passwords.</li>" );
888 # The superuser details are wrong
889 $errs["RootUser"] = "Check username";
890 $errs["RootPW"] = "and password";
892 # The regular user details are wrong
893 $errs["DBuser"] = "Check username";
894 $errs["DBpassword"] = "and password";
900 # General connection problem
901 echo( htmlspecialchars( "failed with error [$errno] $errtx." ) . "</li>\n" );
902 $errs["DBserver"] = "Connection failed";
907 if( !$ok ) { continue; }
909 else if( $conf->DBtype
== 'ibm_db2' ) {
911 $db_user = $conf->RootUser
;
912 $db_pass = $conf->RootPW
;
914 $db_user = $wgDBuser;
915 $db_pass = $wgDBpassword;
918 echo( "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) .
919 "\" as \"" . htmlspecialchars( $db_user ) . "\"..." );
920 $wgDatabase = $dbc->newFromParams($wgDBserver, $db_user, $db_pass, $wgDBname, 1);
921 // enable extra debug messages
922 $dbc->setMode(DatabaseIbm_db2
::INSTALL_MODE
);
923 $wgDatabase->setMode(DatabaseIbm_db2
::INSTALL_MODE
);
925 if (!$wgDatabase->isOpen()) {
926 print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
928 $myver = $wgDatabase->getServerVersion();
930 if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname);
932 } elseif ( $conf->DBtype
== 'sqlite' ) {
933 $wgSQLiteDataDir = $conf->SQLiteDataDir
;
934 echo '<li>Attempting to connect to SQLite database at "' .
935 htmlspecialchars( $wgSQLiteDataDir ) . '": ';
936 if ( !is_dir( $wgSQLiteDataDir ) ) {
937 if ( is_writable( dirname( $wgSQLiteDataDir ) ) ) {
938 $ok = wfMkdirParents( $wgSQLiteDataDir, $wgSQLiteDataDirMode );
943 echo "cannot create data directory</li>";
944 $errs['SQLiteDataDir'] = 'Enter a valid data directory';
948 if ( !is_writable( $wgSQLiteDataDir ) ) {
949 echo "data directory not writable</li>";
950 $errs['SQLiteDataDir'] = 'Enter a writable data directory';
953 $dataFile = DatabaseSqlite
::generateFileName( $wgSQLiteDataDir, $wgDBname );
954 if ( file_exists( $dataFile ) ) {
955 if ( !is_writable( $dataFile ) ) {
956 echo "data file not writable</li>";
957 $errs['SQLiteDataDir'] = basename( $dataFile ) . " is not writable";
961 if ( file_put_contents( $dataFile, '' ) === false ) {
962 echo 'could not create database file "' . htmlspecialchars( basename( $dataFile ) ) . "\"</li>\n";
963 $errs['SQLiteDataDir'] = "couldn't create " . basename( $dataFile );
968 $wgDatabase = new DatabaseSqlite( false, false, false, $wgDBname, 1 );
970 catch( MWException
$ex ) {
971 echo 'error: ' . htmlspecialchars( $ex->getMessage() ) . "</li>\n";
975 if (!$wgDatabase->isOpen()) {
976 print "error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
977 $errs['SQLiteDataDir'] = 'Could not connect to database';
980 $myver = $wgDatabase->getServerVersion();
982 if ( is_callable( array( $wgDatabase, 'initial_setup' ) ) ) {
983 $wgDatabase->initial_setup('', $wgDBname);
986 } elseif ( $conf->DBtype
== 'oracle' ) {
987 echo "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) ."\"</li>";
988 $old_error_level = error_reporting();
989 wfSuppressWarnings();
990 $wgDatabase = $dbc->newFromParams('DUMMY', $wgDBuser, $wgDBpassword, $wgDBname, 1);
992 if (!$wgDatabase->isOpen()) {
994 echo "<li>Connect failed.</li>";
996 if (ini_get('oci8.privileged_connect') === false) {
997 echo "<li>Privileged connect disabled, please set oci8.privileged_connect or run maintenance/ora/user.sql script manually prior to continuing.</li>";
1000 $wgDBadminuser = $conf->RootUser
;
1001 $wgDBadminpassword = $conf->RootPW
;
1002 echo "<li>Attempting to create DB user.</li>";
1003 $wgDatabase = $dbc->newFromParams('DUMMY', $wgDBadminuser, $wgDBadminpassword, $wgDBname, 1, 64);
1004 if ($wgDatabase->isOpen()) {
1005 $wgDBOracleDefTS = $conf->DBdefTS_ora
;
1006 $wgDBOracleTempTS = $conf->DBtempTS_ora
;
1007 $res = $wgDatabase->sourceFile( "../maintenance/ora/user.sql" );
1008 if ($res !== true) dieout($res);
1010 echo "<li>Invalid database superuser, please supply a valid superuser account.</li>";
1011 echo "<li>ERR: ".print_r(oci_error(), true)."</li>";
1016 echo "<li>Database superuser missing, please supply a valid superuser account.</li>";
1020 $errs["RootUser"] = "Check username";
1021 $errs["RootPW"] = "and password";
1023 echo "<li>Attempting to connect to database with new user \"" . htmlspecialchars( $wgDBname ) ."\"</li>";
1024 $wgDatabase = $dbc->newFromParams('DUMMY', $wgDBuser, $wgDBpassword, $wgDBname, 1);
1028 $myver = $wgDatabase->getServerVersion();
1030 } else { # not mysql
1031 error_reporting( E_ALL | E_STRICT
);
1033 ## Possible connect as a superuser
1034 // Changed !mysql to postgres check since it seems to only apply to postgres
1035 if( $useRoot && $conf->DBtype
== 'postgres' ) {
1036 echo( "<li>Attempting to connect to database \"postgres\" as superuser \"" .
1037 htmlspecialchars( $conf->RootUser
) . "\"..." );
1038 $wgDatabase = $dbc->newFromParams($wgDBserver, $conf->RootUser
, $conf->RootPW
, "postgres", 1);
1039 if (!$wgDatabase->isOpen()) {
1040 print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
1041 $errs["DBserver"] = "Could not connect to database as superuser";
1042 $errs["RootUser"] = "Check username";
1043 $errs["RootPW"] = "and password";
1046 $wgDatabase->initial_setup($conf->RootUser
, $conf->RootPW
, 'postgres');
1048 echo( "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) .
1049 "\" as \"" . htmlspecialchars( $wgDBuser ) . "\"..." );
1050 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1);
1051 if (!$wgDatabase->isOpen()) {
1052 print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
1053 $errs["DBserver"] = "Could not connect to database as user";
1054 $errs["DBuser"] = "Check username";
1055 $errs["DBpassword"] = "and password";
1058 $myver = $wgDatabase->getServerVersion();
1060 if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname);
1063 if ( !$wgDatabase->isOpen() ) {
1064 $errs["DBserver"] = "Couldn't connect to database";
1068 print "<li>Connected to " . htmlspecialchars( "{$conf->DBtype} $myver" );
1069 if ($conf->DBtype
== 'mysql') {
1070 if( version_compare( $myver, "4.0.14" ) < 0 ) {
1072 dieout( "-- mysql 4.0.14 or later required. Aborting." );
1074 $mysqlNewAuth = version_compare( $myver, "4.1.0", "ge" );
1075 if( $mysqlNewAuth && $mysqlOldClient ) {
1076 print "; <b class='error'>You are using MySQL 4.1 server, but PHP is linked
1077 to old client libraries; if you have trouble with authentication, see
1078 <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
1079 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>";
1082 if( $mysqlNewAuth ) {
1083 print "; enabling MySQL 4.1/5.0 charset mode";
1085 print "; <b class='error'>MySQL 4.1/5.0 charset mode enabled,
1086 but older version detected; will likely fail.</b>";
1091 @$sel = $wgDatabase->selectDB( $wgDBname );
1093 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
1095 $err = mysql_errno();
1096 $databaseSafe = htmlspecialchars( $wgDBname );
1097 if( $err == 1102 /* Invalid database name */ ) {
1098 print "<ul><li><strong>{$databaseSafe}</strong> is not a valid database name.</li></ul>";
1100 } elseif( $err != 1049 /* Database doesn't exist */ ) {
1101 print "<ul><li>Error selecting database <strong>{$databaseSafe}</strong>: {$err} ";
1102 print htmlspecialchars( mysql_error() ) . "</li></ul>";
1105 print "<li>Attempting to create database...</li>";
1106 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
1108 print "<li>Couldn't create database <tt>" .
1109 htmlspecialchars( $wgDBname ) .
1110 "</tt>; try with root access or check your username/pass.</li>\n";
1111 $errs["RootPW"] = "<- Enter";
1114 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
1116 $wgDatabase->selectDB( $wgDBname );
1118 else if ($conf->DBtype
== 'postgres') {
1119 if( version_compare( $myver, "8.0" ) < 0 ) {
1120 dieout( "<b>Postgres 8.0 or later is required</b>. Aborting." );
1124 if( $wgDatabase->tableExists( "cur" ) ||
$wgDatabase->tableExists( "revision" ) ) {
1125 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n";
1127 if ( $conf->DBtype
== 'mysql') {
1128 # Determine existing default character set
1129 if ( $wgDatabase->tableExists( "revision" ) ) {
1130 $revision = $wgDatabase->escapeLike( $conf->DBprefix
. 'revision' );
1131 $res = $wgDatabase->query( "SHOW TABLE STATUS LIKE '$revision'" );
1132 $row = $wgDatabase->fetchObject( $res );
1134 echo "<li>SHOW TABLE STATUS query failed!</li>\n";
1135 $existingSchema = false;
1136 $existingEngine = false;
1138 if ( preg_match( '/^latin1/', $row->Collation
) ) {
1139 $existingSchema = 'mysql4';
1140 } elseif ( preg_match( '/^utf8/', $row->Collation
) ) {
1141 $existingSchema = 'mysql5';
1142 } elseif ( preg_match( '/^binary/', $row->Collation
) ) {
1143 $existingSchema = 'mysql5-binary';
1145 $existingSchema = false;
1146 echo "<li><strong>Warning:</strong> Unrecognised existing collation</li>\n";
1148 if ( isset( $row->Engine
) ) {
1149 $existingEngine = $row->Engine
;
1151 $existingEngine = $row->Type
;
1154 if ( $existingSchema && $existingSchema != $conf->DBschema
) {
1155 $encExisting = htmlspecialchars( $existingSchema );
1156 $encRequested = htmlspecialchars( $conf->DBschema
);
1157 print "<li><strong>Warning:</strong> you requested the $encRequested schema, " .
1158 "but the existing database has the $encExisting schema. This upgrade script ".
1159 "can't convert it, so it will remain $encExisting.</li>\n";
1160 $conf->setSchema( $existingSchema, $conf->DBengine
);
1162 if ( $existingEngine && $existingEngine != $conf->DBengine
) {
1163 $encExisting = htmlspecialchars( $existingEngine );
1164 $encRequested = htmlspecialchars( $conf->DBengine
);
1165 print "<li><strong>Warning:</strong> you requested the $encRequested storage " .
1166 "engine, but the existing database uses the $encExisting engine. This upgrade " .
1167 "script can't convert it, so it will remain $encExisting.</li>\n";
1168 $conf->setSchema( $conf->DBschema
, $existingEngine );
1172 # Create user if required
1173 if ( $conf->Root
) {
1174 $conn = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
1175 if ( $conn->isOpen() ) {
1176 print "<li>DB user account ok</li>\n";
1179 print "<li>Granting user permissions...";
1180 if( $mysqlOldClient && $mysqlNewAuth ) {
1181 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>";
1184 $res = $wgDatabase->sourceFile( "../maintenance/users.sql" );
1185 if ($res !== true) dieout($res);
1189 print "</ul><pre>\n";
1195 print "<ul><li>Finished update checks.</li>\n";
1196 // if tables don't yet exist
1198 # Determine available storage engines if possible
1199 if ( $conf->DBtype
== 'mysql' && version_compare( $myver, "4.1.2", "ge" ) ) {
1200 $res = $wgDatabase->query( 'SHOW ENGINES' );
1202 while ( $row = $wgDatabase->fetchObject( $res ) ) {
1203 if ( $row->Engine
== $conf->DBengine
&& ( $row->Support
== 'YES' ||
$row->Support
== 'DEFAULT' ) ) {
1208 $wgDatabase->freeResult( $res );
1209 if ( !$found && $conf->DBengine
!= 'MyISAM' ) {
1210 echo "<li><strong>Warning:</strong> " . htmlspecialchars( $conf->DBengine
) .
1211 " storage engine not available, " .
1212 "using MyISAM instead</li>\n";
1213 $conf->setSchema( $conf->DBschema
, 'MyISAM' );
1217 print "<li>Creating tables...";
1218 if ($conf->DBtype
== 'mysql') {
1219 $res = $wgDatabase->sourceFile( "../maintenance/tables.sql" );
1220 if ($res === true) {
1221 print " done.</li>\n<li>Populating interwiki table... \n";
1222 $res = $wgDatabase->sourceFile( "../maintenance/interwiki.sql" );
1224 if ($res === true) {
1225 print " done.</li>\n";
1227 print " <b>FAILED</b></li>\n";
1228 dieout( htmlspecialchars( $res ) );
1230 } elseif (is_callable(array($wgDatabase, 'setup_database'))) {
1231 $wgDatabase->setup_database();
1234 $errs["DBtype"] = "Do not know how to handle database type '$conf->DBtype'";
1239 if ( $conf->DBtype
== 'ibm_db2' ) {
1240 // Now that table creation is done, make sure everything is committed
1241 // Do this before doing inserts through API
1242 if ($wgDatabase->lastError()) {
1243 print "<li>Errors encountered during table creation -- rolled back</li>\n";
1244 $wgDatabase->rollback();
1247 print "<li>MediaWiki tables successfully created</li>\n";
1248 $wgDatabase->commit();
1250 } elseif ( $conf->DBtype
== 'sqlite' ) {
1251 // Ensure proper searchindex format. We have to do that separately because
1252 // if SQLite is compiled without the FTS3 module, table creation syntax will be invalid.
1253 sqlite_setup_searchindex();
1256 print "<li>Initializing statistics...</li>\n";
1257 $wgDatabase->insert( 'site_stats',
1258 array ( 'ss_row_id' => 1,
1259 'ss_total_views' => 0,
1260 'ss_total_edits' => 1, # Main page first edit
1261 'ss_good_articles' => 0, # Main page is not a good article - no internal link
1262 'ss_total_pages' => 1, # Main page
1263 'ss_users' => $conf->SysopName ?
1 : 0, # Sysop account, if created
1264 'ss_admins' => $conf->SysopName ?
1 : 0, # Sysop account, if created
1265 'ss_images' => 0 ) );
1267 # Set up the "regular user" account *if we can, and if we need to*
1268 if( $conf->Root
and $conf->DBtype
== 'mysql') {
1270 $wgDatabase2 = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
1271 if( $wgDatabase2->isOpen() ) {
1272 # Nope, just close the test connection and continue
1273 $wgDatabase2->close();
1274 echo( "<li>User " . htmlspecialchars( $wgDBuser ) . " exists. Skipping grants.</li>\n" );
1276 # Yes, so run the grants
1277 echo( "<li>" . htmlspecialchars( "Granting user permissions to $wgDBuser on $wgDBname..." ) );
1278 $res = $wgDatabase->sourceFile( "../maintenance/users.sql" );
1279 if ( $res === true ) {
1280 echo( " success.</li>\n" );
1282 echo( " <b>FAILED</b>.</li>\n" );
1288 if( $conf->SysopName
) {
1289 $u = User
::newFromName( $conf->getSysopName() );
1291 print "<li><strong class=\"error\">Warning:</strong> Skipped sysop account creation - invalid username!</li>\n";
1293 else if ( 0 == $u->idForName() ) {
1294 $u->addToDatabase();
1295 $u->setPassword( $conf->getSysopPass() );
1298 $u->addGroup( "sysop" );
1299 $u->addGroup( "bureaucrat" );
1301 print "<li>Created sysop account <tt>" .
1302 htmlspecialchars( $conf->SysopName
) . "</tt>.</li>\n";
1304 print "<li>Could not create user - already exists!</li>\n";
1307 print "<li>Skipped sysop account creation, no name given.</li>\n";
1310 $titleobj = Title
::newFromText( wfMsgNoDB( "mainpage" ) );
1311 $article = new Article( $titleobj );
1312 $newid = $article->insertOn( $wgDatabase );
1313 $revision = new Revision( array(
1315 'text' => wfMsg( 'mainpagetext' ) . "\n\n" . wfMsgNoTrans( 'mainpagedocfooter' ),
1318 'user_text' => 'MediaWiki default',
1320 $revid = $revision->insertOn( $wgDatabase );
1321 $article->updateRevisionOn( $wgDatabase, $revision );
1324 /* Write out the config file now that all is well */
1325 print "<li style=\"list-style: none\">\n";
1326 print "<p>Creating LocalSettings.php...</p>\n\n";
1327 $localSettings = "<" . "?php$endl$local";
1328 // Fix up a common line-ending problem (due to CVS on Windows)
1329 $localSettings = str_replace( "\r\n", "\n", $localSettings );
1330 $f = fopen( "LocalSettings.php", 'xt' );
1334 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" .
1335 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
1336 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
1338 if(fwrite( $f, $localSettings ) ) {
1341 writeSuccessMessage();
1345 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" );
1352 $mainListOpened = false;
1354 if( count( $errs ) ) {
1355 /* Display options form */
1357 if( $conf->posted
) {
1358 echo "<p class='error-top'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
1362 <form action
="<?php echo defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php'; ?>" name
="config" method
="post">
1364 <h2
>Site config
</h2
>
1366 <div
class="config-section">
1367 <div
class="config-input">
1368 <?php
aField( $conf, "Sitename", "Wiki name:" ); ?
>
1370 <p
class="config-desc">
1371 Preferably a short word without punctuation
, i
.e
. "Wikipedia".<br
/>
1372 Will appear
as the
namespace name
for "meta" pages
, and throughout the
interface.
1374 <div
class="config-input"><?php
aField( $conf, "EmergencyContact", "Contact e-mail:" ); ?
></div
>
1375 <p
class="config-desc">
1376 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
.
1379 <div
class="config-input">
1380 <label
class='column' for="LanguageCode">Language
:</label
>
1381 <select id
="LanguageCode" name
="LanguageCode"><?php
1382 $list = getLanguageList();
1383 foreach( $list as $code => $name ) {
1384 $sel = ($code == $conf->LanguageCode
) ?
'selected="selected"' : '';
1385 $encCode = htmlspecialchars( $code );
1386 $encName = htmlspecialchars( $name );
1387 echo "\n\t\t<option value=\"$encCode\" $sel>$encName</option>";
1393 <p
class="config-desc">
1394 Select the language
for your wiki
's interface. Some localizations aren't fully complete
. Unicode (UTF
-8) is used
for all localizations
.
1397 <div
class="config-input">
1398 <label
class='column'>Copyright
/license
:</label
>
1401 <li
><?php
aField( $conf, "License", "No license metadata", "radio", "none" ); ?
></li
>
1402 <li
><?php
aField( $conf, "License", "Public Domain", "radio", "pd" ); ?
></li
>
1403 <li
><?php
aField( $conf, "License", "GNU Free Documentation License 1.2", "radio", "gfdl1_2" ); ?
></li
>
1404 <li
><?php
aField( $conf, "License", "GNU Free Documentation License 1.3", "radio", "gfdl1_3" ); ?
></li
>
1406 aField( $conf, "License", "A Creative Commons license - ", "radio", "cc" );
1407 $partner = "MediaWiki";
1408 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
1409 $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/$script?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
1410 $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" );
1411 $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" );
1412 print "<a href=\"$ccApp\" target='_blank'>choose</a>";
1413 if( $conf->License
== "cc" ) { ?
>
1415 <li
><?php
aField( $conf, "RightsIcon", "<img src=\"" . htmlspecialchars( $conf->RightsIcon
) . "\" alt='(Creative Commons icon)' />", "hidden" ); ?
></li
>
1416 <li
><?php
aField( $conf, "RightsText", htmlspecialchars( $conf->RightsText
), "hidden" ); ?
></li
>
1417 <li
><?php
aField( $conf, "RightsCode", "code: " . htmlspecialchars( $conf->RightsCode
), "hidden" ); ?
></li
>
1418 <li
><?php
aField( $conf, "RightsUrl", "<a href=\"" . htmlspecialchars( $conf->RightsUrl
) . "\">" . htmlspecialchars( $conf->RightsUrl
) . "</a>", "hidden" ); ?
></li
>
1424 <p
class="config-desc">
1425 A notice
, icon
, and machine
-readable copyright metadata will be displayed
for the license you pick
.
1429 <div
class="config-input">
1430 <?php
aField( $conf, "SysopName", "Admin username:" ) ?
>
1432 <div
class="config-input">
1433 <?php
aField( $conf, "SysopPass", "Password:", "password" ) ?
>
1435 <div
class="config-input">
1436 <?php
aField( $conf, "SysopPass2", "Password confirm:", "password" ) ?
>
1438 <p
class="config-desc">
1439 An admin can lock
/delete pages
, block users from editing
, and do other maintenance tasks
.<br
/>
1440 A
new account will be added only when creating a
new wiki database
.
1442 The password cannot be the same
as the username
.
1445 <div
class="config-input">
1446 <label
class='column'>Object caching
:</label
>
1449 <li
><?php
aField( $conf, "Shm", "No caching", "radio", "none" ); ?
></li
>
1451 if( $conf->xcache
) {
1453 aField( $conf, 'Shm', 'XCache', 'radio', 'xcache' );
1458 aField( $conf, "Shm", "APC", "radio", "apc" );
1461 if ( $conf->eaccel
) {
1463 aField( $conf, "Shm", "eAccelerator", "radio", "eaccel" );
1468 aField( $conf, "Shm", "DBA (not recommended)", "radio", "dba" );
1472 <li
><?php
aField( $conf, "Shm", "Memcached", "radio", "memcached" ); ?
></li
>
1474 <div style
="clear:left"><?php
aField( $conf, "MCServers", "Memcached servers:", "text" ) ?
></div
>
1476 <p
class="config-desc">
1477 An
object caching system such
as memcached will provide a significant performance boost
,
1478 but needs to be installed
. Provide the server addresses
and ports in a comma
-separated
list.
1480 MediaWiki can also detect
and support eAccelerator
, APC
, and XCache
, but
1481 these should not be used
if the wiki will be running on multiple application servers
.
1483 DBA (Berkeley
-style DB
) is generally slower than using no cache at all
, and is only
1484 recommended
for testing
.
1488 <h2
>E
-mail
, e
-mail notification
and authentication setup
</h2
>
1490 <div
class="config-section">
1491 <div
class="config-input">
1492 <label
class='column'>E
-mail
features (global):</label
>
1494 <li
><?php
aField( $conf, "Email", "Enabled", "radio", "email_enabled" ); ?
></li
>
1495 <li
><?php
aField( $conf, "Email", "Disabled", "radio", "email_disabled" ); ?
></li
>
1498 <p
class="config-desc">
1499 Use this to disable all e
-mail
functions (password reminders
, user
-to
-user e
-mail
, and e
-mail notifications
)
1500 if sending mail doesn
't work on your server.
1503 <div class="config-input">
1504 <label class='column
'>User-to-user e-mail:</label>
1506 <li><?php aField( $conf, "Emailuser", "Enabled", "radio", "emailuser_enabled" ); ?></li>
1507 <li><?php aField( $conf, "Emailuser", "Disabled", "radio", "emailuser_disabled" ); ?></li>
1510 <p class="config-desc">
1511 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.
1513 <div class="config-input">
1514 <label class='column
'>E-mail notification about changes:</label>
1516 <li><?php aField( $conf, "Enotif", "Disabled", "radio", "enotif_disabled" ); ?></li>
1517 <li><?php aField( $conf, "Enotif", "Changes to user discussion pages only", "radio", "enotif_usertalk" ); ?></li>
1518 <li><?php aField( $conf, "Enotif", "Changes to user discussion pages, and to pages on watchlists (not recommended for large wikis)", "radio", "enotif_allpages" ); ?></li>
1521 <div class="config-desc">
1523 For this feature to work, an e-mail address must be present for the user account, and the notification
1524 options in the user's preferences must be enabled
. Also note the
1525 authentication option below
. When testing the feature
, keep in mind that your own changes will never trigger notifications to be sent to yourself
.</p
>
1527 <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
>
1530 <div
class="config-input">
1531 <label
class='column'>E
-mail address authentication
:</label
>
1533 <li
><?php
aField( $conf, "Eauthent", "Disabled", "radio", "eauthent_disabled" ); ?
></li
>
1534 <li
><?php
aField( $conf, "Eauthent", "Enabled", "radio", "eauthent_enabled" ); ?
></li
>
1537 <div
class="config-desc">
1538 <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
1539 change notification mails
. Setting this option is
<b
>recommended
</b
> for public wikis because of potential abuse of the e
-mail features above
.</p
>
1544 <h2
>Database config
</h2
>
1546 <div
class="config-section">
1547 <div
class="config-input">
1548 <label
class='column'>Database type
:</label
>
1550 if (isset($errs['DBpicktype'])) {
1551 print "\t<span class='error'>" . htmlspecialchars( $errs['DBpicktype'] ) . "</span>\n";
1554 <ul
class='plain'><?php
1555 database_picker($conf);
1559 <div id
="db-server-settings1">
1560 <div
class="config-input" style
="clear:left">
1561 <?php
aField( $conf, "DBserver", "Database host:" ); ?
>
1563 <p
class="config-desc">
1564 If your database server isn
't on your web server, enter the name or IP address here.
1568 <div class="config-input"><?php aField( $conf, "DBname", "Database name:" ); ?></div>
1569 <div id="db-server-settings2">
1570 <div class="config-input"><?php aField( $conf, "DBuser", "DB username:" ); ?></div>
1571 <div class="config-input"><?php aField( $conf, "DBpassword", "DB password:", "password" ); ?></div>
1572 <div class="config-input"><?php aField( $conf, "DBpassword2", "DB password confirm:", "password" ); ?></div>
1573 <p class="config-desc">
1574 If you only have a single user account and database available,
1575 enter those here. If you have database root access (see below)
1576 you can specify new accounts/databases to be created. This account
1577 will not be created if it pre-exists. If this is the case, ensure that it
1578 has SELECT, INSERT, UPDATE, and DELETE permissions on the MediaWiki database.
1581 <div class="config-input">
1582 <label class="column">Superuser account:</label>
1583 <input type="checkbox" name="useroot" id="useroot" <?php if( $useRoot ) { ?>checked="checked" <?php } ?> />
1584  <label for="useroot">Use superuser account</label>
1586 <div class="config-input"><?php aField( $conf, "RootUser", "Superuser name:", "text" ); ?></div>
1587 <div class="config-input"><?php aField( $conf, "RootPW", "Superuser password:", "password" ); ?></div>
1589 <p class="config-desc">
1590 If the database user specified above does not exist, or does not have access to create
1591 the database (if needed) or tables within it, please check the box and provide details
1592 of a superuser account, such as <strong>root</strong>, which does.
1596 <?php database_switcher('mysql
'); ?>
1597 <div class="config-input"><?php aField( $conf, "DBprefix", "Database table prefix:" ); ?></div>
1598 <div class="config-desc">
1599 <p>If you need to share one database between multiple wikis, or
1600 between MediaWiki and another web application, you may choose to
1601 add a prefix to all the table names to avoid conflicts.</p>
1603 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
1606 <div class="config-input"><label class="column">Storage Engine</label>
1607 <div>Select one:</div>
1609 <li><?php aField( $conf, "DBengine", "InnoDB", "radio", "InnoDB" ); ?></li>
1610 <li><?php aField( $conf, "DBengine", "MyISAM", "radio", "MyISAM" ); ?></li>
1613 <p class="config-desc">
1614 InnoDB is best for public web installations, since it has good concurrency
1615 support. MyISAM may be faster in single-user installations. MyISAM databases
1616 tend to get corrupted more often than InnoDB databases.
1618 <div class="config-input"><label class="column">Database character set</label>
1619 <div>Select one:</div>
1621 <li><?php aField( $conf, "DBschema", "MySQL 4.1/5.0 binary", "radio", "mysql5-binary" ); ?></li>
1622 <li><?php aField( $conf, "DBschema", "MySQL 4.1/5.0 UTF-8", "radio", "mysql5" ); ?></li>
1623 <li><?php aField( $conf, "DBschema", "MySQL 4.0 backwards-compatible UTF-8", "radio", "mysql4" ); ?></li>
1626 <p class="config-desc">
1627 This option is ignored on upgrade, the same character set will be kept.
1629 <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!.
1631 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>.
1635 <?php database_switcher('postgres
'); ?>
1636 <div class="config-input"><?php aField( $conf, "DBport", "Database port:" ); ?></div>
1637 <div class="config-input"><?php aField( $conf, "DBpgschema", "Schema for mediawiki:" ); ?></div>
1638 <div class="config-input"><?php aField( $conf, "DBts2schema", "Schema for tsearch2:" ); ?></div>
1639 <div class="config-desc">
1640 <p>The username specified above (at "DB username") will have its search path set to the above schemas,
1641 so it is recommended that you create a new user. The above schemas are generally correct:
1642 only change them if you are sure you need to.</p>
1646 <?php database_switcher('sqlite
'); ?>
1647 <div class="config-input"><?php
1648 aField( $conf, "SQLiteDataDir", "SQLite data directory:" );
1650 <div class="config-desc">
1651 <p>SQLite stores table data into files in the
1654 <p>This directory must exist and be writable by the web server.</p>
1658 <?php database_switcher('ibm_db2
'); ?>
1659 <div class="config-input"><?php
1660 aField( $conf, "DBport_db2", "Database port:" );
1662 <div class="config-input"><?php
1663 aField( $conf, "DBdb2schema", "Schema for mediawiki:" );
1665 <div>Select one:</div>
1667 <li><?php aField( $conf, "DBcataloged", "Cataloged (DB2 installed locally)", "radio", "cataloged" ); ?></li>
1668 <li><?php aField( $conf, "DBcataloged", "Uncataloged (remote DB2 through ODBC)", "radio", "uncataloged" ); ?></li>
1670 <div class="config-desc">
1671 <p>If you need to share one database between multiple wikis, or
1672 between MediaWiki and another web application, you may specify
1673 a different schema to avoid conflicts.</p>
1677 <?php database_switcher('oracle
'); ?>
1678 <div class="config-input"><?php aField( $conf, "DBprefix_ora", "Database table prefix:" ); ?></div>
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>
1686 <div class="config-input"><?php aField( $conf, "DBdefTS_ora", "Default tablespace:" ); ?></div>
1687 <div class="config-input"><?php aField( $conf, "DBtempTS_ora", "Temporary tablespace:" ); ?></div>
1690 <div class="config-input" style="padding:2em 0 3em">
1691 <label class='column
'> </label>
1692 <input type="submit" value="Install MediaWiki!" class="btn-install" />
1696 <script type="text/javascript">
1697 window.onload = toggleDBarea( <?php echo Xml::encodeJsVar( $conf->DBtype ); ?>,
1699 ## If they passed in a root user name, don't populate it on page load
1700 echo strlen(importPost('RootUser', '')) ?
0 : 1;
1706 /* -------------------------------------------------------------------------------------- */
1707 function writeSuccessMessage() {
1708 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
1709 if ( wfIniGetBool( 'safe_mode' ) && !ini_get( 'open_basedir' ) ) {
1711 <div class="success-box">
1712 <p>Installation successful!</p>
1713 <p>To complete the installation, please do the following:
1715 <li>Download config/LocalSettings.php with your FTP client or file manager</li>
1716 <li>Upload it to the parent directory</li>
1717 <li>Delete config/LocalSettings.php</li>
1718 <li>Start using <a href='../$script'>your wiki</a>!
1720 <p>If you are in a shared hosting environment, do <strong>not</strong> just move LocalSettings.php
1721 remotely. LocalSettings.php is currently owned by the user your webserver is running under,
1722 which means that anyone on the same server can read your database password! Downloading
1723 it and uploading it again will hopefully change the ownership to a user ID specific to you.</p>
1728 <div class="success-box">
1730 <span class="success-message">Installation successful!</span>
1731 Move the <tt>config/LocalSettings.php</tt> file to the parent directory, then follow
1732 <a href="../$script"> this link</a> to your wiki.</p>
1733 <p>You should change file permissions for <tt>LocalSettings.php</tt> as required to
1734 prevent other users on the server reading passwords and altering configuration data.</p>
1741 function escapePhpString( $string ) {
1742 if ( is_array( $string ) ||
is_object( $string ) ) {
1745 return strtr( $string,
1756 function writeLocalSettings( $conf ) {
1757 $conf->PasswordSender
= $conf->EmergencyContact
;
1758 $magic = ($conf->ImageMagick ?
"" : "# ");
1759 $convert = ($conf->ImageMagick ?
$conf->ImageMagick
: "/usr/bin/convert" );
1760 $rights = ($conf->RightsUrl
) ?
"" : "# ";
1761 $hashedUploads = $conf->safeMode ?
'' : '# ';
1762 $dir = realpath( $conf->SQLiteDataDir
);
1764 $dir = $conf->SQLiteDataDir
; // dumb realpath sometimes fails
1766 $sqliteDataDir = escapePhpString( $dir );
1768 if ( $conf->ShellLocale
) {
1772 $conf->ShellLocale
= 'en_US.UTF-8';
1775 switch ( $conf->Shm
) {
1777 $cacheType = 'CACHE_MEMCACHED';
1778 $mcservers = var_export( $conf->MCServerArray
, true );
1783 $cacheType = 'CACHE_ACCEL';
1784 $mcservers = 'array()';
1787 $cacheType = 'CACHE_DBA';
1788 $mcservers = 'array()';
1791 $cacheType = 'CACHE_NONE';
1792 $mcservers = 'array()';
1795 if ( $conf->Email
== 'email_enabled' ) {
1796 $enableemail = 'true';
1797 $enableuseremail = ( $conf->Emailuser
== 'emailuser_enabled' ) ?
'true' : 'false' ;
1798 $eauthent = ( $conf->Eauthent
== 'eauthent_enabled' ) ?
'true' : 'false' ;
1799 switch ( $conf->Enotif
) {
1800 case 'enotif_usertalk':
1801 $enotifusertalk = 'true';
1802 $enotifwatchlist = 'false';
1804 case 'enotif_allpages':
1805 $enotifusertalk = 'true';
1806 $enotifwatchlist = 'true';
1809 $enotifusertalk = 'false';
1810 $enotifwatchlist = 'false';
1813 $enableuseremail = 'false';
1814 $enableemail = 'false';
1815 $eauthent = 'false';
1816 $enotifusertalk = 'false';
1817 $enotifwatchlist = 'false';
1820 $file = @fopen
( "/dev/urandom", "r" );
1822 $secretKey = bin2hex( fread( $file, 32 ) );
1826 for ( $i=0; $i<8; $i++
) {
1827 $secretKey .= dechex(mt_rand(0, 0x7fffffff));
1829 print "<li>Warning: \$wgSecretKey key is insecure, generated with mt_rand(). Consider changing it manually.</li>\n";
1832 # Add slashes to strings for double quoting
1833 $slconf = wfArrayMap( "escapePhpString", get_object_vars( $conf ) );
1834 if( $conf->License
== 'gfdl1_2' ||
$conf->License
== 'pd' ||
$conf->License
== 'gfdl1_3' ) {
1835 # Needs literal string interpolation for the current style path
1836 $slconf['RightsIcon'] = $conf->RightsIcon
;
1839 if( $conf->DBtype
== 'mysql' ) {
1841 "# MySQL specific settings
1842 \$wgDBprefix = \"{$slconf['DBprefix']}\";
1844 # MySQL table options to use during installation or update
1845 \$wgDBTableOptions = \"{$slconf['DBTableOptions']}\";
1847 # Experimental charset support for MySQL 4.1/5.0.
1848 \$wgDBmysql5 = {$conf->DBmysql5};";
1849 } elseif( $conf->DBtype
== 'postgres' ) {
1851 "# Postgres specific settings
1852 \$wgDBport = \"{$slconf['DBport']}\";
1853 \$wgDBmwschema = \"{$slconf['DBpgschema']}\";
1854 \$wgDBts2schema = \"{$slconf['DBts2schema']}\";";
1855 } elseif( $conf->DBtype
== 'sqlite' ) {
1857 "# SQLite-specific settings
1858 \$wgSQLiteDataDir = \"{$sqliteDataDir}\";";
1859 } elseif( $conf->DBtype
== 'ibm_db2' ) {
1861 "# DB2 specific settings
1862 \$wgDBport = \"{$slconf['DBport_db2']}\";
1863 \$wgDBmwschema = \"{$slconf['DBdb2schema']}\";
1864 \$wgDBcataloged = \"{$slconf['DBcataloged']}\";";
1865 } elseif( $conf->DBtype
== 'oracle' ) {
1867 "# Oracle specific settings
1868 \$wgDBprefix = \"{$slconf['DBprefix_ora']}\";";
1876 # This file was automatically generated by the MediaWiki installer.
1877 # If you make manual changes, please keep track in case you need to
1878 # recreate them later.
1880 # See includes/DefaultSettings.php for all configurable settings
1881 # and their default values, but don't forget to make changes in _this_
1884 # Further documentation for configuration settings may be found at:
1885 # http://www.mediawiki.org/wiki/Manual:Configuration_settings
1887 # If you customize your file layout, set \$IP to the directory that contains
1888 # the other MediaWiki files. It will be used as a base to locate files.
1889 if( defined( 'MW_INSTALL_PATH' ) ) {
1890 \$IP = MW_INSTALL_PATH;
1892 \$IP = dirname( __FILE__ );
1895 \$path = array( \$IP, \"\$IP/includes\", \"\$IP/languages\" );
1896 set_include_path( implode( PATH_SEPARATOR, \$path ) . PATH_SEPARATOR . get_include_path() );
1898 require_once( \"\$IP/includes/DefaultSettings.php\" );
1900 if ( \$wgCommandLineMode ) {
1901 if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
1902 die( \"This script must be run from the command line\\n\" );
1905 ## Uncomment this to disable output compression
1906 # \$wgDisableOutputCompression = true;
1908 \$wgSitename = \"{$slconf['Sitename']}\";
1910 ## The URL base path to the directory containing the wiki;
1911 ## defaults for all runtime URL paths are based off of this.
1912 ## For more information on customizing the URLs please see:
1913 ## http://www.mediawiki.org/wiki/Manual:Short_URL
1914 \$wgScriptPath = \"{$slconf['ScriptPath']}\";
1915 \$wgScriptExtension = \"{$slconf['ScriptExtension']}\";
1917 ## The relative URL path to the skins directory
1918 \$wgStylePath = \"\$wgScriptPath/skins\";
1920 ## The relative URL path to the logo. Make sure you change this from the default,
1921 ## or else you'll overwrite your logo when you upgrade!
1922 \$wgLogo = \"\$wgStylePath/common/images/wiki.png\";
1924 ## UPO means: this is also a user preference option
1926 \$wgEnableEmail = $enableemail;
1927 \$wgEnableUserEmail = $enableuseremail; # UPO
1929 \$wgEmergencyContact = \"{$slconf['EmergencyContact']}\";
1930 \$wgPasswordSender = \"{$slconf['PasswordSender']}\";
1932 \$wgEnotifUserTalk = $enotifusertalk; # UPO
1933 \$wgEnotifWatchlist = $enotifwatchlist; # UPO
1934 \$wgEmailAuthentication = $eauthent;
1936 ## Database settings
1937 \$wgDBtype = \"{$slconf['DBtype']}\";
1938 \$wgDBserver = \"{$slconf['DBserver']}\";
1939 \$wgDBname = \"{$slconf['DBname']}\";
1940 \$wgDBuser = \"{$slconf['DBuser']}\";
1941 \$wgDBpassword = \"{$slconf['DBpassword']}\";
1945 ## Shared memory settings
1946 \$wgMainCacheType = $cacheType;
1947 \$wgMemCachedServers = $mcservers;
1949 ## To enable image uploads, make sure the 'images' directory
1950 ## is writable, then set this to true:
1951 \$wgEnableUploads = false;
1952 {$magic}\$wgUseImageMagick = true;
1953 {$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
1955 ## If you use ImageMagick (or any other shell command) on a
1956 ## Linux server, this will need to be set to the name of an
1957 ## available UTF-8 locale
1958 {$locale}\$wgShellLocale = \"{$slconf['ShellLocale']}\";
1960 ## If you want to use image uploads under safe mode,
1961 ## create the directories images/archive, images/thumb and
1962 ## images/temp, and make them all writable. Then uncomment
1963 ## this, if it's not already uncommented:
1964 {$hashedUploads}\$wgHashedUploadDirectory = false;
1966 ## If you have the appropriate support software installed
1967 ## you can enable inline LaTeX equations:
1970 ## Set \$wgCacheDirectory to a writable directory on the web server
1971 ## to make your wiki go slightly faster. The directory should not
1972 ## be publically accessible from the web.
1973 #\$wgCacheDirectory = \"\$IP/cache\";
1975 \$wgLocalInterwiki = strtolower( \$wgSitename );
1977 \$wgLanguageCode = \"{$slconf['LanguageCode']}\";
1979 \$wgSecretKey = \"$secretKey\";
1981 ## Default skin: you can change the default skin. Use the internal symbolic
1982 ## names, ie 'vector', 'monobook':
1983 \$wgDefaultSkin = 'monobook';
1985 ## For attaching licensing metadata to pages, and displaying an
1986 ## appropriate copyright notice / icon. GNU Free Documentation
1987 ## License and Creative Commons licenses are supported so far.
1988 {$rights}\$wgEnableCreativeCommonsRdf = true;
1989 \$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright
1990 \$wgRightsUrl = \"{$slconf['RightsUrl']}\";
1991 \$wgRightsText = \"{$slconf['RightsText']}\";
1992 \$wgRightsIcon = \"{$slconf['RightsIcon']}\";
1993 # \$wgRightsCode = \"{$slconf['RightsCode']}\"; # Not yet used
1995 \$wgDiff3 = \"{$slconf['diff3']}\";
1997 # When you make changes to this configuration file, this will make
1998 # sure that cached pages are cleared.
1999 \$wgCacheEpoch = max( \$wgCacheEpoch, gmdate( 'YmdHis', @filemtime( __FILE__ ) ) );
2000 "; ## End of setting the $localsettings string
2002 // Keep things in Unix line endings internally;
2003 // the system will write out as local text type.
2004 return str_replace( "\r\n", "\n", $localsettings );
2007 function dieout( $text ) {
2008 global $mainListOpened;
2009 if( $mainListOpened ) echo( "</ul>" );
2010 if( $text != '' && substr( $text, 0, 2 ) != '<p' && substr( $text, 0, 2 ) != '<h' ){
2011 echo "<p>$text</p>\n";
2015 die( "\n\n</div>\n</div>\n</div>\n</div>\n</body>\n</html>" );
2018 function importVar( &$var, $name, $default = "" ) {
2019 if( isset( $var[$name] ) ) {
2020 $retval = $var[$name];
2021 if ( get_magic_quotes_gpc() ) {
2022 $retval = stripslashes( $retval );
2031 function importPost( $name, $default = "" ) {
2032 return importVar( $_POST, $name, $default );
2035 function importCheck( $name ) {
2036 return isset( $_POST[$name] );
2039 function importRequest( $name, $default = "" ) {
2040 return importVar( $_REQUEST, $name, $default );
2043 function aField( &$conf, $field, $text, $type = "text", $value = "", $onclick = '' ) {
2044 static $radioCount = 0;
2046 $xtype = "type=\"$type\"";
2052 $nolabel = ($type == "radio") ||
($type == "hidden");
2054 if ($type == 'radio')
2055 $id .= $radioCount++
;
2058 echo "<label class='column' for=\"$id\">$text</label>";
2061 if( $type == "radio" && $value == $conf->$field ) {
2062 $checked = "checked='checked'";
2066 echo "<input $xtype name=\"$field\" id=\"$id\" class=\"iput-$type\" $checked ";
2068 echo " onclick='toggleDBarea(\"$value\",1)' " ;
2071 if( $type == "radio" ) {
2072 echo htmlspecialchars( $value );
2074 echo htmlspecialchars( $conf->$field );
2080 echo "<label for=\"$id\">$text</label>";
2084 if(isset($errs[$field])) {
2085 echo "<span class='error'>" . htmlspecialchars( $errs[$field] ) . "</span>\n";
2089 function getLanguageList() {
2090 global $wgDummyLanguageCodes;
2093 foreach ( Language
::getLanguageNames() as $code => $name ) {
2094 if( in_array( $code, $wgDummyLanguageCodes ) ) continue;
2095 $codes[$code] = $code . ' - ' . $name;
2101 #Check for location of an executable
2102 # @param string $loc single location to check
2103 # @param array $names filenames to check for.
2104 # @param mixed $versioninfo array of details to use when checking version, use false for no version checking
2105 function locate_executable($loc, $names, $versioninfo = false) {
2106 if (!is_array($names))
2107 $names = array($names);
2109 foreach ($names as $name) {
2110 $command = "$loc".DIRECTORY_SEPARATOR
."$name";
2111 if (@file_exists
($command)) {
2115 $file = str_replace('$1', $command, $versioninfo[0]);
2116 if (strstr(`
$file`
, $versioninfo[1]) !== false)
2123 # Test a memcached server
2124 function testMemcachedServer( $server ) {
2125 $hostport = explode(":", $server);
2128 if ( !function_exists( 'fsockopen' ) ) {
2129 $errstr = "Can't connect to memcached, fsockopen() not present";
2131 if ( !$errstr && count( $hostport ) != 2 ) {
2132 $errstr = 'Please specify host and port';
2135 list( $host, $port ) = $hostport;
2139 $fp = @fsockopen
( $host, $port, $errno, $fsockerr, 1.0 );
2140 if ( $fp === false ) {
2141 $errstr = "Cannot connect to memcached on $host:$port : $fsockerr";
2145 $command = "version\r\n";
2146 $bytes = fwrite( $fp, $command );
2147 if ( $bytes != strlen( $command ) ) {
2148 $errstr = "Cannot write to memcached socket on $host:$port";
2152 $expected = "VERSION ";
2153 $response = fread( $fp, strlen( $expected ) );
2154 if ( $response != $expected ) {
2155 $errstr = "Didn't get correct memcached response from $host:$port";
2162 echo "<li>Connected to memcached on " . htmlspecialchars( "$host:$port" ) ." successfully</li>";
2167 function database_picker($conf) {
2170 foreach(array_keys($ourdb) as $db) {
2171 if ($ourdb[$db]['havedriver']) {
2173 aField( $conf, "DBtype", $ourdb[$db]['fullname'], 'radio', $db, 'onclick');
2180 function database_switcher($db) {
2182 $color = $ourdb[$db]['bgcolor'];
2183 $full = $ourdb[$db]['fullname'];
2184 print "<fieldset id='$db' style='clear:both'><legend>$full-specific options</legend>\n";
2187 function printListItem( $item ) {
2188 print "<li>$item</li>";
2191 # Determine a suitable value for $wgShellLocale
2192 function getShellLocale( $wikiLang ) {
2193 # Give up now if we're in safe mode or open_basedir
2194 # It's theoretically possible but tricky to work with
2195 if ( wfIniGetBool( "safe_mode" ) ||
ini_get( 'open_basedir' ) ||
!function_exists('exec') ) {
2199 $os = php_uname( 's' );
2200 $supported = array( 'Linux', 'SunOS', 'HP-UX' ); # Tested these
2201 if ( !in_array( $os, $supported ) ) {
2205 # Get a list of available locales
2206 $lines = $ret = false;
2207 exec( '/usr/bin/locale -a', $lines, $ret );
2212 $lines = wfArrayMap( 'trim', $lines );
2213 $candidatesByLocale = array();
2214 $candidatesByLang = array();
2215 foreach ( $lines as $line ) {
2216 if ( $line === '' ) {
2219 if ( !preg_match( '/^([a-zA-Z]+)(_[a-zA-Z]+|)\.(utf8|UTF-8)(@[a-zA-Z_]*|)$/i', $line, $m ) ) {
2222 list( $all, $lang, $territory, $charset, $modifier ) = $m;
2223 $candidatesByLocale[$m[0]] = $m;
2224 $candidatesByLang[$lang][] = $m;
2227 # Try the current value of LANG
2228 if ( isset( $candidatesByLocale[ getenv( 'LANG' ) ] ) ) {
2229 return getenv( 'LANG' );
2232 # Try the most common ones
2233 $commonLocales = array( 'en_US.UTF-8', 'en_US.utf8', 'de_DE.UTF-8', 'de_DE.utf8' );
2234 foreach ( $commonLocales as $commonLocale ) {
2235 if ( isset( $candidatesByLocale[$commonLocale] ) ) {
2236 return $commonLocale;
2240 # Is there an available locale in the Wiki's language?
2241 if ( isset( $candidatesByLang[$wikiLang] ) ) {
2242 $m = reset( $candidatesByLang[$wikiLang] );
2246 # Are there any at all?
2247 if ( count( $candidatesByLocale ) ) {
2248 $m = reset( $candidatesByLocale );
2258 <div
class="license">
2260 <p
>This program is free software
; you can redistribute it
and/or modify
2261 it under the terms of the GNU General
Public License
as published by
2262 the Free Software Foundation
; either version
2 of the License
, or
2263 (at your option
) any later version
.</p
>
2265 <p
>This program is distributed in the hope that it will be useful
,
2266 but WITHOUT ANY WARRANTY
; without even the implied warranty of
2267 MERCHANTABILITY
or FITNESS
FOR A PARTICULAR PURPOSE
. See the
2268 GNU General
Public License
for more details
.</p
>
2270 <p
>You should have received
<a href
="../COPYING">a copy of the GNU General
Public License
</a
>
2271 along with this program
; if not
, write to the Free Software
2272 Foundation
, Inc
., 51 Franklin Street
, Fifth Floor
, Boston
, MA
02110-1301, USA
.
2273 or <a href
="http://www.gnu.org/copyleft/gpl.html">read it online
</a
></p
>
2279 <div id
="column-one">
2280 <div
class="portlet" id
="p-logo">
2281 <a style
="background-image: url(../skins/common/images/mediawiki.png);"
2283 title
="Main Page"></a
>
2285 <script type
="text/javascript"> if (window
.isMSIE55
) fixalpha(); </script
>
2286 <div
class='portlet'><div
class='pBody'>
2288 <li
><a href
="../README">Readme
</a
></li
>
2289 <li
><a href
="../RELEASE-NOTES">Release notes
</a
></li
>
2290 <li
><a href
="../docs/">Documentation
</a
></li
>
2291 <li
><a href
="http://www.mediawiki.org/wiki/Help:Contents">User
's Guide</a></li>
2292 <li><a href="http://www.mediawiki.org/wiki/Manual:Contents">Administrator's Guide
</a
></li
>
2293 <li
><a href
="http://www.mediawiki.org/wiki/Manual:FAQ">FAQ
</a
></li
>
2295 <p style
="font-size:90%;margin-top:1em">MediaWiki is Copyright ©
2001-2010 by Magnus Manske
, Brion Vibber
,
2296 Lee Daniel Crocker
, Tim Starling
, Erik Möller
, Gabriel Wicke
, Æ
var Arnfjörð Bjarmason
, Niklas Laxström
,
2297 Domas Mituzas
, Rob Church
, Yuri Astrakhan
, Aryeh Gregor
, Aaron Schulz
and others
.</p
>