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