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