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 error_reporting( E_ALL
);
23 header( "Content-type: text/html; charset=utf-8" );
24 @ini_set
( "display_errors", true );
26 # In case of errors, let output be clean.
27 $wgRequestTime = microtime( true );
29 # Attempt to set up the include path, to fix problems with relative includes
30 $IP = dirname( dirname( __FILE__
) );
31 define( 'MW_INSTALL_PATH', $IP );
32 $sep = PATH_SEPARATOR
;
33 if( !ini_set( "include_path", ".$sep$IP$sep$IP/includes$sep$IP/languages" ) ) {
34 set_include_path( ".$sep$IP$sep$IP/includes$sep$IP/languages" );
37 # Define an entry point and include some files
38 define( "MEDIAWIKI", true );
39 define( "MEDIAWIKI_INSTALL", true );
41 // Run version checks before including other files
42 // so people don't see a scary parse error.
43 require_once( "install-utils.inc" );
44 install_version_checks();
46 require_once( "includes/Defines.php" );
47 require_once( "includes/DefaultSettings.php" );
48 require_once( "includes/MagicWord.php" );
49 require_once( "includes/Namespace.php" );
50 require_once( "includes/ProfilerStub.php" );
52 ## Databases we support:
55 $ourdb['mysql']['fullname'] = 'MySQL';
56 $ourdb['mysql']['havedriver'] = 0;
57 $ourdb['mysql']['compile'] = 'mysql';
58 $ourdb['mysql']['bgcolor'] = '#ffe5a7';
59 $ourdb['mysql']['rootuser'] = 'root';
61 $ourdb['postgres']['fullname'] = 'PostgreSQL';
62 $ourdb['postgres']['havedriver'] = 0;
63 $ourdb['postgres']['compile'] = 'pgsql';
64 $ourdb['postgres']['bgcolor'] = '#aaccff';
65 $ourdb['postgres']['rootuser'] = 'postgres';
68 <!DOCTYPE HTML
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
71 <meta http
-equiv
="Content-type" content
="text/html; charset=utf-8">
72 <title
>MediaWiki
<?php
echo( $wgVersion ); ?
> Installation
</title
>
73 <style type
="text/css">
75 @import
"../skins/monobook/main.css";
79 margin
: 1em
0 1em
2.5em
;
86 .config
-section label
.column
{
98 zoom
: 100%
; /* IE hack */
101 .config
-section
.config
-desc
{
103 margin
: 0 0 2em
18em
;
108 .iput
-text
, .iput
-password
{
115 background
-color
: #fff;
123 background
-color
: #FFF0F0;
124 border
: 2px solid red
;
132 list-style
-type
: none
;
133 list-style
-image
: none
;
151 <script type
="text/javascript">
154 <?php
foreach (array_keys($ourdb) as $db) {
155 echo "\n document.getElementById('$db').style.display='none';";
160 function toggleDBarea(id
,defaultroot
) {
162 var dbarea
= document
.getElementById(id
).style
;
163 dbarea
.display
= (dbarea
.display
== 'none') ?
'block' : 'none';
164 var db
= document
.getElementById('RootUser');
166 <?php
foreach (array_keys($ourdb) as $db) {
167 echo " if (id == '$db') { db.value = '".$ourdb[$db]['rootuser']."';}\n";
176 <div id
="globalWrapper">
177 <div id
="column-content">
179 <div id
="bodyContent">
181 <h1
>MediaWiki
<?php
print $wgVersion ?
> Installation
</h1
>
185 /* Check for existing configurations and bug out! */
187 if( file_exists( "../LocalSettings.php" ) ) {
188 dieout( "<p><strong>Setup has completed, <a href='../index.php'>your wiki</a> is configured.</strong></p>
190 <p>Please delete the /config directory for extra security.</p></div></div></div></div>" );
193 if( file_exists( "./LocalSettings.php" ) ) {
194 writeSuccessMessage();
199 if( !is_writable( "." ) ) {
200 dieout( "<h2>Can't write config file, aborting</h2>
202 <p>In order to configure the wiki you have to make the <tt>config</tt> subdirectory
203 writable by the web server. Once configuration is done you'll move the created
204 <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can
205 then remove the <tt>config</tt> subdirectory entirely.</p>
207 <p>To make the directory writable on a Unix/Linux system:</p>
210 cd <i>/path/to/wiki</i>
214 <p>Afterwards retry to start the <a href=\"\">setup</a>.</p>" );
218 require_once( "install-utils.inc" );
219 require_once( "maintenance/updaters.inc" );
222 function getEncoded( $data ) {
223 # removing latin1 support, no need...
226 function getSitename() { return $this->getEncoded( $this->Sitename
); }
227 function getSysopName() { return $this->getEncoded( $this->SysopName
); }
228 function getSysopPass() { return $this->getEncoded( $this->SysopPass
); }
230 function setSchema( $schema ) {
231 $this->DBschema
= $schema;
232 switch ( $this->DBschema
) {
234 $this->DBTableOptions
= 'ENGINE=InnoDB, DEFAULT CHARSET=utf8';
235 $this->DBmysql5
= 'true';
237 case 'mysql5-binary':
238 $this->DBTableOptions
= 'ENGINE=InnoDB, DEFAULT CHARSET=binary';
239 $this->DBmysql5
= 'true';
242 $this->DBTableOptions
= 'TYPE=InnoDB';
243 $this->DBmysql5
= 'false';
245 # Set the global for use during install
246 global $wgDBTableOptions;
247 $wgDBTableOptions = $this->DBTableOptions
;
255 <b
>Don
't forget security updates!</b> Keep an eye on the
256 <a href="http://mail.wikimedia.org/mailman/listinfo/mediawiki-announce">low-traffic
257 release announcements mailing list</a>.
262 <h2>Checking environment...</h2>
263 <p><em>Please include all of the lines below when reporting installation problems.</em></p>
264 <ul class="env-check">
268 define( 'MW_NO_OUTPUT_BUFFER
', 1 );
269 $conf = new ConfigData;
271 install_version_checks();
273 print "<li>PHP " . phpversion() . " installed</li>\n";
275 ## Temporarily turn off all errors as we try to discover installed databases
276 $olderrnum = error_reporting(0);
278 $phpdatabases = array();
279 foreach (array_keys($ourdb) as $db) {
280 $compname = $ourdb[$db]['compile
'];
281 if (extension_loaded($compname) or dl($compname . '.' . PHP_SHLIB_SUFFIX)) {
282 array_push($phpdatabases, $db);
283 $ourdb[$db]['havedriver
'] = 1;
287 error_reporting($olderrornum);
289 if (!$phpdatabases) {
290 print "Could not find a suitable database driver!<ul>";
291 foreach (array_keys($ourdb) AS $db) {
292 $comp = $ourdb[$db]['compile
'];
293 $full = $ourdb[$db]['fullname
'];
294 print "<li>For <b>$full</b>, compile PHP using <b>--with-$comp</b>, "
295 ."or install the $comp.so module</li>\n";
297 dieout( "</ul></ul>" );
300 print "<li>Found database drivers for:";
301 foreach (array_keys($ourdb) AS $db) {
302 if ($ourdb[$db]['havedriver
']) {
303 $DefaultDBtype = $db;
304 print " ".$ourdb[$db]['fullname
'];
308 if (count($phpdatabases) != 1)
311 if( ini_get( "register_globals" ) ) {
314 <div style="font-size:110%">
315 <strong class="error">Warning:</strong>
316 <strong>PHP's
<tt
><a href
="http://php.net/register_globals">register_globals
</a
></tt
> option is enabled
. Disable it
if you can
.</strong
>
318 MediaWiki will work
, but your server is more exposed to PHP
-based security vulnerabilities
.
325 if( ini_get( "magic_quotes_runtime" ) ) {
327 ?
><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
>
328 This option corrupts data input unpredictably
; you cannot install
or use
329 MediaWiki unless this option is disabled
.
333 if( ini_get( "magic_quotes_sybase" ) ) {
335 ?
><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
>
336 This option corrupts data input unpredictably
; you cannot install
or use
337 MediaWiki unless this option is disabled
.
341 if( ini_get( "mbstring.func_overload" ) ) {
343 ?
><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
>
344 This option causes errors
and may corrupt data unpredictably
;
345 you cannot install
or use MediaWiki unless this option is disabled
.
349 if( ini_get( "zend.ze1_compatibility_mode" ) ) {
351 ?
><li
class="error"><strong
>Fatal
: <a href
="http://www.php.net/manual/en/ini.core.php">zend
.ze1_compatibility_mode
</a
> is active
!</strong
>
352 This option causes horrible bugs with MediaWiki
; you cannot install
or use
353 MediaWiki unless this option is disabled
.
359 dieout( "</ul><p>Cannot install MediaWiki.</p>" );
362 if( ini_get( "safe_mode" ) ) {
363 $conf->safeMode
= true;
365 <li
><b
class='error'>Warning
:</b
> <strong
>PHP
's
366 <a href='http
://www.php.net/features.safe-mode'>safe mode</a> is active.</strong>
367 You may have problems caused by this
, particularly
if using image uploads
.
371 $conf->safeMode
= false;
374 $sapi = php_sapi_name();
375 print "<li>PHP server API is $sapi; ";
376 if( $wgUsePathInfo ) {
377 print "ok, using pretty URLs (<tt>index.php/Page_Title</tt>)";
379 print "using ugly URLs (<tt>index.php?title=Page_Title</tt>)";
383 $conf->xml
= function_exists( "utf8_encode" );
385 print "<li>Have XML / Latin1-UTF-8 conversion support.</li>\n";
387 dieout( "PHP's XML module is missing; the wiki requires functions in
388 this module and won't work in this configuration.
389 If you're running Mandrake, install the php-xml package." );
392 # Check for session support
393 if( !function_exists( 'session_name' ) )
394 dieout( "PHP's session module is missing. MediaWiki requires session support in order to function." );
396 # session.save_path doesn't *have* to be set, but if it is, and it's
397 # not valid/writable/etc. then it can cause problems
398 $sessionSavePath = mw_get_session_save_path();
399 $ssp = htmlspecialchars( $sessionSavePath );
400 # Warn the user if it's not set, but let them proceed
401 if( !$sessionSavePath ) {
402 print "<li><strong>Warning:</strong> A value for <tt>session.save_path</tt>
403 has not been set in PHP.ini. If the default value causes problems with
404 saving session data, set it to a valid path which is read/write/execute
405 for the user your web server is running under.</li>";
406 } elseif ( is_dir( $sessionSavePath ) && is_writable( $sessionSavePath ) ) {
407 # All good? Let the user know
408 print "<li>Session save path (<tt>{$ssp}</tt>) appears to be valid.</li>";
410 # Something not right? Warn the user, but let them proceed
411 print "<li><strong>Warning:</strong> Your <tt>session.save_path</tt> value (<tt>{$ssp}</tt>)
412 appears to be invalid or is not writable. PHP needs to be able to save data to
413 this location for correct session operation.</li>";
416 # Check for PCRE support
417 if( !function_exists( 'preg_match' ) )
418 dieout( "The PCRE support module appears to be missing. MediaWiki requires the
419 Perl-compatible regular expression functions." );
421 $memlimit = ini_get( "memory_limit" );
422 $conf->raiseMemory
= false;
423 if( empty( $memlimit ) ||
$memlimit == -1 ) {
424 print "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n";
426 print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars( $memlimit ) . ". ";
427 $n = intval( $memlimit );
428 if( preg_match( '/^([0-9]+)[Mm]$/', trim( $memlimit ), $m ) ) {
429 $n = intval( $m[1] * (1024*1024) );
431 if( $n < 20*1024*1024 ) {
432 print "Attempting to raise limit to 20M... ";
433 if( false === ini_set( "memory_limit", "20M" ) ) {
434 print "failed.<br /><b>" . htmlspecialchars( $memlimit ) . " seems too low, installation may fail!</b>";
436 $conf->raiseMemory
= true;
443 $conf->turck
= function_exists( 'mmcache_get' );
444 if ( $conf->turck
) {
445 print "<li><a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> installed</li>\n";
448 $conf->apc
= function_exists('apc_fetch');
450 print "<li><a href=\"http://www.php.net/apc\">APC</a> installed</li>";
453 $conf->eaccel
= function_exists( 'eaccelerator_get' );
454 if ( $conf->eaccel
) {
455 $conf->turck
= 'eaccelerator';
456 print "<li><a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> installed</li>\n";
459 if( !$conf->turck
&& !$conf->eaccel
&& !$conf->apc
) {
460 echo( '<li>Couldn\'t find <a href="http://turck-mmcache.sourceforge.net">Turck MMCache</a>,
461 <a href="http://eaccelerator.sourceforge.net">eAccelerator</a>, or
462 <a href="http://www.php.net/apc">APC</a>. Object caching functions cannot be used.</li>' );
465 $conf->diff3
= false;
466 $diff3locations = array_merge(
473 explode( $sep, getenv( "PATH" ) ) );
474 $diff3names = array( "gdiff3", "diff3", "diff3.exe" );
476 $diff3versioninfo = array( '$1 --version 2>&1', 'diff3 (GNU diffutils)' );
477 foreach ($diff3locations as $loc) {
478 $exe = locate_executable($loc, $diff3names, $diff3versioninfo);
479 if ($exe !== false) {
486 print "<li>Found GNU diff3: <tt>$conf->diff3</tt>.</li>";
488 print "<li>GNU diff3 not found.</li>";
490 $conf->ImageMagick
= false;
491 $imcheck = array( "/usr/bin", "/opt/csw/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" );
492 foreach( $imcheck as $dir ) {
493 $im = "$dir/convert";
494 if( file_exists( $im ) ) {
495 print "<li>Found ImageMagick: <tt>$im</tt>; image thumbnailing will be enabled if you enable uploads.</li>\n";
496 $conf->ImageMagick
= $im;
501 $conf->HaveGD
= function_exists( "imagejpeg" );
502 if( $conf->HaveGD
) {
503 print "<li>Found GD graphics library built-in";
504 if( !$conf->ImageMagick
) {
505 print ", image thumbnailing will be enabled if you enable uploads";
509 if( !$conf->ImageMagick
) {
510 print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n";
514 $conf->IP
= dirname( dirname( __FILE__
) );
515 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP
) . "</tt></li>\n";
518 // PHP_SELF isn't available sometimes, such as when PHP is CGI but
519 // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
520 // to get the path to the current script... hopefully it's reliable. SIGH
521 $path = ($_SERVER["PHP_SELF"] === '')
522 ?
$_SERVER["SCRIPT_NAME"]
523 : $_SERVER["PHP_SELF"];
524 $conf->ScriptPath
= preg_replace( '{^(.*)/config.*$}', '$1', $path );
525 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath
) . "</tt></li>\n";
527 print "<li style='font-weight:bold;color:green;font-size:110%'>Environment checked. You can install MediaWiki.</li>\n";
528 $conf->posted
= ($_SERVER["REQUEST_METHOD"] == "POST");
530 $conf->Sitename
= ucfirst( importPost( "Sitename", "" ) );
531 $defaultEmail = empty( $_SERVER["SERVER_ADMIN"] )
533 : $_SERVER["SERVER_ADMIN"];
534 $conf->EmergencyContact
= importPost( "EmergencyContact", $defaultEmail );
535 $conf->DBtype
= importPost( "DBtype", $DefaultDBtype );
539 $conf->DBserver
= importPost( "DBserver", "localhost" );
540 $conf->DBname
= importPost( "DBname", "wikidb" );
541 $conf->DBuser
= importPost( "DBuser", "wikiuser" );
542 $conf->DBpassword
= importPost( "DBpassword" );
543 $conf->DBpassword2
= importPost( "DBpassword2" );
544 $conf->SysopName
= importPost( "SysopName", "WikiSysop" );
545 $conf->SysopPass
= importPost( "SysopPass" );
546 $conf->SysopPass2
= importPost( "SysopPass2" );
547 $conf->RootUser
= importPost( "RootUser", "root" );
548 $conf->RootPW
= importPost( "RootPW", "" );
549 $useRoot = importCheck( 'useroot', false );
552 $conf->DBprefix
= importPost( "DBprefix" );
553 $conf->setSchema( importPost( "DBschema", "mysql4" ) );
554 $conf->LanguageCode
= importPost( "LanguageCode", "en" );
556 ## Postgres specific:
557 $conf->DBport
= importPost( "DBport", "5432" );
558 $conf->DBmwschema
= importPost( "DBmwschema", "mediawiki" );
559 $conf->DBts2schema
= importPost( "DBts2schema", "public" );
561 /* Check for validity */
564 if( $conf->Sitename
== "" ||
$conf->Sitename
== "MediaWiki" ||
$conf->Sitename
== "Mediawiki" ) {
565 $errs["Sitename"] = "Must not be blank or \"MediaWiki\"";
567 if( $conf->DBuser
== "" ) {
568 $errs["DBuser"] = "Must not be blank";
570 if( ($conf->DBtype
== 'mysql') && (strlen($conf->DBuser
) > 16) ) {
571 $errs["DBuser"] = "Username too long";
573 if( $conf->DBpassword
== "" && $conf->DBtype
!= "postgres" ) {
574 $errs["DBpassword"] = "Must not be blank";
576 if( $conf->DBpassword
!= $conf->DBpassword2
) {
577 $errs["DBpassword2"] = "Passwords don't match!";
579 if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix
) ) {
580 $errs["DBprefix"] = "Invalid table prefix";
583 if( $conf->SysopPass
== "" ) {
584 $errs["SysopPass"] = "Must not be blank";
586 if( $conf->SysopPass
!= $conf->SysopPass2
) {
587 $errs["SysopPass2"] = "Passwords don't match!";
590 $conf->License
= importRequest( "License", "none" );
591 if( $conf->License
== "gfdl" ) {
592 $conf->RightsUrl
= "http://www.gnu.org/copyleft/fdl.html";
593 $conf->RightsText
= "GNU Free Documentation License 1.2";
594 $conf->RightsCode
= "gfdl";
595 $conf->RightsIcon
= '${wgScriptPath}/skins/common/images/gnu-fdl.png';
596 } elseif( $conf->License
== "none" ) {
597 $conf->RightsUrl
= $conf->RightsText
= $conf->RightsCode
= $conf->RightsIcon
= "";
599 $conf->RightsUrl
= importRequest( "RightsUrl", "" );
600 $conf->RightsText
= importRequest( "RightsText", "" );
601 $conf->RightsCode
= importRequest( "RightsCode", "" );
602 $conf->RightsIcon
= importRequest( "RightsIcon", "" );
605 $conf->Shm
= importRequest( "Shm", "none" );
606 $conf->MCServers
= importRequest( "MCServers" );
608 /* Test memcached servers */
610 if ( $conf->Shm
== 'memcached' && $conf->MCServers
) {
611 $conf->MCServerArray
= array_map( 'trim', explode( ',', $conf->MCServers
) );
612 foreach ( $conf->MCServerArray
as $server ) {
613 $error = testMemcachedServer( $server );
615 $errs["MCServers"] = $error;
619 } else if ( $conf->Shm
== 'memcached' ) {
620 $errs["MCServers"] = "Please specify at least one server if you wish to use memcached";
623 /* default values for installation */
624 $conf->Email
= importRequest("Email", "email_enabled");
625 $conf->Emailuser
= importRequest("Emailuser", "emailuser_enabled");
626 $conf->Enotif
= importRequest("Enotif", "enotif_allpages");
627 $conf->Eauthent
= importRequest("Eauthent", "eauthent_enabled");
629 if( $conf->posted
&& ( 0 == count( $errs ) ) ) {
630 do { /* So we can 'continue' to end prematurely */
631 $conf->Root
= ($conf->RootPW
!= "");
633 /* Load up the settings and get installin' */
634 $local = writeLocalSettings( $conf );
635 echo "<li style=\"list-style: none\">\n";
636 echo "<p><b>Generating configuration file...</b></p>\n";
639 $wgCommandLineMode = false;
641 $ok = eval( $local );
642 if( $ok === false ) {
643 dieout( "Errors in generated configuration; " .
644 "most likely due to a bug in the installer... " .
645 "Config file was: " .
647 htmlspecialchars( $local ) .
651 $conf->DBtypename
= '';
652 foreach (array_keys($ourdb) as $db) {
653 if ($conf->DBtype
=== $db)
654 $conf->DBtypename
= $ourdb[$db]['fullname'];
656 if ( ! strlen($conf->DBtype
)) {
657 $errs["DBpicktype"] = "Please choose a database type";
661 if (! $conf->DBtypename
) {
662 $errs["DBtype"] = "Unknown database type '$conf->DBtype'";
665 print "<li>Database type: {$conf->DBtypename}</li>\n";
666 $dbclass = 'Database'.ucfirst($conf->DBtype
);
667 $wgDBtype = $conf->DBtype
;
668 $wgDBadminuser = "root";
669 $wgDBadminpassword = $conf->RootPW
;
672 $wgDBprefix = $conf->DBprefix
;
674 ## Postgres specific:
675 $wgDBport = $conf->DBport
;
676 $wgDBmwschema = $conf->DBmwschema
;
677 $wgDBts2schema = $conf->DBts2schema
;
679 $wgCommandLineMode = true;
680 $wgUseDatabaseMessages = false; /* FIXME: For database failure */
681 require_once( "includes/Setup.php" );
684 $wgTitle = Title
::newFromText( "Installation script" );
685 error_reporting( E_ALL
);
686 print "<li>Loading class: $dbclass";
689 if( $conf->DBtype
== 'mysql' ) {
690 $mysqlOldClient = version_compare( mysql_get_client_info(), "4.1.0", "lt" );
691 if( $mysqlOldClient ) {
692 print "<li><b>PHP is linked with old MySQL client libraries. If you are
693 using a MySQL 4.1 server and have problems connecting to the database,
694 see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
695 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b></li>\n";
697 $ok = true; # Let's be optimistic
699 # Decide if we're going to use the superuser or the regular database user
700 $conf->Root
= $useRoot;
702 $db_user = $conf->RootUser
;
703 $db_pass = $conf->RootPW
;
705 $db_user = $wgDBuser;
706 $db_pass = $wgDBpassword;
710 echo( "<li>Attempting to connect to database server as $db_user..." );
711 $wgDatabase = Database
::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 );
713 # Check the connection and respond to errors
714 if( $wgDatabase->isOpen() ) {
717 $wgDBadminuser = $db_user;
718 $wgDBadminpassword = $db_pass;
719 echo( "success.</li>\n" );
720 $wgDatabase->ignoreErrors( true );
721 $myver = $wgDatabase->getServerVersion();
723 # There were errors, report them and back out
725 $errno = mysql_errno();
726 $errtx = htmlspecialchars( mysql_error() );
730 echo( "failed due to authentication errors. Check passwords.</li>" );
732 # The superuser details are wrong
733 $errs["RootUser"] = "Check username";
734 $errs["RootPW"] = "and password";
736 # The regular user details are wrong
737 $errs["DBuser"] = "Check username";
738 $errs["DBpassword"] = "and password";
744 # General connection problem
745 echo( "failed with error [$errno] $errtx.</li>\n" );
746 $errs["DBserver"] = "Connection failed";
751 if( !$ok ) { continue; }
753 } else /* not mysql */ {
754 error_reporting( E_ALL
);
756 ## Possible connect as a superuser
758 $wgDBsuperuser = $conf->RootUser
;
759 echo( "<li>Attempting to connect to database \"postgres\" as superuser \"$wgDBsuperuser\"..." );
760 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBsuperuser, $conf->RootPW
, "postgres", 1);
761 if (!$wgDatabase->isOpen()) {
762 print " error: " . $wgDatabase->lastError() . "</li>\n";
763 $errs["DBserver"] = "Could not connect to database as superuser";
764 $errs["RootUser"] = "Check username";
765 $errs["RootPW"] = "and password";
769 echo( "<li>Attempting to connect to database \"$wgDBname\" as \"$wgDBuser\"..." );
770 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1);
771 if (!$wgDatabase->isOpen()) {
772 print " error: " . $wgDatabase->lastError() . "</li>\n";
774 $myver = $wgDatabase->getServerVersion();
778 if ( !$wgDatabase->isOpen() ) {
779 $errs["DBserver"] = "Couldn't connect to database";
783 print "<li>Connected to $myver";
784 if ($conf->DBtype
== 'mysql') {
785 if( version_compare( $myver, "4.0.14" ) < 0 ) {
786 dieout( " -- mysql 4.0.14 or later required. Aborting." );
788 $mysqlNewAuth = version_compare( $myver, "4.1.0", "ge" );
789 if( $mysqlNewAuth && $mysqlOldClient ) {
790 print "; <b class='error'>You are using MySQL 4.1 server, but PHP is linked
791 to old client libraries; if you have trouble with authentication, see
792 <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
793 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>";
796 if( $mysqlNewAuth ) {
797 print "; enabling MySQL 4.1/5.0 charset mode";
799 print "; <b class='error'>MySQL 4.1/5.0 charset mode enabled,
800 but older version detected; will likely fail.</b>";
805 @$sel = $wgDatabase->selectDB( $wgDBname );
807 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
809 $err = mysql_errno();
810 $databaseSafe = htmlspecialchars( $wgDBname );
811 if( $err == 1102 /* Invalid database name */ ) {
812 print "<ul><li><strong>{$databaseSafe}</strong> is not a valid database name.</li></ul>";
814 } elseif( $err != 1049 /* Database doesn't exist */ ) {
815 print "<ul><li>Error selecting database <strong>{$databaseSafe}</strong>: {$err} ";
816 print htmlspecialchars( mysql_error() ) . "</li></ul>";
819 print "<li>Attempting to create database...</li>";
820 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
822 print "<li>Couldn't create database <tt>" .
823 htmlspecialchars( $wgDBname ) .
824 "</tt>; try with root access or check your username/pass.</li>\n";
825 $errs["RootPW"] = "<- Enter";
828 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
830 $wgDatabase->selectDB( $wgDBname );
832 else if ($conf->DBtype
== 'postgres') {
833 if( version_compare( $myver, "PostgreSQL 8.0" ) < 0 ) {
834 dieout( " <b>Postgres 8.0 or later is required</b>. Aborting.</li></ul>" );
838 if( $wgDatabase->tableExists( "cur" ) ||
$wgDatabase->tableExists( "revision" ) ) {
839 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n";
841 if ( $conf->DBtype
== 'mysql') {
843 # Determine existing default character set
844 if ( $wgDatabase->tableExists( "revision" ) ) {
845 $revision = $wgDatabase->escapeLike( $conf->DBprefix
. 'revision' );
846 $res = $wgDatabase->query( "SHOW TABLE STATUS LIKE '$revision'" );
847 $row = $wgDatabase->fetchObject( $res );
849 echo "<li>SHOW TABLE STATUS query failed!</li>\n";
850 $existingSchema = false;
851 } elseif ( preg_match( '/^latin1/', $row->Collation
) ) {
852 $existingSchema = 'mysql4';
853 } elseif ( preg_match( '/^utf8/', $row->Collation
) ) {
854 $existingSchema = 'mysql5';
855 } elseif ( preg_match( '/^binary/', $row->Collation
) ) {
856 $existingSchema = 'mysql5-binary';
858 $existingSchema = false;
859 echo "<li><strong>Warning:</strong> Unrecognised existing collation</li>\n";
861 if ( $existingSchema && $existingSchema != $conf->DBschema
) {
862 print "<li><strong>Warning:</strong> you requested the {$conf->DBschema} schema, " .
863 "but the existing database has the $existingSchema schema. This upgrade script ".
864 "can't convert it, so it will remain $existingSchema.</li>\n";
865 $conf->setSchema( $existingSchema );
869 # Create user if required
871 $conn = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
872 if ( $conn->isOpen() ) {
873 print "<li>DB user account ok</li>\n";
876 print "<li>Granting user permissions...";
877 if( $mysqlOldClient && $mysqlNewAuth ) {
878 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>";
881 dbsource( "../maintenance/users.sql", $wgDatabase );
885 print "</ul><pre>\n";
891 print "<ul><li>Finished update checks.</li>\n";
893 # FIXME: Check for errors
894 print "<li>Creating tables...";
895 if ($conf->DBtype
== 'mysql') {
896 dbsource( "../maintenance/tables.sql", $wgDatabase );
897 dbsource( "../maintenance/interwiki.sql", $wgDatabase );
898 } else if ($conf->DBtype
== 'postgres') {
899 $wgDatabase->setup_database();
902 $errs["DBtype"] = "Do not know how to handle database type '$conf->DBtype'";
906 print " done.</li>\n";
908 print "<li>Initializing data...</li>\n";
909 $wgDatabase->insert( 'site_stats',
910 array ( 'ss_row_id' => 1,
911 'ss_total_views' => 0,
912 'ss_total_edits' => 0,
913 'ss_good_articles' => 0 ) );
915 # Set up the "regular user" account *if we can, and if we need to*
916 if( $conf->Root
and $conf->DBtype
== 'mysql') {
918 $wgDatabase2 = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
919 if( $wgDatabase2->isOpen() ) {
920 # Nope, just close the test connection and continue
921 $wgDatabase2->close();
922 echo( "<li>User $wgDBuser exists. Skipping grants.</li>\n" );
924 # Yes, so run the grants
925 echo( "<li>Granting user permissions to $wgDBuser on $wgDBname..." );
926 dbsource( "../maintenance/users.sql", $wgDatabase );
927 echo( "success.</li>\n" );
931 if( $conf->SysopName
) {
932 $u = User
::newFromName( $conf->getSysopName() );
934 print "<li><strong class=\"error\">Warning:</strong> Skipped sysop account creation - invalid username!</li>\n";
936 else if ( 0 == $u->idForName() ) {
938 $u->setPassword( $conf->getSysopPass() );
941 $u->addGroup( "sysop" );
942 $u->addGroup( "bureaucrat" );
944 print "<li>Created sysop account <tt>" .
945 htmlspecialchars( $conf->SysopName
) . "</tt>.</li>\n";
947 print "<li>Could not create user - already exists!</li>\n";
950 print "<li>Skipped sysop account creation, no name given.</li>\n";
953 $titleobj = Title
::newFromText( wfMsgNoDB( "mainpage" ) );
954 $article = new Article( $titleobj );
955 $newid = $article->insertOn( $wgDatabase );
956 $revision = new Revision( array(
958 'text' => wfMsg( 'mainpagetext' ) . "\n\n" . wfMsgNoTrans( 'mainpagedocfooter' ),
961 'user_text' => 'MediaWiki default',
963 $revid = $revision->insertOn( $wgDatabase );
964 $article->updateRevisionOn( $wgDatabase, $revision );
967 /* Write out the config file now that all is well */
968 print "<li style=\"list-style: none\">\n";
969 print "<p>Creating LocalSettings.php...</p>\n\n";
970 $localSettings = "<" . "?php$endl$local";
971 // Fix up a common line-ending problem (due to CVS on Windows)
972 $localSettings = str_replace( "\r\n", "\n", $localSettings );
973 $f = fopen( "LocalSettings.php", 'xt' );
976 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" .
977 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
978 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
980 if(fwrite( $f, $localSettings ) ) {
982 writeSuccessMessage();
985 die("<p class='error'>An error occured while writing the config/LocalSettings.php file. Check user rights and disk space then try again.</p>\n");
998 if( count( $errs ) ) {
999 /* Display options form */
1001 if( $conf->posted
) {
1002 echo "<p class='error-top'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
1006 <form action
="index.php" name
="config" method
="post">
1009 <h2
>Site config
</h2
>
1011 <div
class="config-section">
1012 <div
class="config-input">
1014 aField( $conf, "Sitename", "Wiki name:" );
1017 <p
class="config-desc">
1018 Preferably a short word without punctuation
, i
.e
. "Wikipedia".<br
/>
1019 Will appear
as the
namespace name
for "meta" pages
, and throughout the
interface.
1022 <div
class="config-input">
1024 aField( $conf, "EmergencyContact", "Contact e-mail:" );
1027 <p
class="config-desc">
1028 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
.
1031 <div
class="config-input">
1032 <label
class='column' for="LanguageCode">Language
:</label
>
1033 <select id
="LanguageCode" name
="LanguageCode">
1036 $list = getLanguageList();
1037 foreach( $list as $code => $name ) {
1038 $sel = ($code == $conf->LanguageCode
) ?
'selected="selected"' : '';
1039 echo "\t\t<option value=\"$code\" $sel>$name</option>\n";
1044 <p
class="config-desc">
1045 Select the language
for your wiki
's interface. Some localizations aren't fully complete
. Unicode (UTF
-8) is used
for all localizations
.
1048 <div
class="config-input">
1049 <label
class='column'>Copyright
/license
:</label
>
1052 <li
><?php
aField( $conf, "License", "No license metadata", "radio", "none" ); ?
></li
>
1053 <li
><?php
aField( $conf, "License", "GNU Free Documentation License 1.2 (Wikipedia-compatible)", "radio", "gfdl" ); ?
></li
>
1055 aField( $conf, "License", "A Creative Commons license - ", "radio", "cc" );
1056 $partner = "MediaWiki";
1057 $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/index.php?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
1058 $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" );
1059 $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" );
1060 print "<a href=\"$ccApp\" target='_blank'>choose</a>";
1062 <?php
if( $conf->License
== "cc" ) { ?
>
1064 <li
><?php
aField( $conf, "RightsIcon", "<img src=\"" . htmlspecialchars( $conf->RightsIcon
) . "\" alt='(Creative Commons icon)' />", "hidden" ); ?
></li
>
1065 <li
><?php
aField( $conf, "RightsText", htmlspecialchars( $conf->RightsText
), "hidden" ); ?
></li
>
1066 <li
><?php
aField( $conf, "RightsCode", "code: " . htmlspecialchars( $conf->RightsCode
), "hidden" ); ?
></li
>
1067 <li
><?php
aField( $conf, "RightsUrl", "<a href=\"" . htmlspecialchars( $conf->RightsUrl
) . "\">" . htmlspecialchars( $conf->RightsUrl
) . "</a>", "hidden" ); ?
></li
>
1073 <p
class="config-desc">
1074 A notice
, icon
, and machine
-readable copyright metadata will be displayed
for the license you pick
.
1078 <div
class="config-input">
1079 <?php
aField( $conf, "SysopName", "Admin username:" ) ?
>
1081 <div
class="config-input">
1082 <?php
aField( $conf, "SysopPass", "Password:", "password" ) ?
>
1084 <div
class="config-input">
1085 <?php
aField( $conf, "SysopPass2", "Password confirm:", "password" ) ?
>
1087 <p
class="config-desc">
1088 An admin can lock
/delete pages
, block users from editing
, and do other maintenance tasks
.<br
/>
1089 A
new account will be added only when creating a
new wiki database
.
1092 <div
class="config-input">
1093 <label
class='column'>Shared memory caching
:</label
>
1096 <li
><?php
aField( $conf, "Shm", "No caching", "radio", "none" ); ?
></li
>
1098 if ( $conf->turck
) {
1100 aField( $conf, "Shm", "Turck MMCache", "radio", "turck" );
1105 aField( $conf, "Shm", "APC", "radio", "apc" );
1108 if ( $conf->eaccel
) {
1110 aField( $conf, "Shm", "eAccelerator", "radio", "eaccel" );
1114 <li
><?php
aField( $conf, "Shm", "Memcached", "radio", "memcached" ); ?
></li
>
1116 <div style
="clear:left"><?php
aField( $conf, "MCServers", "Memcached servers:", "text" ) ?
></div
>
1118 <p
class="config-desc">
1119 Using a shared memory system such
as Turck MMCache
, APC
, eAccelerator
, or Memcached
1120 will speed up MediaWiki significantly
. Memcached is the best solution but needs to be
1121 installed
. Specify the server addresses
and ports in a comma
-separated
list. Only
1122 use Turck shared memory
if the wiki will be running on a single Apache server
.
1126 <h2
>E
-mail
, e
-mail notification
and authentication setup
</h2
>
1128 <div
class="config-section">
1129 <div
class="config-input">
1130 <label
class='column'>E
-mail
features (global):</label
>
1132 <li
><?php
aField( $conf, "Email", "Enabled", "radio", "email_enabled" ); ?
></li
>
1133 <li
><?php
aField( $conf, "Email", "Disabled", "radio", "email_disabled" ); ?
></li
>
1136 <p
class="config-desc">
1137 Use this to disable all e
-mail
functions (password reminders
, user
-to
-user e
-mail
, and e
-mail notifications
)
1138 if sending mail doesn
't work on your server.
1141 <div class="config-input">
1142 <label class='column
'>User-to-user e-mail:</label>
1144 <li><?php aField( $conf, "Emailuser", "Enabled", "radio", "emailuser_enabled" ); ?></li>
1145 <li><?php aField( $conf, "Emailuser", "Disabled", "radio", "emailuser_disabled" ); ?></li>
1148 <p class="config-desc">
1149 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.
1151 <div class="config-input">
1152 <label class='column
'>E-mail notification about changes:</label>
1154 <li><?php aField( $conf, "Enotif", "Disabled", "radio", "enotif_disabled" ); ?></li>
1155 <li><?php aField( $conf, "Enotif", "Enabled for changes to user discussion pages only", "radio", "enotif_usertalk" ); ?></li>
1156 <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>
1159 <div class="config-desc">
1161 For this feature to work, an e-mail address must be present for the user account, and the notification
1162 options in the user's preferences must be enabled
. Also note the
1163 authentication option below
. When testing the feature
, keep in mind that your own changes will never trigger notifications to be sent to yourself
.</p
>
1165 <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
>
1168 <div
class="config-input">
1169 <label
class='column'>E
-mail address authentication
:</label
>
1171 <li
><?php
aField( $conf, "Eauthent", "Disabled", "radio", "eauthent_disabled" ); ?
></li
>
1172 <li
><?php
aField( $conf, "Eauthent", "Enabled", "radio", "eauthent_enabled" ); ?
></li
>
1175 <div
class="config-desc">
1176 <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
1177 change notification mails
. Setting this option is
<B
>recommended
</B
> for public wikis because of potential abuse of the e
-mail features above
.</p
>
1182 <h2
>Database config
</h2
>
1184 <div
class="config-section">
1185 <div
class="config-input">
1186 <label
class='column'>Database type
:</label
>
1187 <?php
if (isset($errs['DBpicktype'])) print "<span class='error'>$errs[DBpicktype]</span>\n"; ?
>
1188 <ul
class='plain'><?php
database_picker($conf) ?
></ul
>
1191 <div
class="config-input" style
="clear:left"><?php
1192 aField( $conf, "DBserver", "Database host:" );
1194 <p
class="config-desc">
1195 If your database server isn
't on your web server, enter the name or IP address here.
1198 <div class="config-input"><?php
1199 aField( $conf, "DBname", "Database name:" );
1201 <div class="config-input"><?php
1202 aField( $conf, "DBuser", "DB username:" );
1204 <div class="config-input"><?php
1205 aField( $conf, "DBpassword", "DB password:", "password" );
1207 <div class="config-input"><?php
1208 aField( $conf, "DBpassword2", "DB password confirm:", "password" );
1210 <p class="config-desc">
1211 If you only have a single user account and database available,
1212 enter those here. If you have database root access (see below)
1213 you can specify new accounts/databases to be created. This account
1214 will not be created if it pre-exists. If this is the case, ensure that it
1215 has SELECT, INSERT, UPDATE, and DELETE permissions on the MediaWiki database.
1218 <div class="config-input">
1219 <label class="column">Superuser account:</label>
1220 <input type="checkbox" name="useroot" id="useroot" <?php if( $useRoot ) { ?>checked="checked" <?php } ?>/>
1221 <label for="useroot">Use superuser account</label>
1223 <div class="config-input">
1225 aField( $conf, "RootUser", "Superuser name:", "superuser" );
1228 <div class="config-input">
1230 aField( $conf, "RootPW", "Superuser password:", "password" );
1234 <p class="config-desc">
1235 If the database user specified above does not exist, or does not have access to create
1236 the database (if needed) or tables within it, please check the box and provide details
1237 of a superuser account, such as <strong>root</strong>, which does.
1240 <?php database_switcher('mysql
'); ?>
1241 <div class="config-input"><?php
1242 aField( $conf, "DBprefix", "Database table prefix:" );
1244 <div class="config-desc">
1245 <p>If you need to share one database between multiple wikis, or
1246 between MediaWiki and another web application, you may choose to
1247 add a prefix to all the table names to avoid conflicts.</p>
1249 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
1252 <div class="config-input"><label class="column">Database charset</label>
1253 <div>Select one:</div>
1255 <li><?php aField( $conf, "DBschema", "Backwards-compatible UTF-8", "radio", "mysql4" ); ?></li>
1256 <li><?php aField( $conf, "DBschema", "Experimental MySQL 4.1/5.0 UTF-8", "radio", "mysql5" ); ?></li>
1257 <li><?php aField( $conf, "DBschema", "Experimental MySQL 4.1/5.0 binary", "radio", "mysql5-binary" ); ?></li>
1260 <p class="config-desc">
1261 <b>EXPERIMENTAL:</b> You can enable explicit Unicode charset support
1262 for MySQL 4.1 and 5.0 servers. This is not well tested and may
1263 cause things to break. <b>If upgrading an older installation, leave
1264 in backwards-compatible mode.</b>
1268 <?php database_switcher('postgres
'); ?>
1269 <div class="config-input"><?php
1270 aField( $conf, "DBport", "Database port:" );
1272 <div class="config-input"><?php
1273 aField( $conf, "DBmwschema", "Schema for mediawiki:" );
1275 <div class="config-input"><?php
1276 aField( $conf, "DBts2schema", "Schema for tsearch2:" );
1278 <div class="config-desc">
1279 <p>The username specified above (at "DB username") will have its search path set to the above schemas,
1280 so it is recommended that you create a new user. The above schemas are generally correct:
1281 only change them if you are sure you need to.</p>
1285 <div class="config-input" style="padding:2em 0 3em">
1286 <label class='column
'> </label>
1287 <input type="submit" value="Install MediaWiki!" class="btn-install" />
1292 <script type="text/javascript">
1293 window.onload = toggleDBarea('<?php
echo $conf->DBtype
; ?
>',
1295 ## If they passed in a root user name, don't populate it on page load
1296 echo strlen(importPost('RootUser', '')) ?
0 : 1;
1305 /* -------------------------------------------------------------------------------------- */
1306 function writeSuccessMessage() {
1307 if ( ini_get( 'safe_mode' ) && !ini_get( 'open_basedir' ) ) {
1309 <p>Installation successful!</p>
1310 <p>To complete the installation, please do the following:
1312 <li>Download config/LocalSettings.php with your FTP client or file manager</li>
1313 <li>Upload it to the parent directory</li>
1314 <li>Delete config/LocalSettings.php</li>
1315 <li>Start using <a href='../index.php'>your wiki</a>!
1317 <p>If you are in a shared hosting environment, do <strong>not</strong> just move LocalSettings.php
1318 remotely. LocalSettings.php is currently owned by the user your webserver is running under,
1319 which means that anyone on the same server can read your database password! Downloading
1320 it and uploading it again will hopefully change the ownership to a user ID specific to you.</p>
1323 echo "<p><span style='font-weight:bold;color:green;font-size:110%'>Installation successful!</span> Move the <tt>config/LocalSettings.php</tt> file into the parent directory, then follow
1324 <strong><a href='../index.php'>this link</a></strong> to your wiki.</p>\n";
1329 function escapePhpString( $string ) {
1330 return strtr( $string,
1341 function writeLocalSettings( $conf ) {
1342 $conf->PasswordSender
= $conf->EmergencyContact
;
1343 $magic = ($conf->ImageMagick ?
"" : "# ");
1344 $convert = ($conf->ImageMagick ?
$conf->ImageMagick
: "/usr/bin/convert" );
1345 $rights = ($conf->RightsUrl
) ?
"" : "# ";
1346 $hashedUploads = $conf->safeMode ?
'' : '# ';
1348 switch ( $conf->Shm
) {
1350 $cacheType = 'CACHE_MEMCACHED';
1351 $mcservers = var_export( $conf->MCServerArray
, true );
1356 $cacheType = 'CACHE_ACCEL';
1357 $mcservers = 'array()';
1360 $cacheType = 'CACHE_NONE';
1361 $mcservers = 'array()';
1364 if ( $conf->Email
== 'email_enabled' ) {
1365 $enableemail = 'true';
1366 $enableuseremail = ( $conf->Emailuser
== 'emailuser_enabled' ) ?
'true' : 'false' ;
1367 $eauthent = ( $conf->Eauthent
== 'eauthent_enabled' ) ?
'true' : 'false' ;
1368 switch ( $conf->Enotif
) {
1369 case 'enotif_usertalk':
1370 $enotifusertalk = 'true';
1371 $enotifwatchlist = 'false';
1373 case 'enotif_allpages':
1374 $enotifusertalk = 'true';
1375 $enotifwatchlist = 'true';
1378 $enotifusertalk = 'false';
1379 $enotifwatchlist = 'false';
1382 $enableuseremail = 'false';
1383 $enableemail = 'false';
1384 $eauthent = 'false';
1385 $enotifusertalk = 'false';
1386 $enotifwatchlist = 'false';
1389 $file = @fopen
( "/dev/urandom", "r" );
1391 $secretKey = bin2hex( fread( $file, 32 ) );
1395 for ( $i=0; $i<8; $i++
) {
1396 $secretKey .= dechex(mt_rand(0, 0x7fffffff));
1398 print "<li>Warning: \$wgSecretKey key is insecure, generated with mt_rand(). Consider changing it manually.</li>\n";
1401 # Add slashes to strings for double quoting
1402 $slconf = array_map( "escapePhpString", get_object_vars( $conf ) );
1403 if( $conf->License
== 'gfdl' ) {
1404 # Needs literal string interpolation for the current style path
1405 $slconf['RightsIcon'] = $conf->RightsIcon
;
1409 # This file was automatically generated by the MediaWiki installer.
1410 # If you make manual changes, please keep track in case you need to
1411 # recreate them later.
1413 # See includes/DefaultSettings.php for all configurable settings
1414 # and their default values, but don't forget to make changes in _this_
1417 # If you customize your file layout, set \$IP to the directory that contains
1418 # the other MediaWiki files. It will be used as a base to locate files.
1419 if( defined( 'MW_INSTALL_PATH' ) ) {
1420 \$IP = MW_INSTALL_PATH;
1422 \$IP = dirname( __FILE__ );
1425 \$path = array( \$IP, \"\$IP/includes\", \"\$IP/languages\" );
1426 set_include_path( implode( PATH_SEPARATOR, \$path ) . PATH_SEPARATOR . get_include_path() );
1428 require_once( \"includes/DefaultSettings.php\" );
1430 # If PHP's memory limit is very low, some operations may fail.
1431 " . ($conf->raiseMemory ?
'' : '# ' ) . "ini_set( 'memory_limit', '20M' );" . "
1433 if ( \$wgCommandLineMode ) {
1434 if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
1435 die( \"This script must be run from the command line\\n\" );
1438 ## Uncomment this to disable output compression
1439 # \$wgDisableOutputCompression = true;
1441 \$wgSitename = \"{$slconf['Sitename']}\";
1443 ## The URL base path to the directory containing the wiki;
1444 ## defaults for all runtime URL paths are based off of this.
1445 \$wgScriptPath = \"{$slconf['ScriptPath']}\";
1447 ## For more information on customizing the URLs please see:
1448 ## http://www.mediawiki.org/wiki/Manual:Short_URL
1450 \$wgEnableEmail = $enableemail;
1451 \$wgEnableUserEmail = $enableuseremail;
1453 \$wgEmergencyContact = \"{$slconf['EmergencyContact']}\";
1454 \$wgPasswordSender = \"{$slconf['PasswordSender']}\";
1456 ## For a detailed description of the following switches see
1457 ## http://meta.wikimedia.org/Enotif and http://meta.wikimedia.org/Eauthent
1458 ## There are many more options for fine tuning available see
1459 ## /includes/DefaultSettings.php
1460 ## UPO means: this is also a user preference option
1461 \$wgEnotifUserTalk = $enotifusertalk; # UPO
1462 \$wgEnotifWatchlist = $enotifwatchlist; # UPO
1463 \$wgEmailAuthentication = $eauthent;
1465 \$wgDBtype = \"{$slconf['DBtype']}\";
1466 \$wgDBserver = \"{$slconf['DBserver']}\";
1467 \$wgDBname = \"{$slconf['DBname']}\";
1468 \$wgDBuser = \"{$slconf['DBuser']}\";
1469 \$wgDBpassword = \"{$slconf['DBpassword']}\";
1471 # MySQL specific settings
1472 \$wgDBprefix = \"{$slconf['DBprefix']}\";
1474 # MySQL table options to use during installation or update
1475 \$wgDBTableOptions = \"{$slconf['DBTableOptions']}\";
1477 # Experimental charset support for MySQL 4.1/5.0.
1478 \$wgDBmysql5 = {$conf->DBmysql5};
1480 # Postgres specific settings
1481 \$wgDBport = \"{$slconf['DBport']}\";
1482 \$wgDBmwschema = \"{$slconf['DBmwschema']}\";
1483 \$wgDBts2schema = \"{$slconf['DBts2schema']}\";
1485 ## Shared memory settings
1486 \$wgMainCacheType = $cacheType;
1487 \$wgMemCachedServers = $mcservers;
1489 ## To enable image uploads, make sure the 'images' directory
1490 ## is writable, then set this to true:
1491 \$wgEnableUploads = false;
1492 {$magic}\$wgUseImageMagick = true;
1493 {$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
1495 ## If you want to use image uploads under safe mode,
1496 ## create the directories images/archive, images/thumb and
1497 ## images/temp, and make them all writable. Then uncomment
1498 ## this, if it's not already uncommented:
1499 {$hashedUploads}\$wgHashedUploadDirectory = false;
1501 ## If you have the appropriate support software installed
1502 ## you can enable inline LaTeX equations:
1505 \$wgLocalInterwiki = \$wgSitename;
1507 \$wgLanguageCode = \"{$slconf['LanguageCode']}\";
1509 \$wgProxyKey = \"$secretKey\";
1511 ## Default skin: you can change the default skin. Use the internal symbolic
1512 ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook':
1513 \$wgDefaultSkin = 'monobook';
1515 ## For attaching licensing metadata to pages, and displaying an
1516 ## appropriate copyright notice / icon. GNU Free Documentation
1517 ## License and Creative Commons licenses are supported so far.
1518 {$rights}\$wgEnableCreativeCommonsRdf = true;
1519 \$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright
1520 \$wgRightsUrl = \"{$slconf['RightsUrl']}\";
1521 \$wgRightsText = \"{$slconf['RightsText']}\";
1522 \$wgRightsIcon = \"{$slconf['RightsIcon']}\";
1523 # \$wgRightsCode = \"{$slconf['RightsCode']}\"; # Not yet used
1525 \$wgDiff3 = \"{$slconf['diff3']}\";
1527 # When you make changes to this configuration file, this will make
1528 # sure that cached pages are cleared.
1529 \$configdate = gmdate( 'YmdHis', @filemtime( __FILE__ ) );
1530 \$wgCacheEpoch = max( \$wgCacheEpoch, \$configdate );
1531 "; ## End of setting the $localsettings string
1533 // Keep things in Unix line endings internally;
1534 // the system will write out as local text type.
1535 return str_replace( "\r\n", "\n", $localsettings );
1538 function dieout( $text ) {
1539 die( $text . "\n\n</body>\n</html>" );
1542 function importVar( &$var, $name, $default = "" ) {
1543 if( isset( $var[$name] ) ) {
1544 $retval = $var[$name];
1545 if ( get_magic_quotes_gpc() ) {
1546 $retval = stripslashes( $retval );
1554 function importPost( $name, $default = "" ) {
1555 return importVar( $_POST, $name, $default );
1558 function importCheck( $name ) {
1559 return isset( $_POST[$name] );
1562 function importRequest( $name, $default = "" ) {
1563 return importVar( $_REQUEST, $name, $default );
1568 function aField( &$conf, $field, $text, $type = "text", $value = "", $onclick = '' ) {
1571 $xtype = "type=\"$type\"";
1577 $nolabel = ($type == "radio") ||
($type == "hidden");
1579 if ($type == 'radio')
1580 $id .= $radioCount++
;
1585 echo "\t\t<label class='column' for=\"$id\">$text</label>\n";
1588 if( $type == "radio" && $value == $conf->$field ) {
1589 $checked = "checked='checked'";
1593 echo "\t\t<input $xtype name=\"$field\" id=\"$id\" class=\"iput-$type\" $checked ";
1595 echo " onclick='toggleDBarea(\"$value\",1)' " ;
1598 if( $type == "radio" ) {
1599 echo htmlspecialchars( $value );
1601 echo htmlspecialchars( $conf->$field );
1607 echo " $text</label>\n";
1611 if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n";
1614 function getLanguageList() {
1615 global $wgLanguageNames;
1616 if( !isset( $wgLanguageNames ) ) {
1617 require_once( "languages/Names.php" );
1622 $d = opendir( "../languages/messages" );
1623 /* In case we are called from the root directory */
1625 $d = opendir( "languages/messages");
1626 while( false !== ($f = readdir( $d ) ) ) {
1628 if( preg_match( '/Messages([A-Z][a-z_]+)\.php$/', $f, $m ) ) {
1629 $code = str_replace( '_', '-', strtolower( $m[1] ) );
1630 if( isset( $wgLanguageNames[$code] ) ) {
1631 $name = $code . ' - ' . $wgLanguageNames[$code];
1635 $codes[$code] = $name;
1643 #Check for location of an executable
1644 # @param string $loc single location to check
1645 # @param array $names filenames to check for.
1646 # @param mixed $versioninfo array of details to use when checking version, use false for no version checking
1647 function locate_executable($loc, $names, $versioninfo = false) {
1648 if (!is_array($names))
1649 $names = array($names);
1651 foreach ($names as $name) {
1652 $command = "$loc".DIRECTORY_SEPARATOR
."$name";
1653 if (file_exists($command)) {
1657 $file = str_replace('$1', $command, $versioninfo[0]);
1658 if (strstr(`
$file`
, $versioninfo[1]) !== false)
1665 # Test a memcached server
1666 function testMemcachedServer( $server ) {
1667 $hostport = explode(":", $server);
1670 if ( !function_exists( 'fsockopen' ) ) {
1671 $errstr = "Can't connect to memcached, fsockopen() not present";
1673 if ( !$errstr && count( $hostport ) != 2 ) {
1674 $errstr = 'Please specify host and port';
1675 var_dump( $hostport );
1678 list( $host, $port ) = $hostport;
1682 $fp = @fsockopen
( $host, $port, $errno, $fsockerr, 1.0 );
1683 if ( $fp === false ) {
1684 $errstr = "Cannot connect to memcached on $host:$port : $fsockerr";
1688 $command = "version\r\n";
1689 $bytes = fwrite( $fp, $command );
1690 if ( $bytes != strlen( $command ) ) {
1691 $errstr = "Cannot write to memcached socket on $host:$port";
1695 $expected = "VERSION ";
1696 $response = fread( $fp, strlen( $expected ) );
1697 if ( $response != $expected ) {
1698 $errstr = "Didn't get correct memcached response from $host:$port";
1705 echo "<li>Connected to memcached on $host:$port successfully";
1710 function database_picker($conf) {
1713 foreach(array_keys($ourdb) as $db) {
1714 if ($ourdb[$db]['havedriver']) {
1716 aField( $conf, "DBtype", $ourdb[$db]['fullname'], 'radio', $db, 'onclick');
1723 function database_switcher($db) {
1725 $color = $ourdb[$db]['bgcolor'];
1726 $full = $ourdb[$db]['fullname'];
1727 print "<div id='$db' style='display:none; background: $color'>\n";
1728 print "<h3>$full specific options:</h3>\n";
1731 function printListItem( $item ) {
1732 print "<li>$item</li>";
1737 <div
class="license">
1739 <p
>This program is free software
; you can redistribute it
and/or modify
1740 it under the terms of the GNU General
Public License
as published by
1741 the Free Software Foundation
; either version
2 of the License
, or
1742 (at your option
) any later version
.</p
>
1744 <p
>This program is distributed in the hope that it will be useful
,
1745 but WITHOUT ANY WARRANTY
; without even the implied warranty of
1746 MERCHANTABILITY
or FITNESS
FOR A PARTICULAR PURPOSE
. See the
1747 GNU General
Public License
for more details
.</p
>
1749 <p
>You should have received
<a href
="../COPYING">a copy of the GNU General
Public License
</a
>
1750 along with this program
; if not
, write to the Free Software
1751 Foundation
, Inc
., 51 Franklin Street
, Fifth Floor
, Boston
, MA
02110-1301, USA
.
1752 or <a href
="http://www.gnu.org/copyleft/gpl.html">read it online
</a
></p
>
1758 <div id
="column-one">
1759 <div
class="portlet" id
="p-logo">
1760 <a style
="background-image: url(../skins/common/images/mediawiki.png);"
1761 href
="http://www.mediawiki.org/"
1762 title
="Main Page"></a
>
1764 <script type
="text/javascript"> if (window
.isMSIE55
) fixalpha(); </script
>
1765 <div
class='portlet'><div
class='pBody'>
1767 <li
><strong
><a href
="http://www.mediawiki.org/">MediaWiki home
</a
></strong
></li
>
1768 <li
><a href
="../README">Readme
</a
></li
>
1769 <li
><a href
="../RELEASE-NOTES">Release notes
</a
></li
>
1770 <li
><a href
="../docs/">Documentation
</a
></li
>
1771 <li
><a href
="http://meta.wikipedia.org/wiki/MediaWiki_User's_Guide">User
's Guide</a></li>
1772 <li><a href="http://meta.wikimedia.org/wiki/MediaWiki_FAQ">FAQ</a></li>
1774 <p style="font-size:90%;margin-top:1em">MediaWiki is Copyright © 2001-2007 by Magnus Manske, Brion Vibber, Lee Daniel Crocker, Tim Starling, Erik Möller, Gabriel Wicke and others.</p>