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