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