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