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