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