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