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