3 * MediaWiki web-based config/installation
5 * Copyright © 2004 Brion Vibber <brion@pobox.com>, 2006 Rob Church <robchur@gmail.com>
6 * http://www.mediawiki.org/
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 * http://www.gnu.org/copyleft/gpl.html
26 if( !defined( 'MEDIAWIKI_INSTALL' ) ) {
27 die( 'Not an entry point.' );
30 error_reporting( E_ALL | E_STRICT
);
31 header( "Content-type: text/html; charset=utf-8" );
32 @ini_set
( "display_errors", true );
34 # In case of errors, let output be clean.
35 $wgRequestTime = microtime( true );
37 // Run version checks before including other files
38 // so people don't see a scary parse error.
39 require_once( "$IP/maintenance/install-utils.inc" );
40 install_version_checks();
42 require_once( "$IP/includes/Defines.php" );
43 require_once( "$IP/includes/DefaultSettings.php" );
44 require_once( "$IP/includes/AutoLoader.php" );
45 require_once( "$IP/includes/MagicWord.php" );
46 require_once( "$IP/includes/Namespace.php" );
47 require_once( "$IP/includes/ProfilerStub.php" );
48 require_once( "$IP/includes/GlobalFunctions.php" );
49 require_once( "$IP/includes/Hooks.php" );
50 require_once( "$IP/includes/Exception.php" );
51 require_once( "$IP/includes/json/Services_JSON.php" );
52 require_once( "$IP/includes/json/FormatJson.php" );
54 # If we get an exception, the user needs to know
56 $wgShowExceptionDetails = true;
57 $wgShowSQLErrors = true;
58 wfInstallExceptionHandler();
59 ## Databases we support:
63 $ourdb['mysql'] = array(
64 'fullname' => 'MySQL',
67 'bgcolor' => '#ffe5a7',
72 $ourdb['postgres'] = array(
73 'fullname' => 'PostgreSQL',
76 'bgcolor' => '#aaccff',
77 'rootuser' => 'postgres',
81 $ourdb['sqlite'] = array(
82 'fullname' => 'SQLite',
84 'compile' => 'pdo_sqlite',
85 'bgcolor' => '#b1ebb1',
90 $ourdb['ibm_db2'] = array(
93 'compile' => 'ibm_db2',
94 'bgcolor' => '#ffeba1',
95 'rootuser' => 'db2admin',
99 $ourdb['oracle'] = array(
100 'fullname' => 'Oracle',
103 'bgcolor' => '#ffeba1',
105 'serverless' => false
109 <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
110 <html xmlns
="http://www.w3.org/1999/xhtml" lang
="en" dir
="ltr">
112 <meta http
-equiv
="Content-type" content
="text/html; charset=utf-8" />
113 <meta name
="robots" content
="noindex,nofollow"/>
114 <title
>MediaWiki
<?php
echo htmlspecialchars( $wgVersion ); ?
> Installation
</title
>
115 <style type
="text/css">
117 @import
"../skins/monobook/main.css";
121 margin
: 1em
0 1em
2.5em
;
128 .config
-section label
.column
{
140 zoom
: 100%
; /* IE hack */
143 .config
-section
.config
-desc
{
145 margin
: 0 0 2em
18em
;
150 .iput
-text
, .iput
-password
{
157 background
-color
: #fff;
165 background
-color
: #FFF0F0;
166 border
: 2px solid red
;
174 list-style
-type
: none
;
175 list-style
-image
: none
;
192 span
.success
-message
{
203 <script type
="text/javascript">
205 <?php
echo 'var databases = ' . FormatJson
::encode( $ourdb ) . ';'; ?
>
207 function show(id
, showOrHide
) {
208 var i
= document
.getElementById(id
);
209 if (i
) i
.style
.display
= showOrHide ?
'block' : 'none';
212 for (db in databases
) {
216 function toggleDBarea(id
, defaultroot
) {
218 var dbarea
= document
.getElementById(id
);
219 if (dbarea
) dbarea
.style
.display
= (dbarea
.style
.display
== 'none') ?
'block' : 'none';
220 var db
= document
.getElementById('RootUser');
221 db
.value
= databases
[id
].rootuser
;
222 show('db-server-settings1', !databases
[id
].serverless
);
223 show('db-server-settings2', !databases
[id
].serverless
);
230 <div id
="globalWrapper">
231 <div id
="column-content">
233 <div id
="bodyContent">
235 <h1
>MediaWiki
<?php
print htmlspecialchars( $wgVersion ) ?
> Installation
</h1
>
238 $mainListOpened = false; # Is the main list (environement checking) opend ? Used by dieout
240 /* Check for existing configurations and bug out! */
242 if( file_exists( "../LocalSettings.php" ) ) {
243 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
244 dieout( "<p><strong>Setup has completed, <a href='../$script'>your wiki</a> is configured.</strong></p>
245 <p>Please delete the /config directory for extra security.</p>" );
248 if( file_exists( "./LocalSettings.php" ) ) {
249 writeSuccessMessage();
253 if( !is_writable( "." ) ) {
254 dieout( "<h2>Can't write config file, aborting</h2>
256 <p>In order to configure the wiki you have to make the <tt>config</tt> subdirectory
257 writable by the web server. Once configuration is done you'll move the created
258 <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can
259 then remove the <tt>config</tt> subdirectory entirely.</p>
261 <p>To make the directory writable on a Unix/Linux system:</p>
264 cd <i>" . htmlspecialchars( dirname( dirname( __FILE__
) ) ) . "</i>
268 <p>Afterwards retry to start the <a href=\"\">setup</a>.</p>" );
272 require_once( "$IP/maintenance/updaters.inc" );
275 function getEncoded( $data ) {
276 # removing latin1 support, no need...
279 function getSitename() { return $this->getEncoded( $this->Sitename
); }
280 function getSysopName() { return $this->getEncoded( $this->SysopName
); }
281 function getSysopPass() { return $this->getEncoded( $this->SysopPass
); }
283 function setSchema( $schema, $engine ) {
284 $this->DBschema
= $schema;
285 if ( !preg_match( '/^\w*$/', $engine ) ){
288 switch ( $this->DBschema
) {
290 $this->DBTableOptions
= "ENGINE=$engine, DEFAULT CHARSET=utf8";
291 $this->DBmysql5
= 'true';
293 case 'mysql5-binary':
294 $this->DBTableOptions
= "ENGINE=$engine, DEFAULT CHARSET=binary";
295 $this->DBmysql5
= 'true';
298 $this->DBTableOptions
= "TYPE=$engine";
299 $this->DBmysql5
= 'false';
301 $this->DBengine
= $engine;
303 # Set the global for use during install
304 global $wgDBTableOptions;
305 $wgDBTableOptions = $this->DBTableOptions
;
313 <b
>Don
't forget security updates!</b> Keep an eye on the
314 <a href="http://lists.wikimedia.org/mailman/listinfo/mediawiki-announce">low-traffic
315 release announcements mailing list</a>.
320 <h2>Checking environment...</h2>
321 <p><em>Please include all of the lines below when reporting installation problems.</em></p>
322 <ul class="env-check">
324 $mainListOpened = true;
328 define( 'MW_NO_OUTPUT_BUFFER
', 1 );
329 $conf = new ConfigData;
331 install_version_checks();
332 $self = 'Installer
'; # Maintenance script name, to please Setup.php
334 print "<li>PHP " . htmlspecialchars( phpversion() ) . " installed</li>\n";
336 error_reporting( 0 );
337 $phpdatabases = array();
338 foreach (array_keys($ourdb) as $db) {
339 $compname = $ourdb[$db]['compile
'];
340 if( wfDl( $compname ) ) {
341 array_push($phpdatabases, $db);
342 $ourdb[$db]['havedriver
'] = 1;
345 error_reporting( E_ALL | E_STRICT );
347 if (!$phpdatabases) {
348 print "Could not find a suitable database driver!<ul>";
349 foreach (array_keys($ourdb) AS $db) {
350 $comp = $ourdb[$db]['compile
'];
351 $full = $ourdb[$db]['fullname
'];
352 print "<li>For <b>$full</b>, compile PHP using <b>--with-$comp</b>, "
353 ."or install the $comp.so module</li>\n";
359 print "<li>Found database drivers for:";
361 foreach (array_keys($ourdb) AS $db) {
362 if ($ourdb[$db]['havedriver
']) {
363 if ( $DefaultDBtype == '' ) {
364 $DefaultDBtype = $db;
366 print " ".$ourdb[$db]['fullname
'];
371 if( wfIniGetBool( "register_globals" ) ) {
374 <div style="font-size:110%">
375 <strong class="error">Warning:</strong>
376 <strong>PHP's
<tt
><a href
="http://php.net/register_globals">register_globals
</a
></tt
> option is enabled
. Disable it
if you can
.</strong
>
378 MediaWiki will work
, but your server is more exposed to PHP
-based security vulnerabilities
.
385 if( wfIniGetBool( "magic_quotes_runtime" ) ) {
387 ?
><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
>
388 This option corrupts data input unpredictably
; you cannot install
or use
389 MediaWiki unless this option is disabled
.</li
>
393 if( wfIniGetBool( "magic_quotes_sybase" ) ) {
395 ?
><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
>
396 This option corrupts data input unpredictably
; you cannot install
or use
397 MediaWiki unless this option is disabled
.</li
>
401 if( wfIniGetBool( "mbstring.func_overload" ) ) {
403 ?
><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
>
404 This option causes errors
and may corrupt data unpredictably
;
405 you cannot install
or use MediaWiki unless this option is disabled
.</li
>
409 if( wfIniGetBool( "zend.ze1_compatibility_mode" ) ) {
411 ?
><li
class="error"><strong
>Fatal
: <a href
="http://www.php.net/manual/en/ini.core.php">zend
.ze1_compatibility_mode
</a
> is active
!</strong
>
412 This option causes horrible bugs with MediaWiki
; you cannot install
or use
413 MediaWiki unless this option is disabled
.</li
>
418 dieout( "Cannot install MediaWiki." );
421 if( wfIniGetBool( "safe_mode" ) ) {
422 $conf->safeMode
= true;
424 <li
><b
class='error'>Warning
:</b
> <strong
>PHP
's
425 <a href='http
://www.php.net/features.safe-mode'>safe mode</a> is active.</strong>
426 You may have problems caused by this
, particularly
if using image uploads
.
430 $conf->safeMode
= false;
433 $sapi = htmlspecialchars( php_sapi_name() );
434 print "<li>PHP server API is $sapi; ";
435 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
436 if( $wgUsePathInfo ) {
437 print "ok, using pretty URLs (<tt>$script/Page_Title</tt>)";
439 print "using ugly URLs (<tt>$script?title=Page_Title</tt>)";
443 $conf->xml
= function_exists( "utf8_encode" );
445 print "<li>Have XML / Latin1-UTF-8 conversion support.</li>\n";
447 dieout( "PHP's XML module is missing; the wiki requires functions in
448 this module and won't work in this configuration.
449 If you're running Mandrake, install the php-xml package." );
452 # Check for session support
453 if( !function_exists( 'session_name' ) )
454 dieout( "PHP's session module is missing. MediaWiki requires session support in order to function." );
456 # session.save_path doesn't *have* to be set, but if it is, and it's
457 # not valid/writable/etc. then it can cause problems
458 $sessionSavePath = mw_get_session_save_path();
459 $ssp = htmlspecialchars( $sessionSavePath );
460 # Warn the user if it's not set, but let them proceed
461 if( !$sessionSavePath ) {
462 print "<li><strong>Warning:</strong> A value for <tt>session.save_path</tt>
463 has not been set in PHP.ini. If the default value causes problems with
464 saving session data, set it to a valid path which is read/write/execute
465 for the user your web server is running under.</li>";
466 } elseif ( is_dir( $sessionSavePath ) && is_writable( $sessionSavePath ) ) {
467 # All good? Let the user know
468 print "<li>Session save path (<tt>{$ssp}</tt>) appears to be valid.</li>";
470 # Something not right? Warn the user, but let them proceed
471 print "<li><strong>Warning:</strong> Your <tt>session.save_path</tt> value (<tt>{$ssp}</tt>)
472 appears to be invalid or is not writable. PHP needs to be able to save data to
473 this location for correct session operation.</li>";
476 # Check for PCRE support
477 if( !function_exists( 'preg_match' ) )
478 dieout( "The PCRE support module appears to be missing. MediaWiki requires the
479 Perl-compatible regular expression functions." );
481 # The installer can take a while, and we really don't want it to time out
482 wfSuppressWarnings();
486 $memlimit = ini_get( "memory_limit" );
487 if( $memlimit == -1 ) {
488 print "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n";
490 print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars( $memlimit ). " bytes. ";
491 $newlimit = wfMemoryLimit();
492 $memlimit = wfShorthandToInteger( $memlimit );
493 if( $newlimit < $memlimit ) {
494 print "<b>Failed raising limit, installation may fail.</b>";
495 } elseif ( $newlimit > $memlimit ) {
496 print "Raised <tt>memory_limit</tt> to " . htmlspecialchars( $newlimit ) . " bytes. ";
501 $conf->xcache
= function_exists( 'xcache_get' );
503 print "<li><a href=\"http://trac.lighttpd.net/xcache/\">XCache</a> installed</li>\n";
505 $conf->apc
= function_exists('apc_fetch');
507 print "<li><a href=\"http://www.php.net/apc\">APC</a> installed</li>\n";
510 $conf->eaccel
= function_exists( 'eaccelerator_get' );
511 if ( $conf->eaccel
) {
512 print "<li><a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> installed</li>\n";
515 $conf->dba
= function_exists( 'dba_open' );
517 if( !( $conf->eaccel ||
$conf->apc ||
$conf->xcache
) ) {
518 echo( '<li>Couldn\'t find <a href="http://eaccelerator.sourceforge.net">eAccelerator</a>,
519 <a href="http://www.php.net/apc">APC</a> or <a href="http://trac.lighttpd.net/xcache/">XCache</a>;
520 cannot use these for object caching.</li>' );
523 $conf->diff3
= false;
524 $diff3locations = array_merge(
531 explode( PATH_SEPARATOR
, getenv( "PATH" ) ) );
532 $diff3names = array( "gdiff3", "diff3", "diff3.exe" );
534 $diff3versioninfo = array( '$1 --version 2>&1', 'diff3 (GNU diffutils)' );
535 foreach ($diff3locations as $loc) {
536 $exe = locate_executable($loc, $diff3names, $diff3versioninfo);
537 if ($exe !== false) {
544 print "<li>Found GNU diff3: <tt>$conf->diff3</tt>.</li>";
546 print "<li>GNU diff3 not found.</li>";
548 $conf->ImageMagick
= false;
549 $imcheck = array( "/usr/bin", "/opt/csw/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" );
550 foreach( $imcheck as $dir ) {
551 $im = "$dir/convert";
552 if( @file_exists
( $im ) ) {
553 print "<li>Found ImageMagick: <tt>$im</tt>; image thumbnailing will be enabled if you enable uploads.</li>\n";
554 $conf->ImageMagick
= $im;
559 $conf->HaveGD
= function_exists( "imagejpeg" );
560 if( $conf->HaveGD
) {
561 print "<li>Found GD graphics library built-in";
562 if( !$conf->ImageMagick
) {
563 print ", image thumbnailing will be enabled if you enable uploads";
567 if( !$conf->ImageMagick
) {
568 print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n";
572 $conf->IP
= dirname( dirname( __FILE__
) );
573 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP
) . "</tt></li>\n";
576 // PHP_SELF isn't available sometimes, such as when PHP is CGI but
577 // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
578 // to get the path to the current script... hopefully it's reliable. SIGH
579 $path = ($_SERVER["PHP_SELF"] === '')
580 ?
$_SERVER["SCRIPT_NAME"]
581 : $_SERVER["PHP_SELF"];
583 $conf->ScriptPath
= preg_replace( '{^(.*)/config.*$}', '$1', $path );
584 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath
) . "</tt></li>\n";
588 // We may be installing from *.php5 extension file, if so, print message
589 $conf->ScriptExtension
= '.php';
590 if (defined('MW_INSTALL_PHP5_EXT')) {
591 $conf->ScriptExtension
= '.php5';
592 print "<li>Installing MediaWiki with <tt>php5</tt> file extensions</li>\n";
594 print "<li>Installing MediaWiki with <tt>php</tt> file extensions</li>\n";
598 print "<li style='font-weight:bold;color:green;font-size:110%'>Environment checked. You can install MediaWiki.</li>\n";
599 $conf->posted
= ($_SERVER["REQUEST_METHOD"] == "POST");
601 $conf->Sitename
= ucfirst( importPost( "Sitename", "" ) );
602 $defaultEmail = empty( $_SERVER["SERVER_ADMIN"] )
604 : $_SERVER["SERVER_ADMIN"];
605 $conf->EmergencyContact
= importPost( "EmergencyContact", $defaultEmail );
606 $conf->DBtype
= importPost( "DBtype", $DefaultDBtype );
607 if ( !isset( $ourdb[$conf->DBtype
] ) ) {
608 $conf->DBtype
= $DefaultDBtype;
611 $conf->DBserver
= importPost( "DBserver", $wgDBserver );
612 $conf->DBname
= importPost( "DBname", $wgDBname );
613 $conf->DBuser
= importPost( "DBuser", $wgDBuser );
614 $conf->DBpassword
= importPost( "DBpassword" );
615 $conf->DBpassword2
= importPost( "DBpassword2" );
616 $conf->SysopName
= importPost( "SysopName", "WikiSysop" );
617 $conf->SysopPass
= importPost( "SysopPass" );
618 $conf->SysopPass2
= importPost( "SysopPass2" );
619 $conf->RootUser
= importPost( "RootUser" );
620 $conf->RootPW
= importPost( "RootPW", "" );
621 $useRoot = importCheck( 'useroot', false );
622 $conf->LanguageCode
= importPost( "LanguageCode", "en" );
624 $conf->DBprefix
= importPost( "DBprefix" );
626 importPost( "DBschema", "mysql5-binary" ),
627 importPost( "DBengine", "InnoDB" ) );
629 ## Postgres specific:
630 $conf->DBport
= importPost( "DBport", $wgDBport );
631 $conf->DBts2schema
= importPost( "DBts2schema", "public" );
632 $conf->DBpgschema
= importPost( "DBpgschema", "mediawiki" );
635 $conf->SQLiteDataDir
= importPost( "SQLiteDataDir", "$IP/../data" );
638 // New variable in order to have a different default port number
639 $conf->DBport_db2
= importPost( "DBport_db2", "50000" );
640 $conf->DBcataloged
= importPost( "DBcataloged", "cataloged" );
641 $conf->DBdb2schema
= importPost( "DBdb2schema", "mediawiki" );
644 $conf->DBprefix_ora
= importPost( "DBprefix_ora" );
645 $conf->DBdefTS_ora
= importPost( "DBdefTS_ora", "USERS" );
646 $conf->DBtempTS_ora
= importPost( "DBtempTS_ora", "TEMP" );
648 $conf->ShellLocale
= getShellLocale( $conf->LanguageCode
);
650 /* Check for validity */
653 if( preg_match( '/^$|^mediawiki$|#/i', $conf->Sitename
) ) {
654 $errs["Sitename"] = "Must not be blank or \"MediaWiki\" and may not contain \"#\"";
656 if( !$ourdb[$conf->DBtype
]['serverless'] ) {
657 if( $conf->DBuser
== "" ) {
658 $errs["DBuser"] = "Must not be blank";
660 if( ($conf->DBtype
== 'mysql') && (strlen($conf->DBuser
) > 16) ) {
661 $errs["DBuser"] = "Username too long";
663 if( $conf->DBpassword
== "" && $conf->DBtype
!= "postgres" ) {
664 $errs["DBpassword"] = "Must not be blank";
666 if( $conf->DBpassword
!= $conf->DBpassword2
) {
667 $errs["DBpassword2"] = "Passwords don't match!";
670 if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix
) ) {
671 $errs["DBprefix"] = "Invalid table prefix";
673 untaint( $conf->DBprefix
, TC_MYSQL
);
675 if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix_ora
) ) {
676 $errs["DBprefix_ora"] = "Invalid table prefix";
679 error_reporting( E_ALL | E_STRICT
);
682 * Initialise $wgLang and $wgContLang to something so we can
683 * call case-folding methods. Per Brion, this is English for
684 * now, although we could be clever and initialise to the
685 * user-selected language.
687 $wgContLang = Language
::factory( 'en' );
688 $wgLang = $wgContLang;
691 * We're messing about with users, so we need a stub
692 * authentication plugin...
694 $wgAuth = new AuthPlugin();
697 * Validate the initial administrator account; username,
698 * password checks, etc.
700 if( $conf->SysopName
) {
701 # Check that the user can be created
702 $u = User
::newFromName( $conf->SysopName
);
703 if( $u instanceof User
) {
704 # Various password checks
705 if( $conf->SysopPass
!= '' ) {
706 if( $conf->SysopPass
== $conf->SysopPass2
) {
707 if( !$u->isValidPassword( $conf->SysopPass
) ) {
708 $errs['SysopPass'] = "Bad password";
711 $errs['SysopPass2'] = "Passwords don't match";
714 $errs['SysopPass'] = "Cannot be blank";
718 $errs['SysopName'] = "Bad username";
722 $conf->License
= importRequest( "License", "none" );
723 if( $conf->License
== "gfdl1_2" ) {
724 $conf->RightsUrl
= "http://www.gnu.org/licenses/old-licenses/fdl-1.2.txt";
725 $conf->RightsText
= "GNU Free Documentation License 1.2";
726 $conf->RightsCode
= "gfdl1_2";
727 $conf->RightsIcon
= '${wgScriptPath}/skins/common/images/gnu-fdl.png';
728 } elseif( $conf->License
== "gfdl1_3" ) {
729 $conf->RightsUrl
= "http://www.gnu.org/copyleft/fdl.html";
730 $conf->RightsText
= "GNU Free Documentation License 1.3";
731 $conf->RightsCode
= "gfdl1_3";
732 $conf->RightsIcon
= '${wgScriptPath}/skins/common/images/gnu-fdl.png';
733 } elseif( $conf->License
== "none" ) {
734 $conf->RightsUrl
= $conf->RightsText
= $conf->RightsCode
= $conf->RightsIcon
= "";
735 } elseif( $conf->License
== "pd" ) {
736 $conf->RightsUrl
= "http://creativecommons.org/licenses/publicdomain/";
737 $conf->RightsText
= "Public Domain";
738 $conf->RightsCode
= "pd";
739 $conf->RightsIcon
= '${wgScriptPath}/skins/common/images/public-domain.png';
741 $conf->RightsUrl
= importRequest( "RightsUrl", "" );
742 $conf->RightsText
= importRequest( "RightsText", "" );
743 $conf->RightsCode
= importRequest( "RightsCode", "" );
744 $conf->RightsIcon
= importRequest( "RightsIcon", "" );
747 $conf->Shm
= importRequest( "Shm", "none" );
748 $conf->MCServers
= importRequest( "MCServers" );
750 /* Test memcached servers */
752 if ( $conf->Shm
== 'memcached' && $conf->MCServers
) {
753 $conf->MCServerArray
= wfArrayMap( 'trim', explode( ',', $conf->MCServers
) );
754 foreach ( $conf->MCServerArray
as $server ) {
755 $error = testMemcachedServer( $server );
757 $errs["MCServers"] = $error;
761 } else if ( $conf->Shm
== 'memcached' ) {
762 $errs["MCServers"] = "Please specify at least one server if you wish to use memcached";
765 /* default values for installation */
766 $conf->Email
= importRequest("Email", "email_enabled");
767 $conf->Emailuser
= importRequest("Emailuser", "emailuser_enabled");
768 $conf->Enotif
= importRequest("Enotif", "enotif_allpages");
769 $conf->Eauthent
= importRequest("Eauthent", "eauthent_enabled");
771 if( $conf->posted
&& ( 0 == count( $errs ) ) ) {
772 do { /* So we can 'continue' to end prematurely */
773 $conf->Root
= ($conf->RootPW
!= "");
775 /* Load up the settings and get installin' */
776 $local = writeLocalSettings( $conf );
777 echo "<li style=\"list-style: none\">\n";
778 echo "<p><b>Generating configuration file...</b></p>\n";
781 $wgCommandLineMode = false;
783 $ok = eval( $local );
784 if( $ok === false ) {
785 dieout( "<p>Errors in generated configuration; " .
786 "most likely due to a bug in the installer... " .
787 "Config file was: </p>" .
789 htmlspecialchars( $local ) .
792 $conf->DBtypename
= '';
793 foreach (array_keys($ourdb) as $db) {
794 if ($conf->DBtype
=== $db)
795 $conf->DBtypename
= $ourdb[$db]['fullname'];
797 if ( ! strlen($conf->DBtype
)) {
798 $errs["DBpicktype"] = "Please choose a database type";
802 if (! $conf->DBtypename
) {
803 $errs["DBtype"] = "Unknown database type '$conf->DBtype'";
806 print "<li>Database type: " . htmlspecialchars( $conf->DBtypename
) . "</li>\n";
807 $dbclass = 'Database'.ucfirst($conf->DBtype
);
808 $wgDBtype = $conf->DBtype
;
809 $wgDBadminuser = "root";
810 $wgDBadminpassword = $conf->RootPW
;
813 $wgDBprefix = $conf->DBprefix
;
815 ## Postgres specific:
816 $wgDBport = $conf->DBport
;
817 $wgDBts2schema = $conf->DBts2schema
;
819 if( $wgDBtype == 'postgres' ) {
820 $wgDBmwschema = $conf->DBpgschema
;
821 } elseif ( $wgDBtype == 'ibm_db2' ) {
822 $wgDBmwschema = $conf->DBdb2schema
;
825 if( $conf->DBprefix_ora
!= '' ) {
827 $wgDBprefix = $conf->DBprefix_ora
;
831 $wgDBcataloged = $conf->DBcataloged
;
833 $wgCommandLineMode = true;
834 if (! defined ( 'STDERR' ) )
835 define( 'STDERR', fopen("php://stderr", "wb"));
836 $wgUseDatabaseMessages = false; /* FIXME: For database failure */
837 require_once( "$IP/includes/Setup.php" );
838 Language
::getLocalisationCache()->disableBackend();
842 $wgTitle = Title
::newFromText( "Installation script" );
843 error_reporting( E_ALL | E_STRICT
);
844 print "<li>Loading class: " . htmlspecialchars( $dbclass ) . "</li>\n";
845 if ( $conf->DBtype
!= 'sqlite' ) {
849 if( $conf->DBtype
== 'mysql' ) {
850 $mysqlOldClient = version_compare( mysql_get_client_info(), "4.1.0", "lt" );
851 if( $mysqlOldClient ) {
852 print "<li><b>PHP is linked with old MySQL client libraries. If you are
853 using a MySQL 4.1 server and have problems connecting to the database,
854 see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
855 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b></li>\n";
857 $ok = true; # Let's be optimistic
859 # Decide if we're going to use the superuser or the regular database user
860 $conf->Root
= $useRoot;
862 $db_user = $conf->RootUser
;
863 $db_pass = $conf->RootPW
;
865 $db_user = $wgDBuser;
866 $db_pass = $wgDBpassword;
870 echo( "<li>Attempting to connect to database server as " . htmlspecialchars( $db_user ) . "..." );
871 $wgDatabase = Database
::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 );
873 # Check the connection and respond to errors
874 if( $wgDatabase->isOpen() ) {
877 $wgDBadminuser = $db_user;
878 $wgDBadminpassword = $db_pass;
879 echo( "success.</li>\n" );
880 $wgDatabase->ignoreErrors( true );
881 $myver = $wgDatabase->getServerVersion();
883 # There were errors, report them and back out
885 $errno = mysql_errno();
886 $errtx = htmlspecialchars( mysql_error() );
890 echo( "failed due to authentication errors. Check passwords.</li>" );
892 # The superuser details are wrong
893 $errs["RootUser"] = "Check username";
894 $errs["RootPW"] = "and password";
896 # The regular user details are wrong
897 $errs["DBuser"] = "Check username";
898 $errs["DBpassword"] = "and password";
904 # General connection problem
905 echo( htmlspecialchars( "failed with error [$errno] $errtx." ) . "</li>\n" );
906 $errs["DBserver"] = "Connection failed";
911 if( !$ok ) { continue; }
913 else if( $conf->DBtype
== 'ibm_db2' ) {
915 $db_user = $conf->RootUser
;
916 $db_pass = $conf->RootPW
;
918 $db_user = $wgDBuser;
919 $db_pass = $wgDBpassword;
922 echo( "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) .
923 "\" as \"" . htmlspecialchars( $db_user ) . "\"..." );
924 $wgDatabase = $dbc->newFromParams($wgDBserver, $db_user, $db_pass, $wgDBname, 1);
925 // enable extra debug messages
926 $dbc->setMode(DatabaseIbm_db2
::INSTALL_MODE
);
927 $wgDatabase->setMode(DatabaseIbm_db2
::INSTALL_MODE
);
929 if (!$wgDatabase->isOpen()) {
930 print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
932 $myver = $wgDatabase->getServerVersion();
934 if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname);
936 } elseif ( $conf->DBtype
== 'sqlite' ) {
937 $wgSQLiteDataDir = $conf->SQLiteDataDir
;
938 echo '<li>Attempting to connect to SQLite database at "' .
939 htmlspecialchars( $wgSQLiteDataDir ) . '": ';
940 if ( !is_dir( $wgSQLiteDataDir ) ) {
941 if ( is_writable( dirname( $wgSQLiteDataDir ) ) ) {
942 $ok = wfMkdirParents( $wgSQLiteDataDir, $wgSQLiteDataDirMode );
947 echo "cannot create data directory</li>";
948 $errs['SQLiteDataDir'] = 'Enter a valid data directory';
952 if ( !is_writable( $wgSQLiteDataDir ) ) {
953 echo "data directory not writable</li>";
954 $errs['SQLiteDataDir'] = 'Enter a writable data directory';
957 $dataFile = DatabaseSqlite
::generateFileName( $wgSQLiteDataDir, $wgDBname );
958 if ( file_exists( $dataFile ) ) {
959 if ( !is_writable( $dataFile ) ) {
960 echo "data file not writable</li>";
961 $errs['SQLiteDataDir'] = basename( $dataFile ) . " is not writable";
965 if ( file_put_contents( $dataFile, '' ) === false ) {
966 echo 'could not create database file "' . htmlspecialchars( basename( $dataFile ) ) . "\"</li>\n";
967 $errs['SQLiteDataDir'] = "couldn't create " . basename( $dataFile );
972 $wgDatabase = new DatabaseSqlite( false, false, false, $wgDBname, 1 );
974 catch( MWException
$ex ) {
975 echo 'error: ' . htmlspecialchars( $ex->getMessage() ) . "</li>\n";
979 if (!$wgDatabase->isOpen()) {
980 print "error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
981 $errs['SQLiteDataDir'] = 'Could not connect to database';
984 $myver = $wgDatabase->getServerVersion();
986 if ( is_callable( array( $wgDatabase, 'initial_setup' ) ) ) {
987 $wgDatabase->initial_setup('', $wgDBname);
990 } elseif ( $conf->DBtype
== 'oracle' ) {
991 echo "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) ."\"</li>";
992 $old_error_level = error_reporting();
993 wfSuppressWarnings();
994 $wgDatabase = $dbc->newFromParams('DUMMY', $wgDBuser, $wgDBpassword, $wgDBname, 1);
996 if (!$wgDatabase->isOpen()) {
998 echo "<li>Connect failed.</li>";
1000 if (ini_get('oci8.privileged_connect') === false) {
1001 echo "<li>Privileged connect disabled, please set oci8.privileged_connect or run maintenance/ora/user.sql script manually prior to continuing.</li>";
1004 $wgDBadminuser = $conf->RootUser
;
1005 $wgDBadminpassword = $conf->RootPW
;
1006 echo "<li>Attempting to create DB user.</li>";
1007 $wgDatabase = $dbc->newFromParams('DUMMY', $wgDBadminuser, $wgDBadminpassword, $wgDBname, 1, 64);
1008 if ($wgDatabase->isOpen()) {
1009 $wgDBOracleDefTS = $conf->DBdefTS_ora
;
1010 $wgDBOracleTempTS = $conf->DBtempTS_ora
;
1011 $res = $wgDatabase->sourceFile( "../maintenance/ora/user.sql" );
1012 if ($res !== true) dieout($res);
1014 echo "<li>Invalid database superuser, please supply a valid superuser account.</li>";
1015 echo "<li>ERR: ".print_r(oci_error(), true)."</li>";
1020 echo "<li>Database superuser missing, please supply a valid superuser account.</li>";
1024 $errs["RootUser"] = "Check username";
1025 $errs["RootPW"] = "and password";
1027 echo "<li>Attempting to connect to database with new user \"" . htmlspecialchars( $wgDBname ) ."\"</li>";
1028 $wgDatabase = $dbc->newFromParams('DUMMY', $wgDBuser, $wgDBpassword, $wgDBname, 1);
1032 $myver = $wgDatabase->getServerVersion();
1034 } else { # not mysql
1035 error_reporting( E_ALL | E_STRICT
);
1037 ## Possible connect as a superuser
1038 // Changed !mysql to postgres check since it seems to only apply to postgres
1039 if( $useRoot && $conf->DBtype
== 'postgres' ) {
1040 echo( "<li>Attempting to connect to database \"postgres\" as superuser \"" .
1041 htmlspecialchars( $conf->RootUser
) . "\"..." );
1042 $wgDatabase = $dbc->newFromParams($wgDBserver, $conf->RootUser
, $conf->RootPW
, "postgres", 1);
1043 if (!$wgDatabase->isOpen()) {
1044 print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
1045 $errs["DBserver"] = "Could not connect to database as superuser";
1046 $errs["RootUser"] = "Check username";
1047 $errs["RootPW"] = "and password";
1050 $wgDatabase->initial_setup($conf->RootUser
, $conf->RootPW
, 'postgres');
1052 echo( "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) .
1053 "\" as \"" . htmlspecialchars( $wgDBuser ) . "\"..." );
1054 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1);
1055 if (!$wgDatabase->isOpen()) {
1056 print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
1057 $errs["DBserver"] = "Could not connect to database as user";
1058 $errs["DBuser"] = "Check username";
1059 $errs["DBpassword"] = "and password";
1062 $myver = $wgDatabase->getServerVersion();
1064 if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname);
1067 if ( !$wgDatabase->isOpen() ) {
1068 $errs["DBserver"] = "Couldn't connect to database";
1072 print "<li>Connected to " . htmlspecialchars( "{$conf->DBtype} $myver" );
1073 if ($conf->DBtype
== 'mysql') {
1074 if( version_compare( $myver, "4.0.14" ) < 0 ) {
1076 dieout( "-- mysql 4.0.14 or later required. Aborting." );
1078 $mysqlNewAuth = version_compare( $myver, "4.1.0", "ge" );
1079 if( $mysqlNewAuth && $mysqlOldClient ) {
1080 print "; <b class='error'>You are using MySQL 4.1 server, but PHP is linked
1081 to old client libraries; if you have trouble with authentication, see
1082 <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
1083 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>";
1086 if( $mysqlNewAuth ) {
1087 print "; enabling MySQL 4.1/5.0 charset mode";
1089 print "; <b class='error'>MySQL 4.1/5.0 charset mode enabled,
1090 but older version detected; will likely fail.</b>";
1095 @$sel = $wgDatabase->selectDB( $wgDBname );
1097 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
1099 $err = mysql_errno();
1100 $databaseSafe = htmlspecialchars( $wgDBname );
1101 if( $err == 1102 /* Invalid database name */ ) {
1102 print "<ul><li><strong>{$databaseSafe}</strong> is not a valid database name.</li></ul>";
1104 } elseif( $err != 1049 /* Database doesn't exist */ ) {
1105 print "<ul><li>Error selecting database <strong>{$databaseSafe}</strong>: {$err} ";
1106 print htmlspecialchars( mysql_error() ) . "</li></ul>";
1109 print "<li>Attempting to create database...</li>";
1110 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
1112 print "<li>Couldn't create database <tt>" .
1113 htmlspecialchars( $wgDBname ) .
1114 "</tt>; try with root access or check your username/pass.</li>\n";
1115 $errs["RootPW"] = "<- Enter";
1118 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
1120 $wgDatabase->selectDB( $wgDBname );
1122 else if ($conf->DBtype
== 'postgres') {
1123 if( version_compare( $myver, "8.0" ) < 0 ) {
1124 dieout( "<b>Postgres 8.0 or later is required</b>. Aborting." );
1128 if( $wgDatabase->tableExists( "cur" ) ||
$wgDatabase->tableExists( "revision" ) ) {
1129 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n";
1131 if ( $conf->DBtype
== 'mysql') {
1132 # Determine existing default character set
1133 if ( $wgDatabase->tableExists( "revision" ) ) {
1134 $revision = $wgDatabase->escapeLike( $conf->DBprefix
. 'revision' );
1135 $res = $wgDatabase->query( "SHOW TABLE STATUS LIKE '$revision'" );
1136 $row = $wgDatabase->fetchObject( $res );
1138 echo "<li>SHOW TABLE STATUS query failed!</li>\n";
1139 $existingSchema = false;
1140 $existingEngine = false;
1142 if ( preg_match( '/^latin1/', $row->Collation
) ) {
1143 $existingSchema = 'mysql4';
1144 } elseif ( preg_match( '/^utf8/', $row->Collation
) ) {
1145 $existingSchema = 'mysql5';
1146 } elseif ( preg_match( '/^binary/', $row->Collation
) ) {
1147 $existingSchema = 'mysql5-binary';
1149 $existingSchema = false;
1150 echo "<li><strong>Warning:</strong> Unrecognised existing collation</li>\n";
1152 if ( isset( $row->Engine
) ) {
1153 $existingEngine = $row->Engine
;
1155 $existingEngine = $row->Type
;
1158 if ( $existingSchema && $existingSchema != $conf->DBschema
) {
1159 $encExisting = htmlspecialchars( $existingSchema );
1160 $encRequested = htmlspecialchars( $conf->DBschema
);
1161 print "<li><strong>Warning:</strong> you requested the $encRequested schema, " .
1162 "but the existing database has the $encExisting schema. This upgrade script ".
1163 "can't convert it, so it will remain $encExisting.</li>\n";
1164 $conf->setSchema( $existingSchema, $conf->DBengine
);
1166 if ( $existingEngine && $existingEngine != $conf->DBengine
) {
1167 $encExisting = htmlspecialchars( $existingEngine );
1168 $encRequested = htmlspecialchars( $conf->DBengine
);
1169 print "<li><strong>Warning:</strong> you requested the $encRequested storage " .
1170 "engine, but the existing database uses the $encExisting engine. This upgrade " .
1171 "script can't convert it, so it will remain $encExisting.</li>\n";
1172 $conf->setSchema( $conf->DBschema
, $existingEngine );
1176 # Create user if required
1177 if ( $conf->Root
) {
1178 $conn = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
1179 if ( $conn->isOpen() ) {
1180 print "<li>DB user account ok</li>\n";
1183 print "<li>Granting user permissions...";
1184 if( $mysqlOldClient && $mysqlNewAuth ) {
1185 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>";
1188 $res = $wgDatabase->sourceFile( "../maintenance/users.sql" );
1189 if ($res !== true) dieout($res);
1193 print "</ul><pre>\n";
1199 print "<ul><li>Finished update checks.</li>\n";
1200 // if tables don't yet exist
1202 # Determine available storage engines if possible
1203 if ( $conf->DBtype
== 'mysql' && version_compare( $myver, "4.1.2", "ge" ) ) {
1204 $res = $wgDatabase->query( 'SHOW ENGINES' );
1206 while ( $row = $wgDatabase->fetchObject( $res ) ) {
1207 if ( $row->Engine
== $conf->DBengine
&& ( $row->Support
== 'YES' ||
$row->Support
== 'DEFAULT' ) ) {
1212 $wgDatabase->freeResult( $res );
1213 if ( !$found && $conf->DBengine
!= 'MyISAM' ) {
1214 echo "<li><strong>Warning:</strong> " . htmlspecialchars( $conf->DBengine
) .
1215 " storage engine not available, " .
1216 "using MyISAM instead</li>\n";
1217 $conf->setSchema( $conf->DBschema
, 'MyISAM' );
1221 print "<li>Creating tables...";
1222 if ($conf->DBtype
== 'mysql') {
1223 $res = $wgDatabase->sourceFile( "../maintenance/tables.sql" );
1224 if ($res === true) {
1225 print " done.</li>\n<li>Populating interwiki table... \n";
1226 $res = $wgDatabase->sourceFile( "../maintenance/interwiki.sql" );
1228 if ($res === true) {
1229 print " done.</li>\n";
1231 print " <b>FAILED</b></li>\n";
1232 dieout( htmlspecialchars( $res ) );
1234 } elseif (is_callable(array($wgDatabase, 'setup_database'))) {
1235 $wgDatabase->setup_database();
1238 $errs["DBtype"] = "Do not know how to handle database type '$conf->DBtype'";
1243 if ( $conf->DBtype
== 'ibm_db2' ) {
1244 // Now that table creation is done, make sure everything is committed
1245 // Do this before doing inserts through API
1246 if ($wgDatabase->lastError()) {
1247 print "<li>Errors encountered during table creation -- rolled back</li>\n";
1248 $wgDatabase->rollback();
1251 print "<li>MediaWiki tables successfully created</li>\n";
1252 $wgDatabase->commit();
1254 } elseif ( $conf->DBtype
== 'sqlite' ) {
1255 // Ensure proper searchindex format. We have to do that separately because
1256 // if SQLite is compiled without the FTS3 module, table creation syntax will be invalid.
1257 sqlite_setup_searchindex();
1260 print "<li>Initializing statistics...</li>\n";
1261 $wgDatabase->insert( 'site_stats',
1262 array ( 'ss_row_id' => 1,
1263 'ss_total_views' => 0,
1264 'ss_total_edits' => 1, # Main page first edit
1265 'ss_good_articles' => 0, # Main page is not a good article - no internal link
1266 'ss_total_pages' => 1, # Main page
1267 'ss_users' => $conf->SysopName ?
1 : 0, # Sysop account, if created
1268 'ss_admins' => $conf->SysopName ?
1 : 0, # Sysop account, if created
1269 'ss_images' => 0 ) );
1271 # Set up the "regular user" account *if we can, and if we need to*
1272 if( $conf->Root
and $conf->DBtype
== 'mysql') {
1274 $wgDatabase2 = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
1275 if( $wgDatabase2->isOpen() ) {
1276 # Nope, just close the test connection and continue
1277 $wgDatabase2->close();
1278 echo( "<li>User " . htmlspecialchars( $wgDBuser ) . " exists. Skipping grants.</li>\n" );
1280 # Yes, so run the grants
1281 echo( "<li>" . htmlspecialchars( "Granting user permissions to $wgDBuser on $wgDBname..." ) );
1282 $res = $wgDatabase->sourceFile( "../maintenance/users.sql" );
1283 if ( $res === true ) {
1284 echo( " success.</li>\n" );
1286 echo( " <b>FAILED</b>.</li>\n" );
1292 if( $conf->SysopName
) {
1293 $u = User
::newFromName( $conf->getSysopName() );
1295 print "<li><strong class=\"error\">Warning:</strong> Skipped sysop account creation - invalid username!</li>\n";
1297 else if ( 0 == $u->idForName() ) {
1298 $u->addToDatabase();
1299 $u->setPassword( $conf->getSysopPass() );
1302 $u->addGroup( "sysop" );
1303 $u->addGroup( "bureaucrat" );
1305 print "<li>Created sysop account <tt>" .
1306 htmlspecialchars( $conf->SysopName
) . "</tt>.</li>\n";
1308 print "<li>Could not create user - already exists!</li>\n";
1311 print "<li>Skipped sysop account creation, no name given.</li>\n";
1314 $titleobj = Title
::newFromText( wfMsgNoDB( "mainpage" ) );
1315 $article = new Article( $titleobj );
1316 $newid = $article->insertOn( $wgDatabase );
1317 $revision = new Revision( array(
1319 'text' => wfMsg( 'mainpagetext' ) . "\n\n" . wfMsgNoTrans( 'mainpagedocfooter' ),
1322 'user_text' => 'MediaWiki default',
1324 $revid = $revision->insertOn( $wgDatabase );
1325 $article->updateRevisionOn( $wgDatabase, $revision );
1328 /* Write out the config file now that all is well */
1329 print "<li style=\"list-style: none\">\n";
1330 print "<p>Creating LocalSettings.php...</p>\n\n";
1331 $localSettings = "<" . "?php$endl$local";
1332 // Fix up a common line-ending problem (due to CVS on Windows)
1333 $localSettings = str_replace( "\r\n", "\n", $localSettings );
1334 $f = fopen( "LocalSettings.php", 'xt' );
1338 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" .
1339 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
1340 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
1342 if(fwrite( $f, $localSettings ) ) {
1345 writeSuccessMessage();
1349 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" );
1356 $mainListOpened = false;
1358 if( count( $errs ) ) {
1359 /* Display options form */
1361 if( $conf->posted
) {
1362 echo "<p class='error-top'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
1366 <form action
="<?php echo defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php'; ?>" name
="config" method
="post">
1368 <h2
>Site config
</h2
>
1370 <div
class="config-section">
1371 <div
class="config-input">
1372 <?php
aField( $conf, "Sitename", "Wiki name:" ); ?
>
1374 <p
class="config-desc">
1375 Preferably a short word without punctuation
, i
.e
. "Wikipedia".<br
/>
1376 Will appear
as the
namespace name
for "meta" pages
, and throughout the
interface.
1378 <div
class="config-input"><?php
aField( $conf, "EmergencyContact", "Contact e-mail:" ); ?
></div
>
1379 <p
class="config-desc">
1380 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
.
1383 <div
class="config-input">
1384 <label
class='column' for="LanguageCode">Language
:</label
>
1385 <select id
="LanguageCode" name
="LanguageCode"><?php
1386 $list = getLanguageList();
1387 foreach( $list as $code => $name ) {
1388 $sel = ($code == $conf->LanguageCode
) ?
'selected="selected"' : '';
1389 $encCode = htmlspecialchars( $code );
1390 $encName = htmlspecialchars( $name );
1391 echo "\n\t\t<option value=\"$encCode\" $sel>$encName</option>";
1397 <p
class="config-desc">
1398 Select the language
for your wiki
's interface. Some localizations aren't fully complete
. Unicode (UTF
-8) is used
for all localizations
.
1401 <div
class="config-input">
1402 <label
class='column'>Copyright
/license
:</label
>
1405 <li
><?php
aField( $conf, "License", "No license metadata", "radio", "none" ); ?
></li
>
1406 <li
><?php
aField( $conf, "License", "Public Domain", "radio", "pd" ); ?
></li
>
1407 <li
><?php
aField( $conf, "License", "GNU Free Documentation License 1.2", "radio", "gfdl1_2" ); ?
></li
>
1408 <li
><?php
aField( $conf, "License", "GNU Free Documentation License 1.3", "radio", "gfdl1_3" ); ?
></li
>
1410 aField( $conf, "License", "A Creative Commons license - ", "radio", "cc" );
1411 $partner = "MediaWiki";
1412 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
1413 $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/$script?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
1414 $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" );
1415 $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" );
1416 print "<a href=\"$ccApp\" target='_blank'>choose</a>";
1417 if( $conf->License
== "cc" ) { ?
>
1419 <li
><?php
aField( $conf, "RightsIcon", "<img src=\"" . htmlspecialchars( $conf->RightsIcon
) . "\" alt='(Creative Commons icon)' />", "hidden" ); ?
></li
>
1420 <li
><?php
aField( $conf, "RightsText", htmlspecialchars( $conf->RightsText
), "hidden" ); ?
></li
>
1421 <li
><?php
aField( $conf, "RightsCode", "code: " . htmlspecialchars( $conf->RightsCode
), "hidden" ); ?
></li
>
1422 <li
><?php
aField( $conf, "RightsUrl", "<a href=\"" . htmlspecialchars( $conf->RightsUrl
) . "\">" . htmlspecialchars( $conf->RightsUrl
) . "</a>", "hidden" ); ?
></li
>
1428 <p
class="config-desc">
1429 A notice
, icon
, and machine
-readable copyright metadata will be displayed
for the license you pick
.
1433 <div
class="config-input">
1434 <?php
aField( $conf, "SysopName", "Admin username:" ) ?
>
1436 <div
class="config-input">
1437 <?php
aField( $conf, "SysopPass", "Password:", "password" ) ?
>
1439 <div
class="config-input">
1440 <?php
aField( $conf, "SysopPass2", "Password confirm:", "password" ) ?
>
1442 <p
class="config-desc">
1443 An admin can lock
/delete pages
, block users from editing
, and do other maintenance tasks
.<br
/>
1444 A
new account will be added only when creating a
new wiki database
.
1446 The password cannot be the same
as the username
.
1449 <div
class="config-input">
1450 <label
class='column'>Object caching
:</label
>
1453 <li
><?php
aField( $conf, "Shm", "No caching", "radio", "none" ); ?
></li
>
1455 if( $conf->xcache
) {
1457 aField( $conf, 'Shm', 'XCache', 'radio', 'xcache' );
1462 aField( $conf, "Shm", "APC", "radio", "apc" );
1465 if ( $conf->eaccel
) {
1467 aField( $conf, "Shm", "eAccelerator", "radio", "eaccel" );
1472 aField( $conf, "Shm", "DBA (not recommended)", "radio", "dba" );
1476 <li
><?php
aField( $conf, "Shm", "Memcached", "radio", "memcached" ); ?
></li
>
1478 <div style
="clear:left"><?php
aField( $conf, "MCServers", "Memcached servers:", "text" ) ?
></div
>
1480 <p
class="config-desc">
1481 An
object caching system such
as memcached will provide a significant performance boost
,
1482 but needs to be installed
. Provide the server addresses
and ports in a comma
-separated
list.
1484 MediaWiki can also detect
and support eAccelerator
, APC
, and XCache
, but
1485 these should not be used
if the wiki will be running on multiple application servers
.
1487 DBA (Berkeley
-style DB
) is generally slower than using no cache at all
, and is only
1488 recommended
for testing
.
1492 <h2
>E
-mail
, e
-mail notification
and authentication setup
</h2
>
1494 <div
class="config-section">
1495 <div
class="config-input">
1496 <label
class='column'>E
-mail
features (global):</label
>
1498 <li
><?php
aField( $conf, "Email", "Enabled", "radio", "email_enabled" ); ?
></li
>
1499 <li
><?php
aField( $conf, "Email", "Disabled", "radio", "email_disabled" ); ?
></li
>
1502 <p
class="config-desc">
1503 Use this to disable all e
-mail
functions (password reminders
, user
-to
-user e
-mail
, and e
-mail notifications
)
1504 if sending mail doesn
't work on your server.
1507 <div class="config-input">
1508 <label class='column
'>User-to-user e-mail:</label>
1510 <li><?php aField( $conf, "Emailuser", "Enabled", "radio", "emailuser_enabled" ); ?></li>
1511 <li><?php aField( $conf, "Emailuser", "Disabled", "radio", "emailuser_disabled" ); ?></li>
1514 <p class="config-desc">
1515 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.
1517 <div class="config-input">
1518 <label class='column
'>E-mail notification about changes:</label>
1520 <li><?php aField( $conf, "Enotif", "Disabled", "radio", "enotif_disabled" ); ?></li>
1521 <li><?php aField( $conf, "Enotif", "Changes to user discussion pages only", "radio", "enotif_usertalk" ); ?></li>
1522 <li><?php aField( $conf, "Enotif", "Changes to user discussion pages, and to pages on watchlists (not recommended for large wikis)", "radio", "enotif_allpages" ); ?></li>
1525 <div class="config-desc">
1527 For this feature to work, an e-mail address must be present for the user account, and the notification
1528 options in the user's preferences must be enabled
. Also note the
1529 authentication option below
. When testing the feature
, keep in mind that your own changes will never trigger notifications to be sent to yourself
.</p
>
1531 <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
>
1534 <div
class="config-input">
1535 <label
class='column'>E
-mail address authentication
:</label
>
1537 <li
><?php
aField( $conf, "Eauthent", "Disabled", "radio", "eauthent_disabled" ); ?
></li
>
1538 <li
><?php
aField( $conf, "Eauthent", "Enabled", "radio", "eauthent_enabled" ); ?
></li
>
1541 <div
class="config-desc">
1542 <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
1543 change notification mails
. Setting this option is
<b
>recommended
</b
> for public wikis because of potential abuse of the e
-mail features above
.</p
>
1548 <h2
>Database config
</h2
>
1550 <div
class="config-section">
1551 <div
class="config-input">
1552 <label
class='column'>Database type
:</label
>
1554 if (isset($errs['DBpicktype'])) {
1555 print "\t<span class='error'>" . htmlspecialchars( $errs['DBpicktype'] ) . "</span>\n";
1558 <ul
class='plain'><?php
1559 database_picker($conf);
1563 <div id
="db-server-settings1">
1564 <div
class="config-input" style
="clear:left">
1565 <?php
aField( $conf, "DBserver", "Database host:" ); ?
>
1567 <p
class="config-desc">
1568 If your database server isn
't on your web server, enter the name or IP address here.
1572 <div class="config-input"><?php aField( $conf, "DBname", "Database name:" ); ?></div>
1573 <div id="db-server-settings2">
1574 <div class="config-input"><?php aField( $conf, "DBuser", "DB username:" ); ?></div>
1575 <div class="config-input"><?php aField( $conf, "DBpassword", "DB password:", "password" ); ?></div>
1576 <div class="config-input"><?php aField( $conf, "DBpassword2", "DB password confirm:", "password" ); ?></div>
1577 <p class="config-desc">
1578 If you only have a single user account and database available,
1579 enter those here. If you have database root access (see below)
1580 you can specify new accounts/databases to be created. This account
1581 will not be created if it pre-exists. If this is the case, ensure that it
1582 has SELECT, INSERT, UPDATE, and DELETE permissions on the MediaWiki database.
1585 <div class="config-input">
1586 <label class="column">Superuser account:</label>
1587 <input type="checkbox" name="useroot" id="useroot" <?php if( $useRoot ) { ?>checked="checked" <?php } ?> />
1588  <label for="useroot">Use superuser account</label>
1590 <div class="config-input"><?php aField( $conf, "RootUser", "Superuser name:", "text" ); ?></div>
1591 <div class="config-input"><?php aField( $conf, "RootPW", "Superuser password:", "password" ); ?></div>
1593 <p class="config-desc">
1594 If the database user specified above does not exist, or does not have access to create
1595 the database (if needed) or tables within it, please check the box and provide details
1596 of a superuser account, such as <strong>root</strong>, which does.
1600 <?php database_switcher('mysql
'); ?>
1601 <div class="config-input"><?php aField( $conf, "DBprefix", "Database table prefix:" ); ?></div>
1602 <div class="config-desc">
1603 <p>If you need to share one database between multiple wikis, or
1604 between MediaWiki and another web application, you may choose to
1605 add a prefix to all the table names to avoid conflicts.</p>
1607 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
1610 <div class="config-input"><label class="column">Storage Engine</label>
1611 <div>Select one:</div>
1613 <li><?php aField( $conf, "DBengine", "InnoDB", "radio", "InnoDB" ); ?></li>
1614 <li><?php aField( $conf, "DBengine", "MyISAM", "radio", "MyISAM" ); ?></li>
1617 <p class="config-desc">
1618 InnoDB is best for public web installations, since it has good concurrency
1619 support. MyISAM may be faster in single-user installations. MyISAM databases
1620 tend to get corrupted more often than InnoDB databases.
1622 <div class="config-input"><label class="column">Database character set</label>
1623 <div>Select one:</div>
1625 <li><?php aField( $conf, "DBschema", "MySQL 4.1/5.0 binary", "radio", "mysql5-binary" ); ?></li>
1626 <li><?php aField( $conf, "DBschema", "MySQL 4.1/5.0 UTF-8", "radio", "mysql5" ); ?></li>
1627 <li><?php aField( $conf, "DBschema", "MySQL 4.0 backwards-compatible UTF-8", "radio", "mysql4" ); ?></li>
1630 <p class="config-desc">
1631 This option is ignored on upgrade, the same character set will be kept.
1633 <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!.
1635 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>.
1639 <?php database_switcher('postgres
'); ?>
1640 <div class="config-input"><?php aField( $conf, "DBport", "Database port:" ); ?></div>
1641 <div class="config-input"><?php aField( $conf, "DBpgschema", "Schema for mediawiki:" ); ?></div>
1642 <div class="config-input"><?php aField( $conf, "DBts2schema", "Schema for tsearch2:" ); ?></div>
1643 <div class="config-desc">
1644 <p>The username specified above (at "DB username") will have its search path set to the above schemas,
1645 so it is recommended that you create a new user. The above schemas are generally correct:
1646 only change them if you are sure you need to.</p>
1650 <?php database_switcher('sqlite
'); ?>
1651 <div class="config-input"><?php
1652 aField( $conf, "SQLiteDataDir", "SQLite data directory:" );
1654 <div class="config-desc">
1655 <p>SQLite stores table data into files in the
1658 <p>This directory must exist and be writable by the web server.</p>
1662 <?php database_switcher('ibm_db2
'); ?>
1663 <div class="config-input"><?php
1664 aField( $conf, "DBport_db2", "Database port:" );
1666 <div class="config-input"><?php
1667 aField( $conf, "DBdb2schema", "Schema for mediawiki:" );
1669 <div>Select one:</div>
1671 <li><?php aField( $conf, "DBcataloged", "Cataloged (DB2 installed locally)", "radio", "cataloged" ); ?></li>
1672 <li><?php aField( $conf, "DBcataloged", "Uncataloged (remote DB2 through ODBC)", "radio", "uncataloged" ); ?></li>
1674 <div class="config-desc">
1675 <p>If you need to share one database between multiple wikis, or
1676 between MediaWiki and another web application, you may specify
1677 a different schema to avoid conflicts.</p>
1681 <?php database_switcher('oracle
'); ?>
1682 <div class="config-input"><?php aField( $conf, "DBprefix_ora", "Database table prefix:" ); ?></div>
1683 <div class="config-desc">
1684 <p>If you need to share one database between multiple wikis, or
1685 between MediaWiki and another web application, you may choose to
1686 add a prefix to all the table names to avoid conflicts.</p>
1688 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
1690 <div class="config-input"><?php aField( $conf, "DBdefTS_ora", "Default tablespace:" ); ?></div>
1691 <div class="config-input"><?php aField( $conf, "DBtempTS_ora", "Temporary tablespace:" ); ?></div>
1694 <div class="config-input" style="padding:2em 0 3em">
1695 <label class='column
'> </label>
1696 <input type="submit" value="Install MediaWiki!" class="btn-install" />
1700 <script type="text/javascript">
1701 window.onload = toggleDBarea( <?php echo Xml::encodeJsVar( $conf->DBtype ); ?>,
1703 ## If they passed in a root user name, don't populate it on page load
1704 echo strlen(importPost('RootUser', '')) ?
0 : 1;
1710 /* -------------------------------------------------------------------------------------- */
1711 function writeSuccessMessage() {
1712 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
1713 if ( wfIniGetBool( 'safe_mode' ) && !ini_get( 'open_basedir' ) ) {
1715 <div class="success-box">
1716 <p>Installation successful!</p>
1717 <p>To complete the installation, please do the following:
1719 <li>Download config/LocalSettings.php with your FTP client or file manager</li>
1720 <li>Upload it to the parent directory</li>
1721 <li>Delete config/LocalSettings.php</li>
1722 <li>Start using <a href='../$script'>your wiki</a>!
1724 <p>If you are in a shared hosting environment, do <strong>not</strong> just move LocalSettings.php
1725 remotely. LocalSettings.php is currently owned by the user your webserver is running under,
1726 which means that anyone on the same server can read your database password! Downloading
1727 it and uploading it again will hopefully change the ownership to a user ID specific to you.</p>
1732 <div class="success-box">
1734 <span class="success-message">Installation successful!</span>
1735 Move the <tt>config/LocalSettings.php</tt> file to the parent directory, then follow
1736 <a href="../$script"> this link</a> to your wiki.</p>
1737 <p>You should change file permissions for <tt>LocalSettings.php</tt> as required to
1738 prevent other users on the server reading passwords and altering configuration data.</p>
1745 function escapePhpString( $string ) {
1746 if ( is_array( $string ) ||
is_object( $string ) ) {
1749 return strtr( $string,
1760 function writeLocalSettings( $conf ) {
1761 $conf->PasswordSender
= $conf->EmergencyContact
;
1762 $magic = ($conf->ImageMagick ?
"" : "# ");
1763 $convert = ($conf->ImageMagick ?
$conf->ImageMagick
: "/usr/bin/convert" );
1764 $rights = ($conf->RightsUrl
) ?
"" : "# ";
1765 $hashedUploads = $conf->safeMode ?
'' : '# ';
1766 $dir = realpath( $conf->SQLiteDataDir
);
1768 $dir = $conf->SQLiteDataDir
; // dumb realpath sometimes fails
1770 $sqliteDataDir = escapePhpString( $dir );
1772 if ( $conf->ShellLocale
) {
1776 $conf->ShellLocale
= 'en_US.UTF-8';
1779 switch ( $conf->Shm
) {
1781 $cacheType = 'CACHE_MEMCACHED';
1782 $mcservers = var_export( $conf->MCServerArray
, true );
1787 $cacheType = 'CACHE_ACCEL';
1788 $mcservers = 'array()';
1791 $cacheType = 'CACHE_DBA';
1792 $mcservers = 'array()';
1795 $cacheType = 'CACHE_NONE';
1796 $mcservers = 'array()';
1799 if ( $conf->Email
== 'email_enabled' ) {
1800 $enableemail = 'true';
1801 $enableuseremail = ( $conf->Emailuser
== 'emailuser_enabled' ) ?
'true' : 'false' ;
1802 $eauthent = ( $conf->Eauthent
== 'eauthent_enabled' ) ?
'true' : 'false' ;
1803 switch ( $conf->Enotif
) {
1804 case 'enotif_usertalk':
1805 $enotifusertalk = 'true';
1806 $enotifwatchlist = 'false';
1808 case 'enotif_allpages':
1809 $enotifusertalk = 'true';
1810 $enotifwatchlist = 'true';
1813 $enotifusertalk = 'false';
1814 $enotifwatchlist = 'false';
1817 $enableuseremail = 'false';
1818 $enableemail = 'false';
1819 $eauthent = 'false';
1820 $enotifusertalk = 'false';
1821 $enotifwatchlist = 'false';
1824 $file = @fopen
( "/dev/urandom", "r" );
1826 $secretKey = bin2hex( fread( $file, 32 ) );
1830 for ( $i=0; $i<8; $i++
) {
1831 $secretKey .= dechex(mt_rand(0, 0x7fffffff));
1833 print "<li>Warning: \$wgSecretKey key is insecure, generated with mt_rand(). Consider changing it manually.</li>\n";
1836 # Add slashes to strings for double quoting
1837 $slconf = wfArrayMap( "escapePhpString", get_object_vars( $conf ) );
1838 if( $conf->License
== 'gfdl1_2' ||
$conf->License
== 'pd' ||
$conf->License
== 'gfdl1_3' ) {
1839 # Needs literal string interpolation for the current style path
1840 $slconf['RightsIcon'] = $conf->RightsIcon
;
1843 if( $conf->DBtype
== 'mysql' ) {
1845 "# MySQL specific settings
1846 \$wgDBprefix = \"{$slconf['DBprefix']}\";
1848 # MySQL table options to use during installation or update
1849 \$wgDBTableOptions = \"{$slconf['DBTableOptions']}\";
1851 # Experimental charset support for MySQL 4.1/5.0.
1852 \$wgDBmysql5 = {$conf->DBmysql5};";
1853 } elseif( $conf->DBtype
== 'postgres' ) {
1855 "# Postgres specific settings
1856 \$wgDBport = \"{$slconf['DBport']}\";
1857 \$wgDBmwschema = \"{$slconf['DBpgschema']}\";
1858 \$wgDBts2schema = \"{$slconf['DBts2schema']}\";";
1859 } elseif( $conf->DBtype
== 'sqlite' ) {
1861 "# SQLite-specific settings
1862 \$wgSQLiteDataDir = \"{$sqliteDataDir}\";";
1863 } elseif( $conf->DBtype
== 'ibm_db2' ) {
1865 "# DB2 specific settings
1866 \$wgDBport = \"{$slconf['DBport_db2']}\";
1867 \$wgDBmwschema = \"{$slconf['DBdb2schema']}\";
1868 \$wgDBcataloged = \"{$slconf['DBcataloged']}\";";
1869 } elseif( $conf->DBtype
== 'oracle' ) {
1871 "# Oracle specific settings
1872 \$wgDBprefix = \"{$slconf['DBprefix_ora']}\";";
1880 # This file was automatically generated by the MediaWiki installer.
1881 # If you make manual changes, please keep track in case you need to
1882 # recreate them later.
1884 # See includes/DefaultSettings.php for all configurable settings
1885 # and their default values, but don't forget to make changes in _this_
1888 # Further documentation for configuration settings may be found at:
1889 # http://www.mediawiki.org/wiki/Manual:Configuration_settings
1891 # If you customize your file layout, set \$IP to the directory that contains
1892 # the other MediaWiki files. It will be used as a base to locate files.
1893 if( defined( 'MW_INSTALL_PATH' ) ) {
1894 \$IP = MW_INSTALL_PATH;
1896 \$IP = dirname( __FILE__ );
1899 \$path = array( \$IP, \"\$IP/includes\", \"\$IP/languages\" );
1900 set_include_path( implode( PATH_SEPARATOR, \$path ) . PATH_SEPARATOR . get_include_path() );
1902 require_once( \"\$IP/includes/DefaultSettings.php\" );
1904 if ( \$wgCommandLineMode ) {
1905 if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
1906 die( \"This script must be run from the command line\\n\" );
1909 ## Uncomment this to disable output compression
1910 # \$wgDisableOutputCompression = true;
1912 \$wgSitename = \"{$slconf['Sitename']}\";
1914 ## The URL base path to the directory containing the wiki;
1915 ## defaults for all runtime URL paths are based off of this.
1916 ## For more information on customizing the URLs please see:
1917 ## http://www.mediawiki.org/wiki/Manual:Short_URL
1918 \$wgScriptPath = \"{$slconf['ScriptPath']}\";
1919 \$wgScriptExtension = \"{$slconf['ScriptExtension']}\";
1921 ## The relative URL path to the skins directory
1922 \$wgStylePath = \"\$wgScriptPath/skins\";
1924 ## The relative URL path to the logo. Make sure you change this from the default,
1925 ## or else you'll overwrite your logo when you upgrade!
1926 \$wgLogo = \"\$wgStylePath/common/images/wiki.png\";
1928 ## UPO means: this is also a user preference option
1930 \$wgEnableEmail = $enableemail;
1931 \$wgEnableUserEmail = $enableuseremail; # UPO
1933 \$wgEmergencyContact = \"{$slconf['EmergencyContact']}\";
1934 \$wgPasswordSender = \"{$slconf['PasswordSender']}\";
1936 \$wgEnotifUserTalk = $enotifusertalk; # UPO
1937 \$wgEnotifWatchlist = $enotifwatchlist; # UPO
1938 \$wgEmailAuthentication = $eauthent;
1940 ## Database settings
1941 \$wgDBtype = \"{$slconf['DBtype']}\";
1942 \$wgDBserver = \"{$slconf['DBserver']}\";
1943 \$wgDBname = \"{$slconf['DBname']}\";
1944 \$wgDBuser = \"{$slconf['DBuser']}\";
1945 \$wgDBpassword = \"{$slconf['DBpassword']}\";
1949 ## Shared memory settings
1950 \$wgMainCacheType = $cacheType;
1951 \$wgMemCachedServers = $mcservers;
1953 ## To enable image uploads, make sure the 'images' directory
1954 ## is writable, then set this to true:
1955 \$wgEnableUploads = false;
1956 {$magic}\$wgUseImageMagick = true;
1957 {$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
1959 ## If you use ImageMagick (or any other shell command) on a
1960 ## Linux server, this will need to be set to the name of an
1961 ## available UTF-8 locale
1962 {$locale}\$wgShellLocale = \"{$slconf['ShellLocale']}\";
1964 ## If you want to use image uploads under safe mode,
1965 ## create the directories images/archive, images/thumb and
1966 ## images/temp, and make them all writable. Then uncomment
1967 ## this, if it's not already uncommented:
1968 {$hashedUploads}\$wgHashedUploadDirectory = false;
1970 ## If you have the appropriate support software installed
1971 ## you can enable inline LaTeX equations:
1974 ## Set \$wgCacheDirectory to a writable directory on the web server
1975 ## to make your wiki go slightly faster. The directory should not
1976 ## be publically accessible from the web.
1977 #\$wgCacheDirectory = \"\$IP/cache\";
1979 \$wgLocalInterwiki = strtolower( \$wgSitename );
1981 \$wgLanguageCode = \"{$slconf['LanguageCode']}\";
1983 \$wgSecretKey = \"$secretKey\";
1985 ## Default skin: you can change the default skin. Use the internal symbolic
1986 ## names, ie 'vector', 'monobook':
1987 \$wgDefaultSkin = 'monobook';
1989 ## For attaching licensing metadata to pages, and displaying an
1990 ## appropriate copyright notice / icon. GNU Free Documentation
1991 ## License and Creative Commons licenses are supported so far.
1992 {$rights}\$wgEnableCreativeCommonsRdf = true;
1993 \$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright
1994 \$wgRightsUrl = \"{$slconf['RightsUrl']}\";
1995 \$wgRightsText = \"{$slconf['RightsText']}\";
1996 \$wgRightsIcon = \"{$slconf['RightsIcon']}\";
1997 # \$wgRightsCode = \"{$slconf['RightsCode']}\"; # Not yet used
1999 \$wgDiff3 = \"{$slconf['diff3']}\";
2001 # When you make changes to this configuration file, this will make
2002 # sure that cached pages are cleared.
2003 \$wgCacheEpoch = max( \$wgCacheEpoch, gmdate( 'YmdHis', @filemtime( __FILE__ ) ) );
2004 "; ## End of setting the $localsettings string
2006 // Keep things in Unix line endings internally;
2007 // the system will write out as local text type.
2008 return str_replace( "\r\n", "\n", $localsettings );
2011 function dieout( $text ) {
2012 global $mainListOpened;
2013 if( $mainListOpened ) echo( "</ul>" );
2014 if( $text != '' && substr( $text, 0, 2 ) != '<p' && substr( $text, 0, 2 ) != '<h' ){
2015 echo "<p>$text</p>\n";
2019 die( "\n\n</div>\n</div>\n</div>\n</div>\n</body>\n</html>" );
2022 function importVar( &$var, $name, $default = "" ) {
2023 if( isset( $var[$name] ) ) {
2024 $retval = $var[$name];
2025 if ( get_magic_quotes_gpc() ) {
2026 $retval = stripslashes( $retval );
2035 function importPost( $name, $default = "" ) {
2036 return importVar( $_POST, $name, $default );
2039 function importCheck( $name ) {
2040 return isset( $_POST[$name] );
2043 function importRequest( $name, $default = "" ) {
2044 return importVar( $_REQUEST, $name, $default );
2047 function aField( &$conf, $field, $text, $type = "text", $value = "", $onclick = '' ) {
2048 static $radioCount = 0;
2050 $xtype = "type=\"$type\"";
2056 $nolabel = ($type == "radio") ||
($type == "hidden");
2058 if ($type == 'radio')
2059 $id .= $radioCount++
;
2062 echo "<label class='column' for=\"$id\">$text</label>";
2065 if( $type == "radio" && $value == $conf->$field ) {
2066 $checked = "checked='checked'";
2070 echo "<input $xtype name=\"$field\" id=\"$id\" class=\"iput-$type\" $checked ";
2072 echo " onclick='toggleDBarea(\"$value\",1)' " ;
2075 if( $type == "radio" ) {
2076 echo htmlspecialchars( $value );
2078 echo htmlspecialchars( $conf->$field );
2084 echo "<label for=\"$id\">$text</label>";
2088 if(isset($errs[$field])) {
2089 echo "<span class='error'>" . htmlspecialchars( $errs[$field] ) . "</span>\n";
2093 function getLanguageList() {
2094 global $wgDummyLanguageCodes;
2097 foreach ( Language
::getLanguageNames() as $code => $name ) {
2098 if( in_array( $code, $wgDummyLanguageCodes ) ) continue;
2099 $codes[$code] = $code . ' - ' . $name;
2105 #Check for location of an executable
2106 # @param string $loc single location to check
2107 # @param array $names filenames to check for.
2108 # @param mixed $versioninfo array of details to use when checking version, use false for no version checking
2109 function locate_executable($loc, $names, $versioninfo = false) {
2110 if (!is_array($names))
2111 $names = array($names);
2113 foreach ($names as $name) {
2114 $command = "$loc".DIRECTORY_SEPARATOR
."$name";
2115 if (@file_exists
($command)) {
2119 $file = str_replace('$1', $command, $versioninfo[0]);
2120 if (strstr(`
$file`
, $versioninfo[1]) !== false)
2127 # Test a memcached server
2128 function testMemcachedServer( $server ) {
2129 $hostport = explode(":", $server);
2132 if ( !function_exists( 'fsockopen' ) ) {
2133 $errstr = "Can't connect to memcached, fsockopen() not present";
2135 if ( !$errstr && count( $hostport ) != 2 ) {
2136 $errstr = 'Please specify host and port';
2139 list( $host, $port ) = $hostport;
2143 $fp = @fsockopen
( $host, $port, $errno, $fsockerr, 1.0 );
2144 if ( $fp === false ) {
2145 $errstr = "Cannot connect to memcached on $host:$port : $fsockerr";
2149 $command = "version\r\n";
2150 $bytes = fwrite( $fp, $command );
2151 if ( $bytes != strlen( $command ) ) {
2152 $errstr = "Cannot write to memcached socket on $host:$port";
2156 $expected = "VERSION ";
2157 $response = fread( $fp, strlen( $expected ) );
2158 if ( $response != $expected ) {
2159 $errstr = "Didn't get correct memcached response from $host:$port";
2166 echo "<li>Connected to memcached on " . htmlspecialchars( "$host:$port" ) ." successfully</li>";
2171 function database_picker($conf) {
2174 foreach(array_keys($ourdb) as $db) {
2175 if ($ourdb[$db]['havedriver']) {
2177 aField( $conf, "DBtype", $ourdb[$db]['fullname'], 'radio', $db, 'onclick');
2184 function database_switcher($db) {
2186 $color = $ourdb[$db]['bgcolor'];
2187 $full = $ourdb[$db]['fullname'];
2188 print "<fieldset id='$db' style='clear:both'><legend>$full-specific options</legend>\n";
2191 function printListItem( $item ) {
2192 print "<li>$item</li>";
2195 # Determine a suitable value for $wgShellLocale
2196 function getShellLocale( $wikiLang ) {
2197 # Give up now if we're in safe mode or open_basedir
2198 # It's theoretically possible but tricky to work with
2199 if ( wfIniGetBool( "safe_mode" ) ||
ini_get( 'open_basedir' ) ||
!function_exists('exec') ) {
2203 $os = php_uname( 's' );
2204 $supported = array( 'Linux', 'SunOS', 'HP-UX' ); # Tested these
2205 if ( !in_array( $os, $supported ) ) {
2209 # Get a list of available locales
2210 $lines = $ret = false;
2211 exec( '/usr/bin/locale -a', $lines, $ret );
2216 $lines = wfArrayMap( 'trim', $lines );
2217 $candidatesByLocale = array();
2218 $candidatesByLang = array();
2219 foreach ( $lines as $line ) {
2220 if ( $line === '' ) {
2223 if ( !preg_match( '/^([a-zA-Z]+)(_[a-zA-Z]+|)\.(utf8|UTF-8)(@[a-zA-Z_]*|)$/i', $line, $m ) ) {
2226 list( $all, $lang, $territory, $charset, $modifier ) = $m;
2227 $candidatesByLocale[$m[0]] = $m;
2228 $candidatesByLang[$lang][] = $m;
2231 # Try the current value of LANG
2232 if ( isset( $candidatesByLocale[ getenv( 'LANG' ) ] ) ) {
2233 return getenv( 'LANG' );
2236 # Try the most common ones
2237 $commonLocales = array( 'en_US.UTF-8', 'en_US.utf8', 'de_DE.UTF-8', 'de_DE.utf8' );
2238 foreach ( $commonLocales as $commonLocale ) {
2239 if ( isset( $candidatesByLocale[$commonLocale] ) ) {
2240 return $commonLocale;
2244 # Is there an available locale in the Wiki's language?
2245 if ( isset( $candidatesByLang[$wikiLang] ) ) {
2246 $m = reset( $candidatesByLang[$wikiLang] );
2250 # Are there any at all?
2251 if ( count( $candidatesByLocale ) ) {
2252 $m = reset( $candidatesByLocale );
2262 <div
class="license">
2264 <p
>This program is free software
; you can redistribute it
and/or modify
2265 it under the terms of the GNU General
Public License
as published by
2266 the Free Software Foundation
; either version
2 of the License
, or
2267 (at your option
) any later version
.</p
>
2269 <p
>This program is distributed in the hope that it will be useful
,
2270 but WITHOUT ANY WARRANTY
; without even the implied warranty of
2271 MERCHANTABILITY
or FITNESS
FOR A PARTICULAR PURPOSE
. See the
2272 GNU General
Public License
for more details
.</p
>
2274 <p
>You should have received
<a href
="../COPYING">a copy of the GNU General
Public License
</a
>
2275 along with this program
; if not
, write to the Free Software
2276 Foundation
, Inc
., 51 Franklin Street
, Fifth Floor
, Boston
, MA
02110-1301, USA
.
2277 or <a href
="http://www.gnu.org/copyleft/gpl.html">read it online
</a
></p
>
2283 <div id
="column-one">
2284 <div
class="portlet" id
="p-logo">
2285 <a style
="background-image: url(../skins/common/images/mediawiki.png);"
2287 title
="Main Page"></a
>
2289 <script type
="text/javascript"> if (window
.isMSIE55
) fixalpha(); </script
>
2290 <div
class='portlet'><div
class='pBody'>
2292 <li
><a href
="../README">Readme
</a
></li
>
2293 <li
><a href
="../RELEASE-NOTES">Release notes
</a
></li
>
2294 <li
><a href
="../docs/">Documentation
</a
></li
>
2295 <li
><a href
="http://www.mediawiki.org/wiki/Help:Contents">User
's Guide</a></li>
2296 <li><a href="http://www.mediawiki.org/wiki/Manual:Contents">Administrator's Guide
</a
></li
>
2297 <li
><a href
="http://www.mediawiki.org/wiki/Manual:FAQ">FAQ
</a
></li
>
2299 <p style
="font-size:90%;margin-top:1em">MediaWiki is Copyright ©
2001-2010 by Magnus Manske
, Brion Vibber
,
2300 Lee Daniel Crocker
, Tim Starling
, Erik Möller
, Gabriel Wicke
, Æ
var Arnfjörð Bjarmason
, Niklas Laxström
,
2301 Domas Mituzas
, Rob Church
, Yuri Astrakhan
, Aryeh Gregor
, Aaron Schulz
and others
.</p
>