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