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