Fixed variable name typo from r60665. (problems while sending file in previous attemp...
[mediawiki.git] / config / Installer.php
blob57e31a58f177221e7efb2c8d1380ce6ff267b788
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 if( !defined( 'MEDIAWIKI_INSTALL' ) ) {
23 die( 'Not an entry point.' );
26 error_reporting( E_ALL | E_STRICT );
27 header( "Content-type: text/html; charset=utf-8" );
28 @ini_set( "display_errors", true );
30 # In case of errors, let output be clean.
31 $wgRequestTime = microtime( true );
33 // Run version checks before including other files
34 // so people don't see a scary parse error.
35 require_once( "$IP/maintenance/install-utils.inc" );
36 install_version_checks();
38 require_once( "$IP/includes/Defines.php" );
39 require_once( "$IP/includes/DefaultSettings.php" );
40 require_once( "$IP/includes/AutoLoader.php" );
41 require_once( "$IP/includes/MagicWord.php" );
42 require_once( "$IP/includes/Namespace.php" );
43 require_once( "$IP/includes/ProfilerStub.php" );
44 require_once( "$IP/includes/GlobalFunctions.php" );
45 require_once( "$IP/includes/Hooks.php" );
46 require_once( "$IP/includes/Exception.php" );
47 require_once( "$IP/includes/json/Services_JSON.php" );
48 require_once( "$IP/includes/json/FormatJson.php" );
50 # If we get an exception, the user needs to know
51 # all the details
52 $wgShowExceptionDetails = true;
53 $wgShowSQLErrors = true;
54 wfInstallExceptionHandler();
55 ## Databases we support:
57 $ourdb = array();
59 $ourdb['mysql'] = array(
60 'fullname' => 'MySQL',
61 'havedriver' => 0,
62 'compile' => 'mysql',
63 'bgcolor' => '#ffe5a7',
64 'rootuser' => 'root',
65 'serverless' => false
68 $ourdb['postgres'] = array(
69 'fullname' => 'PostgreSQL',
70 'havedriver' => 0,
71 'compile' => 'pgsql',
72 'bgcolor' => '#aaccff',
73 'rootuser' => 'postgres',
74 'serverless' => false
77 $ourdb['sqlite'] = array(
78 'fullname' => 'SQLite',
79 'havedriver' => 0,
80 'compile' => 'pdo_sqlite',
81 'bgcolor' => '#b1ebb1',
82 'rootuser' => '',
83 'serverless' => true
86 $ourdb['mssql'] = array(
87 'fullname' => 'MSSQL',
88 'havedriver' => 0,
89 'compile' => 'mssql_not_ready', # Change to 'mssql' after includes/DatabaseMssql.php added;
90 'bgcolor' => '#ffc0cb',
91 'rootuser' => 'administrator',
92 'serverless' => false
95 $ourdb['ibm_db2'] = array(
96 'fullname' => 'DB2',
97 'havedriver' => 0,
98 'compile' => 'ibm_db2',
99 'bgcolor' => '#ffeba1',
100 'rootuser' => 'db2admin',
101 'serverless' => false
104 $ourdb['oracle'] = array(
105 'fullname' => 'Oracle',
106 'havedriver' => 0,
107 'compile' => 'oci8',
108 'bgcolor' => '#ffeba1',
109 'rootuser' => 'sys',
110 'serverless' => false
114 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
115 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
116 <head>
117 <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
118 <meta name="robots" content="noindex,nofollow"/>
119 <title>MediaWiki <?php echo htmlspecialchars( $wgVersion ); ?> Installation</title>
120 <style type="text/css">
122 @import "../skins/monobook/main.css";
124 .env-check {
125 font-size: 90%;
126 margin: 1em 0 1em 2.5em;
129 .config-section {
130 margin-top: 2em;
133 .config-section label.column {
134 clear: left;
135 font-weight: bold;
136 width: 13em;
137 float: left;
138 text-align: right;
139 padding-right: 1em;
140 padding-top: .2em;
143 .config-input {
144 clear: left;
145 zoom: 100%; /* IE hack */
148 .config-section .config-desc {
149 clear: left;
150 margin: 0 0 2em 18em;
151 padding-top: 1em;
152 font-size: 85%;
155 .iput-text, .iput-password {
156 width: 14em;
157 margin-right: 1em;
160 .error {
161 color: red;
162 background-color: #fff;
163 font-weight: bold;
164 left: 1em;
165 font-size: 100%;
168 .error-top {
169 color: red;
170 background-color: #FFF0F0;
171 border: 2px solid red;
172 font-size: 130%;
173 font-weight: bold;
174 padding: 1em 1.5em;
175 margin: 2em 0 1em;
178 ul.plain {
179 list-style-type: none;
180 list-style-image: none;
181 float: left;
182 margin: 0;
183 padding: 0;
186 .btn-install {
187 font-weight: bold;
188 font-size: 110%;
189 padding: .2em .3em;
192 .license {
193 font-size: 85%;
194 padding-top: 3em;
197 span.success-message {
198 font-weight: bold;
199 font-size: 110%;
200 color: green;
203 .success-box {
204 font-size: 130%;
207 </style>
208 <script type="text/javascript">
209 <!--
210 <?php echo 'var databases = ' . FormatJson::encode( $ourdb ) . ';'; ?>
212 function show(id, showOrHide) {
213 var i = document.getElementById(id);
214 if (i) i.style.display = showOrHide ? 'block' : 'none';
216 function hideall() {
217 for (db in databases) {
218 show(db, false);
221 function toggleDBarea(id, defaultroot) {
222 hideall();
223 var dbarea = document.getElementById(id);
224 if (dbarea) dbarea.style.display = (dbarea.style.display == 'none') ? 'block' : 'none';
225 var db = document.getElementById('RootUser');
226 db.value = databases[id].rootuser;
227 show('db-server-settings1', !databases[id].serverless);
228 show('db-server-settings2', !databases[id].serverless);
230 // -->
231 </script>
232 </head>
234 <body>
235 <div id="globalWrapper">
236 <div id="column-content">
237 <div id="content">
238 <div id="bodyContent">
240 <h1>MediaWiki <?php print htmlspecialchars( $wgVersion ) ?> Installation</h1>
242 <?php
243 $mainListOpened = false; # Is the main list (environement checking) opend ? Used by dieout
245 /* Check for existing configurations and bug out! */
247 if( file_exists( "../LocalSettings.php" ) ) {
248 $script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php';
249 dieout( "<p><strong>Setup has completed, <a href='../$script'>your wiki</a> is configured.</strong></p>
250 <p>Please delete the /config directory for extra security.</p>" );
253 if( file_exists( "./LocalSettings.php" ) ) {
254 writeSuccessMessage();
255 dieout( '' );
258 if( !is_writable( "." ) ) {
259 dieout( "<h2>Can't write config file, aborting</h2>
261 <p>In order to configure the wiki you have to make the <tt>config</tt> subdirectory
262 writable by the web server. Once configuration is done you'll move the created
263 <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can
264 then remove the <tt>config</tt> subdirectory entirely.</p>
266 <p>To make the directory writable on a Unix/Linux system:</p>
268 <pre>
269 cd <i>" . htmlspecialchars( dirname( dirname( __FILE__ ) ) ) . "</i>
270 chmod a+w config
271 </pre>
273 <p>Afterwards retry to start the <a href=\"\">setup</a>.</p>" );
277 require_once( "$IP/maintenance/updaters.inc" );
279 class ConfigData {
280 function getEncoded( $data ) {
281 # removing latin1 support, no need...
282 return $data;
284 function getSitename() { return $this->getEncoded( $this->Sitename ); }
285 function getSysopName() { return $this->getEncoded( $this->SysopName ); }
286 function getSysopPass() { return $this->getEncoded( $this->SysopPass ); }
288 function setSchema( $schema, $engine ) {
289 $this->DBschema = $schema;
290 if ( !preg_match( '/^\w*$/', $engine ) ){
291 $engine = 'InnoDB';
293 switch ( $this->DBschema ) {
294 case 'mysql5':
295 $this->DBTableOptions = "ENGINE=$engine, DEFAULT CHARSET=utf8";
296 $this->DBmysql5 = 'true';
297 break;
298 case 'mysql5-binary':
299 $this->DBTableOptions = "ENGINE=$engine, DEFAULT CHARSET=binary";
300 $this->DBmysql5 = 'true';
301 break;
302 default:
303 $this->DBTableOptions = "TYPE=$engine";
304 $this->DBmysql5 = 'false';
306 $this->DBengine = $engine;
308 # Set the global for use during install
309 global $wgDBTableOptions;
310 $wgDBTableOptions = $this->DBTableOptions;
316 <ul>
317 <li>
318 <b>Don't forget security updates!</b> Keep an eye on the
319 <a href="http://lists.wikimedia.org/mailman/listinfo/mediawiki-announce">low-traffic
320 release announcements mailing list</a>.
321 </li>
322 </ul>
325 <h2>Checking environment...</h2>
326 <p><em>Please include all of the lines below when reporting installation problems.</em></p>
327 <ul class="env-check">
328 <?php
329 $mainListOpened = true;
331 $endl = "
333 define( 'MW_NO_OUTPUT_BUFFER', 1 );
334 $conf = new ConfigData;
336 install_version_checks();
337 $self = 'Installer'; # Maintenance script name, to please Setup.php
339 print "<li>PHP " . htmlspecialchars( phpversion() ) . " installed</li>\n";
341 error_reporting( 0 );
342 $phpdatabases = array();
343 foreach (array_keys($ourdb) as $db) {
344 $compname = $ourdb[$db]['compile'];
345 if( extension_loaded( $compname ) || ( mw_have_dl() && dl( "{$compname}." . PHP_SHLIB_SUFFIX ) ) ) {
346 array_push($phpdatabases, $db);
347 $ourdb[$db]['havedriver'] = 1;
350 error_reporting( E_ALL | E_STRICT );
352 if (!$phpdatabases) {
353 print "Could not find a suitable database driver!<ul>";
354 foreach (array_keys($ourdb) AS $db) {
355 $comp = $ourdb[$db]['compile'];
356 $full = $ourdb[$db]['fullname'];
357 print "<li>For <b>$full</b>, compile PHP using <b>--with-$comp</b>, "
358 ."or install the $comp.so module</li>\n";
360 echo '</ul>';
361 dieout( '' );
364 print "<li>Found database drivers for:";
365 $DefaultDBtype = '';
366 foreach (array_keys($ourdb) AS $db) {
367 if ($ourdb[$db]['havedriver']) {
368 if ( $DefaultDBtype == '' ) {
369 $DefaultDBtype = $db;
371 print " ".$ourdb[$db]['fullname'];
374 print "</li>\n";
376 if( wfIniGetBool( "register_globals" ) ) {
378 <li>
379 <div style="font-size:110%">
380 <strong class="error">Warning:</strong>
381 <strong>PHP's <tt><a href="http://php.net/register_globals">register_globals</a></tt> option is enabled. Disable it if you can.</strong>
382 </div>
383 MediaWiki will work, but your server is more exposed to PHP-based security vulnerabilities.
384 </li>
385 <?php
388 $fatal = false;
390 if( wfIniGetBool( "magic_quotes_runtime" ) ) {
391 $fatal = true;
392 ?><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>
393 This option corrupts data input unpredictably; you cannot install or use
394 MediaWiki unless this option is disabled.</li>
395 <?php
398 if( wfIniGetBool( "magic_quotes_sybase" ) ) {
399 $fatal = true;
400 ?><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>
401 This option corrupts data input unpredictably; you cannot install or use
402 MediaWiki unless this option is disabled.</li>
403 <?php
406 if( wfIniGetBool( "mbstring.func_overload" ) ) {
407 $fatal = true;
408 ?><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>
409 This option causes errors and may corrupt data unpredictably;
410 you cannot install or use MediaWiki unless this option is disabled.</li>
411 <?php
414 if( wfIniGetBool( "zend.ze1_compatibility_mode" ) ) {
415 $fatal = true;
416 ?><li class="error"><strong>Fatal: <a href="http://www.php.net/manual/en/ini.core.php">zend.ze1_compatibility_mode</a> is active!</strong>
417 This option causes horrible bugs with MediaWiki; you cannot install or use
418 MediaWiki unless this option is disabled.</li>
419 <?php
423 if( $fatal ) {
424 dieout( "Cannot install MediaWiki." );
427 if( wfIniGetBool( "safe_mode" ) ) {
428 $conf->safeMode = true;
430 <li><b class='error'>Warning:</b> <strong>PHP's
431 <a href='http://www.php.net/features.safe-mode'>safe mode</a> is active.</strong>
432 You may have problems caused by this, particularly if using image uploads.
433 </li>
434 <?php
435 } else {
436 $conf->safeMode = false;
439 $sapi = htmlspecialchars( php_sapi_name() );
440 print "<li>PHP server API is $sapi; ";
441 $script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php';
442 if( $wgUsePathInfo ) {
443 print "ok, using pretty URLs (<tt>$script/Page_Title</tt>)";
444 } else {
445 print "using ugly URLs (<tt>$script?title=Page_Title</tt>)";
447 print "</li>\n";
449 $conf->xml = function_exists( "utf8_encode" );
450 if( $conf->xml ) {
451 print "<li>Have XML / Latin1-UTF-8 conversion support.</li>\n";
452 } else {
453 dieout( "PHP's XML module is missing; the wiki requires functions in
454 this module and won't work in this configuration.
455 If you're running Mandrake, install the php-xml package." );
458 # Check for session support
459 if( !function_exists( 'session_name' ) )
460 dieout( "PHP's session module is missing. MediaWiki requires session support in order to function." );
462 # session.save_path doesn't *have* to be set, but if it is, and it's
463 # not valid/writable/etc. then it can cause problems
464 $sessionSavePath = mw_get_session_save_path();
465 $ssp = htmlspecialchars( $sessionSavePath );
466 # Warn the user if it's not set, but let them proceed
467 if( !$sessionSavePath ) {
468 print "<li><strong>Warning:</strong> A value for <tt>session.save_path</tt>
469 has not been set in PHP.ini. If the default value causes problems with
470 saving session data, set it to a valid path which is read/write/execute
471 for the user your web server is running under.</li>";
472 } elseif ( is_dir( $sessionSavePath ) && is_writable( $sessionSavePath ) ) {
473 # All good? Let the user know
474 print "<li>Session save path (<tt>{$ssp}</tt>) appears to be valid.</li>";
475 } else {
476 # Something not right? Warn the user, but let them proceed
477 print "<li><strong>Warning:</strong> Your <tt>session.save_path</tt> value (<tt>{$ssp}</tt>)
478 appears to be invalid or is not writable. PHP needs to be able to save data to
479 this location for correct session operation.</li>";
482 # Check for PCRE support
483 if( !function_exists( 'preg_match' ) )
484 dieout( "The PCRE support module appears to be missing. MediaWiki requires the
485 Perl-compatible regular expression functions." );
487 # The installer can take a while, and we really don't want it to time out
488 wfSuppressWarnings();
489 set_time_limit( 0 );
490 wfRestoreWarnings();
492 $memlimit = ini_get( "memory_limit" );
493 if( $memlimit == -1 ) {
494 print "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n";
495 } else {
496 print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars( $memlimit ). " bytes. ";
497 $newlimit = wfMemoryLimit();
498 $memlimit = wfShorthandToInteger( $memlimit );
499 if( $newlimit < $memlimit ) {
500 print "<b>Failed raising limit, installation may fail.</b>";
501 } elseif ( $newlimit > $memlimit ) {
502 print "Raised <tt>memory_limit</tt> to " . htmlspecialchars( $newlimit ) . " bytes. ";
504 print "</li>\n";
507 $conf->turck = function_exists( 'mmcache_get' );
508 if ( $conf->turck ) {
509 print "<li><a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> installed</li>\n";
512 $conf->xcache = function_exists( 'xcache_get' );
513 if( $conf->xcache )
514 print "<li><a href=\"http://trac.lighttpd.net/xcache/\">XCache</a> installed</li>\n";
516 $conf->apc = function_exists('apc_fetch');
517 if ($conf->apc ) {
518 print "<li><a href=\"http://www.php.net/apc\">APC</a> installed</li>\n";
521 $conf->eaccel = function_exists( 'eaccelerator_get' );
522 if ( $conf->eaccel ) {
523 $conf->turck = 'eaccelerator';
524 print "<li><a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> installed</li>\n";
527 $conf->dba = function_exists( 'dba_open' );
529 if( !( $conf->turck || $conf->eaccel || $conf->apc || $conf->xcache ) ) {
530 echo( '<li>Couldn\'t find <a href="http://turck-mmcache.sourceforge.net">Turck MMCache</a>,
531 <a href="http://eaccelerator.sourceforge.net">eAccelerator</a>,
532 <a href="http://www.php.net/apc">APC</a> or <a href="http://trac.lighttpd.net/xcache/">XCache</a>;
533 cannot use these for object caching.</li>' );
536 $conf->diff3 = false;
537 $diff3locations = array_merge(
538 array(
539 "/usr/bin",
540 "/usr/local/bin",
541 "/opt/csw/bin",
542 "/usr/gnu/bin",
543 "/usr/sfw/bin" ),
544 explode( PATH_SEPARATOR, getenv( "PATH" ) ) );
545 $diff3names = array( "gdiff3", "diff3", "diff3.exe" );
547 $diff3versioninfo = array( '$1 --version 2>&1', 'diff3 (GNU diffutils)' );
548 foreach ($diff3locations as $loc) {
549 $exe = locate_executable($loc, $diff3names, $diff3versioninfo);
550 if ($exe !== false) {
551 $conf->diff3 = $exe;
552 break;
556 if ($conf->diff3)
557 print "<li>Found GNU diff3: <tt>$conf->diff3</tt>.</li>";
558 else
559 print "<li>GNU diff3 not found.</li>";
561 $conf->ImageMagick = false;
562 $imcheck = array( "/usr/bin", "/opt/csw/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" );
563 foreach( $imcheck as $dir ) {
564 $im = "$dir/convert";
565 if( @file_exists( $im ) ) {
566 print "<li>Found ImageMagick: <tt>$im</tt>; image thumbnailing will be enabled if you enable uploads.</li>\n";
567 $conf->ImageMagick = $im;
568 break;
572 $conf->HaveGD = function_exists( "imagejpeg" );
573 if( $conf->HaveGD ) {
574 print "<li>Found GD graphics library built-in";
575 if( !$conf->ImageMagick ) {
576 print ", image thumbnailing will be enabled if you enable uploads";
578 print ".</li>\n";
579 } else {
580 if( !$conf->ImageMagick ) {
581 print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n";
585 $conf->IP = dirname( dirname( __FILE__ ) );
586 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP ) . "</tt></li>\n";
589 // PHP_SELF isn't available sometimes, such as when PHP is CGI but
590 // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
591 // to get the path to the current script... hopefully it's reliable. SIGH
592 $path = ($_SERVER["PHP_SELF"] === '')
593 ? $_SERVER["SCRIPT_NAME"]
594 : $_SERVER["PHP_SELF"];
596 $conf->ScriptPath = preg_replace( '{^(.*)/config.*$}', '$1', $path );
597 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath ) . "</tt></li>\n";
601 // We may be installing from *.php5 extension file, if so, print message
602 $conf->ScriptExtension = '.php';
603 if (defined('MW_INSTALL_PHP5_EXT')) {
604 $conf->ScriptExtension = '.php5';
605 print "<li>Installing MediaWiki with <tt>php5</tt> file extensions</li>\n";
606 } else {
607 print "<li>Installing MediaWiki with <tt>php</tt> file extensions</li>\n";
611 print "<li style='font-weight:bold;color:green;font-size:110%'>Environment checked. You can install MediaWiki.</li>\n";
612 $conf->posted = ($_SERVER["REQUEST_METHOD"] == "POST");
614 $conf->Sitename = ucfirst( importPost( "Sitename", "" ) );
615 $defaultEmail = empty( $_SERVER["SERVER_ADMIN"] )
616 ? 'root@localhost'
617 : $_SERVER["SERVER_ADMIN"];
618 $conf->EmergencyContact = importPost( "EmergencyContact", $defaultEmail );
619 $conf->DBtype = importPost( "DBtype", $DefaultDBtype );
620 if ( !isset( $ourdb[$conf->DBtype] ) ) {
621 $conf->DBtype = $DefaultDBtype;
624 $conf->DBserver = importPost( "DBserver", "localhost" );
625 $conf->DBname = importPost( "DBname", "wikidb" );
626 $conf->DBuser = importPost( "DBuser", "wikiuser" );
627 $conf->DBpassword = importPost( "DBpassword" );
628 $conf->DBpassword2 = importPost( "DBpassword2" );
629 $conf->SysopName = importPost( "SysopName", "WikiSysop" );
630 $conf->SysopPass = importPost( "SysopPass" );
631 $conf->SysopPass2 = importPost( "SysopPass2" );
632 $conf->RootUser = importPost( "RootUser", "root" );
633 $conf->RootPW = importPost( "RootPW", "" );
634 $useRoot = importCheck( 'useroot', false );
635 $conf->LanguageCode = importPost( "LanguageCode", "en" );
636 ## MySQL specific:
637 $conf->DBprefix = importPost( "DBprefix" );
638 $conf->setSchema(
639 importPost( "DBschema", "mysql5-binary" ),
640 importPost( "DBengine", "InnoDB" ) );
642 ## Postgres specific:
643 $conf->DBport = importPost( "DBport", "5432" );
644 $conf->DBts2schema = importPost( "DBts2schema", "public" );
645 $conf->DBpgschema = importPost( "DBpgschema", "mediawiki" );
647 ## SQLite specific
648 $conf->SQLiteDataDir = importPost( "SQLiteDataDir", "" );
650 ## MSSQL specific
651 // We need a second field so it doesn't overwrite the MySQL one
652 $conf->DBprefix2 = importPost( "DBprefix2" );
654 ## DB2 specific:
655 // New variable in order to have a different default port number
656 $conf->DBport_db2 = importPost( "DBport_db2", "50000" );
657 $conf->DBcataloged = importPost( "DBcataloged", "cataloged" );
658 $conf->DBdb2schema = importPost( "DBdb2schema", "mediawiki" );
660 // Oracle specific
661 $conf->DBprefix_ora = importPost( "DBprefix_ora" );
662 $conf->DBdefTS_ora = importPost( "DBdefTS_ora", "USERS" );
663 $conf->DBtempTS_ora = importPost( "DBtempTS_ora", "TEMP" );
665 $conf->ShellLocale = getShellLocale( $conf->LanguageCode );
667 /* Check for validity */
668 $errs = array();
670 if( preg_match( '/^$|^mediawiki$|#/i', $conf->Sitename ) ) {
671 $errs["Sitename"] = "Must not be blank or \"MediaWiki\" and may not contain \"#\"";
673 if( !$ourdb[$conf->DBtype]['serverless'] ) {
674 if( $conf->DBuser == "" ) {
675 $errs["DBuser"] = "Must not be blank";
677 if( ($conf->DBtype == 'mysql') && (strlen($conf->DBuser) > 16) ) {
678 $errs["DBuser"] = "Username too long";
680 if( $conf->DBpassword == "" && $conf->DBtype != "postgres" ) {
681 $errs["DBpassword"] = "Must not be blank";
683 if( $conf->DBpassword != $conf->DBpassword2 ) {
684 $errs["DBpassword2"] = "Passwords don't match!";
687 if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix ) ) {
688 $errs["DBprefix"] = "Invalid table prefix";
689 } else {
690 untaint( $conf->DBprefix, TC_MYSQL );
692 if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix_ora ) ) {
693 $errs["DBprefix_ora"] = "Invalid table prefix";
696 error_reporting( E_ALL | E_STRICT );
699 * Initialise $wgLang and $wgContLang to something so we can
700 * call case-folding methods. Per Brion, this is English for
701 * now, although we could be clever and initialise to the
702 * user-selected language.
704 $wgContLang = Language::factory( 'en' );
705 $wgLang = $wgContLang;
708 * We're messing about with users, so we need a stub
709 * authentication plugin...
711 $wgAuth = new AuthPlugin();
714 * Validate the initial administrator account; username,
715 * password checks, etc.
717 if( $conf->SysopName ) {
718 # Check that the user can be created
719 $u = User::newFromName( $conf->SysopName );
720 if( $u instanceof User ) {
721 # Various password checks
722 if( $conf->SysopPass != '' ) {
723 if( $conf->SysopPass == $conf->SysopPass2 ) {
724 if( !$u->isValidPassword( $conf->SysopPass ) ) {
725 $errs['SysopPass'] = "Bad password";
727 } else {
728 $errs['SysopPass2'] = "Passwords don't match";
730 } else {
731 $errs['SysopPass'] = "Cannot be blank";
733 unset( $u );
734 } else {
735 $errs['SysopName'] = "Bad username";
739 $conf->License = importRequest( "License", "none" );
740 if( $conf->License == "gfdl1_2" ) {
741 $conf->RightsUrl = "http://www.gnu.org/licenses/old-licenses/fdl-1.2.txt";
742 $conf->RightsText = "GNU Free Documentation License 1.2";
743 $conf->RightsCode = "gfdl1_2";
744 $conf->RightsIcon = '${wgScriptPath}/skins/common/images/gnu-fdl.png';
745 } elseif( $conf->License == "gfdl1_3" ) {
746 $conf->RightsUrl = "http://www.gnu.org/copyleft/fdl.html";
747 $conf->RightsText = "GNU Free Documentation License 1.3";
748 $conf->RightsCode = "gfdl1_3";
749 $conf->RightsIcon = '${wgScriptPath}/skins/common/images/gnu-fdl.png';
750 } elseif( $conf->License == "none" ) {
751 $conf->RightsUrl = $conf->RightsText = $conf->RightsCode = $conf->RightsIcon = "";
752 } elseif( $conf->License == "pd" ) {
753 $conf->RightsUrl = "http://creativecommons.org/licenses/publicdomain/";
754 $conf->RightsText = "Public Domain";
755 $conf->RightsCode = "pd";
756 $conf->RightsIcon = '${wgScriptPath}/skins/common/images/public-domain.png';
757 } else {
758 $conf->RightsUrl = importRequest( "RightsUrl", "" );
759 $conf->RightsText = importRequest( "RightsText", "" );
760 $conf->RightsCode = importRequest( "RightsCode", "" );
761 $conf->RightsIcon = importRequest( "RightsIcon", "" );
764 $conf->Shm = importRequest( "Shm", "none" );
765 $conf->MCServers = importRequest( "MCServers" );
767 /* Test memcached servers */
769 if ( $conf->Shm == 'memcached' && $conf->MCServers ) {
770 $conf->MCServerArray = wfArrayMap( 'trim', explode( ',', $conf->MCServers ) );
771 foreach ( $conf->MCServerArray as $server ) {
772 $error = testMemcachedServer( $server );
773 if ( $error ) {
774 $errs["MCServers"] = $error;
775 break;
778 } else if ( $conf->Shm == 'memcached' ) {
779 $errs["MCServers"] = "Please specify at least one server if you wish to use memcached";
782 /* default values for installation */
783 $conf->Email = importRequest("Email", "email_enabled");
784 $conf->Emailuser = importRequest("Emailuser", "emailuser_enabled");
785 $conf->Enotif = importRequest("Enotif", "enotif_allpages");
786 $conf->Eauthent = importRequest("Eauthent", "eauthent_enabled");
788 if( $conf->posted && ( 0 == count( $errs ) ) ) {
789 do { /* So we can 'continue' to end prematurely */
790 $conf->Root = ($conf->RootPW != "");
792 /* Load up the settings and get installin' */
793 $local = writeLocalSettings( $conf );
794 echo "<li style=\"list-style: none\">\n";
795 echo "<p><b>Generating configuration file...</b></p>\n";
796 echo "</li>\n";
798 $wgCommandLineMode = false;
799 chdir( ".." );
800 $ok = eval( $local );
801 if( $ok === false ) {
802 dieout( "<p>Errors in generated configuration; " .
803 "most likely due to a bug in the installer... " .
804 "Config file was: </p>" .
805 "<pre>" .
806 htmlspecialchars( $local ) .
807 "</pre>" );
809 $conf->DBtypename = '';
810 foreach (array_keys($ourdb) as $db) {
811 if ($conf->DBtype === $db)
812 $conf->DBtypename = $ourdb[$db]['fullname'];
814 if ( ! strlen($conf->DBtype)) {
815 $errs["DBpicktype"] = "Please choose a database type";
816 continue;
819 if (! $conf->DBtypename) {
820 $errs["DBtype"] = "Unknown database type '$conf->DBtype'";
821 continue;
823 print "<li>Database type: " . htmlspecialchars( $conf->DBtypename ) . "</li>\n";
824 $dbclass = 'Database'.ucfirst($conf->DBtype);
825 $wgDBtype = $conf->DBtype;
826 $wgDBadminuser = "root";
827 $wgDBadminpassword = $conf->RootPW;
829 ## Mysql specific:
830 $wgDBprefix = $conf->DBprefix;
832 ## Postgres specific:
833 $wgDBport = $conf->DBport;
834 $wgDBts2schema = $conf->DBts2schema;
836 if( $wgDBtype == 'postgres' ) {
837 $wgDBmwschema = $conf->DBpgschema;
838 } elseif ( $wgDBtype == 'ibm_db2' ) {
839 $wgDBmwschema = $conf->DBdb2schema;
842 if( $conf->DBprefix2 != '' ) {
843 // For MSSQL
844 $wgDBprefix = $conf->DBprefix2;
845 } elseif( $conf->DBprefix_ora != '' ) {
846 // For Oracle
847 $wgDBprefix = $conf->DBprefix_ora;
850 ## DB2 specific:
851 $wgDBcataloged = $conf->DBcataloged;
853 $wgCommandLineMode = true;
854 if (! defined ( 'STDERR' ) )
855 define( 'STDERR', fopen("php://stderr", "wb"));
856 $wgUseDatabaseMessages = false; /* FIXME: For database failure */
857 require_once( "$IP/includes/Setup.php" );
858 Language::getLocalisationCache()->disableBackend();
860 chdir( "config" );
862 $wgTitle = Title::newFromText( "Installation script" );
863 error_reporting( E_ALL | E_STRICT );
864 print "<li>Loading class: " . htmlspecialchars( $dbclass ) . "</li>\n";
865 if ( $conf->DBtype != 'sqlite' ) {
866 $dbc = new $dbclass;
869 if( $conf->DBtype == 'mysql' ) {
870 $mysqlOldClient = version_compare( mysql_get_client_info(), "4.1.0", "lt" );
871 if( $mysqlOldClient ) {
872 print "<li><b>PHP is linked with old MySQL client libraries. If you are
873 using a MySQL 4.1 server and have problems connecting to the database,
874 see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
875 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b></li>\n";
877 $ok = true; # Let's be optimistic
879 # Decide if we're going to use the superuser or the regular database user
880 $conf->Root = $useRoot;
881 if( $conf->Root ) {
882 $db_user = $conf->RootUser;
883 $db_pass = $conf->RootPW;
884 } else {
885 $db_user = $wgDBuser;
886 $db_pass = $wgDBpassword;
889 # Attempt to connect
890 echo( "<li>Attempting to connect to database server as " . htmlspecialchars( $db_user ) . "..." );
891 $wgDatabase = Database::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 );
893 # Check the connection and respond to errors
894 if( $wgDatabase->isOpen() ) {
895 # Seems OK
896 $ok = true;
897 $wgDBadminuser = $db_user;
898 $wgDBadminpassword = $db_pass;
899 echo( "success.</li>\n" );
900 $wgDatabase->ignoreErrors( true );
901 $myver = $wgDatabase->getServerVersion();
902 } else {
903 # There were errors, report them and back out
904 $ok = false;
905 $errno = mysql_errno();
906 $errtx = htmlspecialchars( mysql_error() );
907 switch( $errno ) {
908 case 1045:
909 case 2000:
910 echo( "failed due to authentication errors. Check passwords.</li>" );
911 if( $conf->Root ) {
912 # The superuser details are wrong
913 $errs["RootUser"] = "Check username";
914 $errs["RootPW"] = "and password";
915 } else {
916 # The regular user details are wrong
917 $errs["DBuser"] = "Check username";
918 $errs["DBpassword"] = "and password";
920 break;
921 case 2002:
922 case 2003:
923 default:
924 # General connection problem
925 echo( htmlspecialchars( "failed with error [$errno] $errtx." ) . "</li>\n" );
926 $errs["DBserver"] = "Connection failed";
927 break;
928 } # switch
929 } #conn. att.
931 if( !$ok ) { continue; }
933 else if( $conf->DBtype == 'ibm_db2' ) {
934 if( $useRoot ) {
935 $db_user = $conf->RootUser;
936 $db_pass = $conf->RootPW;
937 } else {
938 $db_user = $wgDBuser;
939 $db_pass = $wgDBpassword;
942 echo( "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) .
943 "\" as \"" . htmlspecialchars( $db_user ) . "\"..." );
944 $wgDatabase = $dbc->newFromParams($wgDBserver, $db_user, $db_pass, $wgDBname, 1);
945 // enable extra debug messages
946 $dbc->setMode(DatabaseIbm_db2::INSTALL_MODE);
947 $wgDatabase->setMode(DatabaseIbm_db2::INSTALL_MODE);
949 if (!$wgDatabase->isOpen()) {
950 print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
951 } else {
952 $myver = $wgDatabase->getServerVersion();
954 if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname);
956 } elseif ( $conf->DBtype == 'sqlite' ) {
957 if ("$wgSQLiteDataDir" == '') {
958 $wgSQLiteDataDir = dirname($_SERVER['DOCUMENT_ROOT']).'/data';
960 echo '<li>Attempting to connect to SQLite database at "' .
961 htmlspecialchars( $wgSQLiteDataDir ) . '": ';
962 if ( !is_dir( $wgSQLiteDataDir ) ) {
963 if ( is_writable( dirname( $wgSQLiteDataDir ) ) ) {
964 $ok = wfMkdirParents( $wgSQLiteDataDir, $wgSQLiteDataDirMode );
965 } else {
966 $ok = false;
968 if ( !$ok ) {
969 echo "cannot create data directory</li>";
970 $errs['SQLiteDataDir'] = 'Enter a valid data directory';
971 continue;
974 if ( !is_writable( $wgSQLiteDataDir ) ) {
975 echo "data directory not writable</li>";
976 $errs['SQLiteDataDir'] = 'Enter a writable data directory';
977 continue;
979 $dataFile = DatabaseSqlite::generateFileName( $wgSQLiteDataDir, $wgDBname );
980 if ( file_exists( $dataFile ) ) {
981 if ( !is_writable( $dataFile ) ) {
982 echo "data file not writable</li>";
983 $errs['SQLiteDataDir'] = basename( $dataFile ) . " is not writable";
984 continue;
986 } else {
987 if ( file_put_contents( $dataFile, '' ) === false ) {
988 echo 'could not create database file "' . htmlspecialchars( basename( $dataFile ) ) . "\"</li>\n";
989 $errs['SQLiteDataDir'] = "couldn't create " . basename( $dataFile );
990 continue;
993 try {
994 $wgDatabase = new DatabaseSqlite( false, false, false, $wgDBname, 1 );
996 catch( MWException $ex ) {
997 echo 'error: ' . htmlspecialchars( $ex->getMessage() ) . "</li>\n";
998 continue;
1001 if (!$wgDatabase->isOpen()) {
1002 print "error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
1003 $errs['SQLiteDataDir'] = 'Could not connect to database';
1004 continue;
1005 } else {
1006 $myver = $wgDatabase->getServerVersion();
1008 if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname);
1009 echo "ok</li>\n";
1010 } elseif ( $conf->DBtype == 'oracle' ) {
1011 echo "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) ."\"</li>";
1012 $old_error_level = error_reporting();
1013 error_reporting($old_error_level & ~E_WARNING); //disable E_WARNING for test connect (oci returns login denied as warning)
1014 $wgDatabase = $dbc->newFromParams('DUMMY', $wgDBuser, $wgDBpassword, $wgDBname, 1);
1015 error_reporting($old_error_level);
1016 if (!$wgDatabase->isOpen()) {
1017 $ok = true;
1018 echo "<li>Connect failed.</li>";
1019 if ($useRoot) {
1020 if (ini_get('oci8.privileged_connect') === false) {
1021 echo "<li>Privileged connect disabled, please set oci8.privileged_connect or run maintenance/ora/user.sql script manually prior to continuing.</li>";
1022 $ok = false;
1023 } else {
1024 $wgDBadminuser = $conf->RootUser;
1025 $wgDBadminpassword = $conf->RootPW;
1026 echo "<li>Attempting to create DB user.</li>";
1027 $wgDatabase = $dbc->newFromParams('DUMMY', $wgDBadminuser, $wgDBadminpassword, $wgDBname, 1, 64);
1028 if ($wgDatabase->isOpen()) {
1029 $wgDBOracleDefTS = $conf->DBdefTS_ora;
1030 $wgDBOracleTempTS = $conf->DBtempTS_ora;
1031 $wgDatabase->sourceFile( "../maintenance/ora/user.sql" );
1032 } else {
1033 echo "<li>Invalid database superuser, please supply a valid superuser account.</li>";
1034 echo "<li>ERR: ".print_r(oci_error(), true)."</li>";
1035 $ok = false;
1038 } else {
1039 echo "<li>Database superuser missing, please supply a valid superuser account.</li>";
1040 $ok = false;
1042 if (!$ok) {
1043 $errs["RootUser"] = "Check username";
1044 $errs["RootPW"] = "and password";
1045 } else {
1046 echo "<li>Attempting to connect to database with new user \"" . htmlspecialchars( $wgDBname ) ."\"</li>";
1047 $wgDatabase = $dbc->newFromParams('DUMMY', $wgDBuser, $wgDBpassword, $wgDBname, 1);
1050 if ($ok) {
1051 $myver = $wgDatabase->getServerVersion();
1053 } else { # not mysql
1054 error_reporting( E_ALL | E_STRICT );
1055 $wgSuperUser = '';
1056 ## Possible connect as a superuser
1057 // Changed !mysql to postgres check since it seems to only apply to postgres
1058 if( $useRoot && $conf->DBtype == 'postgres' ) {
1059 $wgDBsuperuser = $conf->RootUser;
1060 echo( "<li>Attempting to connect to database \"postgres\" as superuser \"" .
1061 htmlspecialchars( $wgDBsuperuser ) . "\"..." );
1062 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBsuperuser, $conf->RootPW, "postgres", 1);
1063 if (!$wgDatabase->isOpen()) {
1064 print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
1065 $errs["DBserver"] = "Could not connect to database as superuser";
1066 $errs["RootUser"] = "Check username";
1067 $errs["RootPW"] = "and password";
1068 continue;
1070 $wgDatabase->initial_setup($conf->RootPW, 'postgres');
1072 echo( "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) .
1073 "\" as \"" . htmlspecialchars( $wgDBuser ) . "\"..." );
1074 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1);
1075 if (!$wgDatabase->isOpen()) {
1076 print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
1077 $errs["DBserver"] = "Could not connect to database as user";
1078 $errs["DBuser"] = "Check username";
1079 $errs["DBpassword"] = "and password";
1080 continue;
1081 } else {
1082 $myver = $wgDatabase->getServerVersion();
1084 if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname);
1087 if ( !$wgDatabase->isOpen() ) {
1088 $errs["DBserver"] = "Couldn't connect to database";
1089 continue;
1092 print "<li>Connected to " . htmlspecialchars( "{$conf->DBtype} $myver" );
1093 if ($conf->DBtype == 'mysql') {
1094 if( version_compare( $myver, "4.0.14" ) < 0 ) {
1095 print "</li>\n";
1096 dieout( "-- mysql 4.0.14 or later required. Aborting." );
1098 $mysqlNewAuth = version_compare( $myver, "4.1.0", "ge" );
1099 if( $mysqlNewAuth && $mysqlOldClient ) {
1100 print "; <b class='error'>You are using MySQL 4.1 server, but PHP is linked
1101 to old client libraries; if you have trouble with authentication, see
1102 <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
1103 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>";
1105 if( $wgDBmysql5 ) {
1106 if( $mysqlNewAuth ) {
1107 print "; enabling MySQL 4.1/5.0 charset mode";
1108 } else {
1109 print "; <b class='error'>MySQL 4.1/5.0 charset mode enabled,
1110 but older version detected; will likely fail.</b>";
1113 print "</li>\n";
1115 @$sel = $wgDatabase->selectDB( $wgDBname );
1116 if( $sel ) {
1117 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
1118 } else {
1119 $err = mysql_errno();
1120 $databaseSafe = htmlspecialchars( $wgDBname );
1121 if( $err == 1102 /* Invalid database name */ ) {
1122 print "<ul><li><strong>{$databaseSafe}</strong> is not a valid database name.</li></ul>";
1123 continue;
1124 } elseif( $err != 1049 /* Database doesn't exist */ ) {
1125 print "<ul><li>Error selecting database <strong>{$databaseSafe}</strong>: {$err} ";
1126 print htmlspecialchars( mysql_error() ) . "</li></ul>";
1127 continue;
1129 print "<li>Attempting to create database...</li>";
1130 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
1131 if( !$res ) {
1132 print "<li>Couldn't create database <tt>" .
1133 htmlspecialchars( $wgDBname ) .
1134 "</tt>; try with root access or check your username/pass.</li>\n";
1135 $errs["RootPW"] = "<- Enter";
1136 continue;
1138 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
1140 $wgDatabase->selectDB( $wgDBname );
1142 else if ($conf->DBtype == 'postgres') {
1143 if( version_compare( $myver, "8.0" ) < 0 ) {
1144 dieout( "<b>Postgres 8.0 or later is required</b>. Aborting." );
1148 if( $wgDatabase->tableExists( "cur" ) || $wgDatabase->tableExists( "revision" ) ) {
1149 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n";
1151 if ( $conf->DBtype == 'mysql') {
1152 # Determine existing default character set
1153 if ( $wgDatabase->tableExists( "revision" ) ) {
1154 $revision = $wgDatabase->escapeLike( $conf->DBprefix . 'revision' );
1155 $res = $wgDatabase->query( "SHOW TABLE STATUS LIKE '$revision'" );
1156 $row = $wgDatabase->fetchObject( $res );
1157 if ( !$row ) {
1158 echo "<li>SHOW TABLE STATUS query failed!</li>\n";
1159 $existingSchema = false;
1160 $existingEngine = false;
1161 } else {
1162 if ( preg_match( '/^latin1/', $row->Collation ) ) {
1163 $existingSchema = 'mysql4';
1164 } elseif ( preg_match( '/^utf8/', $row->Collation ) ) {
1165 $existingSchema = 'mysql5';
1166 } elseif ( preg_match( '/^binary/', $row->Collation ) ) {
1167 $existingSchema = 'mysql5-binary';
1168 } else {
1169 $existingSchema = false;
1170 echo "<li><strong>Warning:</strong> Unrecognised existing collation</li>\n";
1172 if ( isset( $row->Engine ) ) {
1173 $existingEngine = $row->Engine;
1174 } else {
1175 $existingEngine = $row->Type;
1178 if ( $existingSchema && $existingSchema != $conf->DBschema ) {
1179 $encExisting = htmlspecialchars( $existingSchema );
1180 $encRequested = htmlspecialchars( $conf->DBschema );
1181 print "<li><strong>Warning:</strong> you requested the $encRequested schema, " .
1182 "but the existing database has the $encExisting schema. This upgrade script ".
1183 "can't convert it, so it will remain $encExisting.</li>\n";
1184 $conf->setSchema( $existingSchema, $conf->DBengine );
1186 if ( $existingEngine && $existingEngine != $conf->DBengine ) {
1187 $encExisting = htmlspecialchars( $existingEngine );
1188 $encRequested = htmlspecialchars( $conf->DBengine );
1189 print "<li><strong>Warning:</strong> you requested the $encRequested storage " .
1190 "engine, but the existing database uses the $encExisting engine. This upgrade " .
1191 "script can't convert it, so it will remain $encExisting.</li>\n";
1192 $conf->setSchema( $conf->DBschema, $existingEngine );
1196 # Create user if required
1197 if ( $conf->Root ) {
1198 $conn = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
1199 if ( $conn->isOpen() ) {
1200 print "<li>DB user account ok</li>\n";
1201 $conn->close();
1202 } else {
1203 print "<li>Granting user permissions...";
1204 if( $mysqlOldClient && $mysqlNewAuth ) {
1205 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>";
1207 print "</li>\n";
1208 $wgDatabase->sourceFile( "../maintenance/users.sql" );
1212 print "</ul><pre>\n";
1213 chdir( ".." );
1214 flush();
1215 do_all_updates();
1216 chdir( "config" );
1217 print "</pre>\n";
1218 print "<ul><li>Finished update checks.</li>\n";
1219 // if tables don't yet exist
1220 } else {
1221 # Determine available storage engines if possible
1222 if ( $conf->DBtype == 'mysql' && version_compare( $myver, "4.1.2", "ge" ) ) {
1223 $res = $wgDatabase->query( 'SHOW ENGINES' );
1224 $found = false;
1225 while ( $row = $wgDatabase->fetchObject( $res ) ) {
1226 if ( $row->Engine == $conf->DBengine && ( $row->Support == 'YES' || $row->Support == 'DEFAULT' ) ) {
1227 $found = true;
1228 break;
1231 $wgDatabase->freeResult( $res );
1232 if ( !$found && $conf->DBengine != 'MyISAM' ) {
1233 echo "<li><strong>Warning:</strong> " . htmlspecialchars( $conf->DBengine ) .
1234 " storage engine not available, " .
1235 "using MyISAM instead</li>\n";
1236 $conf->setSchema( $conf->DBschema, 'MyISAM' );
1240 # FIXME: Check for errors
1241 print "<li>Creating tables...";
1242 if ($conf->DBtype == 'mysql') {
1243 $wgDatabase->sourceFile( "../maintenance/tables.sql" );
1244 $wgDatabase->sourceFile( "../maintenance/interwiki.sql" );
1245 } elseif (is_callable(array($wgDatabase, 'setup_database'))) {
1246 $wgDatabase->setup_database();
1248 else {
1249 $errs["DBtype"] = "Do not know how to handle database type '$conf->DBtype'";
1250 continue;
1253 print " done.</li>\n";
1256 if ( $conf->DBtype == 'ibm_db2' ) {
1257 // Now that table creation is done, make sure everything is committed
1258 // Do this before doing inserts through API
1259 if ($wgDatabase->lastError()) {
1260 print "<li>Errors encountered during table creation -- rolled back</li>\n";
1261 $wgDatabase->rollback();
1263 else {
1264 print "<li>MediaWiki tables successfully created</li>\n";
1265 $wgDatabase->commit();
1267 } elseif ( $conf->DBtype == 'sqlite' ) {
1268 // Ensure proper searchindex format. We have to do that separately because
1269 // if SQLite is compiled without the FTS3 module, table creation syntax will be invalid.
1270 sqlite_setup_searchindex();
1273 print "<li>Initializing statistics...</li>\n";
1274 $wgDatabase->insert( 'site_stats',
1275 array ( 'ss_row_id' => 1,
1276 'ss_total_views' => 0,
1277 'ss_total_edits' => 1, # Main page first edit
1278 'ss_good_articles' => 0, # Main page is not a good article - no internal link
1279 'ss_total_pages' => 1, # Main page
1280 'ss_users' => $conf->SysopName ? 1 : 0, # Sysop account, if created
1281 'ss_admins' => $conf->SysopName ? 1 : 0, # Sysop account, if created
1282 'ss_images' => 0 ) );
1284 # Set up the "regular user" account *if we can, and if we need to*
1285 if( $conf->Root and $conf->DBtype == 'mysql') {
1286 # See if we need to
1287 $wgDatabase2 = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
1288 if( $wgDatabase2->isOpen() ) {
1289 # Nope, just close the test connection and continue
1290 $wgDatabase2->close();
1291 echo( "<li>User " . htmlspecialchars( $wgDBuser ) . " exists. Skipping grants.</li>\n" );
1292 } else {
1293 # Yes, so run the grants
1294 echo( "<li>" . htmlspecialchars( "Granting user permissions to $wgDBuser on $wgDBname..." ) );
1295 $wgDatabase->sourceFile( "../maintenance/users.sql" );
1296 echo( "success.</li>\n" );
1300 if( $conf->SysopName ) {
1301 $u = User::newFromName( $conf->getSysopName() );
1302 if ( !$u ) {
1303 print "<li><strong class=\"error\">Warning:</strong> Skipped sysop account creation - invalid username!</li>\n";
1305 else if ( 0 == $u->idForName() ) {
1306 $u->addToDatabase();
1307 $u->setPassword( $conf->getSysopPass() );
1308 $u->saveSettings();
1310 $u->addGroup( "sysop" );
1311 $u->addGroup( "bureaucrat" );
1313 print "<li>Created sysop account <tt>" .
1314 htmlspecialchars( $conf->SysopName ) . "</tt>.</li>\n";
1315 } else {
1316 print "<li>Could not create user - already exists!</li>\n";
1318 } else {
1319 print "<li>Skipped sysop account creation, no name given.</li>\n";
1322 $titleobj = Title::newFromText( wfMsgNoDB( "mainpage" ) );
1323 $article = new Article( $titleobj );
1324 $newid = $article->insertOn( $wgDatabase );
1325 $revision = new Revision( array(
1326 'page' => $newid,
1327 'text' => wfMsg( 'mainpagetext' ) . "\n\n" . wfMsgNoTrans( 'mainpagedocfooter' ),
1328 'comment' => '',
1329 'user' => 0,
1330 'user_text' => 'MediaWiki default',
1331 ) );
1332 $revid = $revision->insertOn( $wgDatabase );
1333 $article->updateRevisionOn( $wgDatabase, $revision );
1336 /* Write out the config file now that all is well */
1337 print "<li style=\"list-style: none\">\n";
1338 print "<p>Creating LocalSettings.php...</p>\n\n";
1339 $localSettings = "<" . "?php$endl$local";
1340 // Fix up a common line-ending problem (due to CVS on Windows)
1341 $localSettings = str_replace( "\r\n", "\n", $localSettings );
1342 $f = fopen( "LocalSettings.php", 'xt' );
1344 if( $f == false ) {
1345 print( "</li>\n" );
1346 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" .
1347 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
1348 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
1350 if(fwrite( $f, $localSettings ) ) {
1351 fclose( $f );
1352 print "<hr/>\n";
1353 writeSuccessMessage();
1354 print "</li>\n";
1355 } else {
1356 fclose( $f );
1357 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" );
1360 } while( false );
1363 print "</ul>\n";
1364 $mainListOpened = false;
1366 if( count( $errs ) ) {
1367 /* Display options form */
1369 if( $conf->posted ) {
1370 echo "<p class='error-top'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
1374 <form action="<?php echo defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php'; ?>" name="config" method="post">
1376 <h2>Site config</h2>
1378 <div class="config-section">
1379 <div class="config-input">
1380 <?php aField( $conf, "Sitename", "Wiki name:" ); ?>
1381 </div>
1382 <p class="config-desc">
1383 Preferably a short word without punctuation, i.e. "Wikipedia".<br />
1384 Will appear as the namespace name for "meta" pages, and throughout the interface.
1385 </p>
1386 <div class="config-input"><?php aField( $conf, "EmergencyContact", "Contact e-mail:" ); ?></div>
1387 <p class="config-desc">
1388 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.
1389 </p>
1391 <div class="config-input">
1392 <label class='column' for="LanguageCode">Language:</label>
1393 <select id="LanguageCode" name="LanguageCode"><?php
1394 $list = getLanguageList();
1395 foreach( $list as $code => $name ) {
1396 $sel = ($code == $conf->LanguageCode) ? 'selected="selected"' : '';
1397 $encCode = htmlspecialchars( $code );
1398 $encName = htmlspecialchars( $name );
1399 echo "\n\t\t<option value=\"$encCode\" $sel>$encName</option>";
1401 echo "\n";
1403 </select>
1404 </div>
1405 <p class="config-desc">
1406 Select the language for your wiki's interface. Some localizations aren't fully complete. Unicode (UTF-8) is used for all localizations.
1407 </p>
1409 <div class="config-input">
1410 <label class='column'>Copyright/license:</label>
1412 <ul class="plain">
1413 <li><?php aField( $conf, "License", "No license metadata", "radio", "none" ); ?></li>
1414 <li><?php aField( $conf, "License", "Public Domain", "radio", "pd" ); ?></li>
1415 <li><?php aField( $conf, "License", "GNU Free Documentation License 1.2", "radio", "gfdl1_2" ); ?></li>
1416 <li><?php aField( $conf, "License", "GNU Free Documentation License 1.3", "radio", "gfdl1_3" ); ?></li>
1417 <li><?php
1418 aField( $conf, "License", "A Creative Commons license - ", "radio", "cc" );
1419 $partner = "MediaWiki";
1420 $script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php';
1421 $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/$script?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
1422 $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" );
1423 $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" );
1424 print "<a href=\"$ccApp\" target='_blank'>choose</a>";
1425 if( $conf->License == "cc" ) { ?>
1426 <ul>
1427 <li><?php aField( $conf, "RightsIcon", "<img src=\"" . htmlspecialchars( $conf->RightsIcon ) . "\" alt='(Creative Commons icon)' />", "hidden" ); ?></li>
1428 <li><?php aField( $conf, "RightsText", htmlspecialchars( $conf->RightsText ), "hidden" ); ?></li>
1429 <li><?php aField( $conf, "RightsCode", "code: " . htmlspecialchars( $conf->RightsCode ), "hidden" ); ?></li>
1430 <li><?php aField( $conf, "RightsUrl", "<a href=\"" . htmlspecialchars( $conf->RightsUrl ) . "\">" . htmlspecialchars( $conf->RightsUrl ) . "</a>", "hidden" ); ?></li>
1431 </ul>
1432 <?php } ?>
1433 </li>
1434 </ul>
1435 </div>
1436 <p class="config-desc">
1437 A notice, icon, and machine-readable copyright metadata will be displayed for the license you pick.
1438 </p>
1441 <div class="config-input">
1442 <?php aField( $conf, "SysopName", "Admin username:" ) ?>
1443 </div>
1444 <div class="config-input">
1445 <?php aField( $conf, "SysopPass", "Password:", "password" ) ?>
1446 </div>
1447 <div class="config-input">
1448 <?php aField( $conf, "SysopPass2", "Password confirm:", "password" ) ?>
1449 </div>
1450 <p class="config-desc">
1451 An admin can lock/delete pages, block users from editing, and do other maintenance tasks.<br />
1452 A new account will be added only when creating a new wiki database.
1453 <br /><br />
1454 The password cannot be the same as the username.
1455 </p>
1457 <div class="config-input">
1458 <label class='column'>Object caching:</label>
1460 <ul class="plain">
1461 <li><?php aField( $conf, "Shm", "No caching", "radio", "none" ); ?></li>
1462 <?php
1463 if ( $conf->turck ) {
1464 echo "<li>";
1465 aField( $conf, "Shm", "Turck MMCache", "radio", "turck" );
1466 echo "</li>\n";
1468 if( $conf->xcache ) {
1469 echo "<li>";
1470 aField( $conf, 'Shm', 'XCache', 'radio', 'xcache' );
1471 echo "</li>\n";
1473 if ( $conf->apc ) {
1474 echo "<li>";
1475 aField( $conf, "Shm", "APC", "radio", "apc" );
1476 echo "</li>\n";
1478 if ( $conf->eaccel ) {
1479 echo "<li>";
1480 aField( $conf, "Shm", "eAccelerator", "radio", "eaccel" );
1481 echo "</li>\n";
1483 if ( $conf->dba ) {
1484 echo "<li>";
1485 aField( $conf, "Shm", "DBA (not recommended)", "radio", "dba" );
1486 echo "</li>";
1489 <li><?php aField( $conf, "Shm", "Memcached", "radio", "memcached" ); ?></li>
1490 </ul>
1491 <div style="clear:left"><?php aField( $conf, "MCServers", "Memcached servers:", "text" ) ?></div>
1492 </div>
1493 <p class="config-desc">
1494 An object caching system such as memcached will provide a significant performance boost,
1495 but needs to be installed. Provide the server addresses and ports in a comma-separated list.
1496 <br /><br />
1497 MediaWiki can also detect and support eAccelerator, Turck MMCache, APC, and XCache, but
1498 these should not be used if the wiki will be running on multiple application servers.
1499 <br /><br />
1500 DBA (Berkeley-style DB) is generally slower than using no cache at all, and is only
1501 recommended for testing.
1502 </p>
1503 </div>
1505 <h2>E-mail, e-mail notification and authentication setup</h2>
1507 <div class="config-section">
1508 <div class="config-input">
1509 <label class='column'>E-mail features (global):</label>
1510 <ul class="plain">
1511 <li><?php aField( $conf, "Email", "Enabled", "radio", "email_enabled" ); ?></li>
1512 <li><?php aField( $conf, "Email", "Disabled", "radio", "email_disabled" ); ?></li>
1513 </ul>
1514 </div>
1515 <p class="config-desc">
1516 Use this to disable all e-mail functions (password reminders, user-to-user e-mail, and e-mail notifications)
1517 if sending mail doesn't work on your server.
1518 </p>
1520 <div class="config-input">
1521 <label class='column'>User-to-user e-mail:</label>
1522 <ul class="plain">
1523 <li><?php aField( $conf, "Emailuser", "Enabled", "radio", "emailuser_enabled" ); ?></li>
1524 <li><?php aField( $conf, "Emailuser", "Disabled", "radio", "emailuser_disabled" ); ?></li>
1525 </ul>
1526 </div>
1527 <p class="config-desc">
1528 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.
1529 </p>
1530 <div class="config-input">
1531 <label class='column'>E-mail notification about changes:</label>
1532 <ul class="plain">
1533 <li><?php aField( $conf, "Enotif", "Disabled", "radio", "enotif_disabled" ); ?></li>
1534 <li><?php aField( $conf, "Enotif", "Enabled for changes to user discussion pages only", "radio", "enotif_usertalk" ); ?></li>
1535 <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>
1536 </ul>
1537 </div>
1538 <div class="config-desc">
1540 For this feature to work, an e-mail address must be present for the user account, and the notification
1541 options in the user's preferences must be enabled. Also note the
1542 authentication option below. When testing the feature, keep in mind that your own changes will never trigger notifications to be sent to yourself.</p>
1544 <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>
1545 </div>
1547 <div class="config-input">
1548 <label class='column'>E-mail address authentication:</label>
1549 <ul class="plain">
1550 <li><?php aField( $conf, "Eauthent", "Disabled", "radio", "eauthent_disabled" ); ?></li>
1551 <li><?php aField( $conf, "Eauthent", "Enabled", "radio", "eauthent_enabled" ); ?></li>
1552 </ul>
1553 </div>
1554 <div class="config-desc">
1555 <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
1556 change notification mails. Setting this option is <b>recommended</b> for public wikis because of potential abuse of the e-mail features above.</p>
1557 </div>
1559 </div>
1561 <h2>Database config</h2>
1563 <div class="config-section">
1564 <div class="config-input">
1565 <label class='column'>Database type:</label>
1566 <?php
1567 if (isset($errs['DBpicktype'])) {
1568 print "\t<span class='error'>" . htmlspecialchars( $errs['DBpicktype'] ) . "</span>\n";
1571 <ul class='plain'><?php
1572 database_picker($conf);
1573 ?></ul>
1574 </div>
1576 <div id="db-server-settings1">
1577 <div class="config-input" style="clear:left">
1578 <?php aField( $conf, "DBserver", "Database host:" ); ?>
1579 </div>
1580 <p class="config-desc">
1581 If your database server isn't on your web server, enter the name or IP address here.
1582 </p>
1583 </div>
1585 <div class="config-input"><?php aField( $conf, "DBname", "Database name:" ); ?></div>
1586 <div id="db-server-settings2">
1587 <div class="config-input"><?php aField( $conf, "DBuser", "DB username:" ); ?></div>
1588 <div class="config-input"><?php aField( $conf, "DBpassword", "DB password:", "password" ); ?></div>
1589 <div class="config-input"><?php aField( $conf, "DBpassword2", "DB password confirm:", "password" ); ?></div>
1590 <p class="config-desc">
1591 If you only have a single user account and database available,
1592 enter those here. If you have database root access (see below)
1593 you can specify new accounts/databases to be created. This account
1594 will not be created if it pre-exists. If this is the case, ensure that it
1595 has SELECT, INSERT, UPDATE, and DELETE permissions on the MediaWiki database.
1596 </p>
1598 <div class="config-input">
1599 <label class="column">Superuser account:</label>
1600 <input type="checkbox" name="useroot" id="useroot" <?php if( $useRoot ) { ?>checked="checked" <?php } ?> />
1601 &nbsp;<label for="useroot">Use superuser account</label>
1602 </div>
1603 <div class="config-input"><?php aField( $conf, "RootUser", "Superuser name:", "text" ); ?></div>
1604 <div class="config-input"><?php aField( $conf, "RootPW", "Superuser password:", "password" ); ?></div>
1606 <p class="config-desc">
1607 If the database user specified above does not exist, or does not have access to create
1608 the database (if needed) or tables within it, please check the box and provide details
1609 of a superuser account, such as <strong>root</strong>, which does.
1610 </p>
1611 </div>
1613 <?php database_switcher('mysql'); ?>
1614 <div class="config-input"><?php aField( $conf, "DBprefix", "Database table prefix:" ); ?></div>
1615 <div class="config-desc">
1616 <p>If you need to share one database between multiple wikis, or
1617 between MediaWiki and another web application, you may choose to
1618 add a prefix to all the table names to avoid conflicts.</p>
1620 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
1621 </div>
1623 <div class="config-input"><label class="column">Storage Engine</label>
1624 <div>Select one:</div>
1625 <ul class="plain">
1626 <li><?php aField( $conf, "DBengine", "InnoDB", "radio", "InnoDB" ); ?></li>
1627 <li><?php aField( $conf, "DBengine", "MyISAM", "radio", "MyISAM" ); ?></li>
1628 </ul>
1629 </div>
1630 <p class="config-desc">
1631 InnoDB is best for public web installations, since it has good concurrency
1632 support. MyISAM may be faster in single-user installations. MyISAM databases
1633 tend to get corrupted more often than InnoDB databases.
1634 </p>
1635 <div class="config-input"><label class="column">Database character set</label>
1636 <div>Select one:</div>
1637 <ul class="plain">
1638 <li><?php aField( $conf, "DBschema", "MySQL 4.1/5.0 binary", "radio", "mysql5-binary" ); ?></li>
1639 <li><?php aField( $conf, "DBschema", "MySQL 4.1/5.0 UTF-8", "radio", "mysql5" ); ?></li>
1640 <li><?php aField( $conf, "DBschema", "MySQL 4.0 backwards-compatible UTF-8", "radio", "mysql4" ); ?></li>
1641 </ul>
1642 </div>
1643 <p class="config-desc">
1644 This option is ignored on upgrade, the same character set will be kept.
1645 <br /><br />
1646 <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!.
1647 <br /><br />
1648 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>.
1649 </p>
1650 </fieldset>
1652 <?php database_switcher('postgres'); ?>
1653 <div class="config-input"><?php aField( $conf, "DBport", "Database port:" ); ?></div>
1654 <div class="config-input"><?php aField( $conf, "DBpgschema", "Schema for mediawiki:" ); ?></div>
1655 <div class="config-input"><?php aField( $conf, "DBts2schema", "Schema for tsearch2:" ); ?></div>
1656 <div class="config-desc">
1657 <p>The username specified above (at "DB username") will have its search path set to the above schemas,
1658 so it is recommended that you create a new user. The above schemas are generally correct:
1659 only change them if you are sure you need to.</p>
1660 </div>
1661 </fieldset>
1663 <?php database_switcher('sqlite'); ?>
1664 <div class="config-input"><?php
1665 aField( $conf, "SQLiteDataDir", "SQLite data directory:" );
1666 ?></div>
1667 <div class="config-desc">
1668 <p>SQLite stores table data into files in the filesystem.
1669 If you do not provide an explicit path, a "data" directory in
1670 the parent of your document root will be used.</p>
1672 <p>This directory must exist and be writable by the web server.</p>
1673 </div>
1674 </fieldset>
1676 <?php database_switcher('mssql'); ?>
1677 <div class="config-input"><?php
1678 aField( $conf, "DBprefix2", "Database table prefix:" );
1679 ?></div>
1680 <div class="config-desc">
1681 <p>If you need to share one database between multiple wikis, or
1682 between MediaWiki and another web application, you may choose to
1683 add a prefix to all the table names to avoid conflicts.</p>
1685 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
1686 </div>
1687 </fieldset>
1689 <?php database_switcher('ibm_db2'); ?>
1690 <div class="config-input"><?php
1691 aField( $conf, "DBport_db2", "Database port:" );
1692 ?></div>
1693 <div class="config-input"><?php
1694 aField( $conf, "DBdb2schema", "Schema for mediawiki:" );
1695 ?></div>
1696 <div>Select one:</div>
1697 <ul class="plain">
1698 <li><?php aField( $conf, "DBcataloged", "Cataloged (DB2 installed locally)", "radio", "cataloged" ); ?></li>
1699 <li><?php aField( $conf, "DBcataloged", "Uncataloged (remote DB2 through ODBC)", "radio", "uncataloged" ); ?></li>
1700 </ul>
1701 <div class="config-desc">
1702 <p>If you need to share one database between multiple wikis, or
1703 between MediaWiki and another web application, you may specify
1704 a different schema to avoid conflicts.</p>
1705 </div>
1706 </fieldset>
1708 <?php database_switcher('oracle'); ?>
1709 <div class="config-input"><?php aField( $conf, "DBprefix_ora", "Database table prefix:" ); ?></div>
1710 <div class="config-desc">
1711 <p>If you need to share one database between multiple wikis, or
1712 between MediaWiki and another web application, you may choose to
1713 add a prefix to all the table names to avoid conflicts.</p>
1715 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
1716 </div>
1717 <div class="config-input"><?php aField( $conf, "DBdefTS_ora", "Default tablespace:" ); ?></div>
1718 <div class="config-input"><?php aField( $conf, "DBtempTS_ora", "Temporary tablespace:" ); ?></div>
1719 </fieldset>
1721 <div class="config-input" style="padding:2em 0 3em">
1722 <label class='column'>&nbsp;</label>
1723 <input type="submit" value="Install MediaWiki!" class="btn-install" />
1724 </div>
1725 </div>
1726 </form>
1727 <script type="text/javascript">
1728 window.onload = toggleDBarea( <?php echo Xml::encodeJsVar( $conf->DBtype ); ?>,
1729 <?php
1730 ## If they passed in a root user name, don't populate it on page load
1731 echo strlen(importPost('RootUser', '')) ? 0 : 1;
1732 ?>);
1733 </script>
1734 <?php
1737 /* -------------------------------------------------------------------------------------- */
1738 function writeSuccessMessage() {
1739 $script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php';
1740 if ( wfIniGetBool( 'safe_mode' ) && !ini_get( 'open_basedir' ) ) {
1741 echo <<<EOT
1742 <div class="success-box">
1743 <p>Installation successful!</p>
1744 <p>To complete the installation, please do the following:
1745 <ol>
1746 <li>Download config/LocalSettings.php with your FTP client or file manager</li>
1747 <li>Upload it to the parent directory</li>
1748 <li>Delete config/LocalSettings.php</li>
1749 <li>Start using <a href='../$script'>your wiki</a>!
1750 </ol>
1751 <p>If you are in a shared hosting environment, do <strong>not</strong> just move LocalSettings.php
1752 remotely. LocalSettings.php is currently owned by the user your webserver is running under,
1753 which means that anyone on the same server can read your database password! Downloading
1754 it and uploading it again will hopefully change the ownership to a user ID specific to you.</p>
1755 </div>
1756 EOT;
1757 } else {
1758 echo <<<EOT
1759 <div class="success-box">
1761 <span class="success-message">Installation successful!</span>
1762 Move the <tt>config/LocalSettings.php</tt> file to the parent directory, then follow
1763 <a href="../$script"> this link</a> to your wiki.</p>
1764 <p>You should change file permissions for <tt>LocalSettings.php</tt> as required to
1765 prevent other users on the server reading passwords and altering configuration data.</p>
1766 </div>
1767 EOT;
1772 function escapePhpString( $string ) {
1773 if ( is_array( $string ) || is_object( $string ) ) {
1774 return false;
1776 return strtr( $string,
1777 array(
1778 "\n" => "\\n",
1779 "\r" => "\\r",
1780 "\t" => "\\t",
1781 "\\" => "\\\\",
1782 "\$" => "\\\$",
1783 "\"" => "\\\""
1787 function writeLocalSettings( $conf ) {
1788 $conf->PasswordSender = $conf->EmergencyContact;
1789 $magic = ($conf->ImageMagick ? "" : "# ");
1790 $convert = ($conf->ImageMagick ? $conf->ImageMagick : "/usr/bin/convert" );
1791 $rights = ($conf->RightsUrl) ? "" : "# ";
1792 $hashedUploads = $conf->safeMode ? '' : '# ';
1794 if ( $conf->ShellLocale ) {
1795 $locale = '';
1796 } else {
1797 $locale = '# ';
1798 $conf->ShellLocale = 'en_US.UTF-8';
1801 switch ( $conf->Shm ) {
1802 case 'memcached':
1803 $cacheType = 'CACHE_MEMCACHED';
1804 $mcservers = var_export( $conf->MCServerArray, true );
1805 break;
1806 case 'turck':
1807 case 'xcache':
1808 case 'apc':
1809 case 'eaccel':
1810 $cacheType = 'CACHE_ACCEL';
1811 $mcservers = 'array()';
1812 break;
1813 case 'dba':
1814 $cacheType = 'CACHE_DBA';
1815 $mcservers = 'array()';
1816 break;
1817 default:
1818 $cacheType = 'CACHE_NONE';
1819 $mcservers = 'array()';
1822 if ( $conf->Email == 'email_enabled' ) {
1823 $enableemail = 'true';
1824 $enableuseremail = ( $conf->Emailuser == 'emailuser_enabled' ) ? 'true' : 'false' ;
1825 $eauthent = ( $conf->Eauthent == 'eauthent_enabled' ) ? 'true' : 'false' ;
1826 switch ( $conf->Enotif ) {
1827 case 'enotif_usertalk':
1828 $enotifusertalk = 'true';
1829 $enotifwatchlist = 'false';
1830 break;
1831 case 'enotif_allpages':
1832 $enotifusertalk = 'true';
1833 $enotifwatchlist = 'true';
1834 break;
1835 default:
1836 $enotifusertalk = 'false';
1837 $enotifwatchlist = 'false';
1839 } else {
1840 $enableuseremail = 'false';
1841 $enableemail = 'false';
1842 $eauthent = 'false';
1843 $enotifusertalk = 'false';
1844 $enotifwatchlist = 'false';
1847 $file = @fopen( "/dev/urandom", "r" );
1848 if ( $file ) {
1849 $secretKey = bin2hex( fread( $file, 32 ) );
1850 fclose( $file );
1851 } else {
1852 $secretKey = "";
1853 for ( $i=0; $i<8; $i++ ) {
1854 $secretKey .= dechex(mt_rand(0, 0x7fffffff));
1856 print "<li>Warning: \$wgSecretKey key is insecure, generated with mt_rand(). Consider changing it manually.</li>\n";
1859 # Add slashes to strings for double quoting
1860 $slconf = wfArrayMap( "escapePhpString", get_object_vars( $conf ) );
1861 if( $conf->License == 'gfdl1_2' || $conf->License == 'pd' || $conf->License == 'gfdl1_3' ) {
1862 # Needs literal string interpolation for the current style path
1863 $slconf['RightsIcon'] = $conf->RightsIcon;
1866 if( $conf->DBtype == 'mysql' ) {
1867 $dbsettings =
1868 "# MySQL specific settings
1869 \$wgDBprefix = \"{$slconf['DBprefix']}\";
1871 # MySQL table options to use during installation or update
1872 \$wgDBTableOptions = \"{$slconf['DBTableOptions']}\";
1874 # Experimental charset support for MySQL 4.1/5.0.
1875 \$wgDBmysql5 = {$conf->DBmysql5};";
1876 } elseif( $conf->DBtype == 'postgres' ) {
1877 $dbsettings =
1878 "# Postgres specific settings
1879 \$wgDBport = \"{$slconf['DBport']}\";
1880 \$wgDBmwschema = \"{$slconf['DBpgschema']}\";
1881 \$wgDBts2schema = \"{$slconf['DBts2schema']}\";";
1882 } elseif( $conf->DBtype == 'sqlite' ) {
1883 $dbsettings =
1884 "# SQLite-specific settings
1885 \$wgSQLiteDataDir = \"{$slconf['SQLiteDataDir']}\";";
1886 } elseif( $conf->DBtype == 'mssql' ) {
1887 $dbsettings =
1888 "# MSSQL specific settings
1889 \$wgDBprefix = \"{$slconf['DBprefix2']}\";";
1890 } elseif( $conf->DBtype == 'ibm_db2' ) {
1891 $dbsettings =
1892 "# DB2 specific settings
1893 \$wgDBport_db2 = \"{$slconf['DBport_db2']}\";
1894 \$wgDBmwschema = \"{$slconf['DBdb2schema']}\";
1895 \$wgDBcataloged = \"{$slconf['DBcataloged']}\";";
1896 } elseif( $conf->DBtype == 'oracle' ) {
1897 $dbsettings =
1898 "# Oracle specific settings
1899 \$wgDBprefix = \"{$slconf['DBprefix']}\";";
1900 } else {
1901 // ummm... :D
1902 $dbsettings = '';
1906 $localsettings = "
1907 # This file was automatically generated by the MediaWiki installer.
1908 # If you make manual changes, please keep track in case you need to
1909 # recreate them later.
1911 # See includes/DefaultSettings.php for all configurable settings
1912 # and their default values, but don't forget to make changes in _this_
1913 # file, not there.
1915 # Further documentation for configuration settings may be found at:
1916 # http://www.mediawiki.org/wiki/Manual:Configuration_settings
1918 # If you customize your file layout, set \$IP to the directory that contains
1919 # the other MediaWiki files. It will be used as a base to locate files.
1920 if( defined( 'MW_INSTALL_PATH' ) ) {
1921 \$IP = MW_INSTALL_PATH;
1922 } else {
1923 \$IP = dirname( __FILE__ );
1926 \$path = array( \$IP, \"\$IP/includes\", \"\$IP/languages\" );
1927 set_include_path( implode( PATH_SEPARATOR, \$path ) . PATH_SEPARATOR . get_include_path() );
1929 require_once( \"\$IP/includes/DefaultSettings.php\" );
1931 if ( \$wgCommandLineMode ) {
1932 if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
1933 die( \"This script must be run from the command line\\n\" );
1936 ## Uncomment this to disable output compression
1937 # \$wgDisableOutputCompression = true;
1939 \$wgSitename = \"{$slconf['Sitename']}\";
1941 ## The URL base path to the directory containing the wiki;
1942 ## defaults for all runtime URL paths are based off of this.
1943 ## For more information on customizing the URLs please see:
1944 ## http://www.mediawiki.org/wiki/Manual:Short_URL
1945 \$wgScriptPath = \"{$slconf['ScriptPath']}\";
1946 \$wgScriptExtension = \"{$slconf['ScriptExtension']}\";
1948 ## The relative URL path to the skins directory
1949 \$wgStylePath = \"\$wgScriptPath/skins\";
1951 ## The relative URL path to the logo. Make sure you change this from the default,
1952 ## or else you'll overwrite your logo when you upgrade!
1953 \$wgLogo = \"\$wgStylePath/common/images/wiki.png\";
1955 ## UPO means: this is also a user preference option
1957 \$wgEnableEmail = $enableemail;
1958 \$wgEnableUserEmail = $enableuseremail; # UPO
1960 \$wgEmergencyContact = \"{$slconf['EmergencyContact']}\";
1961 \$wgPasswordSender = \"{$slconf['PasswordSender']}\";
1963 \$wgEnotifUserTalk = $enotifusertalk; # UPO
1964 \$wgEnotifWatchlist = $enotifwatchlist; # UPO
1965 \$wgEmailAuthentication = $eauthent;
1967 ## Database settings
1968 \$wgDBtype = \"{$slconf['DBtype']}\";
1969 \$wgDBserver = \"{$slconf['DBserver']}\";
1970 \$wgDBname = \"{$slconf['DBname']}\";
1971 \$wgDBuser = \"{$slconf['DBuser']}\";
1972 \$wgDBpassword = \"{$slconf['DBpassword']}\";
1974 {$dbsettings}
1976 ## Shared memory settings
1977 \$wgMainCacheType = $cacheType;
1978 \$wgMemCachedServers = $mcservers;
1980 ## To enable image uploads, make sure the 'images' directory
1981 ## is writable, then set this to true:
1982 \$wgEnableUploads = false;
1983 {$magic}\$wgUseImageMagick = true;
1984 {$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
1986 ## If you use ImageMagick (or any other shell command) on a
1987 ## Linux server, this will need to be set to the name of an
1988 ## available UTF-8 locale
1989 {$locale}\$wgShellLocale = \"{$slconf['ShellLocale']}\";
1991 ## If you want to use image uploads under safe mode,
1992 ## create the directories images/archive, images/thumb and
1993 ## images/temp, and make them all writable. Then uncomment
1994 ## this, if it's not already uncommented:
1995 {$hashedUploads}\$wgHashedUploadDirectory = false;
1997 ## If you have the appropriate support software installed
1998 ## you can enable inline LaTeX equations:
1999 \$wgUseTeX = false;
2001 ## Set \$wgCacheDirectory to a writable directory on the web server
2002 ## to make your wiki go slightly faster. The directory should not
2003 ## be publically accessible from the web.
2004 #\$wgCacheDirectory = \"\$IP/cache\";
2006 \$wgLocalInterwiki = strtolower( \$wgSitename );
2008 \$wgLanguageCode = \"{$slconf['LanguageCode']}\";
2010 \$wgSecretKey = \"$secretKey\";
2012 ## Default skin: you can change the default skin. Use the internal symbolic
2013 ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook':
2014 \$wgDefaultSkin = 'monobook';
2016 ## For attaching licensing metadata to pages, and displaying an
2017 ## appropriate copyright notice / icon. GNU Free Documentation
2018 ## License and Creative Commons licenses are supported so far.
2019 {$rights}\$wgEnableCreativeCommonsRdf = true;
2020 \$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright
2021 \$wgRightsUrl = \"{$slconf['RightsUrl']}\";
2022 \$wgRightsText = \"{$slconf['RightsText']}\";
2023 \$wgRightsIcon = \"{$slconf['RightsIcon']}\";
2024 # \$wgRightsCode = \"{$slconf['RightsCode']}\"; # Not yet used
2026 \$wgDiff3 = \"{$slconf['diff3']}\";
2028 # When you make changes to this configuration file, this will make
2029 # sure that cached pages are cleared.
2030 \$wgCacheEpoch = max( \$wgCacheEpoch, gmdate( 'YmdHis', @filemtime( __FILE__ ) ) );
2031 "; ## End of setting the $localsettings string
2033 // Keep things in Unix line endings internally;
2034 // the system will write out as local text type.
2035 return str_replace( "\r\n", "\n", $localsettings );
2038 function dieout( $text ) {
2039 global $mainListOpened;
2040 if( $mainListOpened ) echo( "</ul>" );
2041 if( $text != '' && substr( $text, 0, 2 ) != '<p' && substr( $text, 0, 2 ) != '<h' ){
2042 echo "<p>$text</p>\n";
2043 } else {
2044 echo $text;
2046 die( "\n\n</div>\n</div>\n</div>\n</div>\n</body>\n</html>" );
2049 function importVar( &$var, $name, $default = "" ) {
2050 if( isset( $var[$name] ) ) {
2051 $retval = $var[$name];
2052 if ( get_magic_quotes_gpc() ) {
2053 $retval = stripslashes( $retval );
2055 } else {
2056 $retval = $default;
2058 taint( $retval );
2059 return $retval;
2062 function importPost( $name, $default = "" ) {
2063 return importVar( $_POST, $name, $default );
2066 function importCheck( $name ) {
2067 return isset( $_POST[$name] );
2070 function importRequest( $name, $default = "" ) {
2071 return importVar( $_REQUEST, $name, $default );
2074 function aField( &$conf, $field, $text, $type = "text", $value = "", $onclick = '' ) {
2075 static $radioCount = 0;
2076 if( $type != "" ) {
2077 $xtype = "type=\"$type\"";
2078 } else {
2079 $xtype = "";
2082 $id = $field;
2083 $nolabel = ($type == "radio") || ($type == "hidden");
2085 if ($type == 'radio')
2086 $id .= $radioCount++;
2088 if( !$nolabel ) {
2089 echo "<label class='column' for=\"$id\">$text</label>";
2092 if( $type == "radio" && $value == $conf->$field ) {
2093 $checked = "checked='checked'";
2094 } else {
2095 $checked = "";
2097 echo "<input $xtype name=\"$field\" id=\"$id\" class=\"iput-$type\" $checked ";
2098 if ($onclick) {
2099 echo " onclick='toggleDBarea(\"$value\",1)' " ;
2101 echo "value=\"";
2102 if( $type == "radio" ) {
2103 echo htmlspecialchars( $value );
2104 } else {
2105 echo htmlspecialchars( $conf->$field );
2109 echo "\" />";
2110 if( $nolabel ) {
2111 echo "<label for=\"$id\">$text</label>";
2114 global $errs;
2115 if(isset($errs[$field])) {
2116 echo "<span class='error'>" . htmlspecialchars( $errs[$field] ) . "</span>\n";
2120 function getLanguageList() {
2121 global $wgLanguageNames, $IP;
2122 if( !isset( $wgLanguageNames ) ) {
2123 require_once( "$IP/languages/Names.php" );
2126 $codes = array();
2128 // qqq is a dummy "language" for documenting messages, other language codes are legacy/fallback.
2129 $blacklist = array( 'qqq', 'als', 'be-x-old', 'dk', 'fiu-vro', 'iu', 'nb', 'simple', 'tp' );
2131 $d = opendir( "../languages/messages" );
2132 /* In case we are called from the root directory */
2133 if (!$d)
2134 $d = opendir( "languages/messages");
2135 while( false !== ($f = readdir( $d ) ) ) {
2136 $m = array();
2137 if( preg_match( '/Messages([A-Z][a-z_]+)\.php$/', $f, $m ) ) {
2138 $code = str_replace( '_', '-', strtolower( $m[1] ) );
2139 if( in_array( $code, $blacklist ) ) continue;
2140 if( isset( $wgLanguageNames[$code] ) ) {
2141 $name = wfBCP47( $code ) . ' - ' . $wgLanguageNames[$code];
2142 } else {
2143 $name = $code;
2145 $codes[$code] = $name;
2148 closedir( $d );
2149 ksort( $codes );
2150 return $codes;
2153 #Check for location of an executable
2154 # @param string $loc single location to check
2155 # @param array $names filenames to check for.
2156 # @param mixed $versioninfo array of details to use when checking version, use false for no version checking
2157 function locate_executable($loc, $names, $versioninfo = false) {
2158 if (!is_array($names))
2159 $names = array($names);
2161 foreach ($names as $name) {
2162 $command = "$loc".DIRECTORY_SEPARATOR."$name";
2163 if (@file_exists($command)) {
2164 if (!$versioninfo)
2165 return $command;
2167 $file = str_replace('$1', $command, $versioninfo[0]);
2168 if (strstr(`$file`, $versioninfo[1]) !== false)
2169 return $command;
2172 return false;
2175 # Test a memcached server
2176 function testMemcachedServer( $server ) {
2177 $hostport = explode(":", $server);
2178 $errstr = false;
2179 $fp = false;
2180 if ( !function_exists( 'fsockopen' ) ) {
2181 $errstr = "Can't connect to memcached, fsockopen() not present";
2183 if ( !$errstr && count( $hostport ) != 2 ) {
2184 $errstr = 'Please specify host and port';
2186 if ( !$errstr ) {
2187 list( $host, $port ) = $hostport;
2188 $errno = 0;
2189 $fsockerr = '';
2191 $fp = @fsockopen( $host, $port, $errno, $fsockerr, 1.0 );
2192 if ( $fp === false ) {
2193 $errstr = "Cannot connect to memcached on $host:$port : $fsockerr";
2196 if ( !$errstr ) {
2197 $command = "version\r\n";
2198 $bytes = fwrite( $fp, $command );
2199 if ( $bytes != strlen( $command ) ) {
2200 $errstr = "Cannot write to memcached socket on $host:$port";
2203 if ( !$errstr ) {
2204 $expected = "VERSION ";
2205 $response = fread( $fp, strlen( $expected ) );
2206 if ( $response != $expected ) {
2207 $errstr = "Didn't get correct memcached response from $host:$port";
2210 if ( $fp ) {
2211 fclose( $fp );
2213 if ( !$errstr ) {
2214 echo "<li>Connected to memcached on " . htmlspecialchars( "$host:$port" ) ." successfully</li>";
2216 return $errstr;
2219 function database_picker($conf) {
2220 global $ourdb;
2221 print "\n";
2222 foreach(array_keys($ourdb) as $db) {
2223 if ($ourdb[$db]['havedriver']) {
2224 print "\t<li>";
2225 aField( $conf, "DBtype", $ourdb[$db]['fullname'], 'radio', $db, 'onclick');
2226 print "</li>\n";
2229 print "\n\t";
2232 function database_switcher($db) {
2233 global $ourdb;
2234 $color = $ourdb[$db]['bgcolor'];
2235 $full = $ourdb[$db]['fullname'];
2236 print "<fieldset id='$db' style='clear:both'><legend>$full-specific options</legend>\n";
2239 function printListItem( $item ) {
2240 print "<li>$item</li>";
2243 # Determine a suitable value for $wgShellLocale
2244 function getShellLocale( $wikiLang ) {
2245 # Give up now if we're in safe mode or open_basedir
2246 # It's theoretically possible but tricky to work with
2247 if ( wfIniGetBool( "safe_mode" ) || ini_get( 'open_basedir' ) || !function_exists('exec') ) {
2248 return false;
2251 $os = php_uname( 's' );
2252 $supported = array( 'Linux', 'SunOS', 'HP-UX' ); # Tested these
2253 if ( !in_array( $os, $supported ) ) {
2254 return false;
2257 # Get a list of available locales
2258 $lines = $ret = false;
2259 exec( '/usr/bin/locale -a', $lines, $ret );
2260 if ( $ret ) {
2261 return false;
2264 $lines = wfArrayMap( 'trim', $lines );
2265 $candidatesByLocale = array();
2266 $candidatesByLang = array();
2267 foreach ( $lines as $line ) {
2268 if ( $line === '' ) {
2269 continue;
2271 if ( !preg_match( '/^([a-zA-Z]+)(_[a-zA-Z]+|)\.(utf8|UTF-8)(@[a-zA-Z_]*|)$/i', $line, $m ) ) {
2272 continue;
2274 list( $all, $lang, $territory, $charset, $modifier ) = $m;
2275 $candidatesByLocale[$m[0]] = $m;
2276 $candidatesByLang[$lang][] = $m;
2279 # Try the current value of LANG
2280 if ( isset( $candidatesByLocale[ getenv( 'LANG' ) ] ) ) {
2281 return getenv( 'LANG' );
2284 # Try the most common ones
2285 $commonLocales = array( 'en_US.UTF-8', 'en_US.utf8', 'de_DE.UTF-8', 'de_DE.utf8' );
2286 foreach ( $commonLocales as $commonLocale ) {
2287 if ( isset( $candidatesByLocale[$commonLocale] ) ) {
2288 return $commonLocale;
2292 # Is there an available locale in the Wiki's language?
2293 if ( isset( $candidatesByLang[$wikiLang] ) ) {
2294 $m = reset( $candidatesByLang[$wikiLang] );
2295 return $m[0];
2298 # Are there any at all?
2299 if ( count( $candidatesByLocale ) ) {
2300 $m = reset( $candidatesByLocale );
2301 return $m[0];
2304 # Give up
2305 return false;
2308 function wfArrayMap( $function, $input ) {
2309 $ret = array_map( $function, $input );
2310 foreach ( $ret as $key => $value ) {
2311 $taint = istainted( $input[$key] );
2312 if ( $taint ) {
2313 taint( $ret[$key], $taint );
2316 return $ret;
2321 <div class="license">
2322 <hr/>
2323 <p>This program is free software; you can redistribute it and/or modify
2324 it under the terms of the GNU General Public License as published by
2325 the Free Software Foundation; either version 2 of the License, or
2326 (at your option) any later version.</p>
2328 <p>This program is distributed in the hope that it will be useful,
2329 but WITHOUT ANY WARRANTY; without even the implied warranty of
2330 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2331 GNU General Public License for more details.</p>
2333 <p>You should have received <a href="../COPYING">a copy of the GNU General Public License</a>
2334 along with this program; if not, write to the Free Software
2335 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2336 or <a href="http://www.gnu.org/copyleft/gpl.html">read it online</a></p>
2337 </div>
2339 </div></div></div>
2342 <div id="column-one">
2343 <div class="portlet" id="p-logo">
2344 <a style="background-image: url(../skins/common/images/mediawiki.png);"
2345 href="../"
2346 title="Main Page"></a>
2347 </div>
2348 <script type="text/javascript"> if (window.isMSIE55) fixalpha(); </script>
2349 <div class='portlet'><div class='pBody'>
2350 <ul>
2351 <li><a href="../README">Readme</a></li>
2352 <li><a href="../RELEASE-NOTES">Release notes</a></li>
2353 <li><a href="../docs/">Documentation</a></li>
2354 <li><a href="http://www.mediawiki.org/wiki/Help:Contents">User's Guide</a></li>
2355 <li><a href="http://www.mediawiki.org/wiki/Manual:Contents">Administrator's Guide</a></li>
2356 <li><a href="http://www.mediawiki.org/wiki/Manual:FAQ">FAQ</a></li>
2357 </ul>
2358 <p style="font-size:90%;margin-top:1em">MediaWiki is Copyright © 2001-2009 by Magnus Manske, Brion Vibber,
2359 Lee Daniel Crocker, Tim Starling, Erik Möller, Gabriel Wicke, Ævar Arnfjörð Bjarmason, Niklas Laxström,
2360 Domas Mituzas, Rob Church, Yuri Astrakhan, Aryeh Gregor, Aaron Schulz and others.</p>
2361 </div></div>
2362 </div>
2364 </div>
2366 </body>
2367 </html>