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