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['mssql'] = array(
91 'fullname' => 'Microsoft SQL Server',
93 'compile' => 'sqlsrv',
94 'bgcolor' => '#cccccc',
99 $ourdb['ibm_db2'] = array(
102 'compile' => 'ibm_db2',
103 'bgcolor' => '#ffeba1',
104 'rootuser' => 'db2admin',
105 'serverless' => false
108 $ourdb['oracle'] = array(
109 'fullname' => 'Oracle',
112 'bgcolor' => '#ffeba1',
114 'serverless' => false
118 <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
119 <html xmlns
="http://www.w3.org/1999/xhtml" lang
="en" dir
="ltr">
121 <meta http
-equiv
="Content-type" content
="text/html; charset=utf-8" />
122 <meta name
="robots" content
="noindex,nofollow"/>
123 <title
>MediaWiki
<?php
echo htmlspecialchars( $wgVersion ); ?
> Installation
</title
>
124 <style type
="text/css">
126 @import
"../skins/monobook/main.css";
130 margin
: 1em
0 1em
2.5em
;
137 .config
-section label
.column
{
149 zoom
: 100%
; /* IE hack */
152 .config
-section
.config
-desc
{
154 margin
: 0 0 2em
18em
;
159 .iput
-text
, .iput
-password
{
166 background
-color
: #fff;
174 background
-color
: #FFF0F0;
175 border
: 2px solid red
;
183 list-style
-type
: none
;
184 list-style
-image
: none
;
201 span
.success
-message
{
212 <script type
="text/javascript">
214 <?php
echo 'var databases = ' . FormatJson
::encode( $ourdb ) . ';'; ?
>
216 function show(id
, showOrHide
) {
217 var i
= document
.getElementById(id
);
218 if (i
) i
.style
.display
= showOrHide ?
'block' : 'none';
221 for (db in databases
) {
225 function toggleDBarea(id
, defaultroot
) {
227 var dbarea
= document
.getElementById(id
);
228 if (dbarea
) dbarea
.style
.display
= (dbarea
.style
.display
== 'none') ?
'block' : 'none';
229 var db
= document
.getElementById('RootUser');
230 db
.value
= databases
[id
].rootuser
;
231 show('db-server-settings1', !databases
[id
].serverless
);
232 show('db-server-settings2', !databases
[id
].serverless
);
239 <div id
="globalWrapper">
240 <div id
="column-content">
242 <div id
="bodyContent">
244 <h1
>MediaWiki
<?php
print htmlspecialchars( $wgVersion ) ?
> Installation
</h1
>
247 $mainListOpened = false; # Is the main list (environement checking) opend ? Used by dieout
249 /* Check for existing configurations and bug out! */
251 if( file_exists( "../LocalSettings.php" ) ) {
252 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
253 dieout( "<p><strong>Setup has completed, <a href='../$script'>your wiki</a> is configured.</strong></p>
254 <p>Please delete the /config directory for extra security.</p>" );
257 if( file_exists( "./LocalSettings.php" ) ) {
258 writeSuccessMessage();
262 if( !is_writable( "." ) ) {
263 dieout( "<h2>Can't write config file, aborting</h2>
265 <p>In order to configure the wiki you have to make the <tt>config</tt> subdirectory
266 writable by the web server. Once configuration is done you'll move the created
267 <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can
268 then remove the <tt>config</tt> subdirectory entirely.</p>
270 <p>To make the directory writable on a Unix/Linux system:</p>
273 cd <i>" . htmlspecialchars( dirname( dirname( __FILE__
) ) ) . "</i>
277 <p>Afterwards retry to start the <a href=\"\">setup</a>.</p>" );
281 require_once( "$IP/maintenance/updaters.inc" );
284 function getEncoded( $data ) {
285 # removing latin1 support, no need...
288 function getSitename() { return $this->getEncoded( $this->Sitename
); }
289 function getSysopName() { return $this->getEncoded( $this->SysopName
); }
290 function getSysopPass() { return $this->getEncoded( $this->SysopPass
); }
292 function setSchema( $schema, $engine ) {
293 $this->DBschema
= $schema;
294 if ( !preg_match( '/^\w*$/', $engine ) ){
297 switch ( $this->DBschema
) {
299 $this->DBTableOptions
= "ENGINE=$engine, DEFAULT CHARSET=utf8";
300 $this->DBmysql5
= 'true';
302 case 'mysql5-binary':
303 $this->DBTableOptions
= "ENGINE=$engine, DEFAULT CHARSET=binary";
304 $this->DBmysql5
= 'true';
307 $this->DBTableOptions
= "TYPE=$engine";
308 $this->DBmysql5
= 'false';
310 $this->DBengine
= $engine;
312 # Set the global for use during install
313 global $wgDBTableOptions;
314 $wgDBTableOptions = $this->DBTableOptions
;
322 <b
>Don
't forget security updates!</b> Keep an eye on the
323 <a href="http://lists.wikimedia.org/mailman/listinfo/mediawiki-announce">low-traffic
324 release announcements mailing list</a>.
329 <h2>Checking environment...</h2>
330 <p><em>Please include all of the lines below when reporting installation problems.</em></p>
331 <ul class="env-check">
333 $mainListOpened = true;
337 define( 'MW_NO_OUTPUT_BUFFER
', 1 );
338 $conf = new ConfigData;
340 install_version_checks();
341 $self = 'Installer
'; # Maintenance script name, to please Setup.php
343 print "<li>PHP " . htmlspecialchars( phpversion() ) . " installed</li>\n";
345 error_reporting( 0 );
346 $phpdatabases = array();
347 foreach (array_keys($ourdb) as $db) {
348 $compname = $ourdb[$db]['compile
'];
349 if( wfDl( $compname ) ) {
350 array_push($phpdatabases, $db);
351 $ourdb[$db]['havedriver
'] = 1;
354 error_reporting( E_ALL | E_STRICT );
356 if (!$phpdatabases) {
357 print "Could not find a suitable database driver!<ul>";
358 foreach (array_keys($ourdb) AS $db) {
359 $comp = $ourdb[$db]['compile
'];
360 $full = $ourdb[$db]['fullname
'];
361 print "<li>For <b>$full</b>, compile PHP using <b>--with-$comp</b>, "
362 ."or install the $comp.so module</li>\n";
368 print "<li>Found database drivers for:";
370 foreach (array_keys($ourdb) AS $db) {
371 if ($ourdb[$db]['havedriver
']) {
372 if ( $DefaultDBtype == '' ) {
373 $DefaultDBtype = $db;
375 print " ".$ourdb[$db]['fullname
'];
380 if( wfIniGetBool( "register_globals" ) ) {
383 <div style="font-size:110%">
384 <strong class="error">Warning:</strong>
385 <strong>PHP's
<tt
><a href
="http://php.net/register_globals">register_globals
</a
></tt
> option is enabled
. Disable it
if you can
.</strong
>
387 MediaWiki will work
, but your server is more exposed to PHP
-based security vulnerabilities
.
394 if( wfIniGetBool( "magic_quotes_runtime" ) ) {
396 ?
><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
>
397 This option corrupts data input unpredictably
; you cannot install
or use
398 MediaWiki unless this option is disabled
.</li
>
402 if( wfIniGetBool( "magic_quotes_sybase" ) ) {
404 ?
><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
>
405 This option corrupts data input unpredictably
; you cannot install
or use
406 MediaWiki unless this option is disabled
.</li
>
410 if( wfIniGetBool( "mbstring.func_overload" ) ) {
412 ?
><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
>
413 This option causes errors
and may corrupt data unpredictably
;
414 you cannot install
or use MediaWiki unless this option is disabled
.</li
>
418 if( wfIniGetBool( "zend.ze1_compatibility_mode" ) ) {
420 ?
><li
class="error"><strong
>Fatal
: <a href
="http://www.php.net/manual/en/ini.core.php">zend
.ze1_compatibility_mode
</a
> is active
!</strong
>
421 This option causes horrible bugs with MediaWiki
; you cannot install
or use
422 MediaWiki unless this option is disabled
.</li
>
427 dieout( "Cannot install MediaWiki." );
430 if( wfIniGetBool( "safe_mode" ) ) {
431 $conf->safeMode
= true;
433 <li
><b
class='error'>Warning
:</b
> <strong
>PHP
's
434 <a href='http
://www.php.net/features.safe-mode'>safe mode</a> is active.</strong>
435 You may have problems caused by this
, particularly
if using image uploads
.
439 $conf->safeMode
= false;
442 $sapi = htmlspecialchars( php_sapi_name() );
443 print "<li>PHP server API is $sapi; ";
444 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
445 if( $wgUsePathInfo ) {
446 print "ok, using pretty URLs (<tt>$script/Page_Title</tt>)";
448 print "using ugly URLs (<tt>$script?title=Page_Title</tt>)";
452 $conf->xml
= function_exists( "utf8_encode" );
454 print "<li>Have XML / Latin1-UTF-8 conversion support.</li>\n";
456 dieout( "PHP's XML module is missing; the wiki requires functions in
457 this module and won't work in this configuration.
458 If you're running Mandrake, install the php-xml package." );
461 # Check for session support
462 if( !function_exists( 'session_name' ) )
463 dieout( "PHP's session module is missing. MediaWiki requires session support in order to function." );
465 # session.save_path doesn't *have* to be set, but if it is, and it's
466 # not valid/writable/etc. then it can cause problems
467 $sessionSavePath = mw_get_session_save_path();
468 $ssp = htmlspecialchars( $sessionSavePath );
469 # Warn the user if it's not set, but let them proceed
470 if( !$sessionSavePath ) {
471 print "<li><strong>Warning:</strong> A value for <tt>session.save_path</tt>
472 has not been set in PHP.ini. If the default value causes problems with
473 saving session data, set it to a valid path which is read/write/execute
474 for the user your web server is running under.</li>";
475 } elseif ( is_dir( $sessionSavePath ) && is_writable( $sessionSavePath ) ) {
476 # All good? Let the user know
477 print "<li>Session save path (<tt>{$ssp}</tt>) appears to be valid.</li>";
479 # Something not right? Warn the user, but let them proceed
480 print "<li><strong>Warning:</strong> Your <tt>session.save_path</tt> value (<tt>{$ssp}</tt>)
481 appears to be invalid or is not writable. PHP needs to be able to save data to
482 this location for correct session operation.</li>";
485 # Check for PCRE support
486 if( !function_exists( 'preg_match' ) )
487 dieout( "The PCRE support module appears to be missing. MediaWiki requires the
488 Perl-compatible regular expression functions." );
490 # The installer can take a while, and we really don't want it to time out
491 wfSuppressWarnings();
495 $memlimit = ini_get( "memory_limit" );
496 if( $memlimit == -1 ) {
497 print "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n";
499 print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars( $memlimit ). " bytes. ";
500 $newlimit = wfMemoryLimit();
501 $memlimit = wfShorthandToInteger( $memlimit );
502 if( $newlimit < $memlimit ) {
503 print "<b>Failed raising limit, installation may fail.</b>";
504 } elseif ( $newlimit > $memlimit ) {
505 print "Raised <tt>memory_limit</tt> to " . htmlspecialchars( $newlimit ) . " bytes. ";
510 $conf->xcache
= function_exists( 'xcache_get' );
512 print "<li><a href=\"http://trac.lighttpd.net/xcache/\">XCache</a> installed</li>\n";
514 $conf->apc
= function_exists('apc_fetch');
516 print "<li><a href=\"http://www.php.net/apc\">APC</a> installed</li>\n";
519 $conf->eaccel
= function_exists( 'eaccelerator_get' );
520 if ( $conf->eaccel
) {
521 print "<li><a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> installed</li>\n";
524 $conf->dba
= function_exists( 'dba_open' );
526 if( !( $conf->eaccel ||
$conf->apc ||
$conf->xcache
) ) {
527 echo( '<li>Couldn\'t find <a href="http://eaccelerator.sourceforge.net">eAccelerator</a>,
528 <a href="http://www.php.net/apc">APC</a> or <a href="http://trac.lighttpd.net/xcache/">XCache</a>;
529 cannot use these for object caching.</li>' );
532 $conf->diff3
= false;
533 $diff3locations = array_merge(
540 explode( PATH_SEPARATOR
, getenv( "PATH" ) ) );
541 $diff3names = array( "gdiff3", "diff3", "diff3.exe" );
543 $diff3versioninfo = array( '$1 --version 2>&1', 'diff3 (GNU diffutils)' );
544 foreach ($diff3locations as $loc) {
545 $exe = locate_executable($loc, $diff3names, $diff3versioninfo);
546 if ($exe !== false) {
553 print "<li>Found GNU diff3: <tt>$conf->diff3</tt>.</li>";
555 print "<li>GNU diff3 not found.</li>";
557 $conf->ImageMagick
= false;
558 $imcheck = array( "/usr/bin", "/opt/csw/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" );
559 foreach( $imcheck as $dir ) {
560 $im = "$dir/convert";
561 if( @file_exists
( $im ) ) {
562 print "<li>Found ImageMagick: <tt>$im</tt>; image thumbnailing will be enabled if you enable uploads.</li>\n";
563 $conf->ImageMagick
= $im;
568 $conf->HaveGD
= function_exists( "imagejpeg" );
569 if( $conf->HaveGD
) {
570 print "<li>Found GD graphics library built-in";
571 if( !$conf->ImageMagick
) {
572 print ", image thumbnailing will be enabled if you enable uploads";
576 if( !$conf->ImageMagick
) {
577 print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n";
581 $conf->IP
= dirname( dirname( __FILE__
) );
582 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP
) . "</tt></li>\n";
585 // PHP_SELF isn't available sometimes, such as when PHP is CGI but
586 // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
587 // to get the path to the current script... hopefully it's reliable. SIGH
588 $path = ($_SERVER["PHP_SELF"] === '')
589 ?
$_SERVER["SCRIPT_NAME"]
590 : $_SERVER["PHP_SELF"];
592 $conf->ScriptPath
= preg_replace( '{^(.*)/config.*$}', '$1', $path );
593 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath
) . "</tt></li>\n";
597 // We may be installing from *.php5 extension file, if so, print message
598 $conf->ScriptExtension
= '.php';
599 if (defined('MW_INSTALL_PHP5_EXT')) {
600 $conf->ScriptExtension
= '.php5';
601 print "<li>Installing MediaWiki with <tt>php5</tt> file extensions</li>\n";
603 print "<li>Installing MediaWiki with <tt>php</tt> file extensions</li>\n";
607 print "<li style='font-weight:bold;color:green;font-size:110%'>Environment checked. You can install MediaWiki.</li>\n";
608 $conf->posted
= ($_SERVER["REQUEST_METHOD"] == "POST");
610 $conf->Sitename
= ucfirst( importPost( "Sitename", "" ) );
611 $defaultEmail = empty( $_SERVER["SERVER_ADMIN"] )
613 : $_SERVER["SERVER_ADMIN"];
614 $conf->EmergencyContact
= importPost( "EmergencyContact", $defaultEmail );
615 $conf->DBtype
= importPost( "DBtype", $DefaultDBtype );
616 if ( !isset( $ourdb[$conf->DBtype
] ) ) {
617 $conf->DBtype
= $DefaultDBtype;
620 $conf->DBserver
= importPost( "DBserver", $wgDBserver );
621 $conf->DBname
= importPost( "DBname", $wgDBname );
622 $conf->DBuser
= importPost( "DBuser", $wgDBuser );
623 $conf->DBpassword
= importPost( "DBpassword" );
624 $conf->DBpassword2
= importPost( "DBpassword2" );
625 $conf->SysopName
= importPost( "SysopName", "WikiSysop" );
626 $conf->SysopPass
= importPost( "SysopPass" );
627 $conf->SysopPass2
= importPost( "SysopPass2" );
628 $conf->RootUser
= importPost( "RootUser" );
629 $conf->RootPW
= importPost( "RootPW", "" );
630 $useRoot = importCheck( 'useroot', false );
631 $conf->LanguageCode
= importPost( "LanguageCode", "en" );
633 $conf->DBprefix
= importPost( "DBprefix" );
635 importPost( "DBschema", "mysql5-binary" ),
636 importPost( "DBengine", "InnoDB" ) );
638 ## Postgres specific:
639 $conf->DBport
= importPost( "DBport", $wgDBport );
640 $conf->DBts2schema
= importPost( "DBts2schema", "public" );
641 $conf->DBpgschema
= importPost( "DBpgschema", "mediawiki" );
644 $conf->SQLiteDataDir
= importPost( "SQLiteDataDir", "$IP/../data" );
647 // New variable in order to have a different default port number
648 $conf->DBport_db2
= importPost( "DBport_db2", "50000" );
649 $conf->DBcataloged
= importPost( "DBcataloged", "cataloged" );
650 $conf->DBdb2schema
= importPost( "DBdb2schema", "mediawiki" );
653 $conf->DBprefix_ora
= importPost( "DBprefix_ora" );
654 $conf->DBdefTS_ora
= importPost( "DBdefTS_ora", "USERS" );
655 $conf->DBtempTS_ora
= importPost( "DBtempTS_ora", "TEMP" );
657 $conf->ShellLocale
= getShellLocale( $conf->LanguageCode
);
659 /* Check for validity */
662 if( preg_match( '/^$|^mediawiki$|#/i', $conf->Sitename
) ) {
663 $errs["Sitename"] = "Must not be blank or \"MediaWiki\" and may not contain \"#\"";
665 if( !$ourdb[$conf->DBtype
]['serverless'] ) {
666 if( $conf->DBuser
== "" ) {
667 $errs["DBuser"] = "Must not be blank";
669 if( ($conf->DBtype
== 'mysql') && (strlen($conf->DBuser
) > 16) ) {
670 $errs["DBuser"] = "Username too long";
672 if( $conf->DBpassword
== "" && $conf->DBtype
!= "postgres" ) {
673 $errs["DBpassword"] = "Must not be blank";
675 if( $conf->DBpassword
!= $conf->DBpassword2
) {
676 $errs["DBpassword2"] = "Passwords don't match!";
679 if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix
) ) {
680 $errs["DBprefix"] = "Invalid table prefix";
682 untaint( $conf->DBprefix
, TC_MYSQL
);
684 if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix_ora
) ) {
685 $errs["DBprefix_ora"] = "Invalid table prefix";
688 error_reporting( E_ALL | E_STRICT
);
691 * Initialise $wgLang and $wgContLang to something so we can
692 * call case-folding methods. Per Brion, this is English for
693 * now, although we could be clever and initialise to the
694 * user-selected language.
696 $wgContLang = Language
::factory( 'en' );
697 $wgLang = $wgContLang;
700 * We're messing about with users, so we need a stub
701 * authentication plugin...
703 $wgAuth = new AuthPlugin();
706 * Validate the initial administrator account; username,
707 * password checks, etc.
709 if( $conf->SysopName
) {
710 # Check that the user can be created
711 $u = User
::newFromName( $conf->SysopName
);
712 if( $u instanceof User
) {
713 # Various password checks
714 if( $conf->SysopPass
!= '' ) {
715 if( $conf->SysopPass
== $conf->SysopPass2
) {
716 if( !$u->isValidPassword( $conf->SysopPass
) ) {
717 $errs['SysopPass'] = "Bad password";
720 $errs['SysopPass2'] = "Passwords don't match";
723 $errs['SysopPass'] = "Cannot be blank";
727 $errs['SysopName'] = "Bad username";
731 $conf->License
= importRequest( "License", "none" );
732 if( $conf->License
== "gfdl1_2" ) {
733 $conf->RightsUrl
= "http://www.gnu.org/licenses/old-licenses/fdl-1.2.txt";
734 $conf->RightsText
= "GNU Free Documentation License 1.2";
735 $conf->RightsCode
= "gfdl1_2";
736 $conf->RightsIcon
= '${wgScriptPath}/skins/common/images/gnu-fdl.png';
737 } elseif( $conf->License
== "gfdl1_3" ) {
738 $conf->RightsUrl
= "http://www.gnu.org/copyleft/fdl.html";
739 $conf->RightsText
= "GNU Free Documentation License 1.3";
740 $conf->RightsCode
= "gfdl1_3";
741 $conf->RightsIcon
= '${wgScriptPath}/skins/common/images/gnu-fdl.png';
742 } elseif( $conf->License
== "none" ) {
743 $conf->RightsUrl
= $conf->RightsText
= $conf->RightsCode
= $conf->RightsIcon
= "";
744 } elseif( $conf->License
== "pd" ) {
745 $conf->RightsUrl
= "http://creativecommons.org/licenses/publicdomain/";
746 $conf->RightsText
= "Public Domain";
747 $conf->RightsCode
= "pd";
748 $conf->RightsIcon
= '${wgScriptPath}/skins/common/images/public-domain.png';
750 $conf->RightsUrl
= importRequest( "RightsUrl", "" );
751 $conf->RightsText
= importRequest( "RightsText", "" );
752 $conf->RightsCode
= importRequest( "RightsCode", "" );
753 $conf->RightsIcon
= importRequest( "RightsIcon", "" );
756 $conf->Shm
= importRequest( "Shm", "none" );
757 $conf->MCServers
= importRequest( "MCServers" );
759 /* Test memcached servers */
761 if ( $conf->Shm
== 'memcached' && $conf->MCServers
) {
762 $conf->MCServerArray
= wfArrayMap( 'trim', explode( ',', $conf->MCServers
) );
763 foreach ( $conf->MCServerArray
as $server ) {
764 $error = testMemcachedServer( $server );
766 $errs["MCServers"] = $error;
770 } else if ( $conf->Shm
== 'memcached' ) {
771 $errs["MCServers"] = "Please specify at least one server if you wish to use memcached";
774 /* default values for installation */
775 $conf->Email
= importRequest("Email", "email_enabled");
776 $conf->Emailuser
= importRequest("Emailuser", "emailuser_enabled");
777 $conf->Enotif
= importRequest("Enotif", "enotif_allpages");
778 $conf->Eauthent
= importRequest("Eauthent", "eauthent_enabled");
780 if( $conf->posted
&& ( 0 == count( $errs ) ) ) {
781 do { /* So we can 'continue' to end prematurely */
782 $conf->Root
= ($conf->RootPW
!= "");
784 /* Load up the settings and get installin' */
785 $local = writeLocalSettings( $conf );
786 echo "<li style=\"list-style: none\">\n";
787 echo "<p><b>Generating configuration file...</b></p>\n";
790 $wgCommandLineMode = false;
792 $ok = eval( $local );
793 if( $ok === false ) {
794 dieout( "<p>Errors in generated configuration; " .
795 "most likely due to a bug in the installer... " .
796 "Config file was: </p>" .
798 htmlspecialchars( $local ) .
801 $conf->DBtypename
= '';
802 foreach (array_keys($ourdb) as $db) {
803 if ($conf->DBtype
=== $db)
804 $conf->DBtypename
= $ourdb[$db]['fullname'];
806 if ( ! strlen($conf->DBtype
)) {
807 $errs["DBpicktype"] = "Please choose a database type";
811 if (! $conf->DBtypename
) {
812 $errs["DBtype"] = "Unknown database type '$conf->DBtype'";
815 print "<li>Database type: " . htmlspecialchars( $conf->DBtypename
) . "</li>\n";
816 $dbclass = 'Database'.ucfirst($conf->DBtype
);
817 $wgDBtype = $conf->DBtype
;
818 $wgDBadminuser = "root";
819 $wgDBadminpassword = $conf->RootPW
;
822 $wgDBprefix = $conf->DBprefix
;
824 ## Postgres specific:
825 $wgDBport = $conf->DBport
;
826 $wgDBts2schema = $conf->DBts2schema
;
828 if( $wgDBtype == 'postgres' ) {
829 $wgDBmwschema = $conf->DBpgschema
;
830 } elseif ( $wgDBtype == 'ibm_db2' ) {
831 $wgDBmwschema = $conf->DBdb2schema
;
834 if( $conf->DBprefix_ora
!= '' ) {
836 $wgDBprefix = $conf->DBprefix_ora
;
840 $wgDBcataloged = $conf->DBcataloged
;
842 $wgCommandLineMode = true;
843 if (! defined ( 'STDERR' ) )
844 define( 'STDERR', fopen("php://stderr", "wb"));
845 $wgUseDatabaseMessages = false; /* FIXME: For database failure */
846 require_once( "$IP/includes/Setup.php" );
847 Language
::getLocalisationCache()->disableBackend();
851 $wgTitle = Title
::newFromText( "Installation script" );
852 error_reporting( E_ALL | E_STRICT
);
853 print "<li>Loading class: " . htmlspecialchars( $dbclass ) . "</li>\n";
854 if ( $conf->DBtype
!= 'sqlite' ) {
858 if( $conf->DBtype
== 'mysql' ) {
859 $mysqlOldClient = version_compare( mysql_get_client_info(), "4.1.0", "lt" );
860 if( $mysqlOldClient ) {
861 print "<li><b>PHP is linked with old MySQL client libraries. If you are
862 using a MySQL 4.1 server and have problems connecting to the database,
863 see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
864 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b></li>\n";
866 $ok = true; # Let's be optimistic
868 # Decide if we're going to use the superuser or the regular database user
869 $conf->Root
= $useRoot;
871 $db_user = $conf->RootUser
;
872 $db_pass = $conf->RootPW
;
874 $db_user = $wgDBuser;
875 $db_pass = $wgDBpassword;
879 echo( "<li>Attempting to connect to database server as " . htmlspecialchars( $db_user ) . "..." );
880 $wgDatabase = Database
::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 );
882 # Check the connection and respond to errors
883 if( $wgDatabase->isOpen() ) {
886 $wgDBadminuser = $db_user;
887 $wgDBadminpassword = $db_pass;
888 echo( "success.</li>\n" );
889 $wgDatabase->ignoreErrors( true );
890 $myver = $wgDatabase->getServerVersion();
892 # There were errors, report them and back out
894 $errno = mysql_errno();
895 $errtx = htmlspecialchars( mysql_error() );
899 echo( "failed due to authentication errors. Check passwords.</li>" );
901 # The superuser details are wrong
902 $errs["RootUser"] = "Check username";
903 $errs["RootPW"] = "and password";
905 # The regular user details are wrong
906 $errs["DBuser"] = "Check username";
907 $errs["DBpassword"] = "and password";
913 # General connection problem
914 echo( htmlspecialchars( "failed with error [$errno] $errtx." ) . "</li>\n" );
915 $errs["DBserver"] = "Connection failed";
920 if( !$ok ) { continue; }
922 else if ( $conf->DBtype
== 'mssql' ) {
923 error_reporting( E_ALL
);
925 # # Possible connect as a superuser
927 $wgDBsuperuser = $conf->RootUser
;
928 echo( "<li>Attempting to connect to database \"{$conf->DBtype}\" as superuser \"{$wgDBsuperuser}\"" );
929 $wgDatabase = $dbc->newFromParams(
937 if ( !$wgDatabase->isOpen() ) {
938 echo( " error: {$wgDatabase->lastError()}</li>\n" );
939 $errs['DBserver'] = 'Could not connect to database as superuser';
940 $errs['RootUser'] = 'Check username';
941 $errs['RootPW'] = 'and password';
944 $wgDatabase->initial_setup( $conf->RootPW
, $conf->DBtype
);
946 echo( "<li>Attempting to connect to database \"{$wgDBname}\" as \"{$wgDBuser}\"..." );
947 $wgDatabase = $dbc->newFromParams(
954 if ( !$wgDatabase->isOpen() ) {
955 echo( " error: {$wgDatabase->lastError()} </li>\n" );
957 $myver = $wgDatabase->getServerVersion();
960 else if( $conf->DBtype
== 'ibm_db2' ) {
962 $db_user = $conf->RootUser
;
963 $db_pass = $conf->RootPW
;
965 $db_user = $wgDBuser;
966 $db_pass = $wgDBpassword;
969 echo( "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) .
970 "\" as \"" . htmlspecialchars( $db_user ) . "\"..." );
971 $wgDatabase = $dbc->newFromParams($wgDBserver, $db_user, $db_pass, $wgDBname, 1);
972 // enable extra debug messages
973 $dbc->setMode(DatabaseIbm_db2
::INSTALL_MODE
);
974 $wgDatabase->setMode(DatabaseIbm_db2
::INSTALL_MODE
);
976 if (!$wgDatabase->isOpen()) {
977 print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
979 $myver = $wgDatabase->getServerVersion();
981 if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname);
983 } elseif ( $conf->DBtype
== 'sqlite' ) {
984 $wgSQLiteDataDir = $conf->SQLiteDataDir
;
985 echo '<li>Attempting to connect to SQLite database at "' .
986 htmlspecialchars( $wgSQLiteDataDir ) . '": ';
987 if ( !is_dir( $wgSQLiteDataDir ) ) {
988 if ( is_writable( dirname( $wgSQLiteDataDir ) ) ) {
989 $ok = wfMkdirParents( $wgSQLiteDataDir, $wgSQLiteDataDirMode );
994 echo "cannot create data directory</li>";
995 $errs['SQLiteDataDir'] = 'Enter a valid data directory';
999 if ( !is_writable( $wgSQLiteDataDir ) ) {
1000 echo "data directory not writable</li>";
1001 $errs['SQLiteDataDir'] = 'Enter a writable data directory';
1004 $dataFile = DatabaseSqlite
::generateFileName( $wgSQLiteDataDir, $wgDBname );
1005 if ( file_exists( $dataFile ) ) {
1006 if ( !is_writable( $dataFile ) ) {
1007 echo "data file not writable</li>";
1008 $errs['SQLiteDataDir'] = basename( $dataFile ) . " is not writable";
1012 if ( file_put_contents( $dataFile, '' ) === false ) {
1013 echo 'could not create database file "' . htmlspecialchars( basename( $dataFile ) ) . "\"</li>\n";
1014 $errs['SQLiteDataDir'] = "couldn't create " . basename( $dataFile );
1019 $wgDatabase = new DatabaseSqlite( false, false, false, $wgDBname, 1 );
1021 catch( MWException
$ex ) {
1022 echo 'error: ' . htmlspecialchars( $ex->getMessage() ) . "</li>\n";
1026 if (!$wgDatabase->isOpen()) {
1027 print "error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
1028 $errs['SQLiteDataDir'] = 'Could not connect to database';
1031 $myver = $wgDatabase->getServerVersion();
1033 if ( is_callable( array( $wgDatabase, 'initial_setup' ) ) ) {
1034 $wgDatabase->initial_setup('', $wgDBname);
1037 } elseif ( $conf->DBtype
== 'oracle' ) {
1038 echo "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) ."\"</li>";
1039 $old_error_level = error_reporting();
1040 wfSuppressWarnings();
1041 $wgDatabase = $dbc->newFromParams('DUMMY', $wgDBuser, $wgDBpassword, $wgDBname, 1);
1042 wfRestoreWarnings();
1043 if (!$wgDatabase->isOpen()) {
1045 echo "<li>Connect failed.</li>";
1047 if (ini_get('oci8.privileged_connect') === false) {
1048 echo "<li>Privileged connect disabled, please set oci8.privileged_connect or run maintenance/ora/user.sql script manually prior to continuing.</li>";
1051 $wgDBadminuser = $conf->RootUser
;
1052 $wgDBadminpassword = $conf->RootPW
;
1053 echo "<li>Attempting to create DB user.</li>";
1054 $wgDatabase = $dbc->newFromParams('DUMMY', $wgDBadminuser, $wgDBadminpassword, $wgDBname, 1, 64);
1055 if ($wgDatabase->isOpen()) {
1056 $wgDBOracleDefTS = $conf->DBdefTS_ora
;
1057 $wgDBOracleTempTS = $conf->DBtempTS_ora
;
1058 $res = $wgDatabase->sourceFile( "../maintenance/ora/user.sql" );
1059 if ($res !== true) dieout($res);
1061 echo "<li>Invalid database superuser, please supply a valid superuser account.</li>";
1062 echo "<li>ERR: ".print_r(oci_error(), true)."</li>";
1067 echo "<li>Database superuser missing, please supply a valid superuser account.</li>";
1071 $errs["RootUser"] = "Check username";
1072 $errs["RootPW"] = "and password";
1074 echo "<li>Attempting to connect to database with new user \"" . htmlspecialchars( $wgDBname ) ."\"</li>";
1075 $wgDatabase = $dbc->newFromParams('DUMMY', $wgDBuser, $wgDBpassword, $wgDBname, 1);
1079 $myver = $wgDatabase->getServerVersion();
1081 } else { # not mysql
1082 error_reporting( E_ALL | E_STRICT
);
1084 ## Possible connect as a superuser
1085 // Changed !mysql to postgres check since it seems to only apply to postgres
1086 if( $useRoot && $conf->DBtype
== 'postgres' ) {
1087 echo( "<li>Attempting to connect to database \"postgres\" as superuser \"" .
1088 htmlspecialchars( $conf->RootUser
) . "\"..." );
1089 $wgDatabase = $dbc->newFromParams($wgDBserver, $conf->RootUser
, $conf->RootPW
, "postgres", 1);
1090 if (!$wgDatabase->isOpen()) {
1091 print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
1092 $errs["DBserver"] = "Could not connect to database as superuser";
1093 $errs["RootUser"] = "Check username";
1094 $errs["RootPW"] = "and password";
1097 $wgDatabase->initial_setup($conf->RootUser
, $conf->RootPW
, 'postgres');
1099 echo( "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) .
1100 "\" as \"" . htmlspecialchars( $wgDBuser ) . "\"..." );
1101 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1);
1102 if (!$wgDatabase->isOpen()) {
1103 print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
1104 $errs["DBserver"] = "Could not connect to database as user";
1105 $errs["DBuser"] = "Check username";
1106 $errs["DBpassword"] = "and password";
1109 $myver = $wgDatabase->getServerVersion();
1111 if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname);
1114 if ( !$wgDatabase->isOpen() ) {
1115 $errs["DBserver"] = "Couldn't connect to database";
1119 print "<li>Connected to " . htmlspecialchars( "{$conf->DBtype} $myver" );
1120 if ($conf->DBtype
== 'mysql') {
1121 if( version_compare( $myver, "4.0.14" ) < 0 ) {
1123 dieout( "-- mysql 4.0.14 or later required. Aborting." );
1125 $mysqlNewAuth = version_compare( $myver, "4.1.0", "ge" );
1126 if( $mysqlNewAuth && $mysqlOldClient ) {
1127 print "; <b class='error'>You are using MySQL 4.1 server, but PHP is linked
1128 to old client libraries; if you have trouble with authentication, see
1129 <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
1130 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>";
1133 if( $mysqlNewAuth ) {
1134 print "; enabling MySQL 4.1/5.0 charset mode";
1136 print "; <b class='error'>MySQL 4.1/5.0 charset mode enabled,
1137 but older version detected; will likely fail.</b>";
1142 @$sel = $wgDatabase->selectDB( $wgDBname );
1144 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
1146 $err = mysql_errno();
1147 $databaseSafe = htmlspecialchars( $wgDBname );
1148 if( $err == 1102 /* Invalid database name */ ) {
1149 print "<ul><li><strong>{$databaseSafe}</strong> is not a valid database name.</li></ul>";
1151 } elseif( $err != 1049 /* Database doesn't exist */ ) {
1152 print "<ul><li>Error selecting database <strong>{$databaseSafe}</strong>: {$err} ";
1153 print htmlspecialchars( mysql_error() ) . "</li></ul>";
1156 print "<li>Attempting to create database...</li>";
1157 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
1159 print "<li>Couldn't create database <tt>" .
1160 htmlspecialchars( $wgDBname ) .
1161 "</tt>; try with root access or check your username/pass.</li>\n";
1162 $errs["RootPW"] = "<- Enter";
1165 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
1167 $wgDatabase->selectDB( $wgDBname );
1169 else if ($conf->DBtype
== 'postgres') {
1170 if( version_compare( $myver, "8.0" ) < 0 ) {
1171 dieout( "<b>Postgres 8.0 or later is required</b>. Aborting." );
1175 if( $wgDatabase->tableExists( "cur" ) ||
$wgDatabase->tableExists( "revision" ) ) {
1176 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n";
1178 if ( $conf->DBtype
== 'mysql') {
1179 # Determine existing default character set
1180 if ( $wgDatabase->tableExists( "revision" ) ) {
1181 $revision = $wgDatabase->escapeLike( $conf->DBprefix
. 'revision' );
1182 $res = $wgDatabase->query( "SHOW TABLE STATUS LIKE '$revision'" );
1183 $row = $wgDatabase->fetchObject( $res );
1185 echo "<li>SHOW TABLE STATUS query failed!</li>\n";
1186 $existingSchema = false;
1187 $existingEngine = false;
1189 if ( preg_match( '/^latin1/', $row->Collation
) ) {
1190 $existingSchema = 'mysql4';
1191 } elseif ( preg_match( '/^utf8/', $row->Collation
) ) {
1192 $existingSchema = 'mysql5';
1193 } elseif ( preg_match( '/^binary/', $row->Collation
) ) {
1194 $existingSchema = 'mysql5-binary';
1196 $existingSchema = false;
1197 echo "<li><strong>Warning:</strong> Unrecognised existing collation</li>\n";
1199 if ( isset( $row->Engine
) ) {
1200 $existingEngine = $row->Engine
;
1202 $existingEngine = $row->Type
;
1205 if ( $existingSchema && $existingSchema != $conf->DBschema
) {
1206 $encExisting = htmlspecialchars( $existingSchema );
1207 $encRequested = htmlspecialchars( $conf->DBschema
);
1208 print "<li><strong>Warning:</strong> you requested the $encRequested schema, " .
1209 "but the existing database has the $encExisting schema. This upgrade script ".
1210 "can't convert it, so it will remain $encExisting.</li>\n";
1211 $conf->setSchema( $existingSchema, $conf->DBengine
);
1213 if ( $existingEngine && $existingEngine != $conf->DBengine
) {
1214 $encExisting = htmlspecialchars( $existingEngine );
1215 $encRequested = htmlspecialchars( $conf->DBengine
);
1216 print "<li><strong>Warning:</strong> you requested the $encRequested storage " .
1217 "engine, but the existing database uses the $encExisting engine. This upgrade " .
1218 "script can't convert it, so it will remain $encExisting.</li>\n";
1219 $conf->setSchema( $conf->DBschema
, $existingEngine );
1223 # Create user if required
1224 if ( $conf->Root
) {
1225 $conn = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
1226 if ( $conn->isOpen() ) {
1227 print "<li>DB user account ok</li>\n";
1230 print "<li>Granting user permissions...";
1231 if( $mysqlOldClient && $mysqlNewAuth ) {
1232 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>";
1235 $res = $wgDatabase->sourceFile( "../maintenance/users.sql" );
1236 if ($res !== true) dieout($res);
1240 print "</ul><pre>\n";
1246 print "<ul><li>Finished update checks.</li>\n";
1247 // if tables don't yet exist
1249 # Determine available storage engines if possible
1250 if ( $conf->DBtype
== 'mysql' && version_compare( $myver, "4.1.2", "ge" ) ) {
1251 $res = $wgDatabase->query( 'SHOW ENGINES' );
1253 while ( $row = $wgDatabase->fetchObject( $res ) ) {
1254 if ( $row->Engine
== $conf->DBengine
&& ( $row->Support
== 'YES' ||
$row->Support
== 'DEFAULT' ) ) {
1259 $wgDatabase->freeResult( $res );
1260 if ( !$found && $conf->DBengine
!= 'MyISAM' ) {
1261 echo "<li><strong>Warning:</strong> " . htmlspecialchars( $conf->DBengine
) .
1262 " storage engine not available, " .
1263 "using MyISAM instead</li>\n";
1264 $conf->setSchema( $conf->DBschema
, 'MyISAM' );
1268 print "<li>Creating tables...";
1269 if ($conf->DBtype
== 'mysql') {
1270 $res = $wgDatabase->sourceFile( "../maintenance/tables.sql" );
1271 if ($res === true) {
1272 print " done.</li>\n<li>Populating interwiki table... \n";
1273 $res = $wgDatabase->sourceFile( "../maintenance/interwiki.sql" );
1275 if ($res === true) {
1276 print " done.</li>\n";
1278 print " <b>FAILED</b></li>\n";
1279 dieout( htmlspecialchars( $res ) );
1281 } elseif (is_callable(array($wgDatabase, 'setup_database'))) {
1282 $wgDatabase->setup_database();
1285 $errs["DBtype"] = "Do not know how to handle database type '$conf->DBtype'";
1290 if ( $conf->DBtype
== 'ibm_db2' ) {
1291 // Now that table creation is done, make sure everything is committed
1292 // Do this before doing inserts through API
1293 if ($wgDatabase->lastError()) {
1294 print "<li>Errors encountered during table creation -- rolled back</li>\n";
1295 $wgDatabase->rollback();
1298 print "<li>MediaWiki tables successfully created</li>\n";
1299 $wgDatabase->commit();
1301 } elseif ( $conf->DBtype
== 'sqlite' ) {
1302 // Ensure proper searchindex format. We have to do that separately because
1303 // if SQLite is compiled without the FTS3 module, table creation syntax will be invalid.
1304 sqlite_setup_searchindex();
1307 print "<li>Initializing statistics...</li>\n";
1308 $wgDatabase->insert( 'site_stats',
1309 array ( 'ss_row_id' => 1,
1310 'ss_total_views' => 0,
1311 'ss_total_edits' => 1, # Main page first edit
1312 'ss_good_articles' => 0, # Main page is not a good article - no internal link
1313 'ss_total_pages' => 1, # Main page
1314 'ss_users' => $conf->SysopName ?
1 : 0, # Sysop account, if created
1315 'ss_admins' => $conf->SysopName ?
1 : 0, # Sysop account, if created
1316 'ss_images' => 0 ) );
1318 # Set up the "regular user" account *if we can, and if we need to*
1319 if( $conf->Root
and $conf->DBtype
== 'mysql') {
1321 $wgDatabase2 = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
1322 if( $wgDatabase2->isOpen() ) {
1323 # Nope, just close the test connection and continue
1324 $wgDatabase2->close();
1325 echo( "<li>User " . htmlspecialchars( $wgDBuser ) . " exists. Skipping grants.</li>\n" );
1327 # Yes, so run the grants
1328 echo( "<li>" . htmlspecialchars( "Granting user permissions to $wgDBuser on $wgDBname..." ) );
1329 $res = $wgDatabase->sourceFile( "../maintenance/users.sql" );
1330 if ( $res === true ) {
1331 echo( " success.</li>\n" );
1333 echo( " <b>FAILED</b>.</li>\n" );
1339 if( $conf->SysopName
) {
1340 $u = User
::newFromName( $conf->getSysopName() );
1342 print "<li><strong class=\"error\">Warning:</strong> Skipped sysop account creation - invalid username!</li>\n";
1344 else if ( 0 == $u->idForName() ) {
1345 $u->addToDatabase();
1346 $u->setPassword( $conf->getSysopPass() );
1349 $u->addGroup( "sysop" );
1350 $u->addGroup( "bureaucrat" );
1352 print "<li>Created sysop account <tt>" .
1353 htmlspecialchars( $conf->SysopName
) . "</tt>.</li>\n";
1355 print "<li>Could not create user - already exists!</li>\n";
1358 print "<li>Skipped sysop account creation, no name given.</li>\n";
1361 $titleobj = Title
::newFromText( wfMsgNoDB( "mainpage" ) );
1362 $article = new Article( $titleobj );
1363 $newid = $article->insertOn( $wgDatabase );
1364 $revision = new Revision( array(
1366 'text' => wfMsg( 'mainpagetext' ) . "\n\n" . wfMsgNoTrans( 'mainpagedocfooter' ),
1369 'user_text' => 'MediaWiki default',
1371 $revid = $revision->insertOn( $wgDatabase );
1372 $article->updateRevisionOn( $wgDatabase, $revision );
1375 /* Write out the config file now that all is well */
1376 print "<li style=\"list-style: none\">\n";
1377 print "<p>Creating LocalSettings.php...</p>\n\n";
1378 $localSettings = "<" . "?php$endl$local";
1379 // Fix up a common line-ending problem (due to CVS on Windows)
1380 $localSettings = str_replace( "\r\n", "\n", $localSettings );
1381 $f = fopen( "LocalSettings.php", 'xt' );
1385 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" .
1386 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
1387 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
1389 if(fwrite( $f, $localSettings ) ) {
1392 writeSuccessMessage();
1396 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" );
1403 $mainListOpened = false;
1405 if( count( $errs ) ) {
1406 /* Display options form */
1408 if( $conf->posted
) {
1409 echo "<p class='error-top'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
1413 <form action
="<?php echo defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php'; ?>" name
="config" method
="post">
1415 <h2
>Site config
</h2
>
1417 <div
class="config-section">
1418 <div
class="config-input">
1419 <?php
aField( $conf, "Sitename", "Wiki name:" ); ?
>
1421 <p
class="config-desc">
1422 Preferably a short word without punctuation
, i
.e
. "Wikipedia".<br
/>
1423 Will appear
as the
namespace name
for "meta" pages
, and throughout the
interface.
1425 <div
class="config-input"><?php
aField( $conf, "EmergencyContact", "Contact e-mail:" ); ?
></div
>
1426 <p
class="config-desc">
1427 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
.
1430 <div
class="config-input">
1431 <label
class='column' for="LanguageCode">Language
:</label
>
1432 <select id
="LanguageCode" name
="LanguageCode"><?php
1433 $list = getLanguageList();
1434 foreach( $list as $code => $name ) {
1435 $sel = ($code == $conf->LanguageCode
) ?
'selected="selected"' : '';
1436 $encCode = htmlspecialchars( $code );
1437 $encName = htmlspecialchars( $name );
1438 echo "\n\t\t<option value=\"$encCode\" $sel>$encName</option>";
1444 <p
class="config-desc">
1445 Select the language
for your wiki
's interface. Some localizations aren't fully complete
. Unicode (UTF
-8) is used
for all localizations
.
1448 <div
class="config-input">
1449 <label
class='column'>Copyright
/license
:</label
>
1452 <li
><?php
aField( $conf, "License", "No license metadata", "radio", "none" ); ?
></li
>
1453 <li
><?php
aField( $conf, "License", "Public Domain", "radio", "pd" ); ?
></li
>
1454 <li
><?php
aField( $conf, "License", "GNU Free Documentation License 1.2", "radio", "gfdl1_2" ); ?
></li
>
1455 <li
><?php
aField( $conf, "License", "GNU Free Documentation License 1.3", "radio", "gfdl1_3" ); ?
></li
>
1457 aField( $conf, "License", "A Creative Commons license - ", "radio", "cc" );
1458 $partner = "MediaWiki";
1459 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
1460 $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/$script?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
1461 $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" );
1462 $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" );
1463 print "<a href=\"$ccApp\" target='_blank'>choose</a>";
1464 if( $conf->License
== "cc" ) { ?
>
1466 <li
><?php
aField( $conf, "RightsIcon", "<img src=\"" . htmlspecialchars( $conf->RightsIcon
) . "\" alt='(Creative Commons icon)' />", "hidden" ); ?
></li
>
1467 <li
><?php
aField( $conf, "RightsText", htmlspecialchars( $conf->RightsText
), "hidden" ); ?
></li
>
1468 <li
><?php
aField( $conf, "RightsCode", "code: " . htmlspecialchars( $conf->RightsCode
), "hidden" ); ?
></li
>
1469 <li
><?php
aField( $conf, "RightsUrl", "<a href=\"" . htmlspecialchars( $conf->RightsUrl
) . "\">" . htmlspecialchars( $conf->RightsUrl
) . "</a>", "hidden" ); ?
></li
>
1475 <p
class="config-desc">
1476 A notice
, icon
, and machine
-readable copyright metadata will be displayed
for the license you pick
.
1480 <div
class="config-input">
1481 <?php
aField( $conf, "SysopName", "Admin username:" ) ?
>
1483 <div
class="config-input">
1484 <?php
aField( $conf, "SysopPass", "Password:", "password" ) ?
>
1486 <div
class="config-input">
1487 <?php
aField( $conf, "SysopPass2", "Password confirm:", "password" ) ?
>
1489 <p
class="config-desc">
1490 An admin can lock
/delete pages
, block users from editing
, and do other maintenance tasks
.<br
/>
1491 A
new account will be added only when creating a
new wiki database
.
1493 The password cannot be the same
as the username
.
1496 <div
class="config-input">
1497 <label
class='column'>Object caching
:</label
>
1500 <li
><?php
aField( $conf, "Shm", "No caching", "radio", "none" ); ?
></li
>
1502 if( $conf->xcache
) {
1504 aField( $conf, 'Shm', 'XCache', 'radio', 'xcache' );
1509 aField( $conf, "Shm", "APC", "radio", "apc" );
1512 if ( $conf->eaccel
) {
1514 aField( $conf, "Shm", "eAccelerator", "radio", "eaccel" );
1519 aField( $conf, "Shm", "DBA (not recommended)", "radio", "dba" );
1523 <li
><?php
aField( $conf, "Shm", "Memcached", "radio", "memcached" ); ?
></li
>
1525 <div style
="clear:left"><?php
aField( $conf, "MCServers", "Memcached servers:", "text" ) ?
></div
>
1527 <p
class="config-desc">
1528 An
object caching system such
as memcached will provide a significant performance boost
,
1529 but needs to be installed
. Provide the server addresses
and ports in a comma
-separated
list.
1531 MediaWiki can also detect
and support eAccelerator
, APC
, and XCache
, but
1532 these should not be used
if the wiki will be running on multiple application servers
.
1534 DBA (Berkeley
-style DB
) is generally slower than using no cache at all
, and is only
1535 recommended
for testing
.
1539 <h2
>E
-mail
, e
-mail notification
and authentication setup
</h2
>
1541 <div
class="config-section">
1542 <div
class="config-input">
1543 <label
class='column'>E
-mail
features (global):</label
>
1545 <li
><?php
aField( $conf, "Email", "Enabled", "radio", "email_enabled" ); ?
></li
>
1546 <li
><?php
aField( $conf, "Email", "Disabled", "radio", "email_disabled" ); ?
></li
>
1549 <p
class="config-desc">
1550 Use this to disable all e
-mail
functions (password reminders
, user
-to
-user e
-mail
, and e
-mail notifications
)
1551 if sending mail doesn
't work on your server.
1554 <div class="config-input">
1555 <label class='column
'>User-to-user e-mail:</label>
1557 <li><?php aField( $conf, "Emailuser", "Enabled", "radio", "emailuser_enabled" ); ?></li>
1558 <li><?php aField( $conf, "Emailuser", "Disabled", "radio", "emailuser_disabled" ); ?></li>
1561 <p class="config-desc">
1562 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.
1564 <div class="config-input">
1565 <label class='column
'>E-mail notification about changes:</label>
1567 <li><?php aField( $conf, "Enotif", "Disabled", "radio", "enotif_disabled" ); ?></li>
1568 <li><?php aField( $conf, "Enotif", "Changes to user discussion pages only", "radio", "enotif_usertalk" ); ?></li>
1569 <li><?php aField( $conf, "Enotif", "Changes to user discussion pages, and to pages on watchlists (not recommended for large wikis)", "radio", "enotif_allpages" ); ?></li>
1572 <div class="config-desc">
1574 For this feature to work, an e-mail address must be present for the user account, and the notification
1575 options in the user's preferences must be enabled
. Also note the
1576 authentication option below
. When testing the feature
, keep in mind that your own changes will never trigger notifications to be sent to yourself
.</p
>
1578 <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
>
1581 <div
class="config-input">
1582 <label
class='column'>E
-mail address authentication
:</label
>
1584 <li
><?php
aField( $conf, "Eauthent", "Disabled", "radio", "eauthent_disabled" ); ?
></li
>
1585 <li
><?php
aField( $conf, "Eauthent", "Enabled", "radio", "eauthent_enabled" ); ?
></li
>
1588 <div
class="config-desc">
1589 <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
1590 change notification mails
. Setting this option is
<b
>recommended
</b
> for public wikis because of potential abuse of the e
-mail features above
.</p
>
1595 <h2
>Database config
</h2
>
1597 <div
class="config-section">
1598 <div
class="config-input">
1599 <label
class='column'>Database type
:</label
>
1601 if (isset($errs['DBpicktype'])) {
1602 print "\t<span class='error'>" . htmlspecialchars( $errs['DBpicktype'] ) . "</span>\n";
1605 <ul
class='plain'><?php
1606 database_picker($conf);
1610 <div id
="db-server-settings1">
1611 <div
class="config-input" style
="clear:left">
1612 <?php
aField( $conf, "DBserver", "Database host:" ); ?
>
1614 <p
class="config-desc">
1615 If your database server isn
't on your web server, enter the name or IP address here.
1619 <div class="config-input"><?php aField( $conf, "DBname", "Database name:" ); ?></div>
1620 <div id="db-server-settings2">
1621 <div class="config-input"><?php aField( $conf, "DBuser", "DB username:" ); ?></div>
1622 <div class="config-input"><?php aField( $conf, "DBpassword", "DB password:", "password" ); ?></div>
1623 <div class="config-input"><?php aField( $conf, "DBpassword2", "DB password confirm:", "password" ); ?></div>
1624 <p class="config-desc">
1625 If you only have a single user account and database available,
1626 enter those here. If you have database root access (see below)
1627 you can specify new accounts/databases to be created. This account
1628 will not be created if it pre-exists. If this is the case, ensure that it
1629 has SELECT, INSERT, UPDATE, and DELETE permissions on the MediaWiki database.
1632 <div class="config-input">
1633 <label class="column">Superuser account:</label>
1634 <input type="checkbox" name="useroot" id="useroot" <?php if( $useRoot ) { ?>checked="checked" <?php } ?> />
1635  <label for="useroot">Use superuser account</label>
1637 <div class="config-input"><?php aField( $conf, "RootUser", "Superuser name:", "text" ); ?></div>
1638 <div class="config-input"><?php aField( $conf, "RootPW", "Superuser password:", "password" ); ?></div>
1640 <p class="config-desc">
1641 If the database user specified above does not exist, or does not have access to create
1642 the database (if needed) or tables within it, please check the box and provide details
1643 of a superuser account, such as <strong>root</strong>, which does.
1647 <?php database_switcher('mysql
'); ?>
1648 <div class="config-input"><?php aField( $conf, "DBprefix", "Database table prefix:" ); ?></div>
1649 <div class="config-desc">
1650 <p>If you need to share one database between multiple wikis, or
1651 between MediaWiki and another web application, you may choose to
1652 add a prefix to all the table names to avoid conflicts.</p>
1654 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
1657 <div class="config-input"><label class="column">Storage Engine</label>
1658 <div>Select one:</div>
1660 <li><?php aField( $conf, "DBengine", "InnoDB", "radio", "InnoDB" ); ?></li>
1661 <li><?php aField( $conf, "DBengine", "MyISAM", "radio", "MyISAM" ); ?></li>
1664 <p class="config-desc">
1665 InnoDB is best for public web installations, since it has good concurrency
1666 support. MyISAM may be faster in single-user installations. MyISAM databases
1667 tend to get corrupted more often than InnoDB databases.
1669 <div class="config-input"><label class="column">Database character set</label>
1670 <div>Select one:</div>
1672 <li><?php aField( $conf, "DBschema", "MySQL 4.1/5.0 binary", "radio", "mysql5-binary" ); ?></li>
1673 <li><?php aField( $conf, "DBschema", "MySQL 4.1/5.0 UTF-8", "radio", "mysql5" ); ?></li>
1674 <li><?php aField( $conf, "DBschema", "MySQL 4.0 backwards-compatible UTF-8", "radio", "mysql4" ); ?></li>
1677 <p class="config-desc">
1678 This option is ignored on upgrade, the same character set will be kept.
1680 <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!.
1682 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>.
1686 <?php database_switcher('postgres
'); ?>
1687 <div class="config-input"><?php aField( $conf, "DBport", "Database port:" ); ?></div>
1688 <div class="config-input"><?php aField( $conf, "DBpgschema", "Schema for mediawiki:" ); ?></div>
1689 <div class="config-input"><?php aField( $conf, "DBts2schema", "Schema for tsearch2:" ); ?></div>
1690 <div class="config-desc">
1691 <p>The username specified above (at "DB username") will have its search path set to the above schemas,
1692 so it is recommended that you create a new user. The above schemas are generally correct:
1693 only change them if you are sure you need to.</p>
1697 <?php database_switcher('sqlite
'); ?>
1698 <div class="config-input"><?php
1699 aField( $conf, "SQLiteDataDir", "SQLite data directory:" );
1701 <div class="config-desc">
1702 <p>SQLite stores table data into files in the
1705 <p>This directory must exist and be writable by the web server.</p>
1710 <?php database_switcher( 'mssql
' ); ?>
1711 <div class="config-desc">
1712 <p>No MS SQL Server specific options at this time.</p>
1716 <?php database_switcher('ibm_db2
'); ?>
1717 <div class="config-input"><?php
1718 aField( $conf, "DBport_db2", "Database port:" );
1720 <div class="config-input"><?php
1721 aField( $conf, "DBdb2schema", "Schema for mediawiki:" );
1723 <div>Select one:</div>
1725 <li><?php aField( $conf, "DBcataloged", "Cataloged (DB2 installed locally)", "radio", "cataloged" ); ?></li>
1726 <li><?php aField( $conf, "DBcataloged", "Uncataloged (remote DB2 through ODBC)", "radio", "uncataloged" ); ?></li>
1728 <div class="config-desc">
1729 <p>If you need to share one database between multiple wikis, or
1730 between MediaWiki and another web application, you may specify
1731 a different schema to avoid conflicts.</p>
1735 <?php database_switcher('oracle
'); ?>
1736 <div class="config-input"><?php aField( $conf, "DBprefix_ora", "Database table prefix:" ); ?></div>
1737 <div class="config-desc">
1738 <p>If you need to share one database between multiple wikis, or
1739 between MediaWiki and another web application, you may choose to
1740 add a prefix to all the table names to avoid conflicts.</p>
1742 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
1744 <div class="config-input"><?php aField( $conf, "DBdefTS_ora", "Default tablespace:" ); ?></div>
1745 <div class="config-input"><?php aField( $conf, "DBtempTS_ora", "Temporary tablespace:" ); ?></div>
1748 <div class="config-input" style="padding:2em 0 3em">
1749 <label class='column
'> </label>
1750 <input type="submit" value="Install MediaWiki!" class="btn-install" />
1754 <script type="text/javascript">
1755 window.onload = toggleDBarea( <?php echo Xml::encodeJsVar( $conf->DBtype ); ?>,
1757 ## If they passed in a root user name, don't populate it on page load
1758 echo strlen(importPost('RootUser', '')) ?
0 : 1;
1764 /* -------------------------------------------------------------------------------------- */
1765 function writeSuccessMessage() {
1766 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
1767 if ( wfIniGetBool( 'safe_mode' ) && !ini_get( 'open_basedir' ) ) {
1769 <div class="success-box">
1770 <p>Installation successful!</p>
1771 <p>To complete the installation, please do the following:
1773 <li>Download config/LocalSettings.php with your FTP client or file manager</li>
1774 <li>Upload it to the parent directory</li>
1775 <li>Delete config/LocalSettings.php</li>
1776 <li>Start using <a href='../$script'>your wiki</a>!
1778 <p>If you are in a shared hosting environment, do <strong>not</strong> just move LocalSettings.php
1779 remotely. LocalSettings.php is currently owned by the user your webserver is running under,
1780 which means that anyone on the same server can read your database password! Downloading
1781 it and uploading it again will hopefully change the ownership to a user ID specific to you.</p>
1786 <div class="success-box">
1788 <span class="success-message">Installation successful!</span>
1789 Move the <tt>config/LocalSettings.php</tt> file to the parent directory, then follow
1790 <a href="../$script"> this link</a> to your wiki.</p>
1791 <p>You should change file permissions for <tt>LocalSettings.php</tt> as required to
1792 prevent other users on the server reading passwords and altering configuration data.</p>
1799 function escapePhpString( $string ) {
1800 if ( is_array( $string ) ||
is_object( $string ) ) {
1803 return strtr( $string,
1814 function writeLocalSettings( $conf ) {
1815 $conf->PasswordSender
= $conf->EmergencyContact
;
1816 $magic = ($conf->ImageMagick ?
"" : "# ");
1817 $convert = ($conf->ImageMagick ?
$conf->ImageMagick
: "/usr/bin/convert" );
1818 $rights = ($conf->RightsUrl
) ?
"" : "# ";
1819 $hashedUploads = $conf->safeMode ?
'' : '# ';
1820 $dir = realpath( $conf->SQLiteDataDir
);
1822 $dir = $conf->SQLiteDataDir
; // dumb realpath sometimes fails
1824 $sqliteDataDir = escapePhpString( $dir );
1826 if ( $conf->ShellLocale
) {
1830 $conf->ShellLocale
= 'en_US.UTF-8';
1833 switch ( $conf->Shm
) {
1835 $cacheType = 'CACHE_MEMCACHED';
1836 $mcservers = var_export( $conf->MCServerArray
, true );
1841 $cacheType = 'CACHE_ACCEL';
1842 $mcservers = 'array()';
1845 $cacheType = 'CACHE_DBA';
1846 $mcservers = 'array()';
1849 $cacheType = 'CACHE_NONE';
1850 $mcservers = 'array()';
1853 if ( $conf->Email
== 'email_enabled' ) {
1854 $enableemail = 'true';
1855 $enableuseremail = ( $conf->Emailuser
== 'emailuser_enabled' ) ?
'true' : 'false' ;
1856 $eauthent = ( $conf->Eauthent
== 'eauthent_enabled' ) ?
'true' : 'false' ;
1857 switch ( $conf->Enotif
) {
1858 case 'enotif_usertalk':
1859 $enotifusertalk = 'true';
1860 $enotifwatchlist = 'false';
1862 case 'enotif_allpages':
1863 $enotifusertalk = 'true';
1864 $enotifwatchlist = 'true';
1867 $enotifusertalk = 'false';
1868 $enotifwatchlist = 'false';
1871 $enableuseremail = 'false';
1872 $enableemail = 'false';
1873 $eauthent = 'false';
1874 $enotifusertalk = 'false';
1875 $enotifwatchlist = 'false';
1878 $file = @fopen
( "/dev/urandom", "r" );
1880 $secretKey = bin2hex( fread( $file, 32 ) );
1884 for ( $i=0; $i<8; $i++
) {
1885 $secretKey .= dechex(mt_rand(0, 0x7fffffff));
1887 print "<li>Warning: \$wgSecretKey key is insecure, generated with mt_rand(). Consider changing it manually.</li>\n";
1890 # Add slashes to strings for double quoting
1891 $slconf = wfArrayMap( "escapePhpString", get_object_vars( $conf ) );
1892 if( $conf->License
== 'gfdl1_2' ||
$conf->License
== 'pd' ||
$conf->License
== 'gfdl1_3' ) {
1893 # Needs literal string interpolation for the current style path
1894 $slconf['RightsIcon'] = $conf->RightsIcon
;
1897 if( $conf->DBtype
== 'mysql' ) {
1899 "# MySQL specific settings
1900 \$wgDBprefix = \"{$slconf['DBprefix']}\";
1902 # MySQL table options to use during installation or update
1903 \$wgDBTableOptions = \"{$slconf['DBTableOptions']}\";
1905 # Experimental charset support for MySQL 4.1/5.0.
1906 \$wgDBmysql5 = {$conf->DBmysql5};";
1907 } elseif( $conf->DBtype
== 'postgres' ) {
1909 "# Postgres specific settings
1910 \$wgDBport = \"{$slconf['DBport']}\";
1911 \$wgDBmwschema = \"{$slconf['DBpgschema']}\";
1912 \$wgDBts2schema = \"{$slconf['DBts2schema']}\";";
1913 } elseif( $conf->DBtype
== 'sqlite' ) {
1915 "# SQLite-specific settings
1916 \$wgSQLiteDataDir = \"{$sqliteDataDir}\";";
1917 } elseif( $conf->DBtype
== 'ibm_db2' ) {
1919 "# DB2 specific settings
1920 \$wgDBport = \"{$slconf['DBport_db2']}\";
1921 \$wgDBmwschema = \"{$slconf['DBdb2schema']}\";
1922 \$wgDBcataloged = \"{$slconf['DBcataloged']}\";";
1923 } elseif( $conf->DBtype
== 'oracle' ) {
1925 "# Oracle specific settings
1926 \$wgDBprefix = \"{$slconf['DBprefix_ora']}\";";
1934 # This file was automatically generated by the MediaWiki installer.
1935 # If you make manual changes, please keep track in case you need to
1936 # recreate them later.
1938 # See includes/DefaultSettings.php for all configurable settings
1939 # and their default values, but don't forget to make changes in _this_
1942 # Further documentation for configuration settings may be found at:
1943 # http://www.mediawiki.org/wiki/Manual:Configuration_settings
1945 # If you customize your file layout, set \$IP to the directory that contains
1946 # the other MediaWiki files. It will be used as a base to locate files.
1947 if( defined( 'MW_INSTALL_PATH' ) ) {
1948 \$IP = MW_INSTALL_PATH;
1950 \$IP = dirname( __FILE__ );
1953 \$path = array( \$IP, \"\$IP/includes\", \"\$IP/languages\" );
1954 set_include_path( implode( PATH_SEPARATOR, \$path ) . PATH_SEPARATOR . get_include_path() );
1956 require_once( \"\$IP/includes/DefaultSettings.php\" );
1958 if ( \$wgCommandLineMode ) {
1959 if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
1960 die( \"This script must be run from the command line\\n\" );
1963 ## Uncomment this to disable output compression
1964 # \$wgDisableOutputCompression = true;
1966 \$wgSitename = \"{$slconf['Sitename']}\";
1968 ## The URL base path to the directory containing the wiki;
1969 ## defaults for all runtime URL paths are based off of this.
1970 ## For more information on customizing the URLs please see:
1971 ## http://www.mediawiki.org/wiki/Manual:Short_URL
1972 \$wgScriptPath = \"{$slconf['ScriptPath']}\";
1973 \$wgScriptExtension = \"{$slconf['ScriptExtension']}\";
1975 ## The relative URL path to the skins directory
1976 \$wgStylePath = \"\$wgScriptPath/skins\";
1978 ## The relative URL path to the logo. Make sure you change this from the default,
1979 ## or else you'll overwrite your logo when you upgrade!
1980 \$wgLogo = \"\$wgStylePath/common/images/wiki.png\";
1982 ## UPO means: this is also a user preference option
1984 \$wgEnableEmail = $enableemail;
1985 \$wgEnableUserEmail = $enableuseremail; # UPO
1987 \$wgEmergencyContact = \"{$slconf['EmergencyContact']}\";
1988 \$wgPasswordSender = \"{$slconf['PasswordSender']}\";
1990 \$wgEnotifUserTalk = $enotifusertalk; # UPO
1991 \$wgEnotifWatchlist = $enotifwatchlist; # UPO
1992 \$wgEmailAuthentication = $eauthent;
1994 ## Database settings
1995 \$wgDBtype = \"{$slconf['DBtype']}\";
1996 \$wgDBserver = \"{$slconf['DBserver']}\";
1997 \$wgDBname = \"{$slconf['DBname']}\";
1998 \$wgDBuser = \"{$slconf['DBuser']}\";
1999 \$wgDBpassword = \"{$slconf['DBpassword']}\";
2003 ## Shared memory settings
2004 \$wgMainCacheType = $cacheType;
2005 \$wgMemCachedServers = $mcservers;
2007 ## To enable image uploads, make sure the 'images' directory
2008 ## is writable, then set this to true:
2009 \$wgEnableUploads = false;
2010 {$magic}\$wgUseImageMagick = true;
2011 {$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
2013 ## If you use ImageMagick (or any other shell command) on a
2014 ## Linux server, this will need to be set to the name of an
2015 ## available UTF-8 locale
2016 {$locale}\$wgShellLocale = \"{$slconf['ShellLocale']}\";
2018 ## If you want to use image uploads under safe mode,
2019 ## create the directories images/archive, images/thumb and
2020 ## images/temp, and make them all writable. Then uncomment
2021 ## this, if it's not already uncommented:
2022 {$hashedUploads}\$wgHashedUploadDirectory = false;
2024 ## If you have the appropriate support software installed
2025 ## you can enable inline LaTeX equations:
2028 ## Set \$wgCacheDirectory to a writable directory on the web server
2029 ## to make your wiki go slightly faster. The directory should not
2030 ## be publically accessible from the web.
2031 #\$wgCacheDirectory = \"\$IP/cache\";
2033 \$wgLocalInterwiki = strtolower( \$wgSitename );
2035 \$wgLanguageCode = \"{$slconf['LanguageCode']}\";
2037 \$wgSecretKey = \"$secretKey\";
2039 ## Default skin: you can change the default skin. Use the internal symbolic
2040 ## names, ie 'vector', 'monobook':
2041 \$wgDefaultSkin = 'monobook';
2043 ## For attaching licensing metadata to pages, and displaying an
2044 ## appropriate copyright notice / icon. GNU Free Documentation
2045 ## License and Creative Commons licenses are supported so far.
2046 {$rights}\$wgEnableCreativeCommonsRdf = true;
2047 \$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright
2048 \$wgRightsUrl = \"{$slconf['RightsUrl']}\";
2049 \$wgRightsText = \"{$slconf['RightsText']}\";
2050 \$wgRightsIcon = \"{$slconf['RightsIcon']}\";
2051 # \$wgRightsCode = \"{$slconf['RightsCode']}\"; # Not yet used
2053 \$wgDiff3 = \"{$slconf['diff3']}\";
2055 # When you make changes to this configuration file, this will make
2056 # sure that cached pages are cleared.
2057 \$wgCacheEpoch = max( \$wgCacheEpoch, gmdate( 'YmdHis', @filemtime( __FILE__ ) ) );
2058 "; ## End of setting the $localsettings string
2060 // Keep things in Unix line endings internally;
2061 // the system will write out as local text type.
2062 return str_replace( "\r\n", "\n", $localsettings );
2065 function dieout( $text ) {
2066 global $mainListOpened;
2067 if( $mainListOpened ) echo( "</ul>" );
2068 if( $text != '' && substr( $text, 0, 2 ) != '<p' && substr( $text, 0, 2 ) != '<h' ){
2069 echo "<p>$text</p>\n";
2073 die( "\n\n</div>\n</div>\n</div>\n</div>\n</body>\n</html>" );
2076 function importVar( &$var, $name, $default = "" ) {
2077 if( isset( $var[$name] ) ) {
2078 $retval = $var[$name];
2079 if ( get_magic_quotes_gpc() ) {
2080 $retval = stripslashes( $retval );
2089 function importPost( $name, $default = "" ) {
2090 return importVar( $_POST, $name, $default );
2093 function importCheck( $name ) {
2094 return isset( $_POST[$name] );
2097 function importRequest( $name, $default = "" ) {
2098 return importVar( $_REQUEST, $name, $default );
2101 function aField( &$conf, $field, $text, $type = "text", $value = "", $onclick = '' ) {
2102 static $radioCount = 0;
2104 $xtype = "type=\"$type\"";
2110 $nolabel = ($type == "radio") ||
($type == "hidden");
2112 if ($type == 'radio')
2113 $id .= $radioCount++
;
2116 echo "<label class='column' for=\"$id\">$text</label>";
2119 if( $type == "radio" && $value == $conf->$field ) {
2120 $checked = "checked='checked'";
2124 echo "<input $xtype name=\"$field\" id=\"$id\" class=\"iput-$type\" $checked ";
2126 echo " onclick='toggleDBarea(\"$value\",1)' " ;
2129 if( $type == "radio" ) {
2130 echo htmlspecialchars( $value );
2132 echo htmlspecialchars( $conf->$field );
2138 echo "<label for=\"$id\">$text</label>";
2142 if(isset($errs[$field])) {
2143 echo "<span class='error'>" . htmlspecialchars( $errs[$field] ) . "</span>\n";
2147 function getLanguageList() {
2148 global $wgDummyLanguageCodes;
2151 foreach ( Language
::getLanguageNames() as $code => $name ) {
2152 if( in_array( $code, $wgDummyLanguageCodes ) ) continue;
2153 $codes[$code] = $code . ' - ' . $name;
2159 #Check for location of an executable
2160 # @param string $loc single location to check
2161 # @param array $names filenames to check for.
2162 # @param mixed $versioninfo array of details to use when checking version, use false for no version checking
2163 function locate_executable($loc, $names, $versioninfo = false) {
2164 if (!is_array($names))
2165 $names = array($names);
2167 foreach ($names as $name) {
2168 $command = "$loc".DIRECTORY_SEPARATOR
."$name";
2169 if (@file_exists
($command)) {
2173 $file = str_replace('$1', $command, $versioninfo[0]);
2174 if (strstr(`
$file`
, $versioninfo[1]) !== false)
2181 # Test a memcached server
2182 function testMemcachedServer( $server ) {
2183 $hostport = explode(":", $server);
2186 if ( !function_exists( 'fsockopen' ) ) {
2187 $errstr = "Can't connect to memcached, fsockopen() not present";
2189 if ( !$errstr && count( $hostport ) != 2 ) {
2190 $errstr = 'Please specify host and port';
2193 list( $host, $port ) = $hostport;
2197 $fp = @fsockopen
( $host, $port, $errno, $fsockerr, 1.0 );
2198 if ( $fp === false ) {
2199 $errstr = "Cannot connect to memcached on $host:$port : $fsockerr";
2203 $command = "version\r\n";
2204 $bytes = fwrite( $fp, $command );
2205 if ( $bytes != strlen( $command ) ) {
2206 $errstr = "Cannot write to memcached socket on $host:$port";
2210 $expected = "VERSION ";
2211 $response = fread( $fp, strlen( $expected ) );
2212 if ( $response != $expected ) {
2213 $errstr = "Didn't get correct memcached response from $host:$port";
2220 echo "<li>Connected to memcached on " . htmlspecialchars( "$host:$port" ) ." successfully</li>";
2225 function database_picker($conf) {
2228 foreach(array_keys($ourdb) as $db) {
2229 if ($ourdb[$db]['havedriver']) {
2231 aField( $conf, "DBtype", $ourdb[$db]['fullname'], 'radio', $db, 'onclick');
2238 function database_switcher($db) {
2240 $color = $ourdb[$db]['bgcolor'];
2241 $full = $ourdb[$db]['fullname'];
2242 print "<fieldset id='$db' style='clear:both'><legend>$full-specific options</legend>\n";
2245 function printListItem( $item ) {
2246 print "<li>$item</li>";
2249 # Determine a suitable value for $wgShellLocale
2250 function getShellLocale( $wikiLang ) {
2251 # Give up now if we're in safe mode or open_basedir
2252 # It's theoretically possible but tricky to work with
2253 if ( wfIniGetBool( "safe_mode" ) ||
ini_get( 'open_basedir' ) ||
!function_exists('exec') ) {
2257 $os = php_uname( 's' );
2258 $supported = array( 'Linux', 'SunOS', 'HP-UX' ); # Tested these
2259 if ( !in_array( $os, $supported ) ) {
2263 # Get a list of available locales
2264 $lines = $ret = false;
2265 exec( '/usr/bin/locale -a', $lines, $ret );
2270 $lines = wfArrayMap( 'trim', $lines );
2271 $candidatesByLocale = array();
2272 $candidatesByLang = array();
2273 foreach ( $lines as $line ) {
2274 if ( $line === '' ) {
2277 if ( !preg_match( '/^([a-zA-Z]+)(_[a-zA-Z]+|)\.(utf8|UTF-8)(@[a-zA-Z_]*|)$/i', $line, $m ) ) {
2280 list( $all, $lang, $territory, $charset, $modifier ) = $m;
2281 $candidatesByLocale[$m[0]] = $m;
2282 $candidatesByLang[$lang][] = $m;
2285 # Try the current value of LANG
2286 if ( isset( $candidatesByLocale[ getenv( 'LANG' ) ] ) ) {
2287 return getenv( 'LANG' );
2290 # Try the most common ones
2291 $commonLocales = array( 'en_US.UTF-8', 'en_US.utf8', 'de_DE.UTF-8', 'de_DE.utf8' );
2292 foreach ( $commonLocales as $commonLocale ) {
2293 if ( isset( $candidatesByLocale[$commonLocale] ) ) {
2294 return $commonLocale;
2298 # Is there an available locale in the Wiki's language?
2299 if ( isset( $candidatesByLang[$wikiLang] ) ) {
2300 $m = reset( $candidatesByLang[$wikiLang] );
2304 # Are there any at all?
2305 if ( count( $candidatesByLocale ) ) {
2306 $m = reset( $candidatesByLocale );
2316 <div
class="license">
2318 <p
>This program is free software
; you can redistribute it
and/or modify
2319 it under the terms of the GNU General
Public License
as published by
2320 the Free Software Foundation
; either version
2 of the License
, or
2321 (at your option
) any later version
.</p
>
2323 <p
>This program is distributed in the hope that it will be useful
,
2324 but WITHOUT ANY WARRANTY
; without even the implied warranty of
2325 MERCHANTABILITY
or FITNESS
FOR A PARTICULAR PURPOSE
. See the
2326 GNU General
Public License
for more details
.</p
>
2328 <p
>You should have received
<a href
="../COPYING">a copy of the GNU General
Public License
</a
>
2329 along with this program
; if not
, write to the Free Software
2330 Foundation
, Inc
., 51 Franklin Street
, Fifth Floor
, Boston
, MA
02110-1301, USA
.
2331 or <a href
="http://www.gnu.org/copyleft/gpl.html">read it online
</a
></p
>
2337 <div id
="column-one">
2338 <div
class="portlet" id
="p-logo">
2339 <a style
="background-image: url(../skins/common/images/mediawiki.png);"
2341 title
="Main Page"></a
>
2343 <script type
="text/javascript"> if (window
.isMSIE55
) fixalpha(); </script
>
2344 <div
class='portlet'><div
class='pBody'>
2346 <li
><a href
="../README">Readme
</a
></li
>
2347 <li
><a href
="../RELEASE-NOTES">Release notes
</a
></li
>
2348 <li
><a href
="../docs/">Documentation
</a
></li
>
2349 <li
><a href
="http://www.mediawiki.org/wiki/Help:Contents">User
's Guide</a></li>
2350 <li><a href="http://www.mediawiki.org/wiki/Manual:Contents">Administrator's Guide
</a
></li
>
2351 <li
><a href
="http://www.mediawiki.org/wiki/Manual:FAQ">FAQ
</a
></li
>
2353 <p style
="font-size:90%;margin-top:1em">MediaWiki is Copyright ©
2001-2010 by Magnus Manske
, Brion Vibber
,
2354 Lee Daniel Crocker
, Tim Starling
, Erik Möller
, Gabriel Wicke
, Æ
var Arnfjörð Bjarmason
, Niklas Laxström
,
2355 Domas Mituzas
, Rob Church
, Yuri Astrakhan
, Aryeh Gregor
, Aaron Schulz
and others
.</p
>