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