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