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