Follow-up on r50351. Fix adding key/value pair.
[mediawiki.git] / config / index.php
blob96e8a14fa49f2f39a067225f85c847e2065b94a5
1 <?php
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 );
33 # Define an entry point and include some files
34 define( "MEDIAWIKI", true );
35 define( "MEDIAWIKI_INSTALL", true );
37 // Run version checks before including other files
38 // so people don't see a scary parse error.
39 require_once( "$IP/install-utils.inc" );
40 install_version_checks();
42 require_once( "$IP/includes/Defines.php" );
43 require_once( "$IP/includes/DefaultSettings.php" );
44 require_once( "$IP/includes/AutoLoader.php" );
45 require_once( "$IP/includes/MagicWord.php" );
46 require_once( "$IP/includes/Namespace.php" );
47 require_once( "$IP/includes/ProfilerStub.php" );
48 require_once( "$IP/includes/GlobalFunctions.php" );
49 require_once( "$IP/includes/Hooks.php" );
50 require_once( "$IP/includes/Exception.php" );
52 # If we get an exception, the user needs to know
53 # all the details
54 $wgShowExceptionDetails = true;
55 $wgShowSQLErrors = true;
56 wfInstallExceptionHandler();
57 ## Databases we support:
59 $ourdb = array();
60 $ourdb['mysql']['fullname'] = 'MySQL';
61 $ourdb['mysql']['havedriver'] = 0;
62 $ourdb['mysql']['compile'] = 'mysql';
63 $ourdb['mysql']['bgcolor'] = '#ffe5a7';
64 $ourdb['mysql']['rootuser'] = 'root';
66 $ourdb['postgres']['fullname'] = 'PostgreSQL';
67 $ourdb['postgres']['havedriver'] = 0;
68 $ourdb['postgres']['compile'] = 'pgsql';
69 $ourdb['postgres']['bgcolor'] = '#aaccff';
70 $ourdb['postgres']['rootuser'] = 'postgres';
72 $ourdb['sqlite']['fullname'] = 'SQLite';
73 $ourdb['sqlite']['havedriver'] = 0;
74 $ourdb['sqlite']['compile'] = 'pdo_sqlite';
75 $ourdb['sqlite']['bgcolor'] = '#b1ebb1';
76 $ourdb['sqlite']['rootuser'] = '';
78 $ourdb['mssql']['fullname'] = 'MSSQL';
79 $ourdb['mssql']['havedriver'] = 0;
80 $ourdb['mssql']['compile'] = 'mssql not ready'; # Change to 'mssql' after includes/DatabaseMssql.php added;
81 $ourdb['mssql']['bgcolor'] = '#ffc0cb';
82 $ourdb['mssql']['rootuser'] = 'administrator';
84 $ourdb['ibm_db2']['fullname'] = 'DB2';
85 $ourdb['ibm_db2']['havedriver'] = 0;
86 $ourdb['ibm_db2']['compile'] = 'ibm_db2';
87 $ourdb['ibm_db2']['bgcolor'] = '#ffeba1';
88 $ourdb['ibm_db2']['rootuser'] = 'db2admin';
91 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
92 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
93 <head>
94 <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
95 <meta name="robots" content="noindex,nofollow"/>
96 <title>MediaWiki <?php echo htmlspecialchars( $wgVersion ); ?> Installation</title>
97 <style type="text/css">
99 @import "../skins/monobook/main.css";
101 .env-check {
102 font-size: 90%;
103 margin: 1em 0 1em 2.5em;
106 .config-section {
107 margin-top: 2em;
110 .config-section label.column {
111 clear: left;
112 font-weight: bold;
113 width: 13em;
114 float: left;
115 text-align: right;
116 padding-right: 1em;
117 padding-top: .2em;
120 .config-input {
121 clear: left;
122 zoom: 100%; /* IE hack */
125 .config-section .config-desc {
126 clear: left;
127 margin: 0 0 2em 18em;
128 padding-top: 1em;
129 font-size: 85%;
132 .iput-text, .iput-password {
133 width: 14em;
134 margin-right: 1em;
137 .error {
138 color: red;
139 background-color: #fff;
140 font-weight: bold;
141 left: 1em;
142 font-size: 100%;
145 .error-top {
146 color: red;
147 background-color: #FFF0F0;
148 border: 2px solid red;
149 font-size: 130%;
150 font-weight: bold;
151 padding: 1em 1.5em;
152 margin: 2em 0 1em;
155 ul.plain {
156 list-style-type: none;
157 list-style-image: none;
158 float: left;
159 margin: 0;
160 padding: 0;
163 .btn-install {
164 font-weight: bold;
165 font-size: 110%;
166 padding: .2em .3em;
169 .license {
170 font-size: 85%;
171 padding-top: 3em;
174 span.success-message {
175 font-weight: bold;
176 font-size: 110%;
177 color: green;
179 .success-box {
180 font-size: 130%;
183 </style>
184 <script type="text/javascript">
185 <!--
186 function hideall() {
187 <?php foreach (array_keys($ourdb) as $db) {
188 echo "\n var i = document.getElementById('$db'); if (i) i.style.display='none';";
193 function toggleDBarea(id,defaultroot) {
194 hideall();
195 var dbarea = document.getElementById(id);
196 if (dbarea) dbarea.style.display = (dbarea.style.display == 'none') ? 'block' : 'none';
197 var db = document.getElementById('RootUser');
198 if (defaultroot) {
199 <?php foreach (array_keys($ourdb) as $db) {
200 echo " if (id == '$db') { db.value = '".$ourdb[$db]['rootuser']."';}\n";
204 // -->
205 </script>
206 </head>
208 <body>
209 <div id="globalWrapper">
210 <div id="column-content">
211 <div id="content">
212 <div id="bodyContent">
214 <h1>MediaWiki <?php print htmlspecialchars( $wgVersion ) ?> Installation</h1>
216 <?php
217 $mainListOpened = false; # Is the main list (environement checking) opend ? Used by dieout
219 /* Check for existing configurations and bug out! */
221 if( file_exists( "../LocalSettings.php" ) ) {
222 $script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php';
223 dieout( "<p><strong>Setup has completed, <a href='../$script'>your wiki</a> is configured.</strong></p>
224 <p>Please delete the /config directory for extra security.</p>" );
227 if( file_exists( "./LocalSettings.php" ) ) {
228 writeSuccessMessage();
229 dieout( '' );
232 if( !is_writable( "." ) ) {
233 dieout( "<h2>Can't write config file, aborting</h2>
235 <p>In order to configure the wiki you have to make the <tt>config</tt> subdirectory
236 writable by the web server. Once configuration is done you'll move the created
237 <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can
238 then remove the <tt>config</tt> subdirectory entirely.</p>
240 <p>To make the directory writable on a Unix/Linux system:</p>
242 <pre>
243 cd <i>/path/to/wiki</i>
244 chmod a+w config
245 </pre>
247 <p>Afterwards retry to start the <a href=\"\">setup</a>.</p>" );
251 require_once( "$IP/install-utils.inc" );
252 require_once( "$IP/maintenance/updaters.inc" );
254 class ConfigData {
255 function getEncoded( $data ) {
256 # removing latin1 support, no need...
257 return $data;
259 function getSitename() { return $this->getEncoded( $this->Sitename ); }
260 function getSysopName() { return $this->getEncoded( $this->SysopName ); }
261 function getSysopPass() { return $this->getEncoded( $this->SysopPass ); }
263 function setSchema( $schema, $engine ) {
264 $this->DBschema = $schema;
265 if ( !preg_match( '/^\w*$/', $engine ) ){
266 $engine = 'InnoDB';
268 switch ( $this->DBschema ) {
269 case 'mysql5':
270 $this->DBTableOptions = "ENGINE=$engine, DEFAULT CHARSET=utf8";
271 $this->DBmysql5 = 'true';
272 break;
273 case 'mysql5-binary':
274 $this->DBTableOptions = "ENGINE=$engine, DEFAULT CHARSET=binary";
275 $this->DBmysql5 = 'true';
276 break;
277 default:
278 $this->DBTableOptions = "TYPE=$engine";
279 $this->DBmysql5 = 'false';
281 $this->DBengine = $engine;
283 # Set the global for use during install
284 global $wgDBTableOptions;
285 $wgDBTableOptions = $this->DBTableOptions;
291 <ul>
292 <li>
293 <b>Don't forget security updates!</b> Keep an eye on the
294 <a href="http://lists.wikimedia.org/mailman/listinfo/mediawiki-announce">low-traffic
295 release announcements mailing list</a>.
296 </li>
297 </ul>
300 <h2>Checking environment...</h2>
301 <p><em>Please include all of the lines below when reporting installation problems.</em></p>
302 <ul class="env-check">
303 <?php
304 $mainListOpened = true;
306 $endl = "
308 define( 'MW_NO_OUTPUT_BUFFER', 1 );
309 $conf = new ConfigData;
311 install_version_checks();
312 $self = 'Installer'; # Maintenance script name, to please Setup.php
314 print "<li>PHP " . htmlspecialchars( phpversion() ) . " installed</li>\n";
316 error_reporting( 0 );
317 $phpdatabases = array();
318 foreach (array_keys($ourdb) as $db) {
319 $compname = $ourdb[$db]['compile'];
320 if( extension_loaded( $compname ) || ( mw_have_dl() && dl( "{$compname}." . PHP_SHLIB_SUFFIX ) ) ) {
321 array_push($phpdatabases, $db);
322 $ourdb[$db]['havedriver'] = 1;
325 error_reporting( E_ALL );
327 if (!$phpdatabases) {
328 print "Could not find a suitable database driver!<ul>";
329 foreach (array_keys($ourdb) AS $db) {
330 $comp = $ourdb[$db]['compile'];
331 $full = $ourdb[$db]['fullname'];
332 print "<li>For <b>$full</b>, compile PHP using <b>--with-$comp</b>, "
333 ."or install the $comp.so module</li>\n";
335 echo '</ul>';
336 dieout( '' );
339 print "<li>Found database drivers for:";
340 $DefaultDBtype = '';
341 foreach (array_keys($ourdb) AS $db) {
342 if ($ourdb[$db]['havedriver']) {
343 if ( $DefaultDBtype == '' ) {
344 $DefaultDBtype = $db;
346 print " ".$ourdb[$db]['fullname'];
349 print "</li>\n";
351 if( wfIniGetBool( "register_globals" ) ) {
353 <li>
354 <div style="font-size:110%">
355 <strong class="error">Warning:</strong>
356 <strong>PHP's <tt><a href="http://php.net/register_globals">register_globals</a></tt> option is enabled. Disable it if you can.</strong>
357 </div>
358 MediaWiki will work, but your server is more exposed to PHP-based security vulnerabilities.
359 </li>
360 <?php
363 $fatal = false;
365 if( wfIniGetBool( "magic_quotes_runtime" ) ) {
366 $fatal = true;
367 ?><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>
368 This option corrupts data input unpredictably; you cannot install or use
369 MediaWiki unless this option is disabled.</li>
370 <?php
373 if( wfIniGetBool( "magic_quotes_sybase" ) ) {
374 $fatal = true;
375 ?><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>
376 This option corrupts data input unpredictably; you cannot install or use
377 MediaWiki unless this option is disabled.</li>
378 <?php
381 if( wfIniGetBool( "mbstring.func_overload" ) ) {
382 $fatal = true;
383 ?><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>
384 This option causes errors and may corrupt data unpredictably;
385 you cannot install or use MediaWiki unless this option is disabled.</li>
386 <?php
389 if( wfIniGetBool( "zend.ze1_compatibility_mode" ) ) {
390 $fatal = true;
391 ?><li class="error"><strong>Fatal: <a href="http://www.php.net/manual/en/ini.core.php">zend.ze1_compatibility_mode</a> is active!</strong>
392 This option causes horrible bugs with MediaWiki; you cannot install or use
393 MediaWiki unless this option is disabled.</li>
394 <?php
398 if( $fatal ) {
399 dieout( "Cannot install MediaWiki." );
402 if( wfIniGetBool( "safe_mode" ) ) {
403 $conf->safeMode = true;
405 <li><b class='error'>Warning:</b> <strong>PHP's
406 <a href='http://www.php.net/features.safe-mode'>safe mode</a> is active.</strong>
407 You may have problems caused by this, particularly if using image uploads.
408 </li>
409 <?php
410 } else {
411 $conf->safeMode = false;
414 $sapi = htmlspecialchars( php_sapi_name() );
415 print "<li>PHP server API is $sapi; ";
416 $script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php';
417 if( $wgUsePathInfo ) {
418 print "ok, using pretty URLs (<tt>$script/Page_Title</tt>)";
419 } else {
420 print "using ugly URLs (<tt>$script?title=Page_Title</tt>)";
422 print "</li>\n";
424 $conf->xml = function_exists( "utf8_encode" );
425 if( $conf->xml ) {
426 print "<li>Have XML / Latin1-UTF-8 conversion support.</li>\n";
427 } else {
428 dieout( "PHP's XML module is missing; the wiki requires functions in
429 this module and won't work in this configuration.
430 If you're running Mandrake, install the php-xml package." );
433 # Check for session support
434 if( !function_exists( 'session_name' ) )
435 dieout( "PHP's session module is missing. MediaWiki requires session support in order to function." );
437 # session.save_path doesn't *have* to be set, but if it is, and it's
438 # not valid/writable/etc. then it can cause problems
439 $sessionSavePath = mw_get_session_save_path();
440 $ssp = htmlspecialchars( $sessionSavePath );
441 # Warn the user if it's not set, but let them proceed
442 if( !$sessionSavePath ) {
443 print "<li><strong>Warning:</strong> A value for <tt>session.save_path</tt>
444 has not been set in PHP.ini. If the default value causes problems with
445 saving session data, set it to a valid path which is read/write/execute
446 for the user your web server is running under.</li>";
447 } elseif ( is_dir( $sessionSavePath ) && is_writable( $sessionSavePath ) ) {
448 # All good? Let the user know
449 print "<li>Session save path (<tt>{$ssp}</tt>) appears to be valid.</li>";
450 } else {
451 # Something not right? Warn the user, but let them proceed
452 print "<li><strong>Warning:</strong> Your <tt>session.save_path</tt> value (<tt>{$ssp}</tt>)
453 appears to be invalid or is not writable. PHP needs to be able to save data to
454 this location for correct session operation.</li>";
457 # Check for PCRE support
458 if( !function_exists( 'preg_match' ) )
459 dieout( "The PCRE support module appears to be missing. MediaWiki requires the
460 Perl-compatible regular expression functions." );
462 $memlimit = ini_get( "memory_limit" );
463 $conf->raiseMemory = false;
464 if( empty( $memlimit ) || $memlimit == -1 ) {
465 print "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n";
466 } else {
467 print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars( $memlimit ) . ". ";
468 $n = intval( $memlimit );
469 if( preg_match( '/^([0-9]+)[Mm]$/', trim( $memlimit ), $m ) ) {
470 $n = intval( $m[1] * (1024*1024) );
472 if( $n < 20*1024*1024 ) {
473 print "Attempting to raise limit to 20M... ";
474 if( false === ini_set( "memory_limit", "20M" ) ) {
475 print "failed.<br /><b>" . htmlspecialchars( $memlimit ) . " seems too low, installation may fail!</b>";
476 } else {
477 $conf->raiseMemory = true;
478 print "ok.";
481 print "</li>\n";
484 $conf->turck = function_exists( 'mmcache_get' );
485 if ( $conf->turck ) {
486 print "<li><a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> installed</li>\n";
489 $conf->xcache = function_exists( 'xcache_get' );
490 if( $conf->xcache )
491 print "<li><a href=\"http://trac.lighttpd.net/xcache/\">XCache</a> installed</li>\n";
493 $conf->apc = function_exists('apc_fetch');
494 if ($conf->apc ) {
495 print "<li><a href=\"http://www.php.net/apc\">APC</a> installed</li>\n";
498 $conf->eaccel = function_exists( 'eaccelerator_get' );
499 if ( $conf->eaccel ) {
500 $conf->turck = 'eaccelerator';
501 print "<li><a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> installed</li>\n";
504 $conf->dba = function_exists( 'dba_open' );
506 if( !( $conf->turck || $conf->eaccel || $conf->apc || $conf->xcache ) ) {
507 echo( '<li>Couldn\'t find <a href="http://turck-mmcache.sourceforge.net">Turck MMCache</a>,
508 <a href="http://eaccelerator.sourceforge.net">eAccelerator</a>,
509 <a href="http://www.php.net/apc">APC</a> or <a href="http://trac.lighttpd.net/xcache/">XCache</a>;
510 cannot use these for object caching.</li>' );
513 $conf->diff3 = false;
514 $diff3locations = array_merge(
515 array(
516 "/usr/bin",
517 "/usr/local/bin",
518 "/opt/csw/bin",
519 "/usr/gnu/bin",
520 "/usr/sfw/bin" ),
521 explode( PATH_SEPARATOR, getenv( "PATH" ) ) );
522 $diff3names = array( "gdiff3", "diff3", "diff3.exe" );
524 $diff3versioninfo = array( '$1 --version 2>&1', 'diff3 (GNU diffutils)' );
525 foreach ($diff3locations as $loc) {
526 $exe = locate_executable($loc, $diff3names, $diff3versioninfo);
527 if ($exe !== false) {
528 $conf->diff3 = $exe;
529 break;
533 if ($conf->diff3)
534 print "<li>Found GNU diff3: <tt>$conf->diff3</tt>.</li>";
535 else
536 print "<li>GNU diff3 not found.</li>";
538 $conf->ImageMagick = false;
539 $imcheck = array( "/usr/bin", "/opt/csw/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" );
540 foreach( $imcheck as $dir ) {
541 $im = "$dir/convert";
542 if( @file_exists( $im ) ) {
543 print "<li>Found ImageMagick: <tt>$im</tt>; image thumbnailing will be enabled if you enable uploads.</li>\n";
544 $conf->ImageMagick = $im;
545 break;
549 $conf->HaveGD = function_exists( "imagejpeg" );
550 if( $conf->HaveGD ) {
551 print "<li>Found GD graphics library built-in";
552 if( !$conf->ImageMagick ) {
553 print ", image thumbnailing will be enabled if you enable uploads";
555 print ".</li>\n";
556 } else {
557 if( !$conf->ImageMagick ) {
558 print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n";
562 $conf->IP = dirname( dirname( __FILE__ ) );
563 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP ) . "</tt></li>\n";
566 // PHP_SELF isn't available sometimes, such as when PHP is CGI but
567 // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
568 // to get the path to the current script... hopefully it's reliable. SIGH
569 $path = ($_SERVER["PHP_SELF"] === '')
570 ? $_SERVER["SCRIPT_NAME"]
571 : $_SERVER["PHP_SELF"];
573 $conf->ScriptPath = preg_replace( '{^(.*)/config.*$}', '$1', $path );
574 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath ) . "</tt></li>\n";
578 // We may be installing from *.php5 extension file, if so, print message
579 $conf->ScriptExtension = '.php';
580 if (defined('MW_INSTALL_PHP5_EXT')) {
581 $conf->ScriptExtension = '.php5';
582 print "<li>Installing MediaWiki with <tt>php5</tt> file extensions</li>\n";
583 } else {
584 print "<li>Installing MediaWiki with <tt>php</tt> file extensions</li>\n";
588 print "<li style='font-weight:bold;color:green;font-size:110%'>Environment checked. You can install MediaWiki.</li>\n";
589 $conf->posted = ($_SERVER["REQUEST_METHOD"] == "POST");
591 $conf->Sitename = ucfirst( importPost( "Sitename", "" ) );
592 $defaultEmail = empty( $_SERVER["SERVER_ADMIN"] )
593 ? 'root@localhost'
594 : $_SERVER["SERVER_ADMIN"];
595 $conf->EmergencyContact = importPost( "EmergencyContact", $defaultEmail );
596 $conf->DBtype = importPost( "DBtype", $DefaultDBtype );
597 if ( !isset( $ourdb[$conf->DBtype] ) ) {
598 $conf->DBtype = $DefaultDBtype;
601 $conf->DBserver = importPost( "DBserver", "localhost" );
602 $conf->DBname = importPost( "DBname", "wikidb" );
603 $conf->DBuser = importPost( "DBuser", "wikiuser" );
604 $conf->DBpassword = importPost( "DBpassword" );
605 $conf->DBpassword2 = importPost( "DBpassword2" );
606 $conf->SysopName = importPost( "SysopName", "WikiSysop" );
607 $conf->SysopPass = importPost( "SysopPass" );
608 $conf->SysopPass2 = importPost( "SysopPass2" );
609 $conf->RootUser = importPost( "RootUser", "root" );
610 $conf->RootPW = importPost( "RootPW", "" );
611 $useRoot = importCheck( 'useroot', false );
612 $conf->LanguageCode = importPost( "LanguageCode", "en" );
613 ## MySQL specific:
614 $conf->DBprefix = importPost( "DBprefix" );
615 $conf->setSchema(
616 importPost( "DBschema", "mysql5-binary" ),
617 importPost( "DBengine", "InnoDB" ) );
619 ## Postgres specific:
620 $conf->DBport = importPost( "DBport", "5432" );
621 $conf->DBmwschema = importPost( "DBmwschema", "mediawiki" );
622 $conf->DBts2schema = importPost( "DBts2schema", "public" );
624 ## SQLite specific
625 $conf->SQLiteDataDir = importPost( "SQLiteDataDir", "" );
627 ## MSSQL specific
628 // We need a second field so it doesn't overwrite the MySQL one
629 $conf->DBprefix2 = importPost( "DBprefix2" );
631 ## DB2 specific:
632 // New variable in order to have a different default port number
633 $conf->DBport_db2 = importPost( "DBport_db2", "50000" );
634 $conf->DBmwschema = importPost( "DBmwschema", "mediawiki" );
635 $conf->DBcataloged = importPost( "DBcataloged", "cataloged" );
637 $conf->ShellLocale = getShellLocale( $conf->LanguageCode );
639 /* Check for validity */
640 $errs = array();
642 if( preg_match( '/^$|^mediawiki$|#/i', $conf->Sitename ) ) {
643 $errs["Sitename"] = "Must not be blank or \"MediaWiki\" and may not contain \"#\"";
645 if( $conf->DBuser == "" ) {
646 $errs["DBuser"] = "Must not be blank";
648 if( ($conf->DBtype == 'mysql') && (strlen($conf->DBuser) > 16) ) {
649 $errs["DBuser"] = "Username too long";
651 if( $conf->DBpassword == "" && $conf->DBtype != "postgres" ) {
652 $errs["DBpassword"] = "Must not be blank";
654 if( $conf->DBpassword != $conf->DBpassword2 ) {
655 $errs["DBpassword2"] = "Passwords don't match!";
657 if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix ) ) {
658 $errs["DBprefix"] = "Invalid table prefix";
659 } else {
660 untaint( $conf->DBprefix, TC_MYSQL );
663 error_reporting( E_ALL );
666 * Initialise $wgLang and $wgContLang to something so we can
667 * call case-folding methods. Per Brion, this is English for
668 * now, although we could be clever and initialise to the
669 * user-selected language.
671 $wgContLang = Language::factory( 'en' );
672 $wgLang = $wgContLang;
675 * We're messing about with users, so we need a stub
676 * authentication plugin...
678 $wgAuth = new AuthPlugin();
681 * Validate the initial administrator account; username,
682 * password checks, etc.
684 if( $conf->SysopName ) {
685 # Check that the user can be created
686 $u = User::newFromName( $conf->SysopName );
687 if( is_a($u, 'User') ) { // please do not use instanceof, it breaks PHP4
688 # Various password checks
689 if( $conf->SysopPass != '' ) {
690 if( $conf->SysopPass == $conf->SysopPass2 ) {
691 if( !$u->isValidPassword( $conf->SysopPass ) ) {
692 $errs['SysopPass'] = "Bad password";
694 } else {
695 $errs['SysopPass2'] = "Passwords don't match";
697 } else {
698 $errs['SysopPass'] = "Cannot be blank";
700 unset( $u );
701 } else {
702 $errs['SysopName'] = "Bad username";
706 $conf->License = importRequest( "License", "none" );
707 if( $conf->License == "gfdl1_2" ) {
708 $conf->RightsUrl = "http://www.gnu.org/licenses/old-licenses/fdl-1.2.txt";
709 $conf->RightsText = "GNU Free Documentation License 1.2";
710 $conf->RightsCode = "gfdl1_2";
711 $conf->RightsIcon = '${wgScriptPath}/skins/common/images/gnu-fdl.png';
712 } elseif( $conf->License == "gfdl1_3" ) {
713 $conf->RightsUrl = "http://www.gnu.org/copyleft/fdl.html";
714 $conf->RightsText = "GNU Free Documentation License 1.3";
715 $conf->RightsCode = "gfdl1_3";
716 $conf->RightsIcon = '${wgScriptPath}/skins/common/images/gnu-fdl.png';
717 } elseif( $conf->License == "none" ) {
718 $conf->RightsUrl = $conf->RightsText = $conf->RightsCode = $conf->RightsIcon = "";
719 } elseif( $conf->License == "pd" ) {
720 $conf->RightsUrl = "http://creativecommons.org/licenses/publicdomain/";
721 $conf->RightsText = "Public Domain";
722 $conf->RightsCode = "pd";
723 $conf->RightsIcon = '${wgScriptPath}/skins/common/images/public-domain.png';
724 } else {
725 $conf->RightsUrl = importRequest( "RightsUrl", "" );
726 $conf->RightsText = importRequest( "RightsText", "" );
727 $conf->RightsCode = importRequest( "RightsCode", "" );
728 $conf->RightsIcon = importRequest( "RightsIcon", "" );
731 $conf->Shm = importRequest( "Shm", "none" );
732 $conf->MCServers = importRequest( "MCServers" );
734 /* Test memcached servers */
736 if ( $conf->Shm == 'memcached' && $conf->MCServers ) {
737 $conf->MCServerArray = wfArrayMap( 'trim', explode( ',', $conf->MCServers ) );
738 foreach ( $conf->MCServerArray as $server ) {
739 $error = testMemcachedServer( $server );
740 if ( $error ) {
741 $errs["MCServers"] = $error;
742 break;
745 } else if ( $conf->Shm == 'memcached' ) {
746 $errs["MCServers"] = "Please specify at least one server if you wish to use memcached";
749 /* default values for installation */
750 $conf->Email = importRequest("Email", "email_enabled");
751 $conf->Emailuser = importRequest("Emailuser", "emailuser_enabled");
752 $conf->Enotif = importRequest("Enotif", "enotif_allpages");
753 $conf->Eauthent = importRequest("Eauthent", "eauthent_enabled");
755 if( $conf->posted && ( 0 == count( $errs ) ) ) {
756 do { /* So we can 'continue' to end prematurely */
757 $conf->Root = ($conf->RootPW != "");
759 /* Load up the settings and get installin' */
760 $local = writeLocalSettings( $conf );
761 echo "<li style=\"list-style: none\">\n";
762 echo "<p><b>Generating configuration file...</b></p>\n";
763 echo "</li>\n";
765 $wgCommandLineMode = false;
766 chdir( ".." );
767 $ok = eval( $local );
768 if( $ok === false ) {
769 dieout( "<p>Errors in generated configuration; " .
770 "most likely due to a bug in the installer... " .
771 "Config file was: </p>" .
772 "<pre>" .
773 htmlspecialchars( $local ) .
774 "</pre>" );
776 $conf->DBtypename = '';
777 foreach (array_keys($ourdb) as $db) {
778 if ($conf->DBtype === $db)
779 $conf->DBtypename = $ourdb[$db]['fullname'];
781 if ( ! strlen($conf->DBtype)) {
782 $errs["DBpicktype"] = "Please choose a database type";
783 continue;
786 if (! $conf->DBtypename) {
787 $errs["DBtype"] = "Unknown database type '$conf->DBtype'";
788 continue;
790 print "<li>Database type: " . htmlspecialchars( $conf->DBtypename ) . "</li>\n";
791 $dbclass = 'Database'.ucfirst($conf->DBtype);
792 $wgDBtype = $conf->DBtype;
793 $wgDBadminuser = "root";
794 $wgDBadminpassword = $conf->RootPW;
796 ## Mysql specific:
797 $wgDBprefix = $conf->DBprefix;
799 ## Postgres specific:
800 $wgDBport = $conf->DBport;
801 $wgDBmwschema = $conf->DBmwschema;
802 $wgDBts2schema = $conf->DBts2schema;
804 if( $conf->DBprefix2 != '' ) {
805 // For MSSQL
806 $wgDBprefix = $conf->DBprefix2;
809 ## DB2 specific:
810 $wgDBcataloged = $conf->DBcataloged;
812 $wgCommandLineMode = true;
813 if (! defined ( 'STDERR' ) )
814 define( 'STDERR', fopen("php://stderr", "wb"));
815 $wgUseDatabaseMessages = false; /* FIXME: For database failure */
816 require_once( "$IP/includes/Setup.php" );
817 chdir( "config" );
819 $wgTitle = Title::newFromText( "Installation script" );
820 error_reporting( E_ALL );
821 print "<li>Loading class: " . htmlspecialchars( $dbclass ) . "</li>\n";
822 if ( $conf->DBtype != 'sqlite' ) {
823 $dbc = new $dbclass;
826 if( $conf->DBtype == 'mysql' ) {
827 $mysqlOldClient = version_compare( mysql_get_client_info(), "4.1.0", "lt" );
828 if( $mysqlOldClient ) {
829 print "<li><b>PHP is linked with old MySQL client libraries. If you are
830 using a MySQL 4.1 server and have problems connecting to the database,
831 see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
832 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b></li>\n";
834 $ok = true; # Let's be optimistic
836 # Decide if we're going to use the superuser or the regular database user
837 $conf->Root = $useRoot;
838 if( $conf->Root ) {
839 $db_user = $conf->RootUser;
840 $db_pass = $conf->RootPW;
841 } else {
842 $db_user = $wgDBuser;
843 $db_pass = $wgDBpassword;
846 # Attempt to connect
847 echo( "<li>Attempting to connect to database server as " . htmlspecialchars( $db_user ) . "..." );
848 $wgDatabase = Database::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 );
850 # Check the connection and respond to errors
851 if( $wgDatabase->isOpen() ) {
852 # Seems OK
853 $ok = true;
854 $wgDBadminuser = $db_user;
855 $wgDBadminpassword = $db_pass;
856 echo( "success.</li>\n" );
857 $wgDatabase->ignoreErrors( true );
858 $myver = $wgDatabase->getServerVersion();
859 } else {
860 # There were errors, report them and back out
861 $ok = false;
862 $errno = mysql_errno();
863 $errtx = htmlspecialchars( mysql_error() );
864 switch( $errno ) {
865 case 1045:
866 case 2000:
867 echo( "failed due to authentication errors. Check passwords.</li>" );
868 if( $conf->Root ) {
869 # The superuser details are wrong
870 $errs["RootUser"] = "Check username";
871 $errs["RootPW"] = "and password";
872 } else {
873 # The regular user details are wrong
874 $errs["DBuser"] = "Check username";
875 $errs["DBpassword"] = "and password";
877 break;
878 case 2002:
879 case 2003:
880 default:
881 # General connection problem
882 echo( htmlspecialchars( "failed with error [$errno] $errtx." ) . "</li>\n" );
883 $errs["DBserver"] = "Connection failed";
884 break;
885 } # switch
886 } #conn. att.
888 if( !$ok ) { continue; }
890 else if( $conf->DBtype == 'ibm_db2' ) {
891 if( $useRoot ) {
892 $db_user = $conf->RootUser;
893 $db_pass = $conf->RootPW;
894 } else {
895 $db_user = $wgDBuser;
896 $db_pass = $wgDBpassword;
899 echo( "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) .
900 "\" as \"" . htmlspecialchars( $db_user ) . "\"..." );
901 $wgDatabase = $dbc->newFromParams($wgDBserver, $db_user, $db_pass, $wgDBname, 1);
902 if (!$wgDatabase->isOpen()) {
903 print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
904 } else {
905 $myver = $wgDatabase->getServerVersion();
907 if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname);
909 } elseif ( $conf->DBtype == 'sqlite' ) {
910 if ("$wgSQLiteDataDir" == '') {
911 $wgSQLiteDataDir = dirname($_SERVER['DOCUMENT_ROOT']).'/data';
913 echo "<li>Attempting to connect to SQLite database at \"" .
914 htmlspecialchars( $wgSQLiteDataDir ) . "\"";
915 if ( !is_dir( $wgSQLiteDataDir ) ) {
916 if ( is_writable( dirname( $wgSQLiteDataDir ) ) ) {
917 $ok = wfMkdirParents( $wgSQLiteDataDir, $wgSQLiteDataDirMode );
918 } else {
919 $ok = false;
921 if ( !$ok ) {
922 echo ": cannot create data directory</li>";
923 $errs['SQLiteDataDir'] = 'Enter a valid data directory';
924 continue;
927 if ( !is_writable( $wgSQLiteDataDir ) ) {
928 echo ": data directory not writable</li>";
929 $errs['SQLiteDataDir'] = 'Enter a writable data directory';
930 continue;
932 $dataFile = "$wgSQLiteDataDir/$wgDBname.sqlite";
933 if ( file_exists( $dataFile ) && !is_writable( $dataFile ) ) {
934 echo ": data file not writable</li>";
935 $errs['SQLiteDataDir'] = "$wgDBname.sqlite is not writable";
936 continue;
938 $wgDatabase = new DatabaseSqlite( false, false, false, $wgDBname, 1 );
939 if (!$wgDatabase->isOpen()) {
940 print ": error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
941 $errs['SQLiteDataDir'] = 'Could not connect to database';
942 continue;
943 } else {
944 $myver = $wgDatabase->getServerVersion();
946 if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname);
947 echo "ok</li>\n";
948 } else { # not mysql
949 error_reporting( E_ALL );
950 $wgSuperUser = '';
951 ## Possible connect as a superuser
952 // Changed !mysql to postgres check since it seems to only apply to postgres
953 if( $useRoot && $conf->DBtype == 'postgres' ) {
954 $wgDBsuperuser = $conf->RootUser;
955 echo( "<li>Attempting to connect to database \"postgres\" as superuser \"" .
956 htmlspecialchars( $wgDBsuperuser ) . "\"..." );
957 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBsuperuser, $conf->RootPW, "postgres", 1);
958 if (!$wgDatabase->isOpen()) {
959 print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
960 $errs["DBserver"] = "Could not connect to database as superuser";
961 $errs["RootUser"] = "Check username";
962 $errs["RootPW"] = "and password";
963 continue;
965 $wgDatabase->initial_setup($conf->RootPW, 'postgres');
967 echo( "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) .
968 "\" as \"" . htmlspecialchars( $wgDBuser ) . "\"..." );
969 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1);
970 if (!$wgDatabase->isOpen()) {
971 print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
972 } else {
973 $myver = $wgDatabase->getServerVersion();
975 if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname);
978 if ( !$wgDatabase->isOpen() ) {
979 $errs["DBserver"] = "Couldn't connect to database";
980 continue;
983 print "<li>Connected to " . htmlspecialchars( "{$conf->DBtype} $myver" );
984 if ($conf->DBtype == 'mysql') {
985 if( version_compare( $myver, "4.0.14" ) < 0 ) {
986 print "</li>\n";
987 dieout( "-- mysql 4.0.14 or later required. Aborting." );
989 $mysqlNewAuth = version_compare( $myver, "4.1.0", "ge" );
990 if( $mysqlNewAuth && $mysqlOldClient ) {
991 print "; <b class='error'>You are using MySQL 4.1 server, but PHP is linked
992 to old client libraries; if you have trouble with authentication, see
993 <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
994 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>";
996 if( $wgDBmysql5 ) {
997 if( $mysqlNewAuth ) {
998 print "; enabling MySQL 4.1/5.0 charset mode";
999 } else {
1000 print "; <b class='error'>MySQL 4.1/5.0 charset mode enabled,
1001 but older version detected; will likely fail.</b>";
1004 print "</li>\n";
1006 @$sel = $wgDatabase->selectDB( $wgDBname );
1007 if( $sel ) {
1008 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
1009 } else {
1010 $err = mysql_errno();
1011 $databaseSafe = htmlspecialchars( $wgDBname );
1012 if( $err == 1102 /* Invalid database name */ ) {
1013 print "<ul><li><strong>{$databaseSafe}</strong> is not a valid database name.</li></ul>";
1014 continue;
1015 } elseif( $err != 1049 /* Database doesn't exist */ ) {
1016 print "<ul><li>Error selecting database <strong>{$databaseSafe}</strong>: {$err} ";
1017 print htmlspecialchars( mysql_error() ) . "</li></ul>";
1018 continue;
1020 print "<li>Attempting to create database...</li>";
1021 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
1022 if( !$res ) {
1023 print "<li>Couldn't create database <tt>" .
1024 htmlspecialchars( $wgDBname ) .
1025 "</tt>; try with root access or check your username/pass.</li>\n";
1026 $errs["RootPW"] = "<- Enter";
1027 continue;
1029 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
1031 $wgDatabase->selectDB( $wgDBname );
1033 else if ($conf->DBtype == 'postgres') {
1034 if( version_compare( $myver, "8.0" ) < 0 ) {
1035 dieout( "<b>Postgres 8.0 or later is required</b>. Aborting." );
1039 if( $wgDatabase->tableExists( "cur" ) || $wgDatabase->tableExists( "revision" ) ) {
1040 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n";
1042 if ( $conf->DBtype == 'mysql') {
1043 # Determine existing default character set
1044 if ( $wgDatabase->tableExists( "revision" ) ) {
1045 $revision = $wgDatabase->escapeLike( $conf->DBprefix . 'revision' );
1046 $res = $wgDatabase->query( "SHOW TABLE STATUS LIKE '$revision'" );
1047 $row = $wgDatabase->fetchObject( $res );
1048 if ( !$row ) {
1049 echo "<li>SHOW TABLE STATUS query failed!</li>\n";
1050 $existingSchema = false;
1051 $existingEngine = false;
1052 } else {
1053 if ( preg_match( '/^latin1/', $row->Collation ) ) {
1054 $existingSchema = 'mysql4';
1055 } elseif ( preg_match( '/^utf8/', $row->Collation ) ) {
1056 $existingSchema = 'mysql5';
1057 } elseif ( preg_match( '/^binary/', $row->Collation ) ) {
1058 $existingSchema = 'mysql5-binary';
1059 } else {
1060 $existingSchema = false;
1061 echo "<li><strong>Warning:</strong> Unrecognised existing collation</li>\n";
1063 if ( isset( $row->Engine ) ) {
1064 $existingEngine = $row->Engine;
1065 } else {
1066 $existingEngine = $row->Type;
1069 if ( $existingSchema && $existingSchema != $conf->DBschema ) {
1070 $encExisting = htmlspecialchars( $existingSchema );
1071 $encRequested = htmlspecialchars( $conf->DBschema );
1072 print "<li><strong>Warning:</strong> you requested the $encRequested schema, " .
1073 "but the existing database has the $encExisting schema. This upgrade script ".
1074 "can't convert it, so it will remain $encExisting.</li>\n";
1075 $conf->setSchema( $existingSchema, $conf->DBengine );
1077 if ( $existingEngine && $existingEngine != $conf->DBengine ) {
1078 $encExisting = htmlspecialchars( $existingEngine );
1079 $encRequested = htmlspecialchars( $conf->DBengine );
1080 print "<li><strong>Warning:</strong> you requested the $encRequested storage " .
1081 "engine, but the existing database uses the $encExisting engine. This upgrade " .
1082 "script can't convert it, so it will remain $encExisting.</li>\n";
1083 $conf->setSchema( $conf->DBschema, $existingEngine );
1087 # Create user if required
1088 if ( $conf->Root ) {
1089 $conn = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
1090 if ( $conn->isOpen() ) {
1091 print "<li>DB user account ok</li>\n";
1092 $conn->close();
1093 } else {
1094 print "<li>Granting user permissions...";
1095 if( $mysqlOldClient && $mysqlNewAuth ) {
1096 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>";
1098 print "</li>\n";
1099 dbsource( "../maintenance/users.sql", $wgDatabase );
1103 print "</ul><pre>\n";
1104 chdir( ".." );
1105 flush();
1106 do_all_updates();
1107 chdir( "config" );
1108 print "</pre>\n";
1109 print "<ul><li>Finished update checks.</li>\n";
1110 } else {
1111 # Determine available storage engines if possible
1112 if ( $conf->DBtype == 'mysql' && version_compare( $myver, "4.1.2", "ge" ) ) {
1113 $res = $wgDatabase->query( 'SHOW ENGINES' );
1114 $found = false;
1115 while ( $row = $wgDatabase->fetchObject( $res ) ) {
1116 if ( $row->Engine == $conf->DBengine ) {
1117 $found = true;
1118 break;
1121 $wgDatabase->freeResult( $res );
1122 if ( !$found && $conf->DBengine != 'MyISAM' ) {
1123 echo "<li><strong>Warning:</strong> " . htmlspecialchars( $conf->DBengine ) .
1124 " storage engine not available, " .
1125 "using MyISAM instead</li>\n";
1126 $conf->setSchema( $conf->DBschema, 'MyISAM' );
1130 # FIXME: Check for errors
1131 print "<li>Creating tables...";
1132 if ($conf->DBtype == 'mysql') {
1133 dbsource( "../maintenance/tables.sql", $wgDatabase );
1134 dbsource( "../maintenance/interwiki.sql", $wgDatabase );
1135 } elseif (is_callable(array($wgDatabase, 'setup_database'))) {
1136 $wgDatabase->setup_database();
1138 else {
1139 $errs["DBtype"] = "Do not know how to handle database type '$conf->DBtype'";
1140 continue;
1143 print " done.</li>\n";
1145 print "<li>Initializing statistics...</li>\n";
1146 $wgDatabase->insert( 'site_stats',
1147 array ( 'ss_row_id' => 1,
1148 'ss_total_views' => 0,
1149 'ss_total_edits' => 1, # Main page first edit
1150 'ss_good_articles' => 0, # Main page is not a good article - no internal link
1151 'ss_total_pages' => 1, # Main page
1152 'ss_users' => $conf->SysopName ? 1 : 0, # Sysop account, if created
1153 'ss_admins' => $conf->SysopName ? 1 : 0, # Sysop account, if created
1154 'ss_images' => 0 ) );
1156 # Set up the "regular user" account *if we can, and if we need to*
1157 if( $conf->Root and $conf->DBtype == 'mysql') {
1158 # See if we need to
1159 $wgDatabase2 = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
1160 if( $wgDatabase2->isOpen() ) {
1161 # Nope, just close the test connection and continue
1162 $wgDatabase2->close();
1163 echo( "<li>User " . htmlspecialchars( $wgDBuser ) . " exists. Skipping grants.</li>\n" );
1164 } else {
1165 # Yes, so run the grants
1166 echo( "<li>" . htmlspecialchars( "Granting user permissions to $wgDBuser on $wgDBname..." ) );
1167 dbsource( "../maintenance/users.sql", $wgDatabase );
1168 echo( "success.</li>\n" );
1172 if( $conf->SysopName ) {
1173 $u = User::newFromName( $conf->getSysopName() );
1174 if ( !$u ) {
1175 print "<li><strong class=\"error\">Warning:</strong> Skipped sysop account creation - invalid username!</li>\n";
1177 else if ( 0 == $u->idForName() ) {
1178 $u->addToDatabase();
1179 $u->setPassword( $conf->getSysopPass() );
1180 $u->saveSettings();
1182 $u->addGroup( "sysop" );
1183 $u->addGroup( "bureaucrat" );
1185 print "<li>Created sysop account <tt>" .
1186 htmlspecialchars( $conf->SysopName ) . "</tt>.</li>\n";
1187 } else {
1188 print "<li>Could not create user - already exists!</li>\n";
1190 } else {
1191 print "<li>Skipped sysop account creation, no name given.</li>\n";
1194 $titleobj = Title::newFromText( wfMsgNoDB( "mainpage" ) );
1195 $article = new Article( $titleobj );
1196 $newid = $article->insertOn( $wgDatabase );
1197 $revision = new Revision( array(
1198 'page' => $newid,
1199 'text' => wfMsg( 'mainpagetext' ) . "\n\n" . wfMsgNoTrans( 'mainpagedocfooter' ),
1200 'comment' => '',
1201 'user' => 0,
1202 'user_text' => 'MediaWiki default',
1203 ) );
1204 $revid = $revision->insertOn( $wgDatabase );
1205 $article->updateRevisionOn( $wgDatabase, $revision );
1207 // Now that all database work is done, make sure everything is committed
1208 $wgDatabase->commit();
1210 /* Write out the config file now that all is well */
1211 print "<li style=\"list-style: none\">\n";
1212 print "<p>Creating LocalSettings.php...</p>\n\n";
1213 $localSettings = "<" . "?php$endl$local";
1214 // Fix up a common line-ending problem (due to CVS on Windows)
1215 $localSettings = str_replace( "\r\n", "\n", $localSettings );
1216 $f = fopen( "LocalSettings.php", 'xt' );
1218 if( $f == false ) {
1219 print( "</li>\n" );
1220 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" .
1221 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
1222 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
1224 if(fwrite( $f, $localSettings ) ) {
1225 fclose( $f );
1226 print "<hr/>\n";
1227 writeSuccessMessage();
1228 print "</li>\n";
1229 } else {
1230 fclose( $f );
1231 dieout( "<p class='error'>An error occured while writing the config/LocalSettings.php file. Check user rights and disk space then try again.</p></li>\n" );
1234 } while( false );
1237 print "</ul>\n";
1238 $mainListOpened = false;
1240 if( count( $errs ) ) {
1241 /* Display options form */
1243 if( $conf->posted ) {
1244 echo "<p class='error-top'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
1248 <form action="<?php echo defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php'; ?>" name="config" method="post">
1250 <h2>Site config</h2>
1252 <div class="config-section">
1253 <div class="config-input">
1254 <?php aField( $conf, "Sitename", "Wiki name:" ); ?>
1255 </div>
1256 <p class="config-desc">
1257 Preferably a short word without punctuation, i.e. "Wikipedia".<br />
1258 Will appear as the namespace name for "meta" pages, and throughout the interface.
1259 </p>
1260 <div class="config-input"><?php aField( $conf, "EmergencyContact", "Contact e-mail:" ); ?></div>
1261 <p class="config-desc">
1262 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.
1263 </p>
1265 <div class="config-input">
1266 <label class='column' for="LanguageCode">Language:</label>
1267 <select id="LanguageCode" name="LanguageCode"><?php
1268 $list = getLanguageList();
1269 foreach( $list as $code => $name ) {
1270 $sel = ($code == $conf->LanguageCode) ? 'selected="selected"' : '';
1271 $encCode = htmlspecialchars( $code );
1272 $encName = htmlspecialchars( $name );
1273 echo "\n\t\t<option value=\"$encCode\" $sel>$encName</option>";
1275 echo "\n";
1277 </select>
1278 </div>
1279 <p class="config-desc">
1280 Select the language for your wiki's interface. Some localizations aren't fully complete. Unicode (UTF-8) is used for all localizations.
1281 </p>
1283 <div class="config-input">
1284 <label class='column'>Copyright/license:</label>
1286 <ul class="plain">
1287 <li><?php aField( $conf, "License", "No license metadata", "radio", "none" ); ?></li>
1288 <li><?php aField( $conf, "License", "Public Domain", "radio", "pd" ); ?></li>
1289 <li><?php aField( $conf, "License", "GNU Free Documentation License 1.2 (Wikipedia-compatible)", "radio", "gfdl1_2" ); ?></li>
1290 <li><?php aField( $conf, "License", "GNU Free Documentation License 1.3", "radio", "gfdl1_3" ); ?></li>
1291 <li><?php
1292 aField( $conf, "License", "A Creative Commons license - ", "radio", "cc" );
1293 $partner = "MediaWiki";
1294 $script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php';
1295 $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/$script?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
1296 $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" );
1297 $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" );
1298 print "<a href=\"$ccApp\" target='_blank'>choose</a>";
1299 if( $conf->License == "cc" ) { ?>
1300 <ul>
1301 <li><?php aField( $conf, "RightsIcon", "<img src=\"" . htmlspecialchars( $conf->RightsIcon ) . "\" alt='(Creative Commons icon)' />", "hidden" ); ?></li>
1302 <li><?php aField( $conf, "RightsText", htmlspecialchars( $conf->RightsText ), "hidden" ); ?></li>
1303 <li><?php aField( $conf, "RightsCode", "code: " . htmlspecialchars( $conf->RightsCode ), "hidden" ); ?></li>
1304 <li><?php aField( $conf, "RightsUrl", "<a href=\"" . htmlspecialchars( $conf->RightsUrl ) . "\">" . htmlspecialchars( $conf->RightsUrl ) . "</a>", "hidden" ); ?></li>
1305 </ul>
1306 <?php } ?>
1307 </li>
1308 </ul>
1309 </div>
1310 <p class="config-desc">
1311 A notice, icon, and machine-readable copyright metadata will be displayed for the license you pick.
1312 </p>
1315 <div class="config-input">
1316 <?php aField( $conf, "SysopName", "Admin username:" ) ?>
1317 </div>
1318 <div class="config-input">
1319 <?php aField( $conf, "SysopPass", "Password:", "password" ) ?>
1320 </div>
1321 <div class="config-input">
1322 <?php aField( $conf, "SysopPass2", "Password confirm:", "password" ) ?>
1323 </div>
1324 <p class="config-desc">
1325 An admin can lock/delete pages, block users from editing, and do other maintenance tasks.<br />
1326 A new account will be added only when creating a new wiki database.
1327 <br /><br />
1328 The password cannot be the same as the username.
1329 </p>
1331 <div class="config-input">
1332 <label class='column'>Object caching:</label>
1334 <ul class="plain">
1335 <li><?php aField( $conf, "Shm", "No caching", "radio", "none" ); ?></li>
1336 <?php
1337 if ( $conf->turck ) {
1338 echo "<li>";
1339 aField( $conf, "Shm", "Turck MMCache", "radio", "turck" );
1340 echo "</li>\n";
1342 if( $conf->xcache ) {
1343 echo "<li>";
1344 aField( $conf, 'Shm', 'XCache', 'radio', 'xcache' );
1345 echo "</li>\n";
1347 if ( $conf->apc ) {
1348 echo "<li>";
1349 aField( $conf, "Shm", "APC", "radio", "apc" );
1350 echo "</li>\n";
1352 if ( $conf->eaccel ) {
1353 echo "<li>";
1354 aField( $conf, "Shm", "eAccelerator", "radio", "eaccel" );
1355 echo "</li>\n";
1357 if ( $conf->dba ) {
1358 echo "<li>";
1359 aField( $conf, "Shm", "DBA (not recommended)", "radio", "dba" );
1360 echo "</li>";
1363 <li><?php aField( $conf, "Shm", "Memcached", "radio", "memcached" ); ?></li>
1364 </ul>
1365 <div style="clear:left"><?php aField( $conf, "MCServers", "Memcached servers:", "text" ) ?></div>
1366 </div>
1367 <p class="config-desc">
1368 An object caching system such as memcached will provide a significant performance boost,
1369 but needs to be installed. Provide the server addresses and ports in a comma-separated list.
1370 <br /><br />
1371 MediaWiki can also detect and support eAccelerator, Turck MMCache, APC, and XCache, but
1372 these should not be used if the wiki will be running on multiple application servers.
1373 <br/><br/>
1374 DBA (Berkeley-style DB) is generally slower than using no cache at all, and is only
1375 recommended for testing.
1376 </p>
1377 </div>
1379 <h2>E-mail, e-mail notification and authentication setup</h2>
1381 <div class="config-section">
1382 <div class="config-input">
1383 <label class='column'>E-mail features (global):</label>
1384 <ul class="plain">
1385 <li><?php aField( $conf, "Email", "Enabled", "radio", "email_enabled" ); ?></li>
1386 <li><?php aField( $conf, "Email", "Disabled", "radio", "email_disabled" ); ?></li>
1387 </ul>
1388 </div>
1389 <p class="config-desc">
1390 Use this to disable all e-mail functions (password reminders, user-to-user e-mail, and e-mail notifications)
1391 if sending mail doesn't work on your server.
1392 </p>
1394 <div class="config-input">
1395 <label class='column'>User-to-user e-mail:</label>
1396 <ul class="plain">
1397 <li><?php aField( $conf, "Emailuser", "Enabled", "radio", "emailuser_enabled" ); ?></li>
1398 <li><?php aField( $conf, "Emailuser", "Disabled", "radio", "emailuser_disabled" ); ?></li>
1399 </ul>
1400 </div>
1401 <p class="config-desc">
1402 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.
1403 </p>
1404 <div class="config-input">
1405 <label class='column'>E-mail notification about changes:</label>
1406 <ul class="plain">
1407 <li><?php aField( $conf, "Enotif", "Disabled", "radio", "enotif_disabled" ); ?></li>
1408 <li><?php aField( $conf, "Enotif", "Enabled for changes to user discussion pages only", "radio", "enotif_usertalk" ); ?></li>
1409 <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>
1410 </ul>
1411 </div>
1412 <div class="config-desc">
1414 For this feature to work, an e-mail address must be present for the user account, and the notification
1415 options in the user's preferences must be enabled. Also note the
1416 authentication option below. When testing the feature, keep in mind that your own changes will never trigger notifications to be sent to yourself.</p>
1418 <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>
1419 </div>
1421 <div class="config-input">
1422 <label class='column'>E-mail address authentication:</label>
1423 <ul class="plain">
1424 <li><?php aField( $conf, "Eauthent", "Disabled", "radio", "eauthent_disabled" ); ?></li>
1425 <li><?php aField( $conf, "Eauthent", "Enabled", "radio", "eauthent_enabled" ); ?></li>
1426 </ul>
1427 </div>
1428 <div class="config-desc">
1429 <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
1430 change notification mails. Setting this option is <b>recommended</b> for public wikis because of potential abuse of the e-mail features above.</p>
1431 </div>
1433 </div>
1435 <h2>Database config</h2>
1437 <div class="config-section">
1438 <div class="config-input">
1439 <label class='column'>Database type:</label>
1440 <?php
1441 if (isset($errs['DBpicktype'])) {
1442 print "\t<span class='error'>" . htmlspecialchars( $errs['DBpicktype'] ) . "</span>\n";
1445 <ul class='plain'><?php
1446 database_picker($conf);
1447 ?></ul>
1448 </div>
1450 <div class="config-input" style="clear:left">
1451 <?php aField( $conf, "DBserver", "Database host:" ); ?>
1452 </div>
1453 <p class="config-desc">
1454 If your database server isn't on your web server, enter the name or IP address here.
1455 </p>
1457 <div class="config-input"><?php aField( $conf, "DBname", "Database name:" ); ?></div>
1458 <div class="config-input"><?php aField( $conf, "DBuser", "DB username:" ); ?></div>
1459 <div class="config-input"><?php aField( $conf, "DBpassword", "DB password:", "password" ); ?></div>
1460 <div class="config-input"><?php aField( $conf, "DBpassword2", "DB password confirm:", "password" ); ?></div>
1461 <p class="config-desc">
1462 If you only have a single user account and database available,
1463 enter those here. If you have database root access (see below)
1464 you can specify new accounts/databases to be created. This account
1465 will not be created if it pre-exists. If this is the case, ensure that it
1466 has SELECT, INSERT, UPDATE, and DELETE permissions on the MediaWiki database.
1467 </p>
1469 <div class="config-input">
1470 <label class="column">Superuser account:</label>
1471 <input type="checkbox" name="useroot" id="useroot" <?php if( $useRoot ) { ?>checked="checked" <?php } ?> />
1472 &nbsp;<label for="useroot">Use superuser account</label>
1473 </div>
1474 <div class="config-input"><?php aField( $conf, "RootUser", "Superuser name:", "text" ); ?></div>
1475 <div class="config-input"><?php aField( $conf, "RootPW", "Superuser password:", "password" ); ?></div>
1477 <p class="config-desc">
1478 If the database user specified above does not exist, or does not have access to create
1479 the database (if needed) or tables within it, please check the box and provide details
1480 of a superuser account, such as <strong>root</strong>, which does.
1481 </p>
1483 <?php database_switcher('mysql'); ?>
1484 <div class="config-input"><?php aField( $conf, "DBprefix", "Database table prefix:" ); ?></div>
1485 <div class="config-desc">
1486 <p>If you need to share one database between multiple wikis, or
1487 between MediaWiki and another web application, you may choose to
1488 add a prefix to all the table names to avoid conflicts.</p>
1490 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
1491 </div>
1493 <div class="config-input"><label class="column">Storage Engine</label>
1494 <div>Select one:</div>
1495 <ul class="plain">
1496 <li><?php aField( $conf, "DBengine", "InnoDB", "radio", "InnoDB" ); ?></li>
1497 <li><?php aField( $conf, "DBengine", "MyISAM", "radio", "MyISAM" ); ?></li>
1498 </ul>
1499 </div>
1500 <p class="config-desc">
1501 InnoDB is best for public web installations, since it has good concurrency
1502 support. MyISAM may be faster in single-user installations. MyISAM databases
1503 tend to get corrupted more often than InnoDB databases.
1504 </p>
1505 <div class="config-input"><label class="column">Database character set</label>
1506 <div>Select one:</div>
1507 <ul class="plain">
1508 <li><?php aField( $conf, "DBschema", "MySQL 4.1/5.0 binary", "radio", "mysql5-binary" ); ?></li>
1509 <li><?php aField( $conf, "DBschema", "MySQL 4.1/5.0 UTF-8", "radio", "mysql5" ); ?></li>
1510 <li><?php aField( $conf, "DBschema", "MySQL 4.0 backwards-compatible UTF-8", "radio", "mysql4" ); ?></li>
1511 </ul>
1512 </div>
1513 <p class="config-desc">
1514 This option is ignored on upgrade, the same character set will be kept.
1515 <br/><br/>
1516 <b>WARNING:</b> If you use <b>backwards-compatible UTF-8</b> on MySQL 4.1+, and subsequently back up the database with <tt>mysqldump</tt>, it may destroy all non-ASCII characters, irreversibly corrupting your backups!.
1517 <br/><br/>
1518 In <b>binary mode</b>, MediaWiki stores UTF-8 text to the database in binary fields. This is more efficient than MySQL's UTF-8 mode, and allows you to use the full range of Unicode characters. In <b>UTF-8 mode</b>, MySQL will know what character set your data is in, and can present and convert it appropriately, but it won't let you store characters above the <a target="_blank" href="http://en.wikipedia.org/wiki/Mapping_of_Unicode_character_planes">Basic Multilingual Plane</a>.
1519 </p>
1520 </fieldset>
1522 <?php database_switcher('postgres'); ?>
1523 <div class="config-input"><?php aField( $conf, "DBport", "Database port:" ); ?></div>
1524 <div class="config-input"><?php aField( $conf, "DBmwschema", "Schema for mediawiki:" ); ?></div>
1525 <div class="config-input"><?php aField( $conf, "DBts2schema", "Schema for tsearch2:" ); ?></div>
1526 <div class="config-desc">
1527 <p>The username specified above (at "DB username") will have its search path set to the above schemas,
1528 so it is recommended that you create a new user. The above schemas are generally correct:
1529 only change them if you are sure you need to.</p>
1530 </div>
1531 </fieldset>
1533 <?php database_switcher('sqlite'); ?>
1534 <div class="config-desc">
1535 <b>NOTE:</b> SQLite only uses the <i>Database name</i> setting above, the user, password and root settings are ignored.
1536 </div>
1537 <div class="config-input"><?php
1538 aField( $conf, "SQLiteDataDir", "SQLite data directory:" );
1539 ?></div>
1540 <div class="config-desc">
1541 <p>SQLite stores table data into files in the filesystem.
1542 If you do not provide an explicit path, a "data" directory in
1543 the parent of your document root will be used.</p>
1545 <p>This directory must exist and be writable by the web server.</p>
1546 </div>
1547 </fieldset>
1549 <?php database_switcher('mssql'); ?>
1550 <div class="config-input"><?php
1551 aField( $conf, "DBprefix2", "Database table prefix:" );
1552 ?></div>
1553 <div class="config-desc">
1554 <p>If you need to share one database between multiple wikis, or
1555 between MediaWiki and another web application, you may choose to
1556 add a prefix to all the table names to avoid conflicts.</p>
1558 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
1559 </div>
1560 </fieldset>
1562 <?php database_switcher('ibm_db2'); ?>
1563 <div class="config-input"><?php
1564 aField( $conf, "DBport_db2", "Database port:" );
1565 ?></div>
1566 <div class="config-input"><?php
1567 aField( $conf, "DBmwschema", "Schema for mediawiki:" );
1568 ?></div>
1569 <div>Select one:</div>
1570 <ul class="plain">
1571 <li><?php aField( $conf, "DBcataloged", "Cataloged (DB2 installed locally)", "radio", "cataloged" ); ?></li>
1572 <li><?php aField( $conf, "DBcataloged", "Uncataloged (remote DB2 through ODBC)", "radio", "uncataloged" ); ?></li>
1573 </ul>
1574 <div class="config-desc">
1575 <p>If you need to share one database between multiple wikis, or
1576 between MediaWiki and another web application, you may specify
1577 a different schema to avoid conflicts.</p>
1578 </div>
1579 </fieldset>
1581 <div class="config-input" style="padding:2em 0 3em">
1582 <label class='column'>&nbsp;</label>
1583 <input type="submit" value="Install MediaWiki!" class="btn-install" />
1584 </div>
1585 </div>
1586 </form>
1587 <script type="text/javascript">
1588 window.onload = toggleDBarea( <?php echo Xml::encodeJsVar( $conf->DBtype ); ?>,
1589 <?php
1590 ## If they passed in a root user name, don't populate it on page load
1591 echo strlen(importPost('RootUser', '')) ? 0 : 1;
1592 ?>);
1593 </script>
1594 <?php
1597 /* -------------------------------------------------------------------------------------- */
1598 function writeSuccessMessage() {
1599 $script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php';
1600 if ( wfIniGetBool( 'safe_mode' ) && !ini_get( 'open_basedir' ) ) {
1601 echo <<<EOT
1602 <div class="success-box">
1603 <p>Installation successful!</p>
1604 <p>To complete the installation, please do the following:
1605 <ol>
1606 <li>Download config/LocalSettings.php with your FTP client or file manager</li>
1607 <li>Upload it to the parent directory</li>
1608 <li>Delete config/LocalSettings.php</li>
1609 <li>Start using <a href='../$script'>your wiki</a>!
1610 </ol>
1611 <p>If you are in a shared hosting environment, do <strong>not</strong> just move LocalSettings.php
1612 remotely. LocalSettings.php is currently owned by the user your webserver is running under,
1613 which means that anyone on the same server can read your database password! Downloading
1614 it and uploading it again will hopefully change the ownership to a user ID specific to you.</p>
1615 </div>
1616 EOT;
1617 } else {
1618 echo <<<EOT
1619 <div class="success-box">
1621 <span class="success-message">Installation successful!</span>
1622 Move the <tt>config/LocalSettings.php</tt> file to the parent directory, then follow
1623 <a href="../$script"> this link</a> to your wiki.</p>
1624 <p>You should change file permissions for <tt>LocalSettings.php</tt> as required to
1625 prevent other users on the server reading passwords and altering configuration data.</p>
1626 </div>
1627 EOT;
1632 function escapePhpString( $string ) {
1633 if ( is_array( $string ) || is_object( $string ) ) {
1634 return false;
1636 return strtr( $string,
1637 array(
1638 "\n" => "\\n",
1639 "\r" => "\\r",
1640 "\t" => "\\t",
1641 "\\" => "\\\\",
1642 "\$" => "\\\$",
1643 "\"" => "\\\""
1647 function writeLocalSettings( $conf ) {
1648 $conf->PasswordSender = $conf->EmergencyContact;
1649 $magic = ($conf->ImageMagick ? "" : "# ");
1650 $convert = ($conf->ImageMagick ? $conf->ImageMagick : "/usr/bin/convert" );
1651 $rights = ($conf->RightsUrl) ? "" : "# ";
1652 $hashedUploads = $conf->safeMode ? '' : '# ';
1654 if ( $conf->ShellLocale ) {
1655 $locale = '';
1656 } else {
1657 $locale = '# ';
1658 $conf->ShellLocale = 'en_US.UTF-8';
1661 switch ( $conf->Shm ) {
1662 case 'memcached':
1663 $cacheType = 'CACHE_MEMCACHED';
1664 $mcservers = var_export( $conf->MCServerArray, true );
1665 break;
1666 case 'turck':
1667 case 'xcache':
1668 case 'apc':
1669 case 'eaccel':
1670 $cacheType = 'CACHE_ACCEL';
1671 $mcservers = 'array()';
1672 break;
1673 case 'dba':
1674 $cacheType = 'CACHE_DBA';
1675 $mcservers = 'array()';
1676 break;
1677 default:
1678 $cacheType = 'CACHE_NONE';
1679 $mcservers = 'array()';
1682 if ( $conf->Email == 'email_enabled' ) {
1683 $enableemail = 'true';
1684 $enableuseremail = ( $conf->Emailuser == 'emailuser_enabled' ) ? 'true' : 'false' ;
1685 $eauthent = ( $conf->Eauthent == 'eauthent_enabled' ) ? 'true' : 'false' ;
1686 switch ( $conf->Enotif ) {
1687 case 'enotif_usertalk':
1688 $enotifusertalk = 'true';
1689 $enotifwatchlist = 'false';
1690 break;
1691 case 'enotif_allpages':
1692 $enotifusertalk = 'true';
1693 $enotifwatchlist = 'true';
1694 break;
1695 default:
1696 $enotifusertalk = 'false';
1697 $enotifwatchlist = 'false';
1699 } else {
1700 $enableuseremail = 'false';
1701 $enableemail = 'false';
1702 $eauthent = 'false';
1703 $enotifusertalk = 'false';
1704 $enotifwatchlist = 'false';
1707 $file = @fopen( "/dev/urandom", "r" );
1708 if ( $file ) {
1709 $secretKey = bin2hex( fread( $file, 32 ) );
1710 fclose( $file );
1711 } else {
1712 $secretKey = "";
1713 for ( $i=0; $i<8; $i++ ) {
1714 $secretKey .= dechex(mt_rand(0, 0x7fffffff));
1716 print "<li>Warning: \$wgSecretKey key is insecure, generated with mt_rand(). Consider changing it manually.</li>\n";
1719 # Add slashes to strings for double quoting
1720 $slconf = wfArrayMap( "escapePhpString", get_object_vars( $conf ) );
1721 if( $conf->License == 'gfdl1_2' || $conf->License == 'pd' || $conf->License == 'gfdl1_3' ) {
1722 # Needs literal string interpolation for the current style path
1723 $slconf['RightsIcon'] = $conf->RightsIcon;
1726 if( $conf->DBtype == 'mysql' ) {
1727 $dbsettings =
1728 "# MySQL specific settings
1729 \$wgDBprefix = \"{$slconf['DBprefix']}\";
1731 # MySQL table options to use during installation or update
1732 \$wgDBTableOptions = \"{$slconf['DBTableOptions']}\";
1734 # Experimental charset support for MySQL 4.1/5.0.
1735 \$wgDBmysql5 = {$conf->DBmysql5};";
1736 } elseif( $conf->DBtype == 'postgres' ) {
1737 $dbsettings =
1738 "# Postgres specific settings
1739 \$wgDBport = \"{$slconf['DBport']}\";
1740 \$wgDBmwschema = \"{$slconf['DBmwschema']}\";
1741 \$wgDBts2schema = \"{$slconf['DBts2schema']}\";";
1742 } elseif( $conf->DBtype == 'sqlite' ) {
1743 $dbsettings =
1744 "# SQLite-specific settings
1745 \$wgSQLiteDataDir = \"{$slconf['SQLiteDataDir']}\";";
1746 } elseif( $conf->DBtype == 'mssql' ) {
1747 $dbsettings =
1748 "# MSSQL specific settings
1749 \$wgDBprefix = \"{$slconf['DBprefix2']}\";";
1750 } elseif( $conf->DBtype == 'ibm_db2' ) {
1751 $dbsettings =
1752 "# DB2 specific settings
1753 \$wgDBport_db2 = \"{$slconf['DBport_db2']}\";
1754 \$wgDBmwschema = \"{$slconf['DBmwschema']}\";
1755 \$wgDBcataloged = \"{$slconf['DBcataloged']}\";";
1756 } else {
1757 // ummm... :D
1758 $dbsettings = '';
1762 $localsettings = "
1763 # This file was automatically generated by the MediaWiki installer.
1764 # If you make manual changes, please keep track in case you need to
1765 # recreate them later.
1767 # See includes/DefaultSettings.php for all configurable settings
1768 # and their default values, but don't forget to make changes in _this_
1769 # file, not there.
1771 # Further documentation for configuration settings may be found at:
1772 # http://www.mediawiki.org/wiki/Manual:Configuration_settings
1774 # If you customize your file layout, set \$IP to the directory that contains
1775 # the other MediaWiki files. It will be used as a base to locate files.
1776 if( defined( 'MW_INSTALL_PATH' ) ) {
1777 \$IP = MW_INSTALL_PATH;
1778 } else {
1779 \$IP = dirname( __FILE__ );
1782 \$path = array( \$IP, \"\$IP/includes\", \"\$IP/languages\" );
1783 set_include_path( implode( PATH_SEPARATOR, \$path ) . PATH_SEPARATOR . get_include_path() );
1785 require_once( \"\$IP/includes/DefaultSettings.php\" );
1787 # If PHP's memory limit is very low, some operations may fail.
1788 " . ($conf->raiseMemory ? '' : '# ' ) . "ini_set( 'memory_limit', '20M' );" . "
1790 if ( \$wgCommandLineMode ) {
1791 if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
1792 die( \"This script must be run from the command line\\n\" );
1795 ## Uncomment this to disable output compression
1796 # \$wgDisableOutputCompression = true;
1798 \$wgSitename = \"{$slconf['Sitename']}\";
1800 ## The URL base path to the directory containing the wiki;
1801 ## defaults for all runtime URL paths are based off of this.
1802 ## For more information on customizing the URLs please see:
1803 ## http://www.mediawiki.org/wiki/Manual:Short_URL
1804 \$wgScriptPath = \"{$slconf['ScriptPath']}\";
1805 \$wgScriptExtension = \"{$slconf['ScriptExtension']}\";
1807 ## UPO means: this is also a user preference option
1809 \$wgEnableEmail = $enableemail;
1810 \$wgEnableUserEmail = $enableuseremail; # UPO
1812 \$wgEmergencyContact = \"{$slconf['EmergencyContact']}\";
1813 \$wgPasswordSender = \"{$slconf['PasswordSender']}\";
1815 \$wgEnotifUserTalk = $enotifusertalk; # UPO
1816 \$wgEnotifWatchlist = $enotifwatchlist; # UPO
1817 \$wgEmailAuthentication = $eauthent;
1819 ## Database settings
1820 \$wgDBtype = \"{$slconf['DBtype']}\";
1821 \$wgDBserver = \"{$slconf['DBserver']}\";
1822 \$wgDBname = \"{$slconf['DBname']}\";
1823 \$wgDBuser = \"{$slconf['DBuser']}\";
1824 \$wgDBpassword = \"{$slconf['DBpassword']}\";
1826 {$dbsettings}
1828 ## Shared memory settings
1829 \$wgMainCacheType = $cacheType;
1830 \$wgMemCachedServers = $mcservers;
1832 ## To enable image uploads, make sure the 'images' directory
1833 ## is writable, then set this to true:
1834 \$wgEnableUploads = false;
1835 {$magic}\$wgUseImageMagick = true;
1836 {$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
1838 ## If you use ImageMagick (or any other shell command) on a
1839 ## Linux server, this will need to be set to the name of an
1840 ## available UTF-8 locale
1841 {$locale}\$wgShellLocale = \"{$slconf['ShellLocale']}\";
1843 ## If you want to use image uploads under safe mode,
1844 ## create the directories images/archive, images/thumb and
1845 ## images/temp, and make them all writable. Then uncomment
1846 ## this, if it's not already uncommented:
1847 {$hashedUploads}\$wgHashedUploadDirectory = false;
1849 ## If you have the appropriate support software installed
1850 ## you can enable inline LaTeX equations:
1851 \$wgUseTeX = false;
1853 \$wgLocalInterwiki = strtolower( \$wgSitename );
1855 \$wgLanguageCode = \"{$slconf['LanguageCode']}\";
1857 \$wgSecretKey = \"$secretKey\";
1859 ## Default skin: you can change the default skin. Use the internal symbolic
1860 ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook':
1861 \$wgDefaultSkin = 'monobook';
1863 ## For attaching licensing metadata to pages, and displaying an
1864 ## appropriate copyright notice / icon. GNU Free Documentation
1865 ## License and Creative Commons licenses are supported so far.
1866 {$rights}\$wgEnableCreativeCommonsRdf = true;
1867 \$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright
1868 \$wgRightsUrl = \"{$slconf['RightsUrl']}\";
1869 \$wgRightsText = \"{$slconf['RightsText']}\";
1870 \$wgRightsIcon = \"{$slconf['RightsIcon']}\";
1871 # \$wgRightsCode = \"{$slconf['RightsCode']}\"; # Not yet used
1873 \$wgDiff3 = \"{$slconf['diff3']}\";
1875 # When you make changes to this configuration file, this will make
1876 # sure that cached pages are cleared.
1877 \$wgCacheEpoch = max( \$wgCacheEpoch, gmdate( 'YmdHis', @filemtime( __FILE__ ) ) );
1878 "; ## End of setting the $localsettings string
1880 // Keep things in Unix line endings internally;
1881 // the system will write out as local text type.
1882 return str_replace( "\r\n", "\n", $localsettings );
1885 function dieout( $text ) {
1886 global $mainListOpened;
1887 if( $mainListOpened ) echo( "</ul>" );
1888 if( $text != '' && substr( $text, 0, 2 ) != '<p' && substr( $text, 0, 2 ) != '<h' ){
1889 echo "<p>$text</p>\n";
1890 } else {
1891 echo $text;
1893 die( "\n\n</div>\n</div>\n</div>\n</div>\n</body>\n</html>" );
1896 function importVar( &$var, $name, $default = "" ) {
1897 if( isset( $var[$name] ) ) {
1898 $retval = $var[$name];
1899 if ( get_magic_quotes_gpc() ) {
1900 $retval = stripslashes( $retval );
1902 } else {
1903 $retval = $default;
1905 taint( $retval );
1906 return $retval;
1909 function importPost( $name, $default = "" ) {
1910 return importVar( $_POST, $name, $default );
1913 function importCheck( $name ) {
1914 return isset( $_POST[$name] );
1917 function importRequest( $name, $default = "" ) {
1918 return importVar( $_REQUEST, $name, $default );
1921 function aField( &$conf, $field, $text, $type = "text", $value = "", $onclick = '' ) {
1922 static $radioCount = 0;
1923 if( $type != "" ) {
1924 $xtype = "type=\"$type\"";
1925 } else {
1926 $xtype = "";
1929 $id = $field;
1930 $nolabel = ($type == "radio") || ($type == "hidden");
1932 if ($type == 'radio')
1933 $id .= $radioCount++;
1935 if( !$nolabel ) {
1936 echo "<label class='column' for=\"$id\">$text</label>";
1939 if( $type == "radio" && $value == $conf->$field ) {
1940 $checked = "checked='checked'";
1941 } else {
1942 $checked = "";
1944 echo "<input $xtype name=\"$field\" id=\"$id\" class=\"iput-$type\" $checked ";
1945 if ($onclick) {
1946 echo " onclick='toggleDBarea(\"$value\",1)' " ;
1948 echo "value=\"";
1949 if( $type == "radio" ) {
1950 echo htmlspecialchars( $value );
1951 } else {
1952 echo htmlspecialchars( $conf->$field );
1956 echo "\" />";
1957 if( $nolabel ) {
1958 echo "<label for=\"$id\">$text</label>";
1961 global $errs;
1962 if(isset($errs[$field])) {
1963 echo "<span class='error'>" . htmlspecialchars( $errs[$field] ) . "</span>\n";
1967 function getLanguageList() {
1968 global $wgLanguageNames, $IP;
1969 if( !isset( $wgLanguageNames ) ) {
1970 require_once( "$IP/languages/Names.php" );
1973 $codes = array();
1975 $d = opendir( "../languages/messages" );
1976 /* In case we are called from the root directory */
1977 if (!$d)
1978 $d = opendir( "languages/messages");
1979 while( false !== ($f = readdir( $d ) ) ) {
1980 $m = array();
1981 if( preg_match( '/Messages([A-Z][a-z_]+)\.php$/', $f, $m ) ) {
1982 $code = str_replace( '_', '-', strtolower( $m[1] ) );
1983 if( isset( $wgLanguageNames[$code] ) ) {
1984 $name = $code . ' - ' . $wgLanguageNames[$code];
1985 } else {
1986 $name = $code;
1988 $codes[$code] = $name;
1991 closedir( $d );
1992 ksort( $codes );
1993 return $codes;
1996 #Check for location of an executable
1997 # @param string $loc single location to check
1998 # @param array $names filenames to check for.
1999 # @param mixed $versioninfo array of details to use when checking version, use false for no version checking
2000 function locate_executable($loc, $names, $versioninfo = false) {
2001 if (!is_array($names))
2002 $names = array($names);
2004 foreach ($names as $name) {
2005 $command = "$loc".DIRECTORY_SEPARATOR."$name";
2006 if (@file_exists($command)) {
2007 if (!$versioninfo)
2008 return $command;
2010 $file = str_replace('$1', $command, $versioninfo[0]);
2011 if (strstr(`$file`, $versioninfo[1]) !== false)
2012 return $command;
2015 return false;
2018 # Test a memcached server
2019 function testMemcachedServer( $server ) {
2020 $hostport = explode(":", $server);
2021 $errstr = false;
2022 $fp = false;
2023 if ( !function_exists( 'fsockopen' ) ) {
2024 $errstr = "Can't connect to memcached, fsockopen() not present";
2026 if ( !$errstr && count( $hostport ) != 2 ) {
2027 $errstr = 'Please specify host and port';
2029 if ( !$errstr ) {
2030 list( $host, $port ) = $hostport;
2031 $errno = 0;
2032 $fsockerr = '';
2034 $fp = @fsockopen( $host, $port, $errno, $fsockerr, 1.0 );
2035 if ( $fp === false ) {
2036 $errstr = "Cannot connect to memcached on $host:$port : $fsockerr";
2039 if ( !$errstr ) {
2040 $command = "version\r\n";
2041 $bytes = fwrite( $fp, $command );
2042 if ( $bytes != strlen( $command ) ) {
2043 $errstr = "Cannot write to memcached socket on $host:$port";
2046 if ( !$errstr ) {
2047 $expected = "VERSION ";
2048 $response = fread( $fp, strlen( $expected ) );
2049 if ( $response != $expected ) {
2050 $errstr = "Didn't get correct memcached response from $host:$port";
2053 if ( $fp ) {
2054 fclose( $fp );
2056 if ( !$errstr ) {
2057 echo "<li>Connected to memcached on " . htmlspecialchars( "$host:$port" ) ." successfully</li>";
2059 return $errstr;
2062 function database_picker($conf) {
2063 global $ourdb;
2064 print "\n";
2065 foreach(array_keys($ourdb) as $db) {
2066 if ($ourdb[$db]['havedriver']) {
2067 print "\t<li>";
2068 aField( $conf, "DBtype", $ourdb[$db]['fullname'], 'radio', $db, 'onclick');
2069 print "</li>\n";
2072 print "\n\t";
2075 function database_switcher($db) {
2076 global $ourdb;
2077 $color = $ourdb[$db]['bgcolor'];
2078 $full = $ourdb[$db]['fullname'];
2079 print "<fieldset id='$db'><legend>$full specific options</legend>\n";
2082 function printListItem( $item ) {
2083 print "<li>$item</li>";
2086 # Determine a suitable value for $wgShellLocale
2087 function getShellLocale( $wikiLang ) {
2088 # Give up now if we're in safe mode or open_basedir
2089 # It's theoretically possible but tricky to work with
2090 if ( wfIniGetBool( "safe_mode" ) || ini_get( 'open_basedir' ) ) {
2091 return false;
2094 $os = php_uname( 's' );
2095 $supported = array( 'Linux', 'SunOS', 'HP-UX' ); # Tested these
2096 if ( !in_array( $os, $supported ) ) {
2097 return false;
2100 # Get a list of available locales
2101 $lines = $ret = false;
2102 exec( '/usr/bin/locale -a', $lines, $ret );
2103 if ( $ret ) {
2104 return false;
2107 $lines = wfArrayMap( 'trim', $lines );
2108 $candidatesByLocale = array();
2109 $candidatesByLang = array();
2110 foreach ( $lines as $line ) {
2111 if ( $line === '' ) {
2112 continue;
2114 if ( !preg_match( '/^([a-zA-Z]+)(_[a-zA-Z]+|)\.(utf8|UTF-8)(@[a-zA-Z_]*|)$/i', $line, $m ) ) {
2115 continue;
2117 list( $all, $lang, $territory, $charset, $modifier ) = $m;
2118 $candidatesByLocale[$m[0]] = $m;
2119 $candidatesByLang[$lang][] = $m;
2122 # Try the current value of LANG
2123 if ( isset( $candidatesByLocale[ getenv( 'LANG' ) ] ) ) {
2124 return getenv( 'LANG' );
2127 # Try the most common ones
2128 $commonLocales = array( 'en_US.UTF-8', 'en_US.utf8', 'de_DE.UTF-8', 'de_DE.utf8' );
2129 foreach ( $commonLocales as $commonLocale ) {
2130 if ( isset( $candidatesByLocale[$commonLocale] ) ) {
2131 return $commonLocale;
2135 # Is there an available locale in the Wiki's language?
2136 if ( isset( $candidatesByLang[$wikiLang] ) ) {
2137 $m = reset( $candidatesByLang[$wikiLang] );
2138 return $m[0];
2141 # Are there any at all?
2142 if ( count( $candidatesByLocale ) ) {
2143 $m = reset( $candidatesByLocale );
2144 return $m[0];
2147 # Give up
2148 return false;
2151 function wfArrayMap( $function, $input ) {
2152 $ret = array_map( $function, $input );
2153 foreach ( $ret as $key => $value ) {
2154 $taint = istainted( $input[$key] );
2155 if ( $taint ) {
2156 taint( $ret[$key], $taint );
2159 return $ret;
2164 <div class="license">
2165 <hr/>
2166 <p>This program is free software; you can redistribute it and/or modify
2167 it under the terms of the GNU General Public License as published by
2168 the Free Software Foundation; either version 2 of the License, or
2169 (at your option) any later version.</p>
2171 <p>This program is distributed in the hope that it will be useful,
2172 but WITHOUT ANY WARRANTY; without even the implied warranty of
2173 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2174 GNU General Public License for more details.</p>
2176 <p>You should have received <a href="../COPYING">a copy of the GNU General Public License</a>
2177 along with this program; if not, write to the Free Software
2178 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2179 or <a href="http://www.gnu.org/copyleft/gpl.html">read it online</a></p>
2180 </div>
2182 </div></div></div>
2185 <div id="column-one">
2186 <div class="portlet" id="p-logo">
2187 <a style="background-image: url(../skins/common/images/mediawiki.png);"
2188 href="../"
2189 title="Main Page"></a>
2190 </div>
2191 <script type="text/javascript"> if (window.isMSIE55) fixalpha(); </script>
2192 <div class='portlet'><div class='pBody'>
2193 <ul>
2194 <li><a href="../README">Readme</a></li>
2195 <li><a href="../RELEASE-NOTES">Release notes</a></li>
2196 <li><a href="../docs/">Documentation</a></li>
2197 <li><a href="http://www.mediawiki.org/wiki/Help:Contents">User's Guide</a></li>
2198 <li><a href="http://www.mediawiki.org/wiki/Manual:Contents">Administrator's Guide</a></li>
2199 <li><a href="http://www.mediawiki.org/wiki/Manual:FAQ">FAQ</a></li>
2200 </ul>
2201 <p style="font-size:90%;margin-top:1em">MediaWiki is Copyright © 2001-2009 by Magnus Manske, Brion Vibber,
2202 Lee Daniel Crocker, Tim Starling, Erik Möller, Gabriel Wicke, Ævar Arnfjörð Bjarmason, Niklas Laxström,
2203 Domas Mituzas, Rob Church, Yuri Astrakhan, Aryeh Gregor, Aaron Schulz and others.</p>
2204 </div></div>
2205 </div>
2207 </div>
2209 </body>
2210 </html>