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