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