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