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