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