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