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/AutoLoader.php" );
49 require_once( "includes/MagicWord.php" );
50 require_once( "includes/Namespace.php" );
51 require_once( "includes/ProfilerStub.php" );
52 require_once( "includes/GlobalFunctions.php" );
53 require_once( "includes/Hooks.php" );
55 # If we get an exception, the user needs to know
57 $wgShowExceptionDetails = true;
59 ## Databases we support:
62 $ourdb['mysql']['fullname'] = 'MySQL';
63 $ourdb['mysql']['havedriver'] = 0;
64 $ourdb['mysql']['compile'] = 'mysql';
65 $ourdb['mysql']['bgcolor'] = '#ffe5a7';
66 $ourdb['mysql']['rootuser'] = 'root';
68 $ourdb['postgres']['fullname'] = 'PostgreSQL';
69 $ourdb['postgres']['havedriver'] = 0;
70 $ourdb['postgres']['compile'] = 'pgsql';
71 $ourdb['postgres']['bgcolor'] = '#aaccff';
72 $ourdb['postgres']['rootuser'] = 'postgres';
75 <!DOCTYPE HTML
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
78 <meta http
-equiv
="Content-type" content
="text/html; charset=utf-8">
79 <title
>MediaWiki
<?php
echo( $wgVersion ); ?
> Installation
</title
>
80 <style type
="text/css">
82 @import
"../skins/monobook/main.css";
86 margin
: 1em
0 1em
2.5em
;
93 .config
-section label
.column
{
105 zoom
: 100%
; /* IE hack */
108 .config
-section
.config
-desc
{
110 margin
: 0 0 2em
18em
;
115 .iput
-text
, .iput
-password
{
122 background
-color
: #fff;
130 background
-color
: #FFF0F0;
131 border
: 2px solid red
;
139 list-style
-type
: none
;
140 list-style
-image
: none
;
158 <script type
="text/javascript">
161 <?php
foreach (array_keys($ourdb) as $db) {
162 echo "\n document.getElementById('$db').style.display='none';";
167 function toggleDBarea(id
,defaultroot
) {
169 var dbarea
= document
.getElementById(id
).style
;
170 dbarea
.display
= (dbarea
.display
== 'none') ?
'block' : 'none';
171 var db
= document
.getElementById('RootUser');
173 <?php
foreach (array_keys($ourdb) as $db) {
174 echo " if (id == '$db') { db.value = '".$ourdb[$db]['rootuser']."';}\n";
183 <div id
="globalWrapper">
184 <div id
="column-content">
186 <div id
="bodyContent">
188 <h1
>MediaWiki
<?php
print $wgVersion ?
> Installation
</h1
>
192 /* Check for existing configurations and bug out! */
194 if( file_exists( "../LocalSettings.php" ) ) {
195 dieout( "<p><strong>Setup has completed, <a href='../index.php'>your wiki</a> is configured.</strong></p>
197 <p>Please delete the /config directory for extra security.</p></div></div></div></div>" );
200 if( file_exists( "./LocalSettings.php" ) ) {
201 writeSuccessMessage();
206 if( !is_writable( "." ) ) {
207 dieout( "<h2>Can't write config file, aborting</h2>
209 <p>In order to configure the wiki you have to make the <tt>config</tt> subdirectory
210 writable by the web server. Once configuration is done you'll move the created
211 <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can
212 then remove the <tt>config</tt> subdirectory entirely.</p>
214 <p>To make the directory writable on a Unix/Linux system:</p>
217 cd <i>/path/to/wiki</i>
221 <p>Afterwards retry to start the <a href=\"\">setup</a>.</p>" );
225 require_once( "install-utils.inc" );
226 require_once( "maintenance/updaters.inc" );
229 function getEncoded( $data ) {
230 # removing latin1 support, no need...
233 function getSitename() { return $this->getEncoded( $this->Sitename
); }
234 function getSysopName() { return $this->getEncoded( $this->SysopName
); }
235 function getSysopPass() { return $this->getEncoded( $this->SysopPass
); }
237 function setSchema( $schema ) {
238 $this->DBschema
= $schema;
239 switch ( $this->DBschema
) {
241 $this->DBTableOptions
= 'ENGINE=InnoDB, DEFAULT CHARSET=utf8';
242 $this->DBmysql5
= 'true';
244 case 'mysql5-binary':
245 $this->DBTableOptions
= 'ENGINE=InnoDB, DEFAULT CHARSET=binary';
246 $this->DBmysql5
= 'true';
249 $this->DBTableOptions
= 'TYPE=InnoDB';
250 $this->DBmysql5
= 'false';
252 # Set the global for use during install
253 global $wgDBTableOptions;
254 $wgDBTableOptions = $this->DBTableOptions
;
262 <b
>Don
't forget security updates!</b> Keep an eye on the
263 <a href="http://mail.wikimedia.org/mailman/listinfo/mediawiki-announce">low-traffic
264 release announcements mailing list</a>.
269 <h2>Checking environment...</h2>
270 <p><em>Please include all of the lines below when reporting installation problems.</em></p>
271 <ul class="env-check">
275 define( 'MW_NO_OUTPUT_BUFFER
', 1 );
276 $conf = new ConfigData;
278 install_version_checks();
279 $self = 'Installer
'; # Maintenance script name, to please Setup.php
281 print "<li>PHP " . phpversion() . " installed</li>\n";
283 error_reporting( 0 );
284 $phpdatabases = array();
285 foreach (array_keys($ourdb) as $db) {
286 $compname = $ourdb[$db]['compile
'];
287 if (extension_loaded($compname) or dl($compname . '.' . PHP_SHLIB_SUFFIX)) {
288 array_push($phpdatabases, $db);
289 $ourdb[$db]['havedriver
'] = 1;
292 error_reporting( E_ALL );
294 if (!$phpdatabases) {
295 print "Could not find a suitable database driver!<ul>";
296 foreach (array_keys($ourdb) AS $db) {
297 $comp = $ourdb[$db]['compile
'];
298 $full = $ourdb[$db]['fullname
'];
299 print "<li>For <b>$full</b>, compile PHP using <b>--with-$comp</b>, "
300 ."or install the $comp.so module</li>\n";
302 dieout( "</ul></ul>" );
305 print "<li>Found database drivers for:";
306 foreach (array_keys($ourdb) AS $db) {
307 if ($ourdb[$db]['havedriver
']) {
308 $DefaultDBtype = $db;
309 print " ".$ourdb[$db]['fullname
'];
313 if (count($phpdatabases) != 1)
316 if( ini_get( "register_globals" ) ) {
319 <div style="font-size:110%">
320 <strong class="error">Warning:</strong>
321 <strong>PHP's
<tt
><a href
="http://php.net/register_globals">register_globals
</a
></tt
> option is enabled
. Disable it
if you can
.</strong
>
323 MediaWiki will work
, but your server is more exposed to PHP
-based security vulnerabilities
.
330 if( ini_get( "magic_quotes_runtime" ) ) {
332 ?
><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
>
333 This option corrupts data input unpredictably
; you cannot install
or use
334 MediaWiki unless this option is disabled
.
338 if( ini_get( "magic_quotes_sybase" ) ) {
340 ?
><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
>
341 This option corrupts data input unpredictably
; you cannot install
or use
342 MediaWiki unless this option is disabled
.
346 if( ini_get( "mbstring.func_overload" ) ) {
348 ?
><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
>
349 This option causes errors
and may corrupt data unpredictably
;
350 you cannot install
or use MediaWiki unless this option is disabled
.
354 if( ini_get( "zend.ze1_compatibility_mode" ) ) {
356 ?
><li
class="error"><strong
>Fatal
: <a href
="http://www.php.net/manual/en/ini.core.php">zend
.ze1_compatibility_mode
</a
> is active
!</strong
>
357 This option causes horrible bugs with MediaWiki
; you cannot install
or use
358 MediaWiki unless this option is disabled
.
364 dieout( "</ul><p>Cannot install MediaWiki.</p>" );
367 if( ini_get( "safe_mode" ) ) {
368 $conf->safeMode
= true;
370 <li
><b
class='error'>Warning
:</b
> <strong
>PHP
's
371 <a href='http
://www.php.net/features.safe-mode'>safe mode</a> is active.</strong>
372 You may have problems caused by this
, particularly
if using image uploads
.
376 $conf->safeMode
= false;
379 $sapi = php_sapi_name();
380 print "<li>PHP server API is $sapi; ";
381 if( $wgUsePathInfo ) {
382 print "ok, using pretty URLs (<tt>index.php/Page_Title</tt>)";
384 print "using ugly URLs (<tt>index.php?title=Page_Title</tt>)";
388 $conf->xml
= function_exists( "utf8_encode" );
390 print "<li>Have XML / Latin1-UTF-8 conversion support.</li>\n";
392 dieout( "PHP's XML module is missing; the wiki requires functions in
393 this module and won't work in this configuration.
394 If you're running Mandrake, install the php-xml package." );
397 # Check for session support
398 if( !function_exists( 'session_name' ) )
399 dieout( "PHP's session module is missing. MediaWiki requires session support in order to function." );
401 # session.save_path doesn't *have* to be set, but if it is, and it's
402 # not valid/writable/etc. then it can cause problems
403 $sessionSavePath = mw_get_session_save_path();
404 $ssp = htmlspecialchars( $sessionSavePath );
405 # Warn the user if it's not set, but let them proceed
406 if( !$sessionSavePath ) {
407 print "<li><strong>Warning:</strong> A value for <tt>session.save_path</tt>
408 has not been set in PHP.ini. If the default value causes problems with
409 saving session data, set it to a valid path which is read/write/execute
410 for the user your web server is running under.</li>";
411 } elseif ( is_dir( $sessionSavePath ) && is_writable( $sessionSavePath ) ) {
412 # All good? Let the user know
413 print "<li>Session save path (<tt>{$ssp}</tt>) appears to be valid.</li>";
415 # Something not right? Warn the user, but let them proceed
416 print "<li><strong>Warning:</strong> Your <tt>session.save_path</tt> value (<tt>{$ssp}</tt>)
417 appears to be invalid or is not writable. PHP needs to be able to save data to
418 this location for correct session operation.</li>";
421 # Check for PCRE support
422 if( !function_exists( 'preg_match' ) )
423 dieout( "The PCRE support module appears to be missing. MediaWiki requires the
424 Perl-compatible regular expression functions." );
426 $memlimit = ini_get( "memory_limit" );
427 $conf->raiseMemory
= false;
428 if( empty( $memlimit ) ||
$memlimit == -1 ) {
429 print "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n";
431 print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars( $memlimit ) . ". ";
432 $n = intval( $memlimit );
433 if( preg_match( '/^([0-9]+)[Mm]$/', trim( $memlimit ), $m ) ) {
434 $n = intval( $m[1] * (1024*1024) );
436 if( $n < 20*1024*1024 ) {
437 print "Attempting to raise limit to 20M... ";
438 if( false === ini_set( "memory_limit", "20M" ) ) {
439 print "failed.<br /><b>" . htmlspecialchars( $memlimit ) . " seems too low, installation may fail!</b>";
441 $conf->raiseMemory
= true;
448 $conf->turck
= function_exists( 'mmcache_get' );
449 if ( $conf->turck
) {
450 print "<li><a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> installed</li>\n";
453 $conf->apc
= function_exists('apc_fetch');
455 print "<li><a href=\"http://www.php.net/apc\">APC</a> installed</li>";
458 $conf->eaccel
= function_exists( 'eaccelerator_get' );
459 if ( $conf->eaccel
) {
460 $conf->turck
= 'eaccelerator';
461 print "<li><a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> installed</li>\n";
464 if( !$conf->turck
&& !$conf->eaccel
&& !$conf->apc
) {
465 echo( '<li>Couldn\'t find <a href="http://turck-mmcache.sourceforge.net">Turck MMCache</a>,
466 <a href="http://eaccelerator.sourceforge.net">eAccelerator</a>, or
467 <a href="http://www.php.net/apc">APC</a>. Object caching functions cannot be used.</li>' );
470 $conf->diff3
= false;
471 $diff3locations = array_merge(
478 explode( $sep, getenv( "PATH" ) ) );
479 $diff3names = array( "gdiff3", "diff3", "diff3.exe" );
481 $diff3versioninfo = array( '$1 --version 2>&1', 'diff3 (GNU diffutils)' );
482 foreach ($diff3locations as $loc) {
483 $exe = locate_executable($loc, $diff3names, $diff3versioninfo);
484 if ($exe !== false) {
491 print "<li>Found GNU diff3: <tt>$conf->diff3</tt>.</li>";
493 print "<li>GNU diff3 not found.</li>";
495 $conf->ImageMagick
= false;
496 $imcheck = array( "/usr/bin", "/opt/csw/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" );
497 foreach( $imcheck as $dir ) {
498 $im = "$dir/convert";
499 if( file_exists( $im ) ) {
500 print "<li>Found ImageMagick: <tt>$im</tt>; image thumbnailing will be enabled if you enable uploads.</li>\n";
501 $conf->ImageMagick
= $im;
506 $conf->HaveGD
= function_exists( "imagejpeg" );
507 if( $conf->HaveGD
) {
508 print "<li>Found GD graphics library built-in";
509 if( !$conf->ImageMagick
) {
510 print ", image thumbnailing will be enabled if you enable uploads";
514 if( !$conf->ImageMagick
) {
515 print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n";
519 $conf->IP
= dirname( dirname( __FILE__
) );
520 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP
) . "</tt></li>\n";
523 // PHP_SELF isn't available sometimes, such as when PHP is CGI but
524 // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
525 // to get the path to the current script... hopefully it's reliable. SIGH
526 $path = ($_SERVER["PHP_SELF"] === '')
527 ?
$_SERVER["SCRIPT_NAME"]
528 : $_SERVER["PHP_SELF"];
529 $conf->ScriptPath
= preg_replace( '{^(.*)/config.*$}', '$1', $path );
530 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath
) . "</tt></li>\n";
532 print "<li style='font-weight:bold;color:green;font-size:110%'>Environment checked. You can install MediaWiki.</li>\n";
533 $conf->posted
= ($_SERVER["REQUEST_METHOD"] == "POST");
535 $conf->Sitename
= ucfirst( importPost( "Sitename", "" ) );
536 $defaultEmail = empty( $_SERVER["SERVER_ADMIN"] )
538 : $_SERVER["SERVER_ADMIN"];
539 $conf->EmergencyContact
= importPost( "EmergencyContact", $defaultEmail );
540 $conf->DBtype
= importPost( "DBtype", $DefaultDBtype );
544 $conf->DBserver
= importPost( "DBserver", "localhost" );
545 $conf->DBname
= importPost( "DBname", "wikidb" );
546 $conf->DBuser
= importPost( "DBuser", "wikiuser" );
547 $conf->DBpassword
= importPost( "DBpassword" );
548 $conf->DBpassword2
= importPost( "DBpassword2" );
549 $conf->SysopName
= importPost( "SysopName", "WikiSysop" );
550 $conf->SysopPass
= importPost( "SysopPass" );
551 $conf->SysopPass2
= importPost( "SysopPass2" );
552 $conf->RootUser
= importPost( "RootUser", "root" );
553 $conf->RootPW
= importPost( "RootPW", "" );
554 $useRoot = importCheck( 'useroot', false );
555 $conf->LanguageCode
= importPost( "LanguageCode", "en" );
558 $conf->DBprefix
= importPost( "DBprefix" );
559 $conf->setSchema( importPost( "DBschema", "mysql4" ) );
561 ## Postgres specific:
562 $conf->DBport
= importPost( "DBport", "5432" );
563 $conf->DBmwschema
= importPost( "DBmwschema", "mediawiki" );
564 $conf->DBts2schema
= importPost( "DBts2schema", "public" );
566 /* Check for validity */
569 if( $conf->Sitename
== "" ||
$conf->Sitename
== "MediaWiki" ||
$conf->Sitename
== "Mediawiki" ) {
570 $errs["Sitename"] = "Must not be blank or \"MediaWiki\"";
572 if( $conf->DBuser
== "" ) {
573 $errs["DBuser"] = "Must not be blank";
575 if( ($conf->DBtype
== 'mysql') && (strlen($conf->DBuser
) > 16) ) {
576 $errs["DBuser"] = "Username too long";
578 if( $conf->DBpassword
== "" && $conf->DBtype
!= "postgres" ) {
579 $errs["DBpassword"] = "Must not be blank";
581 if( $conf->DBpassword
!= $conf->DBpassword2
) {
582 $errs["DBpassword2"] = "Passwords don't match!";
584 if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix
) ) {
585 $errs["DBprefix"] = "Invalid table prefix";
588 error_reporting( E_ALL
);
591 * Initialise $wgLang and $wgContLang to something so we can
592 * call case-folding methods. Per Brion, this is English for
593 * now, although we could be clever and initialise to the
594 * user-selected language.
596 $wgContLang = Language
::factory( 'en' );
597 $wgLang = $wgContLang;
600 * We're messing about with users, so we need a stub
601 * authentication plugin...
603 $wgAuth = new AuthPlugin();
606 * Validate the initial administrator account; username,
607 * password checks, etc.
609 if( $conf->SysopName
) {
610 # Check that the user can be created
611 $u = User
::newFromName( $conf->SysopName
);
612 if( $u instanceof User
) {
613 # Various password checks
614 if( $conf->SysopPass
!= '' ) {
615 if( $conf->SysopPass
== $conf->SysopPass2
) {
616 if( !$u->isValidPassword( $conf->SysopPass
) ) {
617 $errs['SysopPass'] = "Bad password";
620 $errs['SysopPass2'] = "Passwords don't match";
623 $errs['SysopPass'] = "Cannot be blank";
627 $errs['SysopName'] = "Bad username";
631 $conf->License
= importRequest( "License", "none" );
632 if( $conf->License
== "gfdl" ) {
633 $conf->RightsUrl
= "http://www.gnu.org/copyleft/fdl.html";
634 $conf->RightsText
= "GNU Free Documentation License 1.2";
635 $conf->RightsCode
= "gfdl";
636 $conf->RightsIcon
= '${wgScriptPath}/skins/common/images/gnu-fdl.png';
637 } elseif( $conf->License
== "none" ) {
638 $conf->RightsUrl
= $conf->RightsText
= $conf->RightsCode
= $conf->RightsIcon
= "";
640 $conf->RightsUrl
= importRequest( "RightsUrl", "" );
641 $conf->RightsText
= importRequest( "RightsText", "" );
642 $conf->RightsCode
= importRequest( "RightsCode", "" );
643 $conf->RightsIcon
= importRequest( "RightsIcon", "" );
646 $conf->Shm
= importRequest( "Shm", "none" );
647 $conf->MCServers
= importRequest( "MCServers" );
649 /* Test memcached servers */
651 if ( $conf->Shm
== 'memcached' && $conf->MCServers
) {
652 $conf->MCServerArray
= array_map( 'trim', explode( ',', $conf->MCServers
) );
653 foreach ( $conf->MCServerArray
as $server ) {
654 $error = testMemcachedServer( $server );
656 $errs["MCServers"] = $error;
660 } else if ( $conf->Shm
== 'memcached' ) {
661 $errs["MCServers"] = "Please specify at least one server if you wish to use memcached";
664 /* default values for installation */
665 $conf->Email
= importRequest("Email", "email_enabled");
666 $conf->Emailuser
= importRequest("Emailuser", "emailuser_enabled");
667 $conf->Enotif
= importRequest("Enotif", "enotif_allpages");
668 $conf->Eauthent
= importRequest("Eauthent", "eauthent_enabled");
670 if( $conf->posted
&& ( 0 == count( $errs ) ) ) {
671 do { /* So we can 'continue' to end prematurely */
672 $conf->Root
= ($conf->RootPW
!= "");
674 /* Load up the settings and get installin' */
675 $local = writeLocalSettings( $conf );
676 echo "<li style=\"list-style: none\">\n";
677 echo "<p><b>Generating configuration file...</b></p>\n";
680 $wgCommandLineMode = false;
682 $ok = eval( $local );
683 if( $ok === false ) {
684 dieout( "Errors in generated configuration; " .
685 "most likely due to a bug in the installer... " .
686 "Config file was: " .
688 htmlspecialchars( $local ) .
692 $conf->DBtypename
= '';
693 foreach (array_keys($ourdb) as $db) {
694 if ($conf->DBtype
=== $db)
695 $conf->DBtypename
= $ourdb[$db]['fullname'];
697 if ( ! strlen($conf->DBtype
)) {
698 $errs["DBpicktype"] = "Please choose a database type";
702 if (! $conf->DBtypename
) {
703 $errs["DBtype"] = "Unknown database type '$conf->DBtype'";
706 print "<li>Database type: {$conf->DBtypename}</li>\n";
707 $dbclass = 'Database'.ucfirst($conf->DBtype
);
708 $wgDBtype = $conf->DBtype
;
709 $wgDBadminuser = "root";
710 $wgDBadminpassword = $conf->RootPW
;
713 $wgDBprefix = $conf->DBprefix
;
715 ## Postgres specific:
716 $wgDBport = $conf->DBport
;
717 $wgDBmwschema = $conf->DBmwschema
;
718 $wgDBts2schema = $conf->DBts2schema
;
720 $wgCommandLineMode = true;
721 $wgUseDatabaseMessages = false; /* FIXME: For database failure */
722 require_once( "includes/Setup.php" );
725 $wgTitle = Title
::newFromText( "Installation script" );
726 error_reporting( E_ALL
);
727 print "<li>Loading class: $dbclass";
730 if( $conf->DBtype
== 'mysql' ) {
731 $mysqlOldClient = version_compare( mysql_get_client_info(), "4.1.0", "lt" );
732 if( $mysqlOldClient ) {
733 print "<li><b>PHP is linked with old MySQL client libraries. If you are
734 using a MySQL 4.1 server and have problems connecting to the database,
735 see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
736 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b></li>\n";
738 $ok = true; # Let's be optimistic
740 # Decide if we're going to use the superuser or the regular database user
741 $conf->Root
= $useRoot;
743 $db_user = $conf->RootUser
;
744 $db_pass = $conf->RootPW
;
746 $db_user = $wgDBuser;
747 $db_pass = $wgDBpassword;
751 echo( "<li>Attempting to connect to database server as $db_user..." );
752 $wgDatabase = Database
::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 );
754 # Check the connection and respond to errors
755 if( $wgDatabase->isOpen() ) {
758 $wgDBadminuser = $db_user;
759 $wgDBadminpassword = $db_pass;
760 echo( "success.</li>\n" );
761 $wgDatabase->ignoreErrors( true );
762 $myver = $wgDatabase->getServerVersion();
764 # There were errors, report them and back out
766 $errno = mysql_errno();
767 $errtx = htmlspecialchars( mysql_error() );
771 echo( "failed due to authentication errors. Check passwords.</li>" );
773 # The superuser details are wrong
774 $errs["RootUser"] = "Check username";
775 $errs["RootPW"] = "and password";
777 # The regular user details are wrong
778 $errs["DBuser"] = "Check username";
779 $errs["DBpassword"] = "and password";
785 # General connection problem
786 echo( "failed with error [$errno] $errtx.</li>\n" );
787 $errs["DBserver"] = "Connection failed";
792 if( !$ok ) { continue; }
794 } else /* not mysql */ {
795 error_reporting( E_ALL
);
797 ## Possible connect as a superuser
799 $wgDBsuperuser = $conf->RootUser
;
800 echo( "<li>Attempting to connect to database \"postgres\" as superuser \"$wgDBsuperuser\"..." );
801 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBsuperuser, $conf->RootPW
, "postgres", 1);
802 if (!$wgDatabase->isOpen()) {
803 print " error: " . $wgDatabase->lastError() . "</li>\n";
804 $errs["DBserver"] = "Could not connect to database as superuser";
805 $errs["RootUser"] = "Check username";
806 $errs["RootPW"] = "and password";
810 echo( "<li>Attempting to connect to database \"$wgDBname\" as \"$wgDBuser\"..." );
811 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1);
812 if (!$wgDatabase->isOpen()) {
813 print " error: " . $wgDatabase->lastError() . "</li>\n";
815 $myver = $wgDatabase->getServerVersion();
819 if ( !$wgDatabase->isOpen() ) {
820 $errs["DBserver"] = "Couldn't connect to database";
824 print "<li>Connected to $myver";
825 if ($conf->DBtype
== 'mysql') {
826 if( version_compare( $myver, "4.0.14" ) < 0 ) {
827 dieout( " -- mysql 4.0.14 or later required. Aborting." );
829 $mysqlNewAuth = version_compare( $myver, "4.1.0", "ge" );
830 if( $mysqlNewAuth && $mysqlOldClient ) {
831 print "; <b class='error'>You are using MySQL 4.1 server, but PHP is linked
832 to old client libraries; if you have trouble with authentication, see
833 <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
834 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>";
837 if( $mysqlNewAuth ) {
838 print "; enabling MySQL 4.1/5.0 charset mode";
840 print "; <b class='error'>MySQL 4.1/5.0 charset mode enabled,
841 but older version detected; will likely fail.</b>";
846 @$sel = $wgDatabase->selectDB( $wgDBname );
848 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
850 $err = mysql_errno();
851 $databaseSafe = htmlspecialchars( $wgDBname );
852 if( $err == 1102 /* Invalid database name */ ) {
853 print "<ul><li><strong>{$databaseSafe}</strong> is not a valid database name.</li></ul>";
855 } elseif( $err != 1049 /* Database doesn't exist */ ) {
856 print "<ul><li>Error selecting database <strong>{$databaseSafe}</strong>: {$err} ";
857 print htmlspecialchars( mysql_error() ) . "</li></ul>";
860 print "<li>Attempting to create database...</li>";
861 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
863 print "<li>Couldn't create database <tt>" .
864 htmlspecialchars( $wgDBname ) .
865 "</tt>; try with root access or check your username/pass.</li>\n";
866 $errs["RootPW"] = "<- Enter";
869 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
871 $wgDatabase->selectDB( $wgDBname );
873 else if ($conf->DBtype
== 'postgres') {
874 if( version_compare( $myver, "PostgreSQL 8.0" ) < 0 ) {
875 dieout( " <b>Postgres 8.0 or later is required</b>. Aborting.</li></ul>" );
879 if( $wgDatabase->tableExists( "cur" ) ||
$wgDatabase->tableExists( "revision" ) ) {
880 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n";
882 if ( $conf->DBtype
== 'mysql') {
884 # Determine existing default character set
885 if ( $wgDatabase->tableExists( "revision" ) ) {
886 $revision = $wgDatabase->escapeLike( $conf->DBprefix
. 'revision' );
887 $res = $wgDatabase->query( "SHOW TABLE STATUS LIKE '$revision'" );
888 $row = $wgDatabase->fetchObject( $res );
890 echo "<li>SHOW TABLE STATUS query failed!</li>\n";
891 $existingSchema = false;
892 } elseif ( preg_match( '/^latin1/', $row->Collation
) ) {
893 $existingSchema = 'mysql4';
894 } elseif ( preg_match( '/^utf8/', $row->Collation
) ) {
895 $existingSchema = 'mysql5';
896 } elseif ( preg_match( '/^binary/', $row->Collation
) ) {
897 $existingSchema = 'mysql5-binary';
899 $existingSchema = false;
900 echo "<li><strong>Warning:</strong> Unrecognised existing collation</li>\n";
902 if ( $existingSchema && $existingSchema != $conf->DBschema
) {
903 print "<li><strong>Warning:</strong> you requested the {$conf->DBschema} schema, " .
904 "but the existing database has the $existingSchema schema. This upgrade script ".
905 "can't convert it, so it will remain $existingSchema.</li>\n";
906 $conf->setSchema( $existingSchema );
910 # Create user if required
912 $conn = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
913 if ( $conn->isOpen() ) {
914 print "<li>DB user account ok</li>\n";
917 print "<li>Granting user permissions...";
918 if( $mysqlOldClient && $mysqlNewAuth ) {
919 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>";
922 dbsource( "../maintenance/users.sql", $wgDatabase );
926 print "</ul><pre>\n";
932 print "<ul><li>Finished update checks.</li>\n";
934 # FIXME: Check for errors
935 print "<li>Creating tables...";
936 if ($conf->DBtype
== 'mysql') {
937 dbsource( "../maintenance/tables.sql", $wgDatabase );
938 dbsource( "../maintenance/interwiki.sql", $wgDatabase );
939 } else if ($conf->DBtype
== 'postgres') {
940 $wgDatabase->setup_database();
943 $errs["DBtype"] = "Do not know how to handle database type '$conf->DBtype'";
947 print " done.</li>\n";
949 print "<li>Initializing data...</li>\n";
950 $wgDatabase->insert( 'site_stats',
951 array ( 'ss_row_id' => 1,
952 'ss_total_views' => 0,
953 'ss_total_edits' => 0,
954 'ss_good_articles' => 0 ) );
956 # Set up the "regular user" account *if we can, and if we need to*
957 if( $conf->Root
and $conf->DBtype
== 'mysql') {
959 $wgDatabase2 = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
960 if( $wgDatabase2->isOpen() ) {
961 # Nope, just close the test connection and continue
962 $wgDatabase2->close();
963 echo( "<li>User $wgDBuser exists. Skipping grants.</li>\n" );
965 # Yes, so run the grants
966 echo( "<li>Granting user permissions to $wgDBuser on $wgDBname..." );
967 dbsource( "../maintenance/users.sql", $wgDatabase );
968 echo( "success.</li>\n" );
972 if( $conf->SysopName
) {
973 $u = User
::newFromName( $conf->getSysopName() );
975 print "<li><strong class=\"error\">Warning:</strong> Skipped sysop account creation - invalid username!</li>\n";
977 else if ( 0 == $u->idForName() ) {
979 $u->setPassword( $conf->getSysopPass() );
982 $u->addGroup( "sysop" );
983 $u->addGroup( "bureaucrat" );
985 print "<li>Created sysop account <tt>" .
986 htmlspecialchars( $conf->SysopName
) . "</tt>.</li>\n";
988 print "<li>Could not create user - already exists!</li>\n";
991 print "<li>Skipped sysop account creation, no name given.</li>\n";
994 $titleobj = Title
::newFromText( wfMsgNoDB( "mainpage" ) );
995 $article = new Article( $titleobj );
996 $newid = $article->insertOn( $wgDatabase );
997 $revision = new Revision( array(
999 'text' => wfMsg( 'mainpagetext' ) . "\n\n" . wfMsgNoTrans( 'mainpagedocfooter' ),
1002 'user_text' => 'MediaWiki default',
1004 $revid = $revision->insertOn( $wgDatabase );
1005 $article->updateRevisionOn( $wgDatabase, $revision );
1008 /* Write out the config file now that all is well */
1009 print "<li style=\"list-style: none\">\n";
1010 print "<p>Creating LocalSettings.php...</p>\n\n";
1011 $localSettings = "<" . "?php$endl$local";
1012 // Fix up a common line-ending problem (due to CVS on Windows)
1013 $localSettings = str_replace( "\r\n", "\n", $localSettings );
1014 $f = fopen( "LocalSettings.php", 'xt' );
1017 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" .
1018 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
1019 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
1021 if(fwrite( $f, $localSettings ) ) {
1023 writeSuccessMessage();
1026 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");
1039 if( count( $errs ) ) {
1040 /* Display options form */
1042 if( $conf->posted
) {
1043 echo "<p class='error-top'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
1047 <form action
="index.php" name
="config" method
="post">
1050 <h2
>Site config
</h2
>
1052 <div
class="config-section">
1053 <div
class="config-input">
1055 aField( $conf, "Sitename", "Wiki name:" );
1058 <p
class="config-desc">
1059 Preferably a short word without punctuation
, i
.e
. "Wikipedia".<br
/>
1060 Will appear
as the
namespace name
for "meta" pages
, and throughout the
interface.
1063 <div
class="config-input">
1065 aField( $conf, "EmergencyContact", "Contact e-mail:" );
1068 <p
class="config-desc">
1069 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
.
1072 <div
class="config-input">
1073 <label
class='column' for="LanguageCode">Language
:</label
>
1074 <select id
="LanguageCode" name
="LanguageCode">
1077 $list = getLanguageList();
1078 foreach( $list as $code => $name ) {
1079 $sel = ($code == $conf->LanguageCode
) ?
'selected="selected"' : '';
1080 echo "\t\t<option value=\"$code\" $sel>$name</option>\n";
1085 <p
class="config-desc">
1086 Select the language
for your wiki
's interface. Some localizations aren't fully complete
. Unicode (UTF
-8) is used
for all localizations
.
1089 <div
class="config-input">
1090 <label
class='column'>Copyright
/license
:</label
>
1093 <li
><?php
aField( $conf, "License", "No license metadata", "radio", "none" ); ?
></li
>
1094 <li
><?php
aField( $conf, "License", "GNU Free Documentation License 1.2 (Wikipedia-compatible)", "radio", "gfdl" ); ?
></li
>
1096 aField( $conf, "License", "A Creative Commons license - ", "radio", "cc" );
1097 $partner = "MediaWiki";
1098 $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/index.php?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
1099 $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" );
1100 $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" );
1101 print "<a href=\"$ccApp\" target='_blank'>choose</a>";
1103 <?php
if( $conf->License
== "cc" ) { ?
>
1105 <li
><?php
aField( $conf, "RightsIcon", "<img src=\"" . htmlspecialchars( $conf->RightsIcon
) . "\" alt='(Creative Commons icon)' />", "hidden" ); ?
></li
>
1106 <li
><?php
aField( $conf, "RightsText", htmlspecialchars( $conf->RightsText
), "hidden" ); ?
></li
>
1107 <li
><?php
aField( $conf, "RightsCode", "code: " . htmlspecialchars( $conf->RightsCode
), "hidden" ); ?
></li
>
1108 <li
><?php
aField( $conf, "RightsUrl", "<a href=\"" . htmlspecialchars( $conf->RightsUrl
) . "\">" . htmlspecialchars( $conf->RightsUrl
) . "</a>", "hidden" ); ?
></li
>
1114 <p
class="config-desc">
1115 A notice
, icon
, and machine
-readable copyright metadata will be displayed
for the license you pick
.
1119 <div
class="config-input">
1120 <?php
aField( $conf, "SysopName", "Admin username:" ) ?
>
1122 <div
class="config-input">
1123 <?php
aField( $conf, "SysopPass", "Password:", "password" ) ?
>
1125 <div
class="config-input">
1126 <?php
aField( $conf, "SysopPass2", "Password confirm:", "password" ) ?
>
1128 <p
class="config-desc">
1129 An admin can lock
/delete pages
, block users from editing
, and do other maintenance tasks
.<br
/>
1130 A
new account will be added only when creating a
new wiki database
.
1132 <p
class="config-desc">
1133 The password cannot be the same
as the username
.
1136 <div
class="config-input">
1137 <label
class='column'>Shared memory caching
:</label
>
1140 <li
><?php
aField( $conf, "Shm", "No caching", "radio", "none" ); ?
></li
>
1142 if ( $conf->turck
) {
1144 aField( $conf, "Shm", "Turck MMCache", "radio", "turck" );
1149 aField( $conf, "Shm", "APC", "radio", "apc" );
1152 if ( $conf->eaccel
) {
1154 aField( $conf, "Shm", "eAccelerator", "radio", "eaccel" );
1158 <li
><?php
aField( $conf, "Shm", "Memcached", "radio", "memcached" ); ?
></li
>
1160 <div style
="clear:left"><?php
aField( $conf, "MCServers", "Memcached servers:", "text" ) ?
></div
>
1162 <p
class="config-desc">
1163 Using a shared memory system such
as Turck MMCache
, APC
, eAccelerator
, or Memcached
1164 will speed up MediaWiki significantly
. Memcached is the best solution but needs to be
1165 installed
. Specify the server addresses
and ports in a comma
-separated
list. Only
1166 use Turck shared memory
if the wiki will be running on a single Apache server
.
1170 <h2
>E
-mail
, e
-mail notification
and authentication setup
</h2
>
1172 <div
class="config-section">
1173 <div
class="config-input">
1174 <label
class='column'>E
-mail
features (global):</label
>
1176 <li
><?php
aField( $conf, "Email", "Enabled", "radio", "email_enabled" ); ?
></li
>
1177 <li
><?php
aField( $conf, "Email", "Disabled", "radio", "email_disabled" ); ?
></li
>
1180 <p
class="config-desc">
1181 Use this to disable all e
-mail
functions (password reminders
, user
-to
-user e
-mail
, and e
-mail notifications
)
1182 if sending mail doesn
't work on your server.
1185 <div class="config-input">
1186 <label class='column
'>User-to-user e-mail:</label>
1188 <li><?php aField( $conf, "Emailuser", "Enabled", "radio", "emailuser_enabled" ); ?></li>
1189 <li><?php aField( $conf, "Emailuser", "Disabled", "radio", "emailuser_disabled" ); ?></li>
1192 <p class="config-desc">
1193 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.
1195 <div class="config-input">
1196 <label class='column
'>E-mail notification about changes:</label>
1198 <li><?php aField( $conf, "Enotif", "Disabled", "radio", "enotif_disabled" ); ?></li>
1199 <li><?php aField( $conf, "Enotif", "Enabled for changes to user discussion pages only", "radio", "enotif_usertalk" ); ?></li>
1200 <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>
1203 <div class="config-desc">
1205 For this feature to work, an e-mail address must be present for the user account, and the notification
1206 options in the user's preferences must be enabled
. Also note the
1207 authentication option below
. When testing the feature
, keep in mind that your own changes will never trigger notifications to be sent to yourself
.</p
>
1209 <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
>
1212 <div
class="config-input">
1213 <label
class='column'>E
-mail address authentication
:</label
>
1215 <li
><?php
aField( $conf, "Eauthent", "Disabled", "radio", "eauthent_disabled" ); ?
></li
>
1216 <li
><?php
aField( $conf, "Eauthent", "Enabled", "radio", "eauthent_enabled" ); ?
></li
>
1219 <div
class="config-desc">
1220 <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
1221 change notification mails
. Setting this option is
<B
>recommended
</B
> for public wikis because of potential abuse of the e
-mail features above
.</p
>
1226 <h2
>Database config
</h2
>
1228 <div
class="config-section">
1229 <div
class="config-input">
1230 <label
class='column'>Database type
:</label
>
1231 <?php
if (isset($errs['DBpicktype'])) print "<span class='error'>$errs[DBpicktype]</span>\n"; ?
>
1232 <ul
class='plain'><?php
database_picker($conf) ?
></ul
>
1235 <div
class="config-input" style
="clear:left"><?php
1236 aField( $conf, "DBserver", "Database host:" );
1238 <p
class="config-desc">
1239 If your database server isn
't on your web server, enter the name or IP address here.
1242 <div class="config-input"><?php
1243 aField( $conf, "DBname", "Database name:" );
1245 <div class="config-input"><?php
1246 aField( $conf, "DBuser", "DB username:" );
1248 <div class="config-input"><?php
1249 aField( $conf, "DBpassword", "DB password:", "password" );
1251 <div class="config-input"><?php
1252 aField( $conf, "DBpassword2", "DB password confirm:", "password" );
1254 <p class="config-desc">
1255 If you only have a single user account and database available,
1256 enter those here. If you have database root access (see below)
1257 you can specify new accounts/databases to be created. This account
1258 will not be created if it pre-exists. If this is the case, ensure that it
1259 has SELECT, INSERT, UPDATE, and DELETE permissions on the MediaWiki database.
1262 <div class="config-input">
1263 <label class="column">Superuser account:</label>
1264 <input type="checkbox" name="useroot" id="useroot" <?php if( $useRoot ) { ?>checked="checked" <?php } ?>/>
1265 <label for="useroot">Use superuser account</label>
1267 <div class="config-input">
1269 aField( $conf, "RootUser", "Superuser name:", "superuser" );
1272 <div class="config-input">
1274 aField( $conf, "RootPW", "Superuser password:", "password" );
1278 <p class="config-desc">
1279 If the database user specified above does not exist, or does not have access to create
1280 the database (if needed) or tables within it, please check the box and provide details
1281 of a superuser account, such as <strong>root</strong>, which does.
1284 <?php database_switcher('mysql
'); ?>
1285 <div class="config-input"><?php
1286 aField( $conf, "DBprefix", "Database table prefix:" );
1288 <div class="config-desc">
1289 <p>If you need to share one database between multiple wikis, or
1290 between MediaWiki and another web application, you may choose to
1291 add a prefix to all the table names to avoid conflicts.</p>
1293 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
1296 <div class="config-input"><label class="column">Database charset</label>
1297 <div>Select one:</div>
1299 <li><?php aField( $conf, "DBschema", "Backwards-compatible UTF-8", "radio", "mysql4" ); ?></li>
1300 <li><?php aField( $conf, "DBschema", "Experimental MySQL 4.1/5.0 UTF-8", "radio", "mysql5" ); ?></li>
1301 <li><?php aField( $conf, "DBschema", "Experimental MySQL 4.1/5.0 binary", "radio", "mysql5-binary" ); ?></li>
1304 <p class="config-desc">
1305 <b>EXPERIMENTAL:</b> You can enable explicit Unicode charset support
1306 for MySQL 4.1 and 5.0 servers. This is not well tested and may
1307 cause things to break. <b>If upgrading an older installation, leave
1308 in backwards-compatible mode.</b>
1312 <?php database_switcher('postgres
'); ?>
1313 <div class="config-input"><?php
1314 aField( $conf, "DBport", "Database port:" );
1316 <div class="config-input"><?php
1317 aField( $conf, "DBmwschema", "Schema for mediawiki:" );
1319 <div class="config-input"><?php
1320 aField( $conf, "DBts2schema", "Schema for tsearch2:" );
1322 <div class="config-desc">
1323 <p>The username specified above (at "DB username") will have its search path set to the above schemas,
1324 so it is recommended that you create a new user. The above schemas are generally correct:
1325 only change them if you are sure you need to.</p>
1329 <div class="config-input" style="padding:2em 0 3em">
1330 <label class='column
'> </label>
1331 <input type="submit" value="Install MediaWiki!" class="btn-install" />
1336 <script type="text/javascript">
1337 window.onload = toggleDBarea('<?php
echo $conf->DBtype
; ?
>',
1339 ## If they passed in a root user name, don't populate it on page load
1340 echo strlen(importPost('RootUser', '')) ?
0 : 1;
1349 /* -------------------------------------------------------------------------------------- */
1350 function writeSuccessMessage() {
1351 if ( ini_get( 'safe_mode' ) && !ini_get( 'open_basedir' ) ) {
1353 <p>Installation successful!</p>
1354 <p>To complete the installation, please do the following:
1356 <li>Download config/LocalSettings.php with your FTP client or file manager</li>
1357 <li>Upload it to the parent directory</li>
1358 <li>Delete config/LocalSettings.php</li>
1359 <li>Start using <a href='../index.php'>your wiki</a>!
1361 <p>If you are in a shared hosting environment, do <strong>not</strong> just move LocalSettings.php
1362 remotely. LocalSettings.php is currently owned by the user your webserver is running under,
1363 which means that anyone on the same server can read your database password! Downloading
1364 it and uploading it again will hopefully change the ownership to a user ID specific to you.</p>
1367 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
1368 <strong><a href='../index.php'>this link</a></strong> to your wiki.</p>\n";
1373 function escapePhpString( $string ) {
1374 return strtr( $string,
1385 function writeLocalSettings( $conf ) {
1386 $conf->PasswordSender
= $conf->EmergencyContact
;
1387 $magic = ($conf->ImageMagick ?
"" : "# ");
1388 $convert = ($conf->ImageMagick ?
$conf->ImageMagick
: "/usr/bin/convert" );
1389 $rights = ($conf->RightsUrl
) ?
"" : "# ";
1390 $hashedUploads = $conf->safeMode ?
'' : '# ';
1392 switch ( $conf->Shm
) {
1394 $cacheType = 'CACHE_MEMCACHED';
1395 $mcservers = var_export( $conf->MCServerArray
, true );
1400 $cacheType = 'CACHE_ACCEL';
1401 $mcservers = 'array()';
1404 $cacheType = 'CACHE_NONE';
1405 $mcservers = 'array()';
1408 if ( $conf->Email
== 'email_enabled' ) {
1409 $enableemail = 'true';
1410 $enableuseremail = ( $conf->Emailuser
== 'emailuser_enabled' ) ?
'true' : 'false' ;
1411 $eauthent = ( $conf->Eauthent
== 'eauthent_enabled' ) ?
'true' : 'false' ;
1412 switch ( $conf->Enotif
) {
1413 case 'enotif_usertalk':
1414 $enotifusertalk = 'true';
1415 $enotifwatchlist = 'false';
1417 case 'enotif_allpages':
1418 $enotifusertalk = 'true';
1419 $enotifwatchlist = 'true';
1422 $enotifusertalk = 'false';
1423 $enotifwatchlist = 'false';
1426 $enableuseremail = 'false';
1427 $enableemail = 'false';
1428 $eauthent = 'false';
1429 $enotifusertalk = 'false';
1430 $enotifwatchlist = 'false';
1433 $file = @fopen
( "/dev/urandom", "r" );
1435 $secretKey = bin2hex( fread( $file, 32 ) );
1439 for ( $i=0; $i<8; $i++
) {
1440 $secretKey .= dechex(mt_rand(0, 0x7fffffff));
1442 print "<li>Warning: \$wgSecretKey key is insecure, generated with mt_rand(). Consider changing it manually.</li>\n";
1445 # Add slashes to strings for double quoting
1446 $slconf = array_map( "escapePhpString", get_object_vars( $conf ) );
1447 if( $conf->License
== 'gfdl' ) {
1448 # Needs literal string interpolation for the current style path
1449 $slconf['RightsIcon'] = $conf->RightsIcon
;
1453 # This file was automatically generated by the MediaWiki installer.
1454 # If you make manual changes, please keep track in case you need to
1455 # recreate them later.
1457 # See includes/DefaultSettings.php for all configurable settings
1458 # and their default values, but don't forget to make changes in _this_
1461 # If you customize your file layout, set \$IP to the directory that contains
1462 # the other MediaWiki files. It will be used as a base to locate files.
1463 if( defined( 'MW_INSTALL_PATH' ) ) {
1464 \$IP = MW_INSTALL_PATH;
1466 \$IP = dirname( __FILE__ );
1469 \$path = array( \$IP, \"\$IP/includes\", \"\$IP/languages\" );
1470 set_include_path( implode( PATH_SEPARATOR, \$path ) . PATH_SEPARATOR . get_include_path() );
1472 require_once( \"includes/DefaultSettings.php\" );
1474 # If PHP's memory limit is very low, some operations may fail.
1475 " . ($conf->raiseMemory ?
'' : '# ' ) . "ini_set( 'memory_limit', '20M' );" . "
1477 if ( \$wgCommandLineMode ) {
1478 if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
1479 die( \"This script must be run from the command line\\n\" );
1482 ## Uncomment this to disable output compression
1483 # \$wgDisableOutputCompression = true;
1485 \$wgSitename = \"{$slconf['Sitename']}\";
1487 ## The URL base path to the directory containing the wiki;
1488 ## defaults for all runtime URL paths are based off of this.
1489 \$wgScriptPath = \"{$slconf['ScriptPath']}\";
1491 ## For more information on customizing the URLs please see:
1492 ## http://www.mediawiki.org/wiki/Manual:Short_URL
1494 \$wgEnableEmail = $enableemail;
1495 \$wgEnableUserEmail = $enableuseremail;
1497 \$wgEmergencyContact = \"{$slconf['EmergencyContact']}\";
1498 \$wgPasswordSender = \"{$slconf['PasswordSender']}\";
1500 ## For a detailed description of the following switches see
1501 ## http://meta.wikimedia.org/Enotif and http://meta.wikimedia.org/Eauthent
1502 ## There are many more options for fine tuning available see
1503 ## /includes/DefaultSettings.php
1504 ## UPO means: this is also a user preference option
1505 \$wgEnotifUserTalk = $enotifusertalk; # UPO
1506 \$wgEnotifWatchlist = $enotifwatchlist; # UPO
1507 \$wgEmailAuthentication = $eauthent;
1509 \$wgDBtype = \"{$slconf['DBtype']}\";
1510 \$wgDBserver = \"{$slconf['DBserver']}\";
1511 \$wgDBname = \"{$slconf['DBname']}\";
1512 \$wgDBuser = \"{$slconf['DBuser']}\";
1513 \$wgDBpassword = \"{$slconf['DBpassword']}\";
1515 # MySQL specific settings
1516 \$wgDBprefix = \"{$slconf['DBprefix']}\";
1518 # MySQL table options to use during installation or update
1519 \$wgDBTableOptions = \"{$slconf['DBTableOptions']}\";
1521 # Experimental charset support for MySQL 4.1/5.0.
1522 \$wgDBmysql5 = {$conf->DBmysql5};
1524 # Postgres specific settings
1525 \$wgDBport = \"{$slconf['DBport']}\";
1526 \$wgDBmwschema = \"{$slconf['DBmwschema']}\";
1527 \$wgDBts2schema = \"{$slconf['DBts2schema']}\";
1529 ## Shared memory settings
1530 \$wgMainCacheType = $cacheType;
1531 \$wgMemCachedServers = $mcservers;
1533 ## To enable image uploads, make sure the 'images' directory
1534 ## is writable, then set this to true:
1535 \$wgEnableUploads = false;
1536 {$magic}\$wgUseImageMagick = true;
1537 {$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
1539 ## If you want to use image uploads under safe mode,
1540 ## create the directories images/archive, images/thumb and
1541 ## images/temp, and make them all writable. Then uncomment
1542 ## this, if it's not already uncommented:
1543 {$hashedUploads}\$wgHashedUploadDirectory = false;
1545 ## If you have the appropriate support software installed
1546 ## you can enable inline LaTeX equations:
1549 \$wgLocalInterwiki = \$wgSitename;
1551 \$wgLanguageCode = \"{$slconf['LanguageCode']}\";
1553 \$wgProxyKey = \"$secretKey\";
1555 ## Default skin: you can change the default skin. Use the internal symbolic
1556 ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook':
1557 \$wgDefaultSkin = 'monobook';
1559 ## For attaching licensing metadata to pages, and displaying an
1560 ## appropriate copyright notice / icon. GNU Free Documentation
1561 ## License and Creative Commons licenses are supported so far.
1562 {$rights}\$wgEnableCreativeCommonsRdf = true;
1563 \$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright
1564 \$wgRightsUrl = \"{$slconf['RightsUrl']}\";
1565 \$wgRightsText = \"{$slconf['RightsText']}\";
1566 \$wgRightsIcon = \"{$slconf['RightsIcon']}\";
1567 # \$wgRightsCode = \"{$slconf['RightsCode']}\"; # Not yet used
1569 \$wgDiff3 = \"{$slconf['diff3']}\";
1571 # When you make changes to this configuration file, this will make
1572 # sure that cached pages are cleared.
1573 \$configdate = gmdate( 'YmdHis', @filemtime( __FILE__ ) );
1574 \$wgCacheEpoch = max( \$wgCacheEpoch, \$configdate );
1575 "; ## End of setting the $localsettings string
1577 // Keep things in Unix line endings internally;
1578 // the system will write out as local text type.
1579 return str_replace( "\r\n", "\n", $localsettings );
1582 function dieout( $text ) {
1583 die( $text . "\n\n</body>\n</html>" );
1586 function importVar( &$var, $name, $default = "" ) {
1587 if( isset( $var[$name] ) ) {
1588 $retval = $var[$name];
1589 if ( get_magic_quotes_gpc() ) {
1590 $retval = stripslashes( $retval );
1598 function importPost( $name, $default = "" ) {
1599 return importVar( $_POST, $name, $default );
1602 function importCheck( $name ) {
1603 return isset( $_POST[$name] );
1606 function importRequest( $name, $default = "" ) {
1607 return importVar( $_REQUEST, $name, $default );
1612 function aField( &$conf, $field, $text, $type = "text", $value = "", $onclick = '' ) {
1615 $xtype = "type=\"$type\"";
1621 $nolabel = ($type == "radio") ||
($type == "hidden");
1623 if ($type == 'radio')
1624 $id .= $radioCount++
;
1629 echo "\t\t<label class='column' for=\"$id\">$text</label>\n";
1632 if( $type == "radio" && $value == $conf->$field ) {
1633 $checked = "checked='checked'";
1637 echo "\t\t<input $xtype name=\"$field\" id=\"$id\" class=\"iput-$type\" $checked ";
1639 echo " onclick='toggleDBarea(\"$value\",1)' " ;
1642 if( $type == "radio" ) {
1643 echo htmlspecialchars( $value );
1645 echo htmlspecialchars( $conf->$field );
1651 echo " $text</label>\n";
1655 if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n";
1658 function getLanguageList() {
1659 global $wgLanguageNames;
1660 if( !isset( $wgLanguageNames ) ) {
1661 require_once( "languages/Names.php" );
1666 $d = opendir( "../languages/messages" );
1667 /* In case we are called from the root directory */
1669 $d = opendir( "languages/messages");
1670 while( false !== ($f = readdir( $d ) ) ) {
1672 if( preg_match( '/Messages([A-Z][a-z_]+)\.php$/', $f, $m ) ) {
1673 $code = str_replace( '_', '-', strtolower( $m[1] ) );
1674 if( isset( $wgLanguageNames[$code] ) ) {
1675 $name = $code . ' - ' . $wgLanguageNames[$code];
1679 $codes[$code] = $name;
1687 #Check for location of an executable
1688 # @param string $loc single location to check
1689 # @param array $names filenames to check for.
1690 # @param mixed $versioninfo array of details to use when checking version, use false for no version checking
1691 function locate_executable($loc, $names, $versioninfo = false) {
1692 if (!is_array($names))
1693 $names = array($names);
1695 foreach ($names as $name) {
1696 $command = "$loc".DIRECTORY_SEPARATOR
."$name";
1697 if (file_exists($command)) {
1701 $file = str_replace('$1', $command, $versioninfo[0]);
1702 if (strstr(`
$file`
, $versioninfo[1]) !== false)
1709 # Test a memcached server
1710 function testMemcachedServer( $server ) {
1711 $hostport = explode(":", $server);
1714 if ( !function_exists( 'fsockopen' ) ) {
1715 $errstr = "Can't connect to memcached, fsockopen() not present";
1717 if ( !$errstr && count( $hostport ) != 2 ) {
1718 $errstr = 'Please specify host and port';
1719 var_dump( $hostport );
1722 list( $host, $port ) = $hostport;
1726 $fp = @fsockopen
( $host, $port, $errno, $fsockerr, 1.0 );
1727 if ( $fp === false ) {
1728 $errstr = "Cannot connect to memcached on $host:$port : $fsockerr";
1732 $command = "version\r\n";
1733 $bytes = fwrite( $fp, $command );
1734 if ( $bytes != strlen( $command ) ) {
1735 $errstr = "Cannot write to memcached socket on $host:$port";
1739 $expected = "VERSION ";
1740 $response = fread( $fp, strlen( $expected ) );
1741 if ( $response != $expected ) {
1742 $errstr = "Didn't get correct memcached response from $host:$port";
1749 echo "<li>Connected to memcached on $host:$port successfully";
1754 function database_picker($conf) {
1757 foreach(array_keys($ourdb) as $db) {
1758 if ($ourdb[$db]['havedriver']) {
1760 aField( $conf, "DBtype", $ourdb[$db]['fullname'], 'radio', $db, 'onclick');
1767 function database_switcher($db) {
1769 $color = $ourdb[$db]['bgcolor'];
1770 $full = $ourdb[$db]['fullname'];
1771 print "<div id='$db' style='display:none; background: $color'>\n";
1772 print "<h3>$full specific options:</h3>\n";
1775 function printListItem( $item ) {
1776 print "<li>$item</li>";
1781 <div
class="license">
1783 <p
>This program is free software
; you can redistribute it
and/or modify
1784 it under the terms of the GNU General
Public License
as published by
1785 the Free Software Foundation
; either version
2 of the License
, or
1786 (at your option
) any later version
.</p
>
1788 <p
>This program is distributed in the hope that it will be useful
,
1789 but WITHOUT ANY WARRANTY
; without even the implied warranty of
1790 MERCHANTABILITY
or FITNESS
FOR A PARTICULAR PURPOSE
. See the
1791 GNU General
Public License
for more details
.</p
>
1793 <p
>You should have received
<a href
="../COPYING">a copy of the GNU General
Public License
</a
>
1794 along with this program
; if not
, write to the Free Software
1795 Foundation
, Inc
., 51 Franklin Street
, Fifth Floor
, Boston
, MA
02110-1301, USA
.
1796 or <a href
="http://www.gnu.org/copyleft/gpl.html">read it online
</a
></p
>
1802 <div id
="column-one">
1803 <div
class="portlet" id
="p-logo">
1804 <a style
="background-image: url(../skins/common/images/mediawiki.png);"
1805 href
="http://www.mediawiki.org/"
1806 title
="Main Page"></a
>
1808 <script type
="text/javascript"> if (window
.isMSIE55
) fixalpha(); </script
>
1809 <div
class='portlet'><div
class='pBody'>
1811 <li
><strong
><a href
="http://www.mediawiki.org/">MediaWiki home
</a
></strong
></li
>
1812 <li
><a href
="../README">Readme
</a
></li
>
1813 <li
><a href
="../RELEASE-NOTES">Release notes
</a
></li
>
1814 <li
><a href
="../docs/">Documentation
</a
></li
>
1815 <li
><a href
="http://meta.wikipedia.org/wiki/MediaWiki_User's_Guide">User
's Guide</a></li>
1816 <li><a href="http://meta.wikimedia.org/wiki/MediaWiki_FAQ">FAQ</a></li>
1818 <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>