3 # MediaWiki web-based config/installation
4 # Copyright (C) 2004 Brion Vibber <brion@pobox.com>, 2006 Rob Church <robchur@gmail.com>
5 # http://www.mediawiki.org/
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along
18 # with this program; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 # http://www.gnu.org/copyleft/gpl.html
22 if( !defined( 'MEDIAWIKI_INSTALL' ) ) {
23 die( 'Not an entry point.' );
26 error_reporting( E_ALL | E_STRICT
);
27 header( "Content-type: text/html; charset=utf-8" );
28 @ini_set
( "display_errors", true );
30 # In case of errors, let output be clean.
31 $wgRequestTime = microtime( true );
33 // Run version checks before including other files
34 // so people don't see a scary parse error.
35 require_once( "$IP/maintenance/install-utils.inc" );
36 install_version_checks();
38 require_once( "$IP/includes/Defines.php" );
39 require_once( "$IP/includes/DefaultSettings.php" );
40 require_once( "$IP/includes/AutoLoader.php" );
41 require_once( "$IP/includes/MagicWord.php" );
42 require_once( "$IP/includes/Namespace.php" );
43 require_once( "$IP/includes/ProfilerStub.php" );
44 require_once( "$IP/includes/GlobalFunctions.php" );
45 require_once( "$IP/includes/Hooks.php" );
46 require_once( "$IP/includes/Exception.php" );
48 # If we get an exception, the user needs to know
50 $wgShowExceptionDetails = true;
51 $wgShowSQLErrors = true;
52 wfInstallExceptionHandler();
53 ## Databases we support:
56 $ourdb['mysql']['fullname'] = 'MySQL';
57 $ourdb['mysql']['havedriver'] = 0;
58 $ourdb['mysql']['compile'] = 'mysql';
59 $ourdb['mysql']['bgcolor'] = '#ffe5a7';
60 $ourdb['mysql']['rootuser'] = 'root';
62 $ourdb['postgres']['fullname'] = 'PostgreSQL';
63 $ourdb['postgres']['havedriver'] = 0;
64 $ourdb['postgres']['compile'] = 'pgsql';
65 $ourdb['postgres']['bgcolor'] = '#aaccff';
66 $ourdb['postgres']['rootuser'] = 'postgres';
68 $ourdb['sqlite']['fullname'] = 'SQLite';
69 $ourdb['sqlite']['havedriver'] = 0;
70 $ourdb['sqlite']['compile'] = 'pdo_sqlite';
71 $ourdb['sqlite']['bgcolor'] = '#b1ebb1';
72 $ourdb['sqlite']['rootuser'] = '';
74 $ourdb['mssql']['fullname'] = 'MSSQL';
75 $ourdb['mssql']['havedriver'] = 0;
76 $ourdb['mssql']['compile'] = 'mssql not ready'; # Change to 'mssql' after includes/DatabaseMssql.php added;
77 $ourdb['mssql']['bgcolor'] = '#ffc0cb';
78 $ourdb['mssql']['rootuser'] = 'administrator';
80 $ourdb['ibm_db2']['fullname'] = 'DB2';
81 $ourdb['ibm_db2']['havedriver'] = 0;
82 $ourdb['ibm_db2']['compile'] = 'ibm_db2';
83 $ourdb['ibm_db2']['bgcolor'] = '#ffeba1';
84 $ourdb['ibm_db2']['rootuser'] = 'db2admin';
86 $ourdb['oracle']['fullname'] = 'Oracle';
87 $ourdb['oracle']['havedriver'] = 0;
88 $ourdb['oracle']['compile'] = 'oci8';
89 $ourdb['oracle']['bgcolor'] = '#ffeba1';
90 $ourdb['oracle']['rootuser'] = '';
93 <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
94 <html xmlns
="http://www.w3.org/1999/xhtml" xml
:lang
="en" lang
="en" dir
="ltr">
96 <meta http
-equiv
="Content-type" content
="text/html; charset=utf-8" />
97 <meta name
="robots" content
="noindex,nofollow"/>
98 <title
>MediaWiki
<?php
echo htmlspecialchars( $wgVersion ); ?
> Installation
</title
>
99 <style type
="text/css">
101 @import
"../skins/monobook/main.css";
105 margin
: 1em
0 1em
2.5em
;
112 .config
-section label
.column
{
124 zoom
: 100%
; /* IE hack */
127 .config
-section
.config
-desc
{
129 margin
: 0 0 2em
18em
;
134 .iput
-text
, .iput
-password
{
141 background
-color
: #fff;
149 background
-color
: #FFF0F0;
150 border
: 2px solid red
;
158 list-style
-type
: none
;
159 list-style
-image
: none
;
176 span
.success
-message
{
186 <script type
="text/javascript">
189 <?php
foreach (array_keys($ourdb) as $db) {
190 echo "\n var i = document.getElementById('$db'); if (i) i.style.display='none';";
195 function toggleDBarea(id
,defaultroot
) {
197 var dbarea
= document
.getElementById(id
);
198 if (dbarea
) dbarea
.style
.display
= (dbarea
.style
.display
== 'none') ?
'block' : 'none';
199 var db
= document
.getElementById('RootUser');
201 <?php
foreach (array_keys($ourdb) as $db) {
202 echo " if (id == '$db') { db.value = '".$ourdb[$db]['rootuser']."';}\n";
211 <div id
="globalWrapper">
212 <div id
="column-content">
214 <div id
="bodyContent">
216 <h1
>MediaWiki
<?php
print htmlspecialchars( $wgVersion ) ?
> Installation
</h1
>
219 $mainListOpened = false; # Is the main list (environement checking) opend ? Used by dieout
221 /* Check for existing configurations and bug out! */
223 if( file_exists( "../LocalSettings.php" ) ) {
224 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
225 dieout( "<p><strong>Setup has completed, <a href='../$script'>your wiki</a> is configured.</strong></p>
226 <p>Please delete the /config directory for extra security.</p>" );
229 if( file_exists( "./LocalSettings.php" ) ) {
230 writeSuccessMessage();
234 if( !is_writable( "." ) ) {
235 dieout( "<h2>Can't write config file, aborting</h2>
237 <p>In order to configure the wiki you have to make the <tt>config</tt> subdirectory
238 writable by the web server. Once configuration is done you'll move the created
239 <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can
240 then remove the <tt>config</tt> subdirectory entirely.</p>
242 <p>To make the directory writable on a Unix/Linux system:</p>
245 cd <i>" . htmlspecialchars( dirname( dirname( __FILE__
) ) ) . "</i>
249 <p>Afterwards retry to start the <a href=\"\">setup</a>.</p>" );
253 require_once( "$IP/maintenance/updaters.inc" );
256 function getEncoded( $data ) {
257 # removing latin1 support, no need...
260 function getSitename() { return $this->getEncoded( $this->Sitename
); }
261 function getSysopName() { return $this->getEncoded( $this->SysopName
); }
262 function getSysopPass() { return $this->getEncoded( $this->SysopPass
); }
264 function setSchema( $schema, $engine ) {
265 $this->DBschema
= $schema;
266 if ( !preg_match( '/^\w*$/', $engine ) ){
269 switch ( $this->DBschema
) {
271 $this->DBTableOptions
= "ENGINE=$engine, DEFAULT CHARSET=utf8";
272 $this->DBmysql5
= 'true';
274 case 'mysql5-binary':
275 $this->DBTableOptions
= "ENGINE=$engine, DEFAULT CHARSET=binary";
276 $this->DBmysql5
= 'true';
279 $this->DBTableOptions
= "TYPE=$engine";
280 $this->DBmysql5
= 'false';
282 $this->DBengine
= $engine;
284 # Set the global for use during install
285 global $wgDBTableOptions;
286 $wgDBTableOptions = $this->DBTableOptions
;
294 <b
>Don
't forget security updates!</b> Keep an eye on the
295 <a href="http://lists.wikimedia.org/mailman/listinfo/mediawiki-announce">low-traffic
296 release announcements mailing list</a>.
301 <h2>Checking environment...</h2>
302 <p><em>Please include all of the lines below when reporting installation problems.</em></p>
303 <ul class="env-check">
305 $mainListOpened = true;
309 define( 'MW_NO_OUTPUT_BUFFER
', 1 );
310 $conf = new ConfigData;
312 install_version_checks();
313 $self = 'Installer
'; # Maintenance script name, to please Setup.php
315 print "<li>PHP " . htmlspecialchars( phpversion() ) . " installed</li>\n";
317 error_reporting( 0 );
318 $phpdatabases = array();
319 foreach (array_keys($ourdb) as $db) {
320 $compname = $ourdb[$db]['compile
'];
321 if( extension_loaded( $compname ) || ( mw_have_dl() && dl( "{$compname}." . PHP_SHLIB_SUFFIX ) ) ) {
322 array_push($phpdatabases, $db);
323 $ourdb[$db]['havedriver
'] = 1;
326 error_reporting( E_ALL | E_STRICT );
328 if (!$phpdatabases) {
329 print "Could not find a suitable database driver!<ul>";
330 foreach (array_keys($ourdb) AS $db) {
331 $comp = $ourdb[$db]['compile
'];
332 $full = $ourdb[$db]['fullname
'];
333 print "<li>For <b>$full</b>, compile PHP using <b>--with-$comp</b>, "
334 ."or install the $comp.so module</li>\n";
340 print "<li>Found database drivers for:";
342 foreach (array_keys($ourdb) AS $db) {
343 if ($ourdb[$db]['havedriver
']) {
344 if ( $DefaultDBtype == '' ) {
345 $DefaultDBtype = $db;
347 print " ".$ourdb[$db]['fullname
'];
352 if( wfIniGetBool( "register_globals" ) ) {
355 <div style="font-size:110%">
356 <strong class="error">Warning:</strong>
357 <strong>PHP's
<tt
><a href
="http://php.net/register_globals">register_globals
</a
></tt
> option is enabled
. Disable it
if you can
.</strong
>
359 MediaWiki will work
, but your server is more exposed to PHP
-based security vulnerabilities
.
366 if( wfIniGetBool( "magic_quotes_runtime" ) ) {
368 ?
><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
>
369 This option corrupts data input unpredictably
; you cannot install
or use
370 MediaWiki unless this option is disabled
.</li
>
374 if( wfIniGetBool( "magic_quotes_sybase" ) ) {
376 ?
><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
>
377 This option corrupts data input unpredictably
; you cannot install
or use
378 MediaWiki unless this option is disabled
.</li
>
382 if( wfIniGetBool( "mbstring.func_overload" ) ) {
384 ?
><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
>
385 This option causes errors
and may corrupt data unpredictably
;
386 you cannot install
or use MediaWiki unless this option is disabled
.</li
>
390 if( wfIniGetBool( "zend.ze1_compatibility_mode" ) ) {
392 ?
><li
class="error"><strong
>Fatal
: <a href
="http://www.php.net/manual/en/ini.core.php">zend
.ze1_compatibility_mode
</a
> is active
!</strong
>
393 This option causes horrible bugs with MediaWiki
; you cannot install
or use
394 MediaWiki unless this option is disabled
.</li
>
400 dieout( "Cannot install MediaWiki." );
403 if( wfIniGetBool( "safe_mode" ) ) {
404 $conf->safeMode
= true;
406 <li
><b
class='error'>Warning
:</b
> <strong
>PHP
's
407 <a href='http
://www.php.net/features.safe-mode'>safe mode</a> is active.</strong>
408 You may have problems caused by this
, particularly
if using image uploads
.
412 $conf->safeMode
= false;
415 $sapi = htmlspecialchars( php_sapi_name() );
416 print "<li>PHP server API is $sapi; ";
417 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
418 if( $wgUsePathInfo ) {
419 print "ok, using pretty URLs (<tt>$script/Page_Title</tt>)";
421 print "using ugly URLs (<tt>$script?title=Page_Title</tt>)";
425 $conf->xml
= function_exists( "utf8_encode" );
427 print "<li>Have XML / Latin1-UTF-8 conversion support.</li>\n";
429 dieout( "PHP's XML module is missing; the wiki requires functions in
430 this module and won't work in this configuration.
431 If you're running Mandrake, install the php-xml package." );
434 # Check for session support
435 if( !function_exists( 'session_name' ) )
436 dieout( "PHP's session module is missing. MediaWiki requires session support in order to function." );
438 # session.save_path doesn't *have* to be set, but if it is, and it's
439 # not valid/writable/etc. then it can cause problems
440 $sessionSavePath = mw_get_session_save_path();
441 $ssp = htmlspecialchars( $sessionSavePath );
442 # Warn the user if it's not set, but let them proceed
443 if( !$sessionSavePath ) {
444 print "<li><strong>Warning:</strong> A value for <tt>session.save_path</tt>
445 has not been set in PHP.ini. If the default value causes problems with
446 saving session data, set it to a valid path which is read/write/execute
447 for the user your web server is running under.</li>";
448 } elseif ( is_dir( $sessionSavePath ) && is_writable( $sessionSavePath ) ) {
449 # All good? Let the user know
450 print "<li>Session save path (<tt>{$ssp}</tt>) appears to be valid.</li>";
452 # Something not right? Warn the user, but let them proceed
453 print "<li><strong>Warning:</strong> Your <tt>session.save_path</tt> value (<tt>{$ssp}</tt>)
454 appears to be invalid or is not writable. PHP needs to be able to save data to
455 this location for correct session operation.</li>";
458 # Check for PCRE support
459 if( !function_exists( 'preg_match' ) )
460 dieout( "The PCRE support module appears to be missing. MediaWiki requires the
461 Perl-compatible regular expression functions." );
463 # The installer can take a while, and we really don't want it to time out
464 wfSuppressWarnings();
468 $memlimit = ini_get( "memory_limit" );
469 if( $memlimit == -1 ) {
470 print "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n";
472 print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars( $memlimit ). " bytes. ";
473 $newlimit = wfMemoryLimit();
474 $memlimit = wfShorthandToInteger( $memlimit );
475 if( $newlimit < $memlimit ) {
476 print "<b>Failed raising limit, installation may fail.</b>";
477 } elseif ( $newlimit > $memlimit ) {
478 print "Raised <tt>memory_limit</tt> to " . htmlspecialchars( $newlimit ) . " bytes. ";
483 $conf->turck
= function_exists( 'mmcache_get' );
484 if ( $conf->turck
) {
485 print "<li><a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> installed</li>\n";
488 $conf->xcache
= function_exists( 'xcache_get' );
490 print "<li><a href=\"http://trac.lighttpd.net/xcache/\">XCache</a> installed</li>\n";
492 $conf->apc
= function_exists('apc_fetch');
494 print "<li><a href=\"http://www.php.net/apc\">APC</a> installed</li>\n";
497 $conf->eaccel
= function_exists( 'eaccelerator_get' );
498 if ( $conf->eaccel
) {
499 $conf->turck
= 'eaccelerator';
500 print "<li><a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> installed</li>\n";
503 $conf->dba
= function_exists( 'dba_open' );
505 if( !( $conf->turck ||
$conf->eaccel ||
$conf->apc ||
$conf->xcache
) ) {
506 echo( '<li>Couldn\'t find <a href="http://turck-mmcache.sourceforge.net">Turck MMCache</a>,
507 <a href="http://eaccelerator.sourceforge.net">eAccelerator</a>,
508 <a href="http://www.php.net/apc">APC</a> or <a href="http://trac.lighttpd.net/xcache/">XCache</a>;
509 cannot use these for object caching.</li>' );
512 $conf->phpCliPath
= false;
513 $phpClilocations = array_merge(
520 explode( PATH_SEPARATOR
, getenv( "PATH" ) ) );
521 $phpClinames = array( "php", "php.exe" );
522 foreach ($phpClilocations as $loc) {
523 $exe = locate_executable($loc, $phpClinames);
524 if ($exe !== false) {
525 $conf->phpCliPath
= $exe;
530 $conf->diff3
= false;
531 $diff3locations = array_merge(
538 explode( PATH_SEPARATOR
, getenv( "PATH" ) ) );
539 $diff3names = array( "gdiff3", "diff3", "diff3.exe" );
541 $diff3versioninfo = array( '$1 --version 2>&1', 'diff3 (GNU diffutils)' );
542 foreach ($diff3locations as $loc) {
543 $exe = locate_executable($loc, $diff3names, $diff3versioninfo);
544 if ($exe !== false) {
551 print "<li>Found GNU diff3: <tt>$conf->diff3</tt>.</li>";
553 print "<li>GNU diff3 not found.</li>";
555 $conf->ImageMagick
= false;
556 $imcheck = array( "/usr/bin", "/opt/csw/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" );
557 foreach( $imcheck as $dir ) {
558 $im = "$dir/convert";
559 if( @file_exists
( $im ) ) {
560 print "<li>Found ImageMagick: <tt>$im</tt>; image thumbnailing will be enabled if you enable uploads.</li>\n";
561 $conf->ImageMagick
= $im;
566 $conf->HaveGD
= function_exists( "imagejpeg" );
567 if( $conf->HaveGD
) {
568 print "<li>Found GD graphics library built-in";
569 if( !$conf->ImageMagick
) {
570 print ", image thumbnailing will be enabled if you enable uploads";
574 if( !$conf->ImageMagick
) {
575 print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n";
579 $conf->IP
= dirname( dirname( __FILE__
) );
580 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP
) . "</tt></li>\n";
583 // PHP_SELF isn't available sometimes, such as when PHP is CGI but
584 // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
585 // to get the path to the current script... hopefully it's reliable. SIGH
586 $path = ($_SERVER["PHP_SELF"] === '')
587 ?
$_SERVER["SCRIPT_NAME"]
588 : $_SERVER["PHP_SELF"];
590 $conf->ScriptPath
= preg_replace( '{^(.*)/config.*$}', '$1', $path );
591 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath
) . "</tt></li>\n";
595 // We may be installing from *.php5 extension file, if so, print message
596 $conf->ScriptExtension
= '.php';
597 if (defined('MW_INSTALL_PHP5_EXT')) {
598 $conf->ScriptExtension
= '.php5';
599 print "<li>Installing MediaWiki with <tt>php5</tt> file extensions</li>\n";
601 print "<li>Installing MediaWiki with <tt>php</tt> file extensions</li>\n";
605 print "<li style='font-weight:bold;color:green;font-size:110%'>Environment checked. You can install MediaWiki.</li>\n";
606 $conf->posted
= ($_SERVER["REQUEST_METHOD"] == "POST");
608 $conf->Sitename
= ucfirst( importPost( "Sitename", "" ) );
609 $defaultEmail = empty( $_SERVER["SERVER_ADMIN"] )
611 : $_SERVER["SERVER_ADMIN"];
612 $conf->EmergencyContact
= importPost( "EmergencyContact", $defaultEmail );
613 $conf->DBtype
= importPost( "DBtype", $DefaultDBtype );
614 if ( !isset( $ourdb[$conf->DBtype
] ) ) {
615 $conf->DBtype
= $DefaultDBtype;
618 $conf->DBserver
= importPost( "DBserver", "localhost" );
619 $conf->DBname
= importPost( "DBname", "wikidb" );
620 $conf->DBuser
= importPost( "DBuser", "wikiuser" );
621 $conf->DBpassword
= importPost( "DBpassword" );
622 $conf->DBpassword2
= importPost( "DBpassword2" );
623 $conf->SysopName
= importPost( "SysopName", "WikiSysop" );
624 $conf->SysopPass
= importPost( "SysopPass" );
625 $conf->SysopPass2
= importPost( "SysopPass2" );
626 $conf->RootUser
= importPost( "RootUser", "root" );
627 $conf->RootPW
= importPost( "RootPW", "" );
628 $useRoot = importCheck( 'useroot', false );
629 $conf->LanguageCode
= importPost( "LanguageCode", "en" );
631 $conf->DBprefix
= importPost( "DBprefix" );
633 importPost( "DBschema", "mysql5-binary" ),
634 importPost( "DBengine", "InnoDB" ) );
636 ## Postgres specific:
637 $conf->DBport
= importPost( "DBport", "5432" );
638 $conf->DBmwschema
= importPost( "DBmwschema", "mediawiki" );
639 $conf->DBts2schema
= importPost( "DBts2schema", "public" );
642 $conf->SQLiteDataDir
= importPost( "SQLiteDataDir", "" );
645 // We need a second field so it doesn't overwrite the MySQL one
646 $conf->DBprefix2
= importPost( "DBprefix2" );
649 // New variable in order to have a different default port number
650 $conf->DBport_db2
= importPost( "DBport_db2", "50000" );
651 $conf->DBmwschema
= importPost( "DBmwschema", "mediawiki" );
652 $conf->DBcataloged
= importPost( "DBcataloged", "cataloged" );
655 $conf->DBprefix_ora
= importPost( "DBprefix_ora" );
656 $conf->DBdefTS_ora
= importPost( "DBdefTS_ora", "USERS" );
657 $conf->DBtempTS_ora
= importPost( "DBtempTS_ora", "TEMP" );
659 $conf->ShellLocale
= getShellLocale( $conf->LanguageCode
);
661 /* Check for validity */
664 if( preg_match( '/^$|^mediawiki$|#/i', $conf->Sitename
) ) {
665 $errs["Sitename"] = "Must not be blank or \"MediaWiki\" and may not contain \"#\"";
667 if( $conf->DBuser
== "" ) {
668 $errs["DBuser"] = "Must not be blank";
670 if( ($conf->DBtype
== 'mysql') && (strlen($conf->DBuser
) > 16) ) {
671 $errs["DBuser"] = "Username too long";
673 if( $conf->DBpassword
== "" && $conf->DBtype
!= "postgres" ) {
674 $errs["DBpassword"] = "Must not be blank";
676 if( $conf->DBpassword
!= $conf->DBpassword2
) {
677 $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
) !== true ) {
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 $wgDBmwschema = $conf->DBmwschema
;
827 $wgDBts2schema = $conf->DBts2schema
;
829 if( $conf->DBprefix2
!= '' ) {
831 $wgDBprefix = $conf->DBprefix2
;
832 } elseif( $conf->DBprefix_ora
!= '' ) {
834 $wgDBprefix = $conf->DBprefix_ora
;
838 $wgDBcataloged = $conf->DBcataloged
;
840 $wgCommandLineMode = true;
841 if (! defined ( 'STDERR' ) )
842 define( 'STDERR', fopen("php://stderr", "wb"));
843 $wgUseDatabaseMessages = false; /* FIXME: For database failure */
844 require_once( "$IP/includes/Setup.php" );
845 Language
::getLocalisationCache()->disableBackend();
849 $wgTitle = Title
::newFromText( "Installation script" );
850 error_reporting( E_ALL | E_STRICT
);
851 print "<li>Loading class: " . htmlspecialchars( $dbclass ) . "</li>\n";
852 if ( $conf->DBtype
!= 'sqlite' ) {
856 if( $conf->DBtype
== 'mysql' ) {
857 $mysqlOldClient = version_compare( mysql_get_client_info(), "4.1.0", "lt" );
858 if( $mysqlOldClient ) {
859 print "<li><b>PHP is linked with old MySQL client libraries. If you are
860 using a MySQL 4.1 server and have problems connecting to the database,
861 see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
862 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b></li>\n";
864 $ok = true; # Let's be optimistic
866 # Decide if we're going to use the superuser or the regular database user
867 $conf->Root
= $useRoot;
869 $db_user = $conf->RootUser
;
870 $db_pass = $conf->RootPW
;
872 $db_user = $wgDBuser;
873 $db_pass = $wgDBpassword;
877 echo( "<li>Attempting to connect to database server as " . htmlspecialchars( $db_user ) . "..." );
878 $wgDatabase = Database
::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 );
880 # Check the connection and respond to errors
881 if( $wgDatabase->isOpen() ) {
884 $wgDBadminuser = $db_user;
885 $wgDBadminpassword = $db_pass;
886 echo( "success.</li>\n" );
887 $wgDatabase->ignoreErrors( true );
888 $myver = $wgDatabase->getServerVersion();
890 # There were errors, report them and back out
892 $errno = mysql_errno();
893 $errtx = htmlspecialchars( mysql_error() );
897 echo( "failed due to authentication errors. Check passwords.</li>" );
899 # The superuser details are wrong
900 $errs["RootUser"] = "Check username";
901 $errs["RootPW"] = "and password";
903 # The regular user details are wrong
904 $errs["DBuser"] = "Check username";
905 $errs["DBpassword"] = "and password";
911 # General connection problem
912 echo( htmlspecialchars( "failed with error [$errno] $errtx." ) . "</li>\n" );
913 $errs["DBserver"] = "Connection failed";
918 if( !$ok ) { continue; }
920 else if( $conf->DBtype
== 'ibm_db2' ) {
922 $db_user = $conf->RootUser
;
923 $db_pass = $conf->RootPW
;
925 $db_user = $wgDBuser;
926 $db_pass = $wgDBpassword;
929 echo( "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) .
930 "\" as \"" . htmlspecialchars( $db_user ) . "\"..." );
931 $wgDatabase = $dbc->newFromParams($wgDBserver, $db_user, $db_pass, $wgDBname, 1);
932 // enable extra debug messages
933 $dbc->setMode(DatabaseIbm_db2
::INSTALL_MODE
);
934 $wgDatabase->setMode(DatabaseIbm_db2
::INSTALL_MODE
);
936 if (!$wgDatabase->isOpen()) {
937 print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
939 $myver = $wgDatabase->getServerVersion();
941 if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname);
943 } elseif ( $conf->DBtype
== 'sqlite' ) {
944 if ("$wgSQLiteDataDir" == '') {
945 $wgSQLiteDataDir = dirname($_SERVER['DOCUMENT_ROOT']).'/data';
947 echo "<li>Attempting to connect to SQLite database at \"" .
948 htmlspecialchars( $wgSQLiteDataDir ) . "\"";
949 if ( !is_dir( $wgSQLiteDataDir ) ) {
950 if ( is_writable( dirname( $wgSQLiteDataDir ) ) ) {
951 $ok = wfMkdirParents( $wgSQLiteDataDir, $wgSQLiteDataDirMode );
956 echo ": cannot create data directory</li>";
957 $errs['SQLiteDataDir'] = 'Enter a valid data directory';
961 if ( !is_writable( $wgSQLiteDataDir ) ) {
962 echo ": data directory not writable</li>";
963 $errs['SQLiteDataDir'] = 'Enter a writable data directory';
966 $dataFile = "$wgSQLiteDataDir/$wgDBname.sqlite";
967 if ( file_exists( $dataFile ) && !is_writable( $dataFile ) ) {
968 echo ": data file not writable</li>";
969 $errs['SQLiteDataDir'] = "$wgDBname.sqlite is not writable";
972 $wgDatabase = new DatabaseSqlite( false, false, false, $wgDBname, 1 );
973 if (!$wgDatabase->isOpen()) {
974 print ": error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
975 $errs['SQLiteDataDir'] = 'Could not connect to database';
978 $myver = $wgDatabase->getServerVersion();
980 if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname);
982 } elseif ( $conf->DBtype
== 'oracle' ) {
983 echo "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) ."\"</li>";
984 $wgDatabase = $dbc->newFromParams('DUMMY', $wgDBuser, $wgDBpassword, $wgDBname, 1);
985 if (!$wgDatabase->isOpen()) {
987 echo "<li>Connect failed.</li>";
989 if (ini_get('oci8.privileged_connect') === false) {
990 echo "<li>Privileged connect disabled, please set oci8.privileged_connect or run maintenance/ora/user.sql script manually prior to continuing.</li>";
993 $wgDBadminuser = $conf->RootUser
;
994 $wgDBadminpassword = $conf->RootPW
;
995 echo "<li>Attempting to create DB user.</li>";
996 $wgDatabase = $dbc->newFromParams('DUMMY', $wgDBadminuser, $wgDBadminpassword, $wgDBname, 1, 64);
997 if ($wgDatabase->isOpen()) {
998 $wgDBOracleDefTS = $conf->DBdefTS_ora
;
999 $wgDBOracleTempTS = $conf->DBtempTS_ora
;
1000 $wgDatabase->sourceFile( "../maintenance/ora/user.sql" );
1002 echo "<li>Invalid database superuser, please supply a valid superuser account.</li>";
1003 echo "<li>ERR: ".print_r(oci_error(), true)."</li>";
1008 echo "<li>Database superuser missing, please supply a valid superuser account.</li>";
1012 $errs["RootUser"] = "Check username";
1013 $errs["RootPW"] = "and password";
1015 echo "<li>Attempting to connect to database with new user \"" . htmlspecialchars( $wgDBname ) ."\"</li>";
1016 $wgDatabase = $dbc->newFromParams('DUMMY', $wgDBuser, $wgDBpassword, $wgDBname, 1);
1020 $myver = $wgDatabase->getServerVersion();
1022 } else { # not mysql
1023 error_reporting( E_ALL | E_STRICT
);
1025 ## Possible connect as a superuser
1026 // Changed !mysql to postgres check since it seems to only apply to postgres
1027 if( $useRoot && $conf->DBtype
== 'postgres' ) {
1028 $wgDBsuperuser = $conf->RootUser
;
1029 echo( "<li>Attempting to connect to database \"postgres\" as superuser \"" .
1030 htmlspecialchars( $wgDBsuperuser ) . "\"..." );
1031 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBsuperuser, $conf->RootPW
, "postgres", 1);
1032 if (!$wgDatabase->isOpen()) {
1033 print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
1034 $errs["DBserver"] = "Could not connect to database as superuser";
1035 $errs["RootUser"] = "Check username";
1036 $errs["RootPW"] = "and password";
1039 $wgDatabase->initial_setup($conf->RootPW
, 'postgres');
1041 echo( "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) .
1042 "\" as \"" . htmlspecialchars( $wgDBuser ) . "\"..." );
1043 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1);
1044 if (!$wgDatabase->isOpen()) {
1045 print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
1046 $errs["DBserver"] = "Could not connect to database as user";
1047 $errs["DBuser"] = "Check username";
1048 $errs["DBpassword"] = "and password";
1051 $myver = $wgDatabase->getServerVersion();
1053 if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname);
1056 if ( !$wgDatabase->isOpen() ) {
1057 $errs["DBserver"] = "Couldn't connect to database";
1061 print "<li>Connected to " . htmlspecialchars( "{$conf->DBtype} $myver" );
1062 if ($conf->DBtype
== 'mysql') {
1063 if( version_compare( $myver, "4.0.14" ) < 0 ) {
1065 dieout( "-- mysql 4.0.14 or later required. Aborting." );
1067 $mysqlNewAuth = version_compare( $myver, "4.1.0", "ge" );
1068 if( $mysqlNewAuth && $mysqlOldClient ) {
1069 print "; <b class='error'>You are using MySQL 4.1 server, but PHP is linked
1070 to old client libraries; if you have trouble with authentication, see
1071 <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
1072 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>";
1075 if( $mysqlNewAuth ) {
1076 print "; enabling MySQL 4.1/5.0 charset mode";
1078 print "; <b class='error'>MySQL 4.1/5.0 charset mode enabled,
1079 but older version detected; will likely fail.</b>";
1084 @$sel = $wgDatabase->selectDB( $wgDBname );
1086 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
1088 $err = mysql_errno();
1089 $databaseSafe = htmlspecialchars( $wgDBname );
1090 if( $err == 1102 /* Invalid database name */ ) {
1091 print "<ul><li><strong>{$databaseSafe}</strong> is not a valid database name.</li></ul>";
1093 } elseif( $err != 1049 /* Database doesn't exist */ ) {
1094 print "<ul><li>Error selecting database <strong>{$databaseSafe}</strong>: {$err} ";
1095 print htmlspecialchars( mysql_error() ) . "</li></ul>";
1098 print "<li>Attempting to create database...</li>";
1099 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
1101 print "<li>Couldn't create database <tt>" .
1102 htmlspecialchars( $wgDBname ) .
1103 "</tt>; try with root access or check your username/pass.</li>\n";
1104 $errs["RootPW"] = "<- Enter";
1107 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
1109 $wgDatabase->selectDB( $wgDBname );
1111 else if ($conf->DBtype
== 'postgres') {
1112 if( version_compare( $myver, "8.0" ) < 0 ) {
1113 dieout( "<b>Postgres 8.0 or later is required</b>. Aborting." );
1117 if( $wgDatabase->tableExists( "cur" ) ||
$wgDatabase->tableExists( "revision" ) ) {
1118 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n";
1120 if ( $conf->DBtype
== 'mysql') {
1121 # Determine existing default character set
1122 if ( $wgDatabase->tableExists( "revision" ) ) {
1123 $revision = $wgDatabase->escapeLike( $conf->DBprefix
. 'revision' );
1124 $res = $wgDatabase->query( "SHOW TABLE STATUS LIKE '$revision'" );
1125 $row = $wgDatabase->fetchObject( $res );
1127 echo "<li>SHOW TABLE STATUS query failed!</li>\n";
1128 $existingSchema = false;
1129 $existingEngine = false;
1131 if ( preg_match( '/^latin1/', $row->Collation
) ) {
1132 $existingSchema = 'mysql4';
1133 } elseif ( preg_match( '/^utf8/', $row->Collation
) ) {
1134 $existingSchema = 'mysql5';
1135 } elseif ( preg_match( '/^binary/', $row->Collation
) ) {
1136 $existingSchema = 'mysql5-binary';
1138 $existingSchema = false;
1139 echo "<li><strong>Warning:</strong> Unrecognised existing collation</li>\n";
1141 if ( isset( $row->Engine
) ) {
1142 $existingEngine = $row->Engine
;
1144 $existingEngine = $row->Type
;
1147 if ( $existingSchema && $existingSchema != $conf->DBschema
) {
1148 $encExisting = htmlspecialchars( $existingSchema );
1149 $encRequested = htmlspecialchars( $conf->DBschema
);
1150 print "<li><strong>Warning:</strong> you requested the $encRequested schema, " .
1151 "but the existing database has the $encExisting schema. This upgrade script ".
1152 "can't convert it, so it will remain $encExisting.</li>\n";
1153 $conf->setSchema( $existingSchema, $conf->DBengine
);
1155 if ( $existingEngine && $existingEngine != $conf->DBengine
) {
1156 $encExisting = htmlspecialchars( $existingEngine );
1157 $encRequested = htmlspecialchars( $conf->DBengine
);
1158 print "<li><strong>Warning:</strong> you requested the $encRequested storage " .
1159 "engine, but the existing database uses the $encExisting engine. This upgrade " .
1160 "script can't convert it, so it will remain $encExisting.</li>\n";
1161 $conf->setSchema( $conf->DBschema
, $existingEngine );
1165 # Create user if required
1166 if ( $conf->Root
) {
1167 $conn = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
1168 if ( $conn->isOpen() ) {
1169 print "<li>DB user account ok</li>\n";
1172 print "<li>Granting user permissions...";
1173 if( $mysqlOldClient && $mysqlNewAuth ) {
1174 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>";
1177 $wgDatabase->sourceFile( "../maintenance/users.sql" );
1181 print "</ul><pre>\n";
1187 print "<ul><li>Finished update checks.</li>\n";
1188 // if tables don't yet exist
1190 # Determine available storage engines if possible
1191 if ( $conf->DBtype
== 'mysql' && version_compare( $myver, "4.1.2", "ge" ) ) {
1192 $res = $wgDatabase->query( 'SHOW ENGINES' );
1194 while ( $row = $wgDatabase->fetchObject( $res ) ) {
1195 if ( $row->Engine
== $conf->DBengine
&& ( $row->Support
== 'YES' ||
$row->Support
== 'DEFAULT' ) ) {
1200 $wgDatabase->freeResult( $res );
1201 if ( !$found && $conf->DBengine
!= 'MyISAM' ) {
1202 echo "<li><strong>Warning:</strong> " . htmlspecialchars( $conf->DBengine
) .
1203 " storage engine not available, " .
1204 "using MyISAM instead</li>\n";
1205 $conf->setSchema( $conf->DBschema
, 'MyISAM' );
1209 # FIXME: Check for errors
1210 print "<li>Creating tables...";
1211 if ($conf->DBtype
== 'mysql') {
1212 $wgDatabase->sourceFile( "../maintenance/tables.sql" );
1213 $wgDatabase->sourceFile( "../maintenance/interwiki.sql" );
1214 } elseif (is_callable(array($wgDatabase, 'setup_database'))) {
1215 $wgDatabase->setup_database();
1218 $errs["DBtype"] = "Do not know how to handle database type '$conf->DBtype'";
1222 print " done.</li>\n";
1225 if ($conf->DBtype
== 'ibm_db2') {
1226 // Now that table creation is done, make sure everything is committed
1227 // Do this before doing inserts through API
1228 if ($wgDatabase->lastError()) {
1229 print "<li>Errors encountered during table creation -- rolled back</li>\n";
1230 $wgDatabase->rollback();
1233 print "<li>MediaWiki tables successfully created</li>\n";
1234 $wgDatabase->commit();
1238 print "<li>Initializing statistics...</li>\n";
1239 $wgDatabase->insert( 'site_stats',
1240 array ( 'ss_row_id' => 1,
1241 'ss_total_views' => 0,
1242 'ss_total_edits' => 1, # Main page first edit
1243 'ss_good_articles' => 0, # Main page is not a good article - no internal link
1244 'ss_total_pages' => 1, # Main page
1245 'ss_users' => $conf->SysopName ?
1 : 0, # Sysop account, if created
1246 'ss_admins' => $conf->SysopName ?
1 : 0, # Sysop account, if created
1247 'ss_images' => 0 ) );
1249 # Set up the "regular user" account *if we can, and if we need to*
1250 if( $conf->Root
and $conf->DBtype
== 'mysql') {
1252 $wgDatabase2 = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
1253 if( $wgDatabase2->isOpen() ) {
1254 # Nope, just close the test connection and continue
1255 $wgDatabase2->close();
1256 echo( "<li>User " . htmlspecialchars( $wgDBuser ) . " exists. Skipping grants.</li>\n" );
1258 # Yes, so run the grants
1259 echo( "<li>" . htmlspecialchars( "Granting user permissions to $wgDBuser on $wgDBname..." ) );
1260 $wgDatabase->sourceFile( "../maintenance/users.sql" );
1261 echo( "success.</li>\n" );
1265 if( $conf->SysopName
) {
1266 $u = User
::newFromName( $conf->getSysopName() );
1268 print "<li><strong class=\"error\">Warning:</strong> Skipped sysop account creation - invalid username!</li>\n";
1270 else if ( 0 == $u->idForName() ) {
1271 $u->addToDatabase();
1272 $u->setPassword( $conf->getSysopPass() );
1275 $u->addGroup( "sysop" );
1276 $u->addGroup( "bureaucrat" );
1278 print "<li>Created sysop account <tt>" .
1279 htmlspecialchars( $conf->SysopName
) . "</tt>.</li>\n";
1281 print "<li>Could not create user - already exists!</li>\n";
1284 print "<li>Skipped sysop account creation, no name given.</li>\n";
1287 $titleobj = Title
::newFromText( wfMsgNoDB( "mainpage" ) );
1288 $article = new Article( $titleobj );
1289 $newid = $article->insertOn( $wgDatabase );
1290 $revision = new Revision( array(
1292 'text' => wfMsg( 'mainpagetext' ) . "\n\n" . wfMsgNoTrans( 'mainpagedocfooter' ),
1295 'user_text' => 'MediaWiki default',
1297 $revid = $revision->insertOn( $wgDatabase );
1298 $article->updateRevisionOn( $wgDatabase, $revision );
1301 /* Write out the config file now that all is well */
1302 print "<li style=\"list-style: none\">\n";
1303 print "<p>Creating LocalSettings.php...</p>\n\n";
1304 $localSettings = "<" . "?php$endl$local";
1305 // Fix up a common line-ending problem (due to CVS on Windows)
1306 $localSettings = str_replace( "\r\n", "\n", $localSettings );
1307 $f = fopen( "LocalSettings.php", 'xt' );
1311 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" .
1312 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
1313 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
1315 if(fwrite( $f, $localSettings ) ) {
1318 writeSuccessMessage();
1322 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" );
1329 $mainListOpened = false;
1331 if( count( $errs ) ) {
1332 /* Display options form */
1334 if( $conf->posted
) {
1335 echo "<p class='error-top'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
1339 <form action
="<?php echo defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php'; ?>" name
="config" method
="post">
1341 <h2
>Site config
</h2
>
1343 <div
class="config-section">
1344 <div
class="config-input">
1345 <?php
aField( $conf, "Sitename", "Wiki name:" ); ?
>
1347 <p
class="config-desc">
1348 Preferably a short word without punctuation
, i
.e
. "Wikipedia".<br
/>
1349 Will appear
as the
namespace name
for "meta" pages
, and throughout the
interface.
1351 <div
class="config-input"><?php
aField( $conf, "EmergencyContact", "Contact e-mail:" ); ?
></div
>
1352 <p
class="config-desc">
1353 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
.
1356 <div
class="config-input">
1357 <label
class='column' for="LanguageCode">Language
:</label
>
1358 <select id
="LanguageCode" name
="LanguageCode"><?php
1359 $list = getLanguageList();
1360 foreach( $list as $code => $name ) {
1361 $sel = ($code == $conf->LanguageCode
) ?
'selected="selected"' : '';
1362 $encCode = htmlspecialchars( $code );
1363 $encName = htmlspecialchars( $name );
1364 echo "\n\t\t<option value=\"$encCode\" $sel>$encName</option>";
1370 <p
class="config-desc">
1371 Select the language
for your wiki
's interface. Some localizations aren't fully complete
. Unicode (UTF
-8) is used
for all localizations
.
1374 <div
class="config-input">
1375 <label
class='column'>Copyright
/license
:</label
>
1378 <li
><?php
aField( $conf, "License", "No license metadata", "radio", "none" ); ?
></li
>
1379 <li
><?php
aField( $conf, "License", "Public Domain", "radio", "pd" ); ?
></li
>
1380 <li
><?php
aField( $conf, "License", "GNU Free Documentation License 1.2", "radio", "gfdl1_2" ); ?
></li
>
1381 <li
><?php
aField( $conf, "License", "GNU Free Documentation License 1.3", "radio", "gfdl1_3" ); ?
></li
>
1383 aField( $conf, "License", "A Creative Commons license - ", "radio", "cc" );
1384 $partner = "MediaWiki";
1385 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
1386 $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/$script?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
1387 $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" );
1388 $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" );
1389 print "<a href=\"$ccApp\" target='_blank'>choose</a>";
1390 if( $conf->License
== "cc" ) { ?
>
1392 <li
><?php
aField( $conf, "RightsIcon", "<img src=\"" . htmlspecialchars( $conf->RightsIcon
) . "\" alt='(Creative Commons icon)' />", "hidden" ); ?
></li
>
1393 <li
><?php
aField( $conf, "RightsText", htmlspecialchars( $conf->RightsText
), "hidden" ); ?
></li
>
1394 <li
><?php
aField( $conf, "RightsCode", "code: " . htmlspecialchars( $conf->RightsCode
), "hidden" ); ?
></li
>
1395 <li
><?php
aField( $conf, "RightsUrl", "<a href=\"" . htmlspecialchars( $conf->RightsUrl
) . "\">" . htmlspecialchars( $conf->RightsUrl
) . "</a>", "hidden" ); ?
></li
>
1401 <p
class="config-desc">
1402 A notice
, icon
, and machine
-readable copyright metadata will be displayed
for the license you pick
.
1406 <div
class="config-input">
1407 <?php
aField( $conf, "SysopName", "Admin username:" ) ?
>
1409 <div
class="config-input">
1410 <?php
aField( $conf, "SysopPass", "Password:", "password" ) ?
>
1412 <div
class="config-input">
1413 <?php
aField( $conf, "SysopPass2", "Password confirm:", "password" ) ?
>
1415 <p
class="config-desc">
1416 An admin can lock
/delete pages
, block users from editing
, and do other maintenance tasks
.<br
/>
1417 A
new account will be added only when creating a
new wiki database
.
1419 The password cannot be the same
as the username
.
1422 <div
class="config-input">
1423 <label
class='column'>Object caching
:</label
>
1426 <li
><?php
aField( $conf, "Shm", "No caching", "radio", "none" ); ?
></li
>
1428 if ( $conf->turck
) {
1430 aField( $conf, "Shm", "Turck MMCache", "radio", "turck" );
1433 if( $conf->xcache
) {
1435 aField( $conf, 'Shm', 'XCache', 'radio', 'xcache' );
1440 aField( $conf, "Shm", "APC", "radio", "apc" );
1443 if ( $conf->eaccel
) {
1445 aField( $conf, "Shm", "eAccelerator", "radio", "eaccel" );
1450 aField( $conf, "Shm", "DBA (not recommended)", "radio", "dba" );
1454 <li
><?php
aField( $conf, "Shm", "Memcached", "radio", "memcached" ); ?
></li
>
1456 <div style
="clear:left"><?php
aField( $conf, "MCServers", "Memcached servers:", "text" ) ?
></div
>
1458 <p
class="config-desc">
1459 An
object caching system such
as memcached will provide a significant performance boost
,
1460 but needs to be installed
. Provide the server addresses
and ports in a comma
-separated
list.
1462 MediaWiki can also detect
and support eAccelerator
, Turck MMCache
, APC
, and XCache
, but
1463 these should not be used
if the wiki will be running on multiple application servers
.
1465 DBA (Berkeley
-style DB
) is generally slower than using no cache at all
, and is only
1466 recommended
for testing
.
1470 <h2
>E
-mail
, e
-mail notification
and authentication setup
</h2
>
1472 <div
class="config-section">
1473 <div
class="config-input">
1474 <label
class='column'>E
-mail
features (global):</label
>
1476 <li
><?php
aField( $conf, "Email", "Enabled", "radio", "email_enabled" ); ?
></li
>
1477 <li
><?php
aField( $conf, "Email", "Disabled", "radio", "email_disabled" ); ?
></li
>
1480 <p
class="config-desc">
1481 Use this to disable all e
-mail
functions (password reminders
, user
-to
-user e
-mail
, and e
-mail notifications
)
1482 if sending mail doesn
't work on your server.
1485 <div class="config-input">
1486 <label class='column
'>User-to-user e-mail:</label>
1488 <li><?php aField( $conf, "Emailuser", "Enabled", "radio", "emailuser_enabled" ); ?></li>
1489 <li><?php aField( $conf, "Emailuser", "Disabled", "radio", "emailuser_disabled" ); ?></li>
1492 <p class="config-desc">
1493 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.
1495 <div class="config-input">
1496 <label class='column
'>E-mail notification about changes:</label>
1498 <li><?php aField( $conf, "Enotif", "Disabled", "radio", "enotif_disabled" ); ?></li>
1499 <li><?php aField( $conf, "Enotif", "Enabled for changes to user discussion pages only", "radio", "enotif_usertalk" ); ?></li>
1500 <li><?php aField( $conf, "Enotif", "Enabled for changes to user discussion pages, and to pages on watchlists (not recommended for large wikis)", "radio", "enotif_allpages" ); ?></li>
1503 <div class="config-desc">
1505 For this feature to work, an e-mail address must be present for the user account, and the notification
1506 options in the user's preferences must be enabled
. Also note the
1507 authentication option below
. When testing the feature
, keep in mind that your own changes will never trigger notifications to be sent to yourself
.</p
>
1509 <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
>
1512 <div
class="config-input">
1513 <label
class='column'>E
-mail address authentication
:</label
>
1515 <li
><?php
aField( $conf, "Eauthent", "Disabled", "radio", "eauthent_disabled" ); ?
></li
>
1516 <li
><?php
aField( $conf, "Eauthent", "Enabled", "radio", "eauthent_enabled" ); ?
></li
>
1519 <div
class="config-desc">
1520 <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
1521 change notification mails
. Setting this option is
<b
>recommended
</b
> for public wikis because of potential abuse of the e
-mail features above
.</p
>
1526 <h2
>Database config
</h2
>
1528 <div
class="config-section">
1529 <div
class="config-input">
1530 <label
class='column'>Database type
:</label
>
1532 if (isset($errs['DBpicktype'])) {
1533 print "\t<span class='error'>" . htmlspecialchars( $errs['DBpicktype'] ) . "</span>\n";
1536 <ul
class='plain'><?php
1537 database_picker($conf);
1541 <div
class="config-input" style
="clear:left">
1542 <?php
aField( $conf, "DBserver", "Database host:" ); ?
>
1544 <p
class="config-desc">
1545 If your database server isn
't on your web server, enter the name or IP address here.
1548 <div class="config-input"><?php aField( $conf, "DBname", "Database name:" ); ?></div>
1549 <div class="config-input"><?php aField( $conf, "DBuser", "DB username:" ); ?></div>
1550 <div class="config-input"><?php aField( $conf, "DBpassword", "DB password:", "password" ); ?></div>
1551 <div class="config-input"><?php aField( $conf, "DBpassword2", "DB password confirm:", "password" ); ?></div>
1552 <p class="config-desc">
1553 If you only have a single user account and database available,
1554 enter those here. If you have database root access (see below)
1555 you can specify new accounts/databases to be created. This account
1556 will not be created if it pre-exists. If this is the case, ensure that it
1557 has SELECT, INSERT, UPDATE, and DELETE permissions on the MediaWiki database.
1560 <div class="config-input">
1561 <label class="column">Superuser account:</label>
1562 <input type="checkbox" name="useroot" id="useroot" <?php if( $useRoot ) { ?>checked="checked" <?php } ?> />
1563 <label for="useroot">Use superuser account</label>
1565 <div class="config-input"><?php aField( $conf, "RootUser", "Superuser name:", "text" ); ?></div>
1566 <div class="config-input"><?php aField( $conf, "RootPW", "Superuser password:", "password" ); ?></div>
1568 <p class="config-desc">
1569 If the database user specified above does not exist, or does not have access to create
1570 the database (if needed) or tables within it, please check the box and provide details
1571 of a superuser account, such as <strong>root</strong>, which does.
1574 <?php database_switcher('mysql
'); ?>
1575 <div class="config-input"><?php aField( $conf, "DBprefix", "Database table prefix:" ); ?></div>
1576 <div class="config-desc">
1577 <p>If you need to share one database between multiple wikis, or
1578 between MediaWiki and another web application, you may choose to
1579 add a prefix to all the table names to avoid conflicts.</p>
1581 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
1584 <div class="config-input"><label class="column">Storage Engine</label>
1585 <div>Select one:</div>
1587 <li><?php aField( $conf, "DBengine", "InnoDB", "radio", "InnoDB" ); ?></li>
1588 <li><?php aField( $conf, "DBengine", "MyISAM", "radio", "MyISAM" ); ?></li>
1591 <p class="config-desc">
1592 InnoDB is best for public web installations, since it has good concurrency
1593 support. MyISAM may be faster in single-user installations. MyISAM databases
1594 tend to get corrupted more often than InnoDB databases.
1596 <div class="config-input"><label class="column">Database character set</label>
1597 <div>Select one:</div>
1599 <li><?php aField( $conf, "DBschema", "MySQL 4.1/5.0 binary", "radio", "mysql5-binary" ); ?></li>
1600 <li><?php aField( $conf, "DBschema", "MySQL 4.1/5.0 UTF-8", "radio", "mysql5" ); ?></li>
1601 <li><?php aField( $conf, "DBschema", "MySQL 4.0 backwards-compatible UTF-8", "radio", "mysql4" ); ?></li>
1604 <p class="config-desc">
1605 This option is ignored on upgrade, the same character set will be kept.
1607 <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!.
1609 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>.
1613 <?php database_switcher('postgres
'); ?>
1614 <div class="config-input"><?php aField( $conf, "DBport", "Database port:" ); ?></div>
1615 <div class="config-input"><?php aField( $conf, "DBmwschema", "Schema for mediawiki:" ); ?></div>
1616 <div class="config-input"><?php aField( $conf, "DBts2schema", "Schema for tsearch2:" ); ?></div>
1617 <div class="config-desc">
1618 <p>The username specified above (at "DB username") will have its search path set to the above schemas,
1619 so it is recommended that you create a new user. The above schemas are generally correct:
1620 only change them if you are sure you need to.</p>
1624 <?php database_switcher('sqlite
'); ?>
1625 <div class="config-desc">
1626 <b>NOTE:</b> SQLite only uses the <i>Database name</i> setting above, the user, password and root settings are ignored.
1628 <div class="config-input"><?php
1629 aField( $conf, "SQLiteDataDir", "SQLite data directory:" );
1631 <div class="config-desc">
1632 <p>SQLite stores table data into files in the filesystem.
1633 If you do not provide an explicit path, a "data" directory in
1634 the parent of your document root will be used.</p>
1636 <p>This directory must exist and be writable by the web server.</p>
1640 <?php database_switcher('mssql
'); ?>
1641 <div class="config-input"><?php
1642 aField( $conf, "DBprefix2", "Database table prefix:" );
1644 <div class="config-desc">
1645 <p>If you need to share one database between multiple wikis, or
1646 between MediaWiki and another web application, you may choose to
1647 add a prefix to all the table names to avoid conflicts.</p>
1649 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
1653 <?php database_switcher('ibm_db2
'); ?>
1654 <div class="config-input"><?php
1655 aField( $conf, "DBport_db2", "Database port:" );
1657 <div class="config-input"><?php
1658 aField( $conf, "DBmwschema", "Schema for mediawiki:" );
1660 <div>Select one:</div>
1662 <li><?php aField( $conf, "DBcataloged", "Cataloged (DB2 installed locally)", "radio", "cataloged" ); ?></li>
1663 <li><?php aField( $conf, "DBcataloged", "Uncataloged (remote DB2 through ODBC)", "radio", "uncataloged" ); ?></li>
1665 <div class="config-desc">
1666 <p>If you need to share one database between multiple wikis, or
1667 between MediaWiki and another web application, you may specify
1668 a different schema to avoid conflicts.</p>
1672 <?php database_switcher('oracle
'); ?>
1673 <div class="config-input"><?php aField( $conf, "DBprefix_ora", "Database table prefix:" ); ?></div>
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 choose to
1677 add a prefix to all the table names to avoid conflicts.</p>
1679 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
1681 <div class="config-input"><?php aField( $conf, "DBdefTS_ora", "Default tablespace:" ); ?></div>
1682 <div class="config-input"><?php aField( $conf, "DBtempTS_ora", "Temporary tablespace:" ); ?></div>
1685 <div class="config-input" style="padding:2em 0 3em">
1686 <label class='column
'> </label>
1687 <input type="submit" value="Install MediaWiki!" class="btn-install" />
1691 <script type="text/javascript">
1692 window.onload = toggleDBarea( <?php echo Xml::encodeJsVar( $conf->DBtype ); ?>,
1694 ## If they passed in a root user name, don't populate it on page load
1695 echo strlen(importPost('RootUser', '')) ?
0 : 1;
1701 /* -------------------------------------------------------------------------------------- */
1702 function writeSuccessMessage() {
1703 $script = defined('MW_INSTALL_PHP5_EXT') ?
'index.php5' : 'index.php';
1704 if ( wfIniGetBool( 'safe_mode' ) && !ini_get( 'open_basedir' ) ) {
1706 <div class="success-box">
1707 <p>Installation successful!</p>
1708 <p>To complete the installation, please do the following:
1710 <li>Download config/LocalSettings.php with your FTP client or file manager</li>
1711 <li>Upload it to the parent directory</li>
1712 <li>Delete config/LocalSettings.php</li>
1713 <li>Start using <a href='../$script'>your wiki</a>!
1715 <p>If you are in a shared hosting environment, do <strong>not</strong> just move LocalSettings.php
1716 remotely. LocalSettings.php is currently owned by the user your webserver is running under,
1717 which means that anyone on the same server can read your database password! Downloading
1718 it and uploading it again will hopefully change the ownership to a user ID specific to you.</p>
1723 <div class="success-box">
1725 <span class="success-message">Installation successful!</span>
1726 Move the <tt>config/LocalSettings.php</tt> file to the parent directory, then follow
1727 <a href="../$script"> this link</a> to your wiki.</p>
1728 <p>You should change file permissions for <tt>LocalSettings.php</tt> as required to
1729 prevent other users on the server reading passwords and altering configuration data.</p>
1736 function escapePhpString( $string ) {
1737 if ( is_array( $string ) ||
is_object( $string ) ) {
1740 return strtr( $string,
1751 function writeLocalSettings( $conf ) {
1752 $conf->PasswordSender
= $conf->EmergencyContact
;
1753 $magic = ($conf->ImageMagick ?
"" : "# ");
1754 $convert = ($conf->ImageMagick ?
$conf->ImageMagick
: "/usr/bin/convert" );
1755 $rights = ($conf->RightsUrl
) ?
"" : "# ";
1756 $hashedUploads = $conf->safeMode ?
'' : '# ';
1758 if ( $conf->ShellLocale
) {
1762 $conf->ShellLocale
= 'en_US.UTF-8';
1765 switch ( $conf->Shm
) {
1767 $cacheType = 'CACHE_MEMCACHED';
1768 $mcservers = var_export( $conf->MCServerArray
, true );
1774 $cacheType = 'CACHE_ACCEL';
1775 $mcservers = 'array()';
1778 $cacheType = 'CACHE_DBA';
1779 $mcservers = 'array()';
1782 $cacheType = 'CACHE_NONE';
1783 $mcservers = 'array()';
1786 if ( $conf->Email
== 'email_enabled' ) {
1787 $enableemail = 'true';
1788 $enableuseremail = ( $conf->Emailuser
== 'emailuser_enabled' ) ?
'true' : 'false' ;
1789 $eauthent = ( $conf->Eauthent
== 'eauthent_enabled' ) ?
'true' : 'false' ;
1790 switch ( $conf->Enotif
) {
1791 case 'enotif_usertalk':
1792 $enotifusertalk = 'true';
1793 $enotifwatchlist = 'false';
1795 case 'enotif_allpages':
1796 $enotifusertalk = 'true';
1797 $enotifwatchlist = 'true';
1800 $enotifusertalk = 'false';
1801 $enotifwatchlist = 'false';
1804 $enableuseremail = 'false';
1805 $enableemail = 'false';
1806 $eauthent = 'false';
1807 $enotifusertalk = 'false';
1808 $enotifwatchlist = 'false';
1811 $file = @fopen
( "/dev/urandom", "r" );
1813 $secretKey = bin2hex( fread( $file, 32 ) );
1817 for ( $i=0; $i<8; $i++
) {
1818 $secretKey .= dechex(mt_rand(0, 0x7fffffff));
1820 print "<li>Warning: \$wgSecretKey key is insecure, generated with mt_rand(). Consider changing it manually.</li>\n";
1823 # Add slashes to strings for double quoting
1824 $slconf = wfArrayMap( "escapePhpString", get_object_vars( $conf ) );
1825 if( $conf->License
== 'gfdl1_2' ||
$conf->License
== 'pd' ||
$conf->License
== 'gfdl1_3' ) {
1826 # Needs literal string interpolation for the current style path
1827 $slconf['RightsIcon'] = $conf->RightsIcon
;
1830 if( $conf->DBtype
== 'mysql' ) {
1832 "# MySQL specific settings
1833 \$wgDBprefix = \"{$slconf['DBprefix']}\";
1835 # MySQL table options to use during installation or update
1836 \$wgDBTableOptions = \"{$slconf['DBTableOptions']}\";
1838 # Experimental charset support for MySQL 4.1/5.0.
1839 \$wgDBmysql5 = {$conf->DBmysql5};";
1840 } elseif( $conf->DBtype
== 'postgres' ) {
1842 "# Postgres specific settings
1843 \$wgDBport = \"{$slconf['DBport']}\";
1844 \$wgDBmwschema = \"{$slconf['DBmwschema']}\";
1845 \$wgDBts2schema = \"{$slconf['DBts2schema']}\";";
1846 } elseif( $conf->DBtype
== 'sqlite' ) {
1848 "# SQLite-specific settings
1849 \$wgSQLiteDataDir = \"{$slconf['SQLiteDataDir']}\";";
1850 } elseif( $conf->DBtype
== 'mssql' ) {
1852 "# MSSQL specific settings
1853 \$wgDBprefix = \"{$slconf['DBprefix2']}\";";
1854 } elseif( $conf->DBtype
== 'ibm_db2' ) {
1856 "# DB2 specific settings
1857 \$wgDBport_db2 = \"{$slconf['DBport_db2']}\";
1858 \$wgDBmwschema = \"{$slconf['DBmwschema']}\";
1859 \$wgDBcataloged = \"{$slconf['DBcataloged']}\";";
1860 } elseif( $conf->DBtype
== 'oracle' ) {
1862 "# Oracle specific settings
1863 \$wgDBprefix = \"{$slconf['DBprefix']}\";";
1871 # This file was automatically generated by the MediaWiki installer.
1872 # If you make manual changes, please keep track in case you need to
1873 # recreate them later.
1875 # See includes/DefaultSettings.php for all configurable settings
1876 # and their default values, but don't forget to make changes in _this_
1879 # Further documentation for configuration settings may be found at:
1880 # http://www.mediawiki.org/wiki/Manual:Configuration_settings
1882 # If you customize your file layout, set \$IP to the directory that contains
1883 # the other MediaWiki files. It will be used as a base to locate files.
1884 if( defined( 'MW_INSTALL_PATH' ) ) {
1885 \$IP = MW_INSTALL_PATH;
1887 \$IP = dirname( __FILE__ );
1890 \$path = array( \$IP, \"\$IP/includes\", \"\$IP/languages\" );
1891 set_include_path( implode( PATH_SEPARATOR, \$path ) . PATH_SEPARATOR . get_include_path() );
1893 require_once( \"\$IP/includes/DefaultSettings.php\" );
1895 if ( \$wgCommandLineMode ) {
1896 if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
1897 die( \"This script must be run from the command line\\n\" );
1900 ## Uncomment this to disable output compression
1901 # \$wgDisableOutputCompression = true;
1903 \$wgSitename = \"{$slconf['Sitename']}\";
1905 ## The URL base path to the directory containing the wiki;
1906 ## defaults for all runtime URL paths are based off of this.
1907 ## For more information on customizing the URLs please see:
1908 ## http://www.mediawiki.org/wiki/Manual:Short_URL
1909 \$wgScriptPath = \"{$slconf['ScriptPath']}\";
1910 \$wgScriptExtension = \"{$slconf['ScriptExtension']}\";
1912 ## UPO means: this is also a user preference option
1914 \$wgEnableEmail = $enableemail;
1915 \$wgEnableUserEmail = $enableuseremail; # UPO
1917 \$wgEmergencyContact = \"{$slconf['EmergencyContact']}\";
1918 \$wgPasswordSender = \"{$slconf['PasswordSender']}\";
1920 \$wgEnotifUserTalk = $enotifusertalk; # UPO
1921 \$wgEnotifWatchlist = $enotifwatchlist; # UPO
1922 \$wgEmailAuthentication = $eauthent;
1924 ## Database settings
1925 \$wgDBtype = \"{$slconf['DBtype']}\";
1926 \$wgDBserver = \"{$slconf['DBserver']}\";
1927 \$wgDBname = \"{$slconf['DBname']}\";
1928 \$wgDBuser = \"{$slconf['DBuser']}\";
1929 \$wgDBpassword = \"{$slconf['DBpassword']}\";
1933 ## Shared memory settings
1934 \$wgMainCacheType = $cacheType;
1935 \$wgMemCachedServers = $mcservers;
1937 ## To enable image uploads, make sure the 'images' directory
1938 ## is writable, then set this to true:
1939 \$wgEnableUploads = false;
1940 {$magic}\$wgUseImageMagick = true;
1941 {$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
1943 ## If you use ImageMagick (or any other shell command) on a
1944 ## Linux server, this will need to be set to the name of an
1945 ## available UTF-8 locale
1946 {$locale}\$wgShellLocale = \"{$slconf['ShellLocale']}\";
1948 ## If you want to use image uploads under safe mode,
1949 ## create the directories images/archive, images/thumb and
1950 ## images/temp, and make them all writable. Then uncomment
1951 ## this, if it's not already uncommented:
1952 {$hashedUploads}\$wgHashedUploadDirectory = false;
1954 ## If you have the appropriate support software installed
1955 ## you can enable inline LaTeX equations:
1958 ## Set \$wgCacheDirectory to a writable directory on the web server
1959 ## to make your wiki go slightly faster. The directory should not
1960 ## be publically accessible from the web.
1961 #\$wgCacheDirectory = \"\$IP/cache\";
1963 \$wgLocalInterwiki = strtolower( \$wgSitename );
1965 \$wgLanguageCode = \"{$slconf['LanguageCode']}\";
1967 \$wgSecretKey = \"$secretKey\";
1969 ## Default skin: you can change the default skin. Use the internal symbolic
1970 ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook':
1971 \$wgDefaultSkin = 'monobook';
1973 ## For attaching licensing metadata to pages, and displaying an
1974 ## appropriate copyright notice / icon. GNU Free Documentation
1975 ## License and Creative Commons licenses are supported so far.
1976 {$rights}\$wgEnableCreativeCommonsRdf = true;
1977 \$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright
1978 \$wgRightsUrl = \"{$slconf['RightsUrl']}\";
1979 \$wgRightsText = \"{$slconf['RightsText']}\";
1980 \$wgRightsIcon = \"{$slconf['RightsIcon']}\";
1981 # \$wgRightsCode = \"{$slconf['RightsCode']}\"; # Not yet used
1983 \$wgDiff3 = \"{$slconf['diff3']}\";
1985 \$wgPhpCliPath = \"{$slconf['phpCliPath']}\";
1987 # When you make changes to this configuration file, this will make
1988 # sure that cached pages are cleared.
1989 \$wgCacheEpoch = max( \$wgCacheEpoch, gmdate( 'YmdHis', @filemtime( __FILE__ ) ) );
1990 "; ## End of setting the $localsettings string
1992 // Keep things in Unix line endings internally;
1993 // the system will write out as local text type.
1994 return str_replace( "\r\n", "\n", $localsettings );
1997 function dieout( $text ) {
1998 global $mainListOpened;
1999 if( $mainListOpened ) echo( "</ul>" );
2000 if( $text != '' && substr( $text, 0, 2 ) != '<p' && substr( $text, 0, 2 ) != '<h' ){
2001 echo "<p>$text</p>\n";
2005 die( "\n\n</div>\n</div>\n</div>\n</div>\n</body>\n</html>" );
2008 function importVar( &$var, $name, $default = "" ) {
2009 if( isset( $var[$name] ) ) {
2010 $retval = $var[$name];
2011 if ( get_magic_quotes_gpc() ) {
2012 $retval = stripslashes( $retval );
2021 function importPost( $name, $default = "" ) {
2022 return importVar( $_POST, $name, $default );
2025 function importCheck( $name ) {
2026 return isset( $_POST[$name] );
2029 function importRequest( $name, $default = "" ) {
2030 return importVar( $_REQUEST, $name, $default );
2033 function aField( &$conf, $field, $text, $type = "text", $value = "", $onclick = '' ) {
2034 static $radioCount = 0;
2036 $xtype = "type=\"$type\"";
2042 $nolabel = ($type == "radio") ||
($type == "hidden");
2044 if ($type == 'radio')
2045 $id .= $radioCount++
;
2048 echo "<label class='column' for=\"$id\">$text</label>";
2051 if( $type == "radio" && $value == $conf->$field ) {
2052 $checked = "checked='checked'";
2056 echo "<input $xtype name=\"$field\" id=\"$id\" class=\"iput-$type\" $checked ";
2058 echo " onclick='toggleDBarea(\"$value\",1)' " ;
2061 if( $type == "radio" ) {
2062 echo htmlspecialchars( $value );
2064 echo htmlspecialchars( $conf->$field );
2070 echo "<label for=\"$id\">$text</label>";
2074 if(isset($errs[$field])) {
2075 echo "<span class='error'>" . htmlspecialchars( $errs[$field] ) . "</span>\n";
2079 function getLanguageList() {
2080 global $wgLanguageNames, $IP;
2081 if( !isset( $wgLanguageNames ) ) {
2082 require_once( "$IP/languages/Names.php" );
2087 $d = opendir( "../languages/messages" );
2088 /* In case we are called from the root directory */
2090 $d = opendir( "languages/messages");
2091 while( false !== ($f = readdir( $d ) ) ) {
2093 if( preg_match( '/Messages([A-Z][a-z_]+)\.php$/', $f, $m ) ) {
2094 $code = str_replace( '_', '-', strtolower( $m[1] ) );
2095 if( isset( $wgLanguageNames[$code] ) ) {
2096 $name = wfBCP47( $code ) . ' - ' . $wgLanguageNames[$code];
2100 $codes[$code] = $name;
2108 #Check for location of an executable
2109 # @param string $loc single location to check
2110 # @param array $names filenames to check for.
2111 # @param mixed $versioninfo array of details to use when checking version, use false for no version checking
2112 function locate_executable($loc, $names, $versioninfo = false) {
2113 if (!is_array($names))
2114 $names = array($names);
2116 foreach ($names as $name) {
2117 $command = "$loc".DIRECTORY_SEPARATOR
."$name";
2118 if (@file_exists
($command)) {
2122 $file = str_replace('$1', $command, $versioninfo[0]);
2123 if (strstr(`
$file`
, $versioninfo[1]) !== false)
2130 # Test a memcached server
2131 function testMemcachedServer( $server ) {
2132 $hostport = explode(":", $server);
2135 if ( !function_exists( 'fsockopen' ) ) {
2136 $errstr = "Can't connect to memcached, fsockopen() not present";
2138 if ( !$errstr && count( $hostport ) != 2 ) {
2139 $errstr = 'Please specify host and port';
2142 list( $host, $port ) = $hostport;
2146 $fp = @fsockopen
( $host, $port, $errno, $fsockerr, 1.0 );
2147 if ( $fp === false ) {
2148 $errstr = "Cannot connect to memcached on $host:$port : $fsockerr";
2152 $command = "version\r\n";
2153 $bytes = fwrite( $fp, $command );
2154 if ( $bytes != strlen( $command ) ) {
2155 $errstr = "Cannot write to memcached socket on $host:$port";
2159 $expected = "VERSION ";
2160 $response = fread( $fp, strlen( $expected ) );
2161 if ( $response != $expected ) {
2162 $errstr = "Didn't get correct memcached response from $host:$port";
2169 echo "<li>Connected to memcached on " . htmlspecialchars( "$host:$port" ) ." successfully</li>";
2174 function database_picker($conf) {
2177 foreach(array_keys($ourdb) as $db) {
2178 if ($ourdb[$db]['havedriver']) {
2180 aField( $conf, "DBtype", $ourdb[$db]['fullname'], 'radio', $db, 'onclick');
2187 function database_switcher($db) {
2189 $color = $ourdb[$db]['bgcolor'];
2190 $full = $ourdb[$db]['fullname'];
2191 print "<fieldset id='$db'><legend>$full specific options</legend>\n";
2194 function printListItem( $item ) {
2195 print "<li>$item</li>";
2198 # Determine a suitable value for $wgShellLocale
2199 function getShellLocale( $wikiLang ) {
2200 # Give up now if we're in safe mode or open_basedir
2201 # It's theoretically possible but tricky to work with
2202 if ( wfIniGetBool( "safe_mode" ) ||
ini_get( 'open_basedir' ) ) {
2206 $os = php_uname( 's' );
2207 $supported = array( 'Linux', 'SunOS', 'HP-UX' ); # Tested these
2208 if ( !in_array( $os, $supported ) ) {
2212 # Get a list of available locales
2213 $lines = $ret = false;
2214 exec( '/usr/bin/locale -a', $lines, $ret );
2219 $lines = wfArrayMap( 'trim', $lines );
2220 $candidatesByLocale = array();
2221 $candidatesByLang = array();
2222 foreach ( $lines as $line ) {
2223 if ( $line === '' ) {
2226 if ( !preg_match( '/^([a-zA-Z]+)(_[a-zA-Z]+|)\.(utf8|UTF-8)(@[a-zA-Z_]*|)$/i', $line, $m ) ) {
2229 list( $all, $lang, $territory, $charset, $modifier ) = $m;
2230 $candidatesByLocale[$m[0]] = $m;
2231 $candidatesByLang[$lang][] = $m;
2234 # Try the current value of LANG
2235 if ( isset( $candidatesByLocale[ getenv( 'LANG' ) ] ) ) {
2236 return getenv( 'LANG' );
2239 # Try the most common ones
2240 $commonLocales = array( 'en_US.UTF-8', 'en_US.utf8', 'de_DE.UTF-8', 'de_DE.utf8' );
2241 foreach ( $commonLocales as $commonLocale ) {
2242 if ( isset( $candidatesByLocale[$commonLocale] ) ) {
2243 return $commonLocale;
2247 # Is there an available locale in the Wiki's language?
2248 if ( isset( $candidatesByLang[$wikiLang] ) ) {
2249 $m = reset( $candidatesByLang[$wikiLang] );
2253 # Are there any at all?
2254 if ( count( $candidatesByLocale ) ) {
2255 $m = reset( $candidatesByLocale );
2263 function wfArrayMap( $function, $input ) {
2264 $ret = array_map( $function, $input );
2265 foreach ( $ret as $key => $value ) {
2266 $taint = istainted( $input[$key] );
2268 taint( $ret[$key], $taint );
2276 <div
class="license">
2278 <p
>This program is free software
; you can redistribute it
and/or modify
2279 it under the terms of the GNU General
Public License
as published by
2280 the Free Software Foundation
; either version
2 of the License
, or
2281 (at your option
) any later version
.</p
>
2283 <p
>This program is distributed in the hope that it will be useful
,
2284 but WITHOUT ANY WARRANTY
; without even the implied warranty of
2285 MERCHANTABILITY
or FITNESS
FOR A PARTICULAR PURPOSE
. See the
2286 GNU General
Public License
for more details
.</p
>
2288 <p
>You should have received
<a href
="../COPYING">a copy of the GNU General
Public License
</a
>
2289 along with this program
; if not
, write to the Free Software
2290 Foundation
, Inc
., 51 Franklin Street
, Fifth Floor
, Boston
, MA
02110-1301, USA
.
2291 or <a href
="http://www.gnu.org/copyleft/gpl.html">read it online
</a
></p
>
2297 <div id
="column-one">
2298 <div
class="portlet" id
="p-logo">
2299 <a style
="background-image: url(../skins/common/images/mediawiki.png);"
2301 title
="Main Page"></a
>
2303 <script type
="text/javascript"> if (window
.isMSIE55
) fixalpha(); </script
>
2304 <div
class='portlet'><div
class='pBody'>
2306 <li
><a href
="../README">Readme
</a
></li
>
2307 <li
><a href
="../RELEASE-NOTES">Release notes
</a
></li
>
2308 <li
><a href
="../docs/">Documentation
</a
></li
>
2309 <li
><a href
="http://www.mediawiki.org/wiki/Help:Contents">User
's Guide</a></li>
2310 <li><a href="http://www.mediawiki.org/wiki/Manual:Contents">Administrator's Guide
</a
></li
>
2311 <li
><a href
="http://www.mediawiki.org/wiki/Manual:FAQ">FAQ
</a
></li
>
2313 <p style
="font-size:90%;margin-top:1em">MediaWiki is Copyright ©
2001-2009 by Magnus Manske
, Brion Vibber
,
2314 Lee Daniel Crocker
, Tim Starling
, Erik Möller
, Gabriel Wicke
, Æ
var Arnfjörð Bjarmason
, Niklas Laxström
,
2315 Domas Mituzas
, Rob Church
, Yuri Astrakhan
, Aryeh Gregor
, Aaron Schulz
and others
.</p
>