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