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
;
157 span
.success
-message
{
167 <script type
="text/javascript">
170 <?php
foreach (array_keys($ourdb) as $db) {
171 echo "\n document.getElementById('$db').style.display='none';";
176 function toggleDBarea(id
,defaultroot
) {
178 var dbarea
= document
.getElementById(id
).style
;
179 dbarea
.display
= (dbarea
.display
== 'none') ?
'block' : 'none';
180 var db
= document
.getElementById('RootUser');
182 <?php
foreach (array_keys($ourdb) as $db) {
183 echo " if (id == '$db') { db.value = '".$ourdb[$db]['rootuser']."';}\n";
192 <div id
="globalWrapper">
193 <div id
="column-content">
195 <div id
="bodyContent">
197 <h1
>MediaWiki
<?php
print $wgVersion ?
> Installation
</h1
>
201 /* Check for existing configurations and bug out! */
203 if( file_exists( "../LocalSettings.php" ) ) {
204 dieout( "<p><strong>Setup has completed, <a href='../index.php'>your wiki</a> is configured.</strong></p>
206 <p>Please delete the /config directory for extra security.</p></div></div></div></div>" );
209 if( file_exists( "./LocalSettings.php" ) ) {
210 writeSuccessMessage();
215 if( !is_writable( "." ) ) {
216 dieout( "<h2>Can't write config file, aborting</h2>
218 <p>In order to configure the wiki you have to make the <tt>config</tt> subdirectory
219 writable by the web server. Once configuration is done you'll move the created
220 <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can
221 then remove the <tt>config</tt> subdirectory entirely.</p>
223 <p>To make the directory writable on a Unix/Linux system:</p>
226 cd <i>/path/to/wiki</i>
230 <p>Afterwards retry to start the <a href=\"\">setup</a>.</p>" );
234 require_once( "install-utils.inc" );
235 require_once( "maintenance/updaters.inc" );
238 function getEncoded( $data ) {
239 # removing latin1 support, no need...
242 function getSitename() { return $this->getEncoded( $this->Sitename
); }
243 function getSysopName() { return $this->getEncoded( $this->SysopName
); }
244 function getSysopPass() { return $this->getEncoded( $this->SysopPass
); }
246 function setSchema( $schema, $engine ) {
247 $this->DBschema
= $schema;
248 if ( !preg_match( '/^\w*$/', $engine ) ){
251 switch ( $this->DBschema
) {
253 $this->DBTableOptions
= "ENGINE=$engine, DEFAULT CHARSET=utf8";
254 $this->DBmysql5
= 'true';
256 case 'mysql5-binary':
257 $this->DBTableOptions
= "ENGINE=$engine, DEFAULT CHARSET=binary";
258 $this->DBmysql5
= 'true';
261 $this->DBTableOptions
= "TYPE=$engine";
262 $this->DBmysql5
= 'false';
264 $this->DBengine
= $engine;
266 # Set the global for use during install
267 global $wgDBTableOptions;
268 $wgDBTableOptions = $this->DBTableOptions
;
276 <b
>Don
't forget security updates!</b> Keep an eye on the
277 <a href="http://mail.wikimedia.org/mailman/listinfo/mediawiki-announce">low-traffic
278 release announcements mailing list</a>.
283 <h2>Checking environment...</h2>
284 <p><em>Please include all of the lines below when reporting installation problems.</em></p>
285 <ul class="env-check">
289 define( 'MW_NO_OUTPUT_BUFFER
', 1 );
290 $conf = new ConfigData;
292 install_version_checks();
293 $self = 'Installer
'; # Maintenance script name, to please Setup.php
295 print "<li>PHP " . phpversion() . " installed</li>\n";
297 error_reporting( 0 );
298 $phpdatabases = array();
299 foreach (array_keys($ourdb) as $db) {
300 $compname = $ourdb[$db]['compile
'];
301 if (extension_loaded($compname) or dl($compname . '.' . PHP_SHLIB_SUFFIX)) {
302 array_push($phpdatabases, $db);
303 $ourdb[$db]['havedriver
'] = 1;
306 error_reporting( E_ALL );
308 if (!$phpdatabases) {
309 print "Could not find a suitable database driver!<ul>";
310 foreach (array_keys($ourdb) AS $db) {
311 $comp = $ourdb[$db]['compile
'];
312 $full = $ourdb[$db]['fullname
'];
313 print "<li>For <b>$full</b>, compile PHP using <b>--with-$comp</b>, "
314 ."or install the $comp.so module</li>\n";
316 dieout( "</ul></ul>" );
319 print "<li>Found database drivers for:";
321 foreach (array_keys($ourdb) AS $db) {
322 if ($ourdb[$db]['havedriver
']) {
323 if ( $DefaultDBtype == '' ) {
324 $DefaultDBtype = $db;
326 print " ".$ourdb[$db]['fullname
'];
331 if( ini_get( "register_globals" ) ) {
334 <div style="font-size:110%">
335 <strong class="error">Warning:</strong>
336 <strong>PHP's
<tt
><a href
="http://php.net/register_globals">register_globals
</a
></tt
> option is enabled
. Disable it
if you can
.</strong
>
338 MediaWiki will work
, but your server is more exposed to PHP
-based security vulnerabilities
.
345 if( ini_get( "magic_quotes_runtime" ) ) {
347 ?
><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
>
348 This option corrupts data input unpredictably
; you cannot install
or use
349 MediaWiki unless this option is disabled
.
353 if( ini_get( "magic_quotes_sybase" ) ) {
355 ?
><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
>
356 This option corrupts data input unpredictably
; you cannot install
or use
357 MediaWiki unless this option is disabled
.
361 if( ini_get( "mbstring.func_overload" ) ) {
363 ?
><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
>
364 This option causes errors
and may corrupt data unpredictably
;
365 you cannot install
or use MediaWiki unless this option is disabled
.
369 if( ini_get( "zend.ze1_compatibility_mode" ) ) {
371 ?
><li
class="error"><strong
>Fatal
: <a href
="http://www.php.net/manual/en/ini.core.php">zend
.ze1_compatibility_mode
</a
> is active
!</strong
>
372 This option causes horrible bugs with MediaWiki
; you cannot install
or use
373 MediaWiki unless this option is disabled
.
379 dieout( "</ul><p>Cannot install MediaWiki.</p>" );
382 if( ini_get( "safe_mode" ) ) {
383 $conf->safeMode
= true;
385 <li
><b
class='error'>Warning
:</b
> <strong
>PHP
's
386 <a href='http
://www.php.net/features.safe-mode'>safe mode</a> is active.</strong>
387 You may have problems caused by this
, particularly
if using image uploads
.
391 $conf->safeMode
= false;
394 $sapi = php_sapi_name();
395 print "<li>PHP server API is $sapi; ";
396 if( $wgUsePathInfo ) {
397 print "ok, using pretty URLs (<tt>index.php/Page_Title</tt>)";
399 print "using ugly URLs (<tt>index.php?title=Page_Title</tt>)";
403 $conf->xml
= function_exists( "utf8_encode" );
405 print "<li>Have XML / Latin1-UTF-8 conversion support.</li>\n";
407 dieout( "PHP's XML module is missing; the wiki requires functions in
408 this module and won't work in this configuration.
409 If you're running Mandrake, install the php-xml package." );
412 # Check for session support
413 if( !function_exists( 'session_name' ) )
414 dieout( "PHP's session module is missing. MediaWiki requires session support in order to function." );
416 # session.save_path doesn't *have* to be set, but if it is, and it's
417 # not valid/writable/etc. then it can cause problems
418 $sessionSavePath = mw_get_session_save_path();
419 $ssp = htmlspecialchars( $sessionSavePath );
420 # Warn the user if it's not set, but let them proceed
421 if( !$sessionSavePath ) {
422 print "<li><strong>Warning:</strong> A value for <tt>session.save_path</tt>
423 has not been set in PHP.ini. If the default value causes problems with
424 saving session data, set it to a valid path which is read/write/execute
425 for the user your web server is running under.</li>";
426 } elseif ( is_dir( $sessionSavePath ) && is_writable( $sessionSavePath ) ) {
427 # All good? Let the user know
428 print "<li>Session save path (<tt>{$ssp}</tt>) appears to be valid.</li>";
430 # Something not right? Warn the user, but let them proceed
431 print "<li><strong>Warning:</strong> Your <tt>session.save_path</tt> value (<tt>{$ssp}</tt>)
432 appears to be invalid or is not writable. PHP needs to be able to save data to
433 this location for correct session operation.</li>";
436 # Check for PCRE support
437 if( !function_exists( 'preg_match' ) )
438 dieout( "The PCRE support module appears to be missing. MediaWiki requires the
439 Perl-compatible regular expression functions." );
441 $memlimit = ini_get( "memory_limit" );
442 $conf->raiseMemory
= false;
443 if( empty( $memlimit ) ||
$memlimit == -1 ) {
444 print "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n";
446 print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars( $memlimit ) . ". ";
447 $n = intval( $memlimit );
448 if( preg_match( '/^([0-9]+)[Mm]$/', trim( $memlimit ), $m ) ) {
449 $n = intval( $m[1] * (1024*1024) );
451 if( $n < 20*1024*1024 ) {
452 print "Attempting to raise limit to 20M... ";
453 if( false === ini_set( "memory_limit", "20M" ) ) {
454 print "failed.<br /><b>" . htmlspecialchars( $memlimit ) . " seems too low, installation may fail!</b>";
456 $conf->raiseMemory
= true;
463 $conf->turck
= function_exists( 'mmcache_get' );
464 if ( $conf->turck
) {
465 print "<li><a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> installed</li>\n";
468 $conf->xcache
= function_exists( 'xcache_get' );
470 print "<li><a href=\"http://trac.lighttpd.net/xcache/\">XCache</a> installed</li>";
472 $conf->apc
= function_exists('apc_fetch');
474 print "<li><a href=\"http://www.php.net/apc\">APC</a> installed</li>";
477 $conf->eaccel
= function_exists( 'eaccelerator_get' );
478 if ( $conf->eaccel
) {
479 $conf->turck
= 'eaccelerator';
480 print "<li><a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> installed</li>\n";
483 if( !( $conf->turck ||
$conf->eaccel ||
$conf->apc ||
$conf->xcache
) ) {
484 echo( '<li>Couldn\'t find <a href="http://turck-mmcache.sourceforge.net">Turck MMCache</a>,
485 <a href="http://eaccelerator.sourceforge.net">eAccelerator</a>,
486 <a href="http://www.php.net/apc">APC</a> or <a href="http://trac.lighttpd.net/xcache/">XCache</a>.
487 Object caching functions cannot be used.</li>' );
490 $conf->diff3
= false;
491 $diff3locations = array_merge(
498 explode( $sep, getenv( "PATH" ) ) );
499 $diff3names = array( "gdiff3", "diff3", "diff3.exe" );
501 $diff3versioninfo = array( '$1 --version 2>&1', 'diff3 (GNU diffutils)' );
502 foreach ($diff3locations as $loc) {
503 $exe = locate_executable($loc, $diff3names, $diff3versioninfo);
504 if ($exe !== false) {
511 print "<li>Found GNU diff3: <tt>$conf->diff3</tt>.</li>";
513 print "<li>GNU diff3 not found.</li>";
515 $conf->ImageMagick
= false;
516 $imcheck = array( "/usr/bin", "/opt/csw/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" );
517 foreach( $imcheck as $dir ) {
518 $im = "$dir/convert";
519 if( file_exists( $im ) ) {
520 print "<li>Found ImageMagick: <tt>$im</tt>; image thumbnailing will be enabled if you enable uploads.</li>\n";
521 $conf->ImageMagick
= $im;
526 $conf->HaveGD
= function_exists( "imagejpeg" );
527 if( $conf->HaveGD
) {
528 print "<li>Found GD graphics library built-in";
529 if( !$conf->ImageMagick
) {
530 print ", image thumbnailing will be enabled if you enable uploads";
534 if( !$conf->ImageMagick
) {
535 print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n";
539 $conf->IP
= dirname( dirname( __FILE__
) );
540 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP
) . "</tt></li>\n";
543 // PHP_SELF isn't available sometimes, such as when PHP is CGI but
544 // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
545 // to get the path to the current script... hopefully it's reliable. SIGH
546 $path = ($_SERVER["PHP_SELF"] === '')
547 ?
$_SERVER["SCRIPT_NAME"]
548 : $_SERVER["PHP_SELF"];
549 $conf->ScriptPath
= preg_replace( '{^(.*)/config.*$}', '$1', $path );
550 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath
) . "</tt></li>\n";
552 print "<li style='font-weight:bold;color:green;font-size:110%'>Environment checked. You can install MediaWiki.</li>\n";
553 $conf->posted
= ($_SERVER["REQUEST_METHOD"] == "POST");
555 $conf->Sitename
= ucfirst( importPost( "Sitename", "" ) );
556 $defaultEmail = empty( $_SERVER["SERVER_ADMIN"] )
558 : $_SERVER["SERVER_ADMIN"];
559 $conf->EmergencyContact
= importPost( "EmergencyContact", $defaultEmail );
560 $conf->DBtype
= importPost( "DBtype", $DefaultDBtype );
564 $conf->DBserver
= importPost( "DBserver", "localhost" );
565 $conf->DBname
= importPost( "DBname", "wikidb" );
566 $conf->DBuser
= importPost( "DBuser", "wikiuser" );
567 $conf->DBpassword
= importPost( "DBpassword" );
568 $conf->DBpassword2
= importPost( "DBpassword2" );
569 $conf->SysopName
= importPost( "SysopName", "WikiSysop" );
570 $conf->SysopPass
= importPost( "SysopPass" );
571 $conf->SysopPass2
= importPost( "SysopPass2" );
572 $conf->RootUser
= importPost( "RootUser", "root" );
573 $conf->RootPW
= importPost( "RootPW", "" );
574 $useRoot = importCheck( 'useroot', false );
575 $conf->LanguageCode
= importPost( "LanguageCode", "en" );
578 $conf->DBprefix
= importPost( "DBprefix" );
580 importPost( "DBschema", "mysql4" ),
581 importPost( "DBengine", "InnoDB" ) );
583 ## Postgres specific:
584 $conf->DBport
= importPost( "DBport", "5432" );
585 $conf->DBmwschema
= importPost( "DBmwschema", "mediawiki" );
586 $conf->DBts2schema
= importPost( "DBts2schema", "public" );
588 /* Check for validity */
591 if( $conf->Sitename
== "" ||
$conf->Sitename
== "MediaWiki" ||
$conf->Sitename
== "Mediawiki" ) {
592 $errs["Sitename"] = "Must not be blank or \"MediaWiki\"";
594 if( $conf->DBuser
== "" ) {
595 $errs["DBuser"] = "Must not be blank";
597 if( ($conf->DBtype
== 'mysql') && (strlen($conf->DBuser
) > 16) ) {
598 $errs["DBuser"] = "Username too long";
600 if( $conf->DBpassword
== "" && $conf->DBtype
!= "postgres" ) {
601 $errs["DBpassword"] = "Must not be blank";
603 if( $conf->DBpassword
!= $conf->DBpassword2
) {
604 $errs["DBpassword2"] = "Passwords don't match!";
606 if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix
) ) {
607 $errs["DBprefix"] = "Invalid table prefix";
610 error_reporting( E_ALL
);
613 * Initialise $wgLang and $wgContLang to something so we can
614 * call case-folding methods. Per Brion, this is English for
615 * now, although we could be clever and initialise to the
616 * user-selected language.
618 $wgContLang = Language
::factory( 'en' );
619 $wgLang = $wgContLang;
622 * We're messing about with users, so we need a stub
623 * authentication plugin...
625 $wgAuth = new AuthPlugin();
628 * Validate the initial administrator account; username,
629 * password checks, etc.
631 if( $conf->SysopName
) {
632 # Check that the user can be created
633 $u = User
::newFromName( $conf->SysopName
);
634 if( $u instanceof User
) {
635 # Various password checks
636 if( $conf->SysopPass
!= '' ) {
637 if( $conf->SysopPass
== $conf->SysopPass2
) {
638 if( !$u->isValidPassword( $conf->SysopPass
) ) {
639 $errs['SysopPass'] = "Bad password";
642 $errs['SysopPass2'] = "Passwords don't match";
645 $errs['SysopPass'] = "Cannot be blank";
649 $errs['SysopName'] = "Bad username";
653 $conf->License
= importRequest( "License", "none" );
654 if( $conf->License
== "gfdl" ) {
655 $conf->RightsUrl
= "http://www.gnu.org/copyleft/fdl.html";
656 $conf->RightsText
= "GNU Free Documentation License 1.2";
657 $conf->RightsCode
= "gfdl";
658 $conf->RightsIcon
= '${wgScriptPath}/skins/common/images/gnu-fdl.png';
659 } elseif( $conf->License
== "none" ) {
660 $conf->RightsUrl
= $conf->RightsText
= $conf->RightsCode
= $conf->RightsIcon
= "";
662 $conf->RightsUrl
= importRequest( "RightsUrl", "" );
663 $conf->RightsText
= importRequest( "RightsText", "" );
664 $conf->RightsCode
= importRequest( "RightsCode", "" );
665 $conf->RightsIcon
= importRequest( "RightsIcon", "" );
668 $conf->Shm
= importRequest( "Shm", "none" );
669 $conf->MCServers
= importRequest( "MCServers" );
671 /* Test memcached servers */
673 if ( $conf->Shm
== 'memcached' && $conf->MCServers
) {
674 $conf->MCServerArray
= array_map( 'trim', explode( ',', $conf->MCServers
) );
675 foreach ( $conf->MCServerArray
as $server ) {
676 $error = testMemcachedServer( $server );
678 $errs["MCServers"] = $error;
682 } else if ( $conf->Shm
== 'memcached' ) {
683 $errs["MCServers"] = "Please specify at least one server if you wish to use memcached";
686 /* default values for installation */
687 $conf->Email
= importRequest("Email", "email_enabled");
688 $conf->Emailuser
= importRequest("Emailuser", "emailuser_enabled");
689 $conf->Enotif
= importRequest("Enotif", "enotif_allpages");
690 $conf->Eauthent
= importRequest("Eauthent", "eauthent_enabled");
692 if( $conf->posted
&& ( 0 == count( $errs ) ) ) {
693 do { /* So we can 'continue' to end prematurely */
694 $conf->Root
= ($conf->RootPW
!= "");
696 /* Load up the settings and get installin' */
697 $local = writeLocalSettings( $conf );
698 echo "<li style=\"list-style: none\">\n";
699 echo "<p><b>Generating configuration file...</b></p>\n";
702 $wgCommandLineMode = false;
704 $ok = eval( $local );
705 if( $ok === false ) {
706 dieout( "Errors in generated configuration; " .
707 "most likely due to a bug in the installer... " .
708 "Config file was: " .
710 htmlspecialchars( $local ) .
714 $conf->DBtypename
= '';
715 foreach (array_keys($ourdb) as $db) {
716 if ($conf->DBtype
=== $db)
717 $conf->DBtypename
= $ourdb[$db]['fullname'];
719 if ( ! strlen($conf->DBtype
)) {
720 $errs["DBpicktype"] = "Please choose a database type";
724 if (! $conf->DBtypename
) {
725 $errs["DBtype"] = "Unknown database type '$conf->DBtype'";
728 print "<li>Database type: {$conf->DBtypename}</li>\n";
729 $dbclass = 'Database'.ucfirst($conf->DBtype
);
730 $wgDBtype = $conf->DBtype
;
731 $wgDBadminuser = "root";
732 $wgDBadminpassword = $conf->RootPW
;
735 $wgDBprefix = $conf->DBprefix
;
737 ## Postgres specific:
738 $wgDBport = $conf->DBport
;
739 $wgDBmwschema = $conf->DBmwschema
;
740 $wgDBts2schema = $conf->DBts2schema
;
742 $wgCommandLineMode = true;
743 $wgUseDatabaseMessages = false; /* FIXME: For database failure */
744 require_once( "includes/Setup.php" );
747 $wgTitle = Title
::newFromText( "Installation script" );
748 error_reporting( E_ALL
);
749 print "<li>Loading class: $dbclass";
752 if( $conf->DBtype
== 'mysql' ) {
753 $mysqlOldClient = version_compare( mysql_get_client_info(), "4.1.0", "lt" );
754 if( $mysqlOldClient ) {
755 print "<li><b>PHP is linked with old MySQL client libraries. If you are
756 using a MySQL 4.1 server and have problems connecting to the database,
757 see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
758 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b></li>\n";
760 $ok = true; # Let's be optimistic
762 # Decide if we're going to use the superuser or the regular database user
763 $conf->Root
= $useRoot;
765 $db_user = $conf->RootUser
;
766 $db_pass = $conf->RootPW
;
768 $db_user = $wgDBuser;
769 $db_pass = $wgDBpassword;
773 echo( "<li>Attempting to connect to database server as $db_user..." );
774 $wgDatabase = Database
::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 );
776 # Check the connection and respond to errors
777 if( $wgDatabase->isOpen() ) {
780 $wgDBadminuser = $db_user;
781 $wgDBadminpassword = $db_pass;
782 echo( "success.</li>\n" );
783 $wgDatabase->ignoreErrors( true );
784 $myver = $wgDatabase->getServerVersion();
786 # There were errors, report them and back out
788 $errno = mysql_errno();
789 $errtx = htmlspecialchars( mysql_error() );
793 echo( "failed due to authentication errors. Check passwords.</li>" );
795 # The superuser details are wrong
796 $errs["RootUser"] = "Check username";
797 $errs["RootPW"] = "and password";
799 # The regular user details are wrong
800 $errs["DBuser"] = "Check username";
801 $errs["DBpassword"] = "and password";
807 # General connection problem
808 echo( "failed with error [$errno] $errtx.</li>\n" );
809 $errs["DBserver"] = "Connection failed";
814 if( !$ok ) { continue; }
816 } else /* not mysql */ {
817 error_reporting( E_ALL
);
819 ## Possible connect as a superuser
821 $wgDBsuperuser = $conf->RootUser
;
822 echo( "<li>Attempting to connect to database \"postgres\" as superuser \"$wgDBsuperuser\"..." );
823 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBsuperuser, $conf->RootPW
, "postgres", 1);
824 if (!$wgDatabase->isOpen()) {
825 print " error: " . $wgDatabase->lastError() . "</li>\n";
826 $errs["DBserver"] = "Could not connect to database as superuser";
827 $errs["RootUser"] = "Check username";
828 $errs["RootPW"] = "and password";
832 echo( "<li>Attempting to connect to database \"$wgDBname\" as \"$wgDBuser\"..." );
833 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1);
834 if (!$wgDatabase->isOpen()) {
835 print " error: " . $wgDatabase->lastError() . "</li>\n";
837 $myver = $wgDatabase->getServerVersion();
841 if ( !$wgDatabase->isOpen() ) {
842 $errs["DBserver"] = "Couldn't connect to database";
846 print "<li>Connected to $myver";
847 if ($conf->DBtype
== 'mysql') {
848 if( version_compare( $myver, "4.0.14" ) < 0 ) {
849 dieout( " -- mysql 4.0.14 or later required. Aborting." );
851 $mysqlNewAuth = version_compare( $myver, "4.1.0", "ge" );
852 if( $mysqlNewAuth && $mysqlOldClient ) {
853 print "; <b class='error'>You are using MySQL 4.1 server, but PHP is linked
854 to old client libraries; if you have trouble with authentication, see
855 <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
856 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>";
859 if( $mysqlNewAuth ) {
860 print "; enabling MySQL 4.1/5.0 charset mode";
862 print "; <b class='error'>MySQL 4.1/5.0 charset mode enabled,
863 but older version detected; will likely fail.</b>";
868 @$sel = $wgDatabase->selectDB( $wgDBname );
870 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
872 $err = mysql_errno();
873 $databaseSafe = htmlspecialchars( $wgDBname );
874 if( $err == 1102 /* Invalid database name */ ) {
875 print "<ul><li><strong>{$databaseSafe}</strong> is not a valid database name.</li></ul>";
877 } elseif( $err != 1049 /* Database doesn't exist */ ) {
878 print "<ul><li>Error selecting database <strong>{$databaseSafe}</strong>: {$err} ";
879 print htmlspecialchars( mysql_error() ) . "</li></ul>";
882 print "<li>Attempting to create database...</li>";
883 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
885 print "<li>Couldn't create database <tt>" .
886 htmlspecialchars( $wgDBname ) .
887 "</tt>; try with root access or check your username/pass.</li>\n";
888 $errs["RootPW"] = "<- Enter";
891 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
893 $wgDatabase->selectDB( $wgDBname );
895 else if ($conf->DBtype
== 'postgres') {
896 if( version_compare( $myver, "PostgreSQL 8.0" ) < 0 ) {
897 dieout( " <b>Postgres 8.0 or later is required</b>. Aborting.</li></ul>" );
901 if( $wgDatabase->tableExists( "cur" ) ||
$wgDatabase->tableExists( "revision" ) ) {
902 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n";
904 if ( $conf->DBtype
== 'mysql') {
905 # Determine existing default character set
906 if ( $wgDatabase->tableExists( "revision" ) ) {
907 $revision = $wgDatabase->escapeLike( $conf->DBprefix
. 'revision' );
908 $res = $wgDatabase->query( "SHOW TABLE STATUS LIKE '$revision'" );
909 $row = $wgDatabase->fetchObject( $res );
911 echo "<li>SHOW TABLE STATUS query failed!</li>\n";
912 $existingSchema = false;
913 $existingEngine = false;
915 if ( preg_match( '/^latin1/', $row->Collation
) ) {
916 $existingSchema = 'mysql4';
917 } elseif ( preg_match( '/^utf8/', $row->Collation
) ) {
918 $existingSchema = 'mysql5';
919 } elseif ( preg_match( '/^binary/', $row->Collation
) ) {
920 $existingSchema = 'mysql5-binary';
922 $existingSchema = false;
923 echo "<li><strong>Warning:</strong> Unrecognised existing collation</li>\n";
925 if ( isset( $row->Engine
) ) {
926 $existingEngine = $row->Engine
;
928 $existingEngine = $row->Type
;
931 if ( $existingSchema && $existingSchema != $conf->DBschema
) {
932 print "<li><strong>Warning:</strong> you requested the {$conf->DBschema} schema, " .
933 "but the existing database has the $existingSchema schema. This upgrade script ".
934 "can't convert it, so it will remain $existingSchema.</li>\n";
935 $conf->setSchema( $existingSchema, $conf->DBengine
);
937 if ( $existingEngine && $existingEngine != $conf->DBengine
) {
938 print "<li><strong>Warning:</strong> you requested the {$conf->DBengine} storage " .
939 "engine, but the existing database uses the $existingEngine engine. This upgrade " .
940 "script can't convert it, so it will remain $existingEngine.</li>\n";
941 $conf->setSchema( $conf->DBschema
, $existingEngine );
945 # Create user if required
947 $conn = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
948 if ( $conn->isOpen() ) {
949 print "<li>DB user account ok</li>\n";
952 print "<li>Granting user permissions...";
953 if( $mysqlOldClient && $mysqlNewAuth ) {
954 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>";
957 dbsource( "../maintenance/users.sql", $wgDatabase );
961 print "</ul><pre>\n";
967 print "<ul><li>Finished update checks.</li>\n";
969 # Determine available storage engines if possible
970 if ( $conf->DBtype
== 'mysql' && version_compare( $myver, "4.1.2", "ge" ) ) {
971 $res = $wgDatabase->query( 'SHOW ENGINES' );
973 while ( $row = $wgDatabase->fetchObject( $res ) ) {
974 if ( $row->Engine
== $conf->DBengine
) {
979 $wgDatabase->freeResult( $res );
980 if ( !$found && $conf->DBengine
!= 'MyISAM' ) {
981 echo "<li><strong>Warning:</strong> {$conf->DBengine} storage engine not available, " .
982 "using MyISAM instead</li>\n";
983 $conf->setSchema( $conf->DBschema
, 'MyISAM' );
987 # FIXME: Check for errors
988 print "<li>Creating tables...";
989 if ($conf->DBtype
== 'mysql') {
990 dbsource( "../maintenance/tables.sql", $wgDatabase );
991 dbsource( "../maintenance/interwiki.sql", $wgDatabase );
992 } else if ($conf->DBtype
== 'postgres') {
993 $wgDatabase->setup_database();
996 $errs["DBtype"] = "Do not know how to handle database type '$conf->DBtype'";
1000 print " done.</li>\n";
1002 print "<li>Initializing data...</li>\n";
1003 $wgDatabase->insert( 'site_stats',
1004 array ( 'ss_row_id' => 1,
1005 'ss_total_views' => 0,
1006 'ss_total_edits' => 0,
1007 'ss_good_articles' => 0 ) );
1009 # Set up the "regular user" account *if we can, and if we need to*
1010 if( $conf->Root
and $conf->DBtype
== 'mysql') {
1012 $wgDatabase2 = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
1013 if( $wgDatabase2->isOpen() ) {
1014 # Nope, just close the test connection and continue
1015 $wgDatabase2->close();
1016 echo( "<li>User $wgDBuser exists. Skipping grants.</li>\n" );
1018 # Yes, so run the grants
1019 echo( "<li>Granting user permissions to $wgDBuser on $wgDBname..." );
1020 dbsource( "../maintenance/users.sql", $wgDatabase );
1021 echo( "success.</li>\n" );
1025 if( $conf->SysopName
) {
1026 $u = User
::newFromName( $conf->getSysopName() );
1028 print "<li><strong class=\"error\">Warning:</strong> Skipped sysop account creation - invalid username!</li>\n";
1030 else if ( 0 == $u->idForName() ) {
1031 $u->addToDatabase();
1032 $u->setPassword( $conf->getSysopPass() );
1035 $u->addGroup( "sysop" );
1036 $u->addGroup( "bureaucrat" );
1038 print "<li>Created sysop account <tt>" .
1039 htmlspecialchars( $conf->SysopName
) . "</tt>.</li>\n";
1041 print "<li>Could not create user - already exists!</li>\n";
1044 print "<li>Skipped sysop account creation, no name given.</li>\n";
1047 $titleobj = Title
::newFromText( wfMsgNoDB( "mainpage" ) );
1048 $article = new Article( $titleobj );
1049 $newid = $article->insertOn( $wgDatabase );
1050 $revision = new Revision( array(
1052 'text' => wfMsg( 'mainpagetext' ) . "\n\n" . wfMsgNoTrans( 'mainpagedocfooter' ),
1055 'user_text' => 'MediaWiki default',
1057 $revid = $revision->insertOn( $wgDatabase );
1058 $article->updateRevisionOn( $wgDatabase, $revision );
1061 /* Write out the config file now that all is well */
1062 print "<li style=\"list-style: none\">\n";
1063 print "<p>Creating LocalSettings.php...</p>\n\n";
1064 $localSettings = "<" . "?php$endl$local";
1065 // Fix up a common line-ending problem (due to CVS on Windows)
1066 $localSettings = str_replace( "\r\n", "\n", $localSettings );
1067 $f = fopen( "LocalSettings.php", 'xt' );
1070 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" .
1071 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
1072 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
1074 if(fwrite( $f, $localSettings ) ) {
1076 print "</li></ul><hr/>\n";
1077 writeSuccessMessage();
1080 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");
1081 print "</li></ul>\n";
1092 if( count( $errs ) ) {
1093 /* Display options form */
1095 if( $conf->posted
) {
1096 echo "<p class='error-top'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
1100 <form action
="index.php" name
="config" method
="post">
1103 <h2
>Site config
</h2
>
1105 <div
class="config-section">
1106 <div
class="config-input">
1108 aField( $conf, "Sitename", "Wiki name:" );
1111 <p
class="config-desc">
1112 Preferably a short word without punctuation
, i
.e
. "Wikipedia".<br
/>
1113 Will appear
as the
namespace name
for "meta" pages
, and throughout the
interface.
1116 <div
class="config-input">
1118 aField( $conf, "EmergencyContact", "Contact e-mail:" );
1121 <p
class="config-desc">
1122 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
.
1125 <div
class="config-input">
1126 <label
class='column' for="LanguageCode">Language
:</label
>
1127 <select id
="LanguageCode" name
="LanguageCode">
1130 $list = getLanguageList();
1131 foreach( $list as $code => $name ) {
1132 $sel = ($code == $conf->LanguageCode
) ?
'selected="selected"' : '';
1133 echo "\t\t<option value=\"$code\" $sel>$name</option>\n";
1138 <p
class="config-desc">
1139 Select the language
for your wiki
's interface. Some localizations aren't fully complete
. Unicode (UTF
-8) is used
for all localizations
.
1142 <div
class="config-input">
1143 <label
class='column'>Copyright
/license
:</label
>
1146 <li
><?php
aField( $conf, "License", "No license metadata", "radio", "none" ); ?
></li
>
1147 <li
><?php
aField( $conf, "License", "GNU Free Documentation License 1.2 (Wikipedia-compatible)", "radio", "gfdl" ); ?
></li
>
1149 aField( $conf, "License", "A Creative Commons license - ", "radio", "cc" );
1150 $partner = "MediaWiki";
1151 $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/index.php?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
1152 $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" );
1153 $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" );
1154 print "<a href=\"$ccApp\" target='_blank'>choose</a>";
1156 <?php
if( $conf->License
== "cc" ) { ?
>
1158 <li
><?php
aField( $conf, "RightsIcon", "<img src=\"" . htmlspecialchars( $conf->RightsIcon
) . "\" alt='(Creative Commons icon)' />", "hidden" ); ?
></li
>
1159 <li
><?php
aField( $conf, "RightsText", htmlspecialchars( $conf->RightsText
), "hidden" ); ?
></li
>
1160 <li
><?php
aField( $conf, "RightsCode", "code: " . htmlspecialchars( $conf->RightsCode
), "hidden" ); ?
></li
>
1161 <li
><?php
aField( $conf, "RightsUrl", "<a href=\"" . htmlspecialchars( $conf->RightsUrl
) . "\">" . htmlspecialchars( $conf->RightsUrl
) . "</a>", "hidden" ); ?
></li
>
1167 <p
class="config-desc">
1168 A notice
, icon
, and machine
-readable copyright metadata will be displayed
for the license you pick
.
1172 <div
class="config-input">
1173 <?php
aField( $conf, "SysopName", "Admin username:" ) ?
>
1175 <div
class="config-input">
1176 <?php
aField( $conf, "SysopPass", "Password:", "password" ) ?
>
1178 <div
class="config-input">
1179 <?php
aField( $conf, "SysopPass2", "Password confirm:", "password" ) ?
>
1181 <p
class="config-desc">
1182 An admin can lock
/delete pages
, block users from editing
, and do other maintenance tasks
.<br
/>
1183 A
new account will be added only when creating a
new wiki database
.
1185 The password cannot be the same
as the username
.
1188 <div
class="config-input">
1189 <label
class='column'>Shared memory caching
:</label
>
1192 <li
><?php
aField( $conf, "Shm", "No caching", "radio", "none" ); ?
></li
>
1194 if ( $conf->turck
) {
1196 aField( $conf, "Shm", "Turck MMCache", "radio", "turck" );
1199 if( $conf->xcache
) {
1201 aField( $conf, 'Shm', 'XCache', 'radio', 'xcache' );
1206 aField( $conf, "Shm", "APC", "radio", "apc" );
1209 if ( $conf->eaccel
) {
1211 aField( $conf, "Shm", "eAccelerator", "radio", "eaccel" );
1215 <li
><?php
aField( $conf, "Shm", "Memcached", "radio", "memcached" ); ?
></li
>
1217 <div style
="clear:left"><?php
aField( $conf, "MCServers", "Memcached servers:", "text" ) ?
></div
>
1219 <p
class="config-desc">
1220 An
object caching system such
as memcached will provide a significant performance boost
,
1221 but needs to be installed
. Provide the server addresses
and ports in a comma
-separated
list.
1223 MediaWiki can also detect
and support eAccelerator
, Turck MMCache
, APC
, and XCache
, but
1224 these should not be used
if the wiki will be running on multiple application servers
.
1228 <h2
>E
-mail
, e
-mail notification
and authentication setup
</h2
>
1230 <div
class="config-section">
1231 <div
class="config-input">
1232 <label
class='column'>E
-mail
features (global):</label
>
1234 <li
><?php
aField( $conf, "Email", "Enabled", "radio", "email_enabled" ); ?
></li
>
1235 <li
><?php
aField( $conf, "Email", "Disabled", "radio", "email_disabled" ); ?
></li
>
1238 <p
class="config-desc">
1239 Use this to disable all e
-mail
functions (password reminders
, user
-to
-user e
-mail
, and e
-mail notifications
)
1240 if sending mail doesn
't work on your server.
1243 <div class="config-input">
1244 <label class='column
'>User-to-user e-mail:</label>
1246 <li><?php aField( $conf, "Emailuser", "Enabled", "radio", "emailuser_enabled" ); ?></li>
1247 <li><?php aField( $conf, "Emailuser", "Disabled", "radio", "emailuser_disabled" ); ?></li>
1250 <p class="config-desc">
1251 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.
1253 <div class="config-input">
1254 <label class='column
'>E-mail notification about changes:</label>
1256 <li><?php aField( $conf, "Enotif", "Disabled", "radio", "enotif_disabled" ); ?></li>
1257 <li><?php aField( $conf, "Enotif", "Enabled for changes to user discussion pages only", "radio", "enotif_usertalk" ); ?></li>
1258 <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>
1261 <div class="config-desc">
1263 For this feature to work, an e-mail address must be present for the user account, and the notification
1264 options in the user's preferences must be enabled
. Also note the
1265 authentication option below
. When testing the feature
, keep in mind that your own changes will never trigger notifications to be sent to yourself
.</p
>
1267 <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
>
1270 <div
class="config-input">
1271 <label
class='column'>E
-mail address authentication
:</label
>
1273 <li
><?php
aField( $conf, "Eauthent", "Disabled", "radio", "eauthent_disabled" ); ?
></li
>
1274 <li
><?php
aField( $conf, "Eauthent", "Enabled", "radio", "eauthent_enabled" ); ?
></li
>
1277 <div
class="config-desc">
1278 <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
1279 change notification mails
. Setting this option is
<B
>recommended
</B
> for public wikis because of potential abuse of the e
-mail features above
.</p
>
1284 <h2
>Database config
</h2
>
1286 <div
class="config-section">
1287 <div
class="config-input">
1288 <label
class='column'>Database type
:</label
>
1289 <?php
if (isset($errs['DBpicktype'])) print "<span class='error'>$errs[DBpicktype]</span>\n"; ?
>
1290 <ul
class='plain'><?php
database_picker($conf) ?
></ul
>
1293 <div
class="config-input" style
="clear:left"><?php
1294 aField( $conf, "DBserver", "Database host:" );
1296 <p
class="config-desc">
1297 If your database server isn
't on your web server, enter the name or IP address here.
1300 <div class="config-input"><?php
1301 aField( $conf, "DBname", "Database name:" );
1303 <div class="config-input"><?php
1304 aField( $conf, "DBuser", "DB username:" );
1306 <div class="config-input"><?php
1307 aField( $conf, "DBpassword", "DB password:", "password" );
1309 <div class="config-input"><?php
1310 aField( $conf, "DBpassword2", "DB password confirm:", "password" );
1312 <p class="config-desc">
1313 If you only have a single user account and database available,
1314 enter those here. If you have database root access (see below)
1315 you can specify new accounts/databases to be created. This account
1316 will not be created if it pre-exists. If this is the case, ensure that it
1317 has SELECT, INSERT, UPDATE, and DELETE permissions on the MediaWiki database.
1320 <div class="config-input">
1321 <label class="column">Superuser account:</label>
1322 <input type="checkbox" name="useroot" id="useroot" <?php if( $useRoot ) { ?>checked="checked" <?php } ?>/>
1323 <label for="useroot">Use superuser account</label>
1325 <div class="config-input">
1327 aField( $conf, "RootUser", "Superuser name:", "superuser" );
1330 <div class="config-input">
1332 aField( $conf, "RootPW", "Superuser password:", "password" );
1336 <p class="config-desc">
1337 If the database user specified above does not exist, or does not have access to create
1338 the database (if needed) or tables within it, please check the box and provide details
1339 of a superuser account, such as <strong>root</strong>, which does.
1342 <?php database_switcher('mysql
'); ?>
1343 <div class="config-input"><?php
1344 aField( $conf, "DBprefix", "Database table prefix:" );
1346 <div class="config-desc">
1347 <p>If you need to share one database between multiple wikis, or
1348 between MediaWiki and another web application, you may choose to
1349 add a prefix to all the table names to avoid conflicts.</p>
1351 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
1354 <div class="config-input"><label class="column">Storage Engine</label>
1355 <div>Select one:</div>
1357 <li><?php aField( $conf, "DBengine", "InnoDB", "radio", "InnoDB" ); ?></li>
1358 <li><?php aField( $conf, "DBengine", "MyISAM", "radio", "MyISAM" ); ?></li>
1361 <p class="config-desc">
1362 InnoDB is best for public web installations, since it has good concurrency
1363 support. MyISAM may be faster in single-user installations. MyISAM databases
1364 tend to get corrupted more often than InnoDB databases.
1366 <div class="config-input"><label class="column">Database character set</label>
1367 <div>Select one:</div>
1369 <li><?php aField( $conf, "DBschema", "Backwards-compatible UTF-8", "radio", "mysql4" ); ?></li>
1370 <li><?php aField( $conf, "DBschema", "Experimental MySQL 4.1/5.0 UTF-8", "radio", "mysql5" ); ?></li>
1371 <li><?php aField( $conf, "DBschema", "Experimental MySQL 4.1/5.0 binary", "radio", "mysql5-binary" ); ?></li>
1374 <p class="config-desc">
1375 <b>EXPERIMENTAL:</b> You can enable explicit Unicode charset support
1376 for MySQL 4.1 and 5.0 servers. This is not well tested and may
1377 cause things to break. <b>If upgrading an older installation, leave
1378 in backwards-compatible mode.</b>
1382 <?php database_switcher('postgres
'); ?>
1383 <div class="config-input"><?php
1384 aField( $conf, "DBport", "Database port:" );
1386 <div class="config-input"><?php
1387 aField( $conf, "DBmwschema", "Schema for mediawiki:" );
1389 <div class="config-input"><?php
1390 aField( $conf, "DBts2schema", "Schema for tsearch2:" );
1392 <div class="config-desc">
1393 <p>The username specified above (at "DB username") will have its search path set to the above schemas,
1394 so it is recommended that you create a new user. The above schemas are generally correct:
1395 only change them if you are sure you need to.</p>
1399 <div class="config-input" style="padding:2em 0 3em">
1400 <label class='column
'> </label>
1401 <input type="submit" value="Install MediaWiki!" class="btn-install" />
1406 <script type="text/javascript">
1407 window.onload = toggleDBarea('<?php
echo $conf->DBtype
; ?
>',
1409 ## If they passed in a root user name, don't populate it on page load
1410 echo strlen(importPost('RootUser', '')) ?
0 : 1;
1419 /* -------------------------------------------------------------------------------------- */
1420 function writeSuccessMessage() {
1421 if ( ini_get( 'safe_mode' ) && !ini_get( 'open_basedir' ) ) {
1423 <div class="success-box">
1424 <p>Installation successful!</p>
1425 <p>To complete the installation, please do the following:
1427 <li>Download config/LocalSettings.php with your FTP client or file manager</li>
1428 <li>Upload it to the parent directory</li>
1429 <li>Delete config/LocalSettings.php</li>
1430 <li>Start using <a href='../index.php'>your wiki</a>!
1432 <p>If you are in a shared hosting environment, do <strong>not</strong> just move LocalSettings.php
1433 remotely. LocalSettings.php is currently owned by the user your webserver is running under,
1434 which means that anyone on the same server can read your database password! Downloading
1435 it and uploading it again will hopefully change the ownership to a user ID specific to you.</p>
1440 <div class="success-box">
1442 <span class="success-message">Installation successful!</span>
1443 Move the <tt>config/LocalSettings.php</tt> file to the parent directory, then follow
1444 <a href="../index.php"> this link</a> to your wiki.</p>
1445 <p>You should change file permissions for <tt>LocalSettings.php</tt> as required to
1446 prevent other users on the server reading passwords and altering configuration data.</p>
1453 function escapePhpString( $string ) {
1454 return strtr( $string,
1465 function writeLocalSettings( $conf ) {
1466 $conf->PasswordSender
= $conf->EmergencyContact
;
1467 $magic = ($conf->ImageMagick ?
"" : "# ");
1468 $convert = ($conf->ImageMagick ?
$conf->ImageMagick
: "/usr/bin/convert" );
1469 $rights = ($conf->RightsUrl
) ?
"" : "# ";
1470 $hashedUploads = $conf->safeMode ?
'' : '# ';
1472 switch ( $conf->Shm
) {
1474 $cacheType = 'CACHE_MEMCACHED';
1475 $mcservers = var_export( $conf->MCServerArray
, true );
1481 $cacheType = 'CACHE_ACCEL';
1482 $mcservers = 'array()';
1485 $cacheType = 'CACHE_NONE';
1486 $mcservers = 'array()';
1489 if ( $conf->Email
== 'email_enabled' ) {
1490 $enableemail = 'true';
1491 $enableuseremail = ( $conf->Emailuser
== 'emailuser_enabled' ) ?
'true' : 'false' ;
1492 $eauthent = ( $conf->Eauthent
== 'eauthent_enabled' ) ?
'true' : 'false' ;
1493 switch ( $conf->Enotif
) {
1494 case 'enotif_usertalk':
1495 $enotifusertalk = 'true';
1496 $enotifwatchlist = 'false';
1498 case 'enotif_allpages':
1499 $enotifusertalk = 'true';
1500 $enotifwatchlist = 'true';
1503 $enotifusertalk = 'false';
1504 $enotifwatchlist = 'false';
1507 $enableuseremail = 'false';
1508 $enableemail = 'false';
1509 $eauthent = 'false';
1510 $enotifusertalk = 'false';
1511 $enotifwatchlist = 'false';
1514 $file = @fopen
( "/dev/urandom", "r" );
1516 $secretKey = bin2hex( fread( $file, 32 ) );
1520 for ( $i=0; $i<8; $i++
) {
1521 $secretKey .= dechex(mt_rand(0, 0x7fffffff));
1523 print "<li>Warning: \$wgSecretKey key is insecure, generated with mt_rand(). Consider changing it manually.</li>\n";
1526 # Add slashes to strings for double quoting
1527 $slconf = array_map( "escapePhpString", get_object_vars( $conf ) );
1528 if( $conf->License
== 'gfdl' ) {
1529 # Needs literal string interpolation for the current style path
1530 $slconf['RightsIcon'] = $conf->RightsIcon
;
1534 # This file was automatically generated by the MediaWiki installer.
1535 # If you make manual changes, please keep track in case you need to
1536 # recreate them later.
1538 # See includes/DefaultSettings.php for all configurable settings
1539 # and their default values, but don't forget to make changes in _this_
1542 # If you customize your file layout, set \$IP to the directory that contains
1543 # the other MediaWiki files. It will be used as a base to locate files.
1544 if( defined( 'MW_INSTALL_PATH' ) ) {
1545 \$IP = MW_INSTALL_PATH;
1547 \$IP = dirname( __FILE__ );
1550 \$path = array( \$IP, \"\$IP/includes\", \"\$IP/languages\" );
1551 set_include_path( implode( PATH_SEPARATOR, \$path ) . PATH_SEPARATOR . get_include_path() );
1553 require_once( \"includes/DefaultSettings.php\" );
1555 # If PHP's memory limit is very low, some operations may fail.
1556 " . ($conf->raiseMemory ?
'' : '# ' ) . "ini_set( 'memory_limit', '20M' );" . "
1558 if ( \$wgCommandLineMode ) {
1559 if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
1560 die( \"This script must be run from the command line\\n\" );
1563 ## Uncomment this to disable output compression
1564 # \$wgDisableOutputCompression = true;
1566 \$wgSitename = \"{$slconf['Sitename']}\";
1568 ## The URL base path to the directory containing the wiki;
1569 ## defaults for all runtime URL paths are based off of this.
1570 \$wgScriptPath = \"{$slconf['ScriptPath']}\";
1572 ## For more information on customizing the URLs please see:
1573 ## http://www.mediawiki.org/wiki/Manual:Short_URL
1575 \$wgEnableEmail = $enableemail;
1576 \$wgEnableUserEmail = $enableuseremail;
1578 \$wgEmergencyContact = \"{$slconf['EmergencyContact']}\";
1579 \$wgPasswordSender = \"{$slconf['PasswordSender']}\";
1581 ## For a detailed description of the following switches see
1582 ## http://meta.wikimedia.org/Enotif and http://meta.wikimedia.org/Eauthent
1583 ## There are many more options for fine tuning available see
1584 ## /includes/DefaultSettings.php
1585 ## UPO means: this is also a user preference option
1586 \$wgEnotifUserTalk = $enotifusertalk; # UPO
1587 \$wgEnotifWatchlist = $enotifwatchlist; # UPO
1588 \$wgEmailAuthentication = $eauthent;
1590 \$wgDBtype = \"{$slconf['DBtype']}\";
1591 \$wgDBserver = \"{$slconf['DBserver']}\";
1592 \$wgDBname = \"{$slconf['DBname']}\";
1593 \$wgDBuser = \"{$slconf['DBuser']}\";
1594 \$wgDBpassword = \"{$slconf['DBpassword']}\";
1596 # MySQL specific settings
1597 \$wgDBprefix = \"{$slconf['DBprefix']}\";
1599 # MySQL table options to use during installation or update
1600 \$wgDBTableOptions = \"{$slconf['DBTableOptions']}\";
1602 # Experimental charset support for MySQL 4.1/5.0.
1603 \$wgDBmysql5 = {$conf->DBmysql5};
1605 # Postgres specific settings
1606 \$wgDBport = \"{$slconf['DBport']}\";
1607 \$wgDBmwschema = \"{$slconf['DBmwschema']}\";
1608 \$wgDBts2schema = \"{$slconf['DBts2schema']}\";
1610 ## Shared memory settings
1611 \$wgMainCacheType = $cacheType;
1612 \$wgMemCachedServers = $mcservers;
1614 ## To enable image uploads, make sure the 'images' directory
1615 ## is writable, then set this to true:
1616 \$wgEnableUploads = false;
1617 {$magic}\$wgUseImageMagick = true;
1618 {$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
1620 ## If you want to use image uploads under safe mode,
1621 ## create the directories images/archive, images/thumb and
1622 ## images/temp, and make them all writable. Then uncomment
1623 ## this, if it's not already uncommented:
1624 {$hashedUploads}\$wgHashedUploadDirectory = false;
1626 ## If you have the appropriate support software installed
1627 ## you can enable inline LaTeX equations:
1630 \$wgLocalInterwiki = \$wgSitename;
1632 \$wgLanguageCode = \"{$slconf['LanguageCode']}\";
1634 \$wgProxyKey = \"$secretKey\";
1636 ## Default skin: you can change the default skin. Use the internal symbolic
1637 ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook':
1638 \$wgDefaultSkin = 'monobook';
1640 ## For attaching licensing metadata to pages, and displaying an
1641 ## appropriate copyright notice / icon. GNU Free Documentation
1642 ## License and Creative Commons licenses are supported so far.
1643 {$rights}\$wgEnableCreativeCommonsRdf = true;
1644 \$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright
1645 \$wgRightsUrl = \"{$slconf['RightsUrl']}\";
1646 \$wgRightsText = \"{$slconf['RightsText']}\";
1647 \$wgRightsIcon = \"{$slconf['RightsIcon']}\";
1648 # \$wgRightsCode = \"{$slconf['RightsCode']}\"; # Not yet used
1650 \$wgDiff3 = \"{$slconf['diff3']}\";
1652 # When you make changes to this configuration file, this will make
1653 # sure that cached pages are cleared.
1654 \$configdate = gmdate( 'YmdHis', @filemtime( __FILE__ ) );
1655 \$wgCacheEpoch = max( \$wgCacheEpoch, \$configdate );
1656 "; ## End of setting the $localsettings string
1658 // Keep things in Unix line endings internally;
1659 // the system will write out as local text type.
1660 return str_replace( "\r\n", "\n", $localsettings );
1663 function dieout( $text ) {
1664 die( $text . "\n\n</body>\n</html>" );
1667 function importVar( &$var, $name, $default = "" ) {
1668 if( isset( $var[$name] ) ) {
1669 $retval = $var[$name];
1670 if ( get_magic_quotes_gpc() ) {
1671 $retval = stripslashes( $retval );
1679 function importPost( $name, $default = "" ) {
1680 return importVar( $_POST, $name, $default );
1683 function importCheck( $name ) {
1684 return isset( $_POST[$name] );
1687 function importRequest( $name, $default = "" ) {
1688 return importVar( $_REQUEST, $name, $default );
1693 function aField( &$conf, $field, $text, $type = "text", $value = "", $onclick = '' ) {
1696 $xtype = "type=\"$type\"";
1702 $nolabel = ($type == "radio") ||
($type == "hidden");
1704 if ($type == 'radio')
1705 $id .= $radioCount++
;
1710 echo "\t\t<label class='column' for=\"$id\">$text</label>\n";
1713 if( $type == "radio" && $value == $conf->$field ) {
1714 $checked = "checked='checked'";
1718 echo "\t\t<input $xtype name=\"$field\" id=\"$id\" class=\"iput-$type\" $checked ";
1720 echo " onclick='toggleDBarea(\"$value\",1)' " ;
1723 if( $type == "radio" ) {
1724 echo htmlspecialchars( $value );
1726 echo htmlspecialchars( $conf->$field );
1732 echo " $text</label>\n";
1736 if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n";
1739 function getLanguageList() {
1740 global $wgLanguageNames;
1741 if( !isset( $wgLanguageNames ) ) {
1742 require_once( "languages/Names.php" );
1747 $d = opendir( "../languages/messages" );
1748 /* In case we are called from the root directory */
1750 $d = opendir( "languages/messages");
1751 while( false !== ($f = readdir( $d ) ) ) {
1753 if( preg_match( '/Messages([A-Z][a-z_]+)\.php$/', $f, $m ) ) {
1754 $code = str_replace( '_', '-', strtolower( $m[1] ) );
1755 if( isset( $wgLanguageNames[$code] ) ) {
1756 $name = $code . ' - ' . $wgLanguageNames[$code];
1760 $codes[$code] = $name;
1768 #Check for location of an executable
1769 # @param string $loc single location to check
1770 # @param array $names filenames to check for.
1771 # @param mixed $versioninfo array of details to use when checking version, use false for no version checking
1772 function locate_executable($loc, $names, $versioninfo = false) {
1773 if (!is_array($names))
1774 $names = array($names);
1776 foreach ($names as $name) {
1777 $command = "$loc".DIRECTORY_SEPARATOR
."$name";
1778 if (file_exists($command)) {
1782 $file = str_replace('$1', $command, $versioninfo[0]);
1783 if (strstr(`
$file`
, $versioninfo[1]) !== false)
1790 # Test a memcached server
1791 function testMemcachedServer( $server ) {
1792 $hostport = explode(":", $server);
1795 if ( !function_exists( 'fsockopen' ) ) {
1796 $errstr = "Can't connect to memcached, fsockopen() not present";
1798 if ( !$errstr && count( $hostport ) != 2 ) {
1799 $errstr = 'Please specify host and port';
1800 var_dump( $hostport );
1803 list( $host, $port ) = $hostport;
1807 $fp = @fsockopen
( $host, $port, $errno, $fsockerr, 1.0 );
1808 if ( $fp === false ) {
1809 $errstr = "Cannot connect to memcached on $host:$port : $fsockerr";
1813 $command = "version\r\n";
1814 $bytes = fwrite( $fp, $command );
1815 if ( $bytes != strlen( $command ) ) {
1816 $errstr = "Cannot write to memcached socket on $host:$port";
1820 $expected = "VERSION ";
1821 $response = fread( $fp, strlen( $expected ) );
1822 if ( $response != $expected ) {
1823 $errstr = "Didn't get correct memcached response from $host:$port";
1830 echo "<li>Connected to memcached on $host:$port successfully";
1835 function database_picker($conf) {
1838 foreach(array_keys($ourdb) as $db) {
1839 if ($ourdb[$db]['havedriver']) {
1841 aField( $conf, "DBtype", $ourdb[$db]['fullname'], 'radio', $db, 'onclick');
1848 function database_switcher($db) {
1850 $color = $ourdb[$db]['bgcolor'];
1851 $full = $ourdb[$db]['fullname'];
1852 print "<fieldset id='$db'><legend>$full specific options</legend>\n";
1855 function printListItem( $item ) {
1856 print "<li>$item</li>";
1861 <div
class="license">
1863 <p
>This program is free software
; you can redistribute it
and/or modify
1864 it under the terms of the GNU General
Public License
as published by
1865 the Free Software Foundation
; either version
2 of the License
, or
1866 (at your option
) any later version
.</p
>
1868 <p
>This program is distributed in the hope that it will be useful
,
1869 but WITHOUT ANY WARRANTY
; without even the implied warranty of
1870 MERCHANTABILITY
or FITNESS
FOR A PARTICULAR PURPOSE
. See the
1871 GNU General
Public License
for more details
.</p
>
1873 <p
>You should have received
<a href
="../COPYING">a copy of the GNU General
Public License
</a
>
1874 along with this program
; if not
, write to the Free Software
1875 Foundation
, Inc
., 51 Franklin Street
, Fifth Floor
, Boston
, MA
02110-1301, USA
.
1876 or <a href
="http://www.gnu.org/copyleft/gpl.html">read it online
</a
></p
>
1882 <div id
="column-one">
1883 <div
class="portlet" id
="p-logo">
1884 <a style
="background-image: url(../skins/common/images/mediawiki.png);"
1885 href
="http://www.mediawiki.org/"
1886 title
="Main Page"></a
>
1888 <script type
="text/javascript"> if (window
.isMSIE55
) fixalpha(); </script
>
1889 <div
class='portlet'><div
class='pBody'>
1891 <li
><strong
><a href
="http://www.mediawiki.org/">MediaWiki home
</a
></strong
></li
>
1892 <li
><a href
="../README">Readme
</a
></li
>
1893 <li
><a href
="../RELEASE-NOTES">Release notes
</a
></li
>
1894 <li
><a href
="../docs/">Documentation
</a
></li
>
1895 <li
><a href
="http://meta.wikipedia.org/wiki/MediaWiki_User's_Guide">User
's Guide</a></li>
1896 <li><a href="http://meta.wikimedia.org/wiki/MediaWiki_FAQ">FAQ</a></li>
1898 <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>