(bug 7589) Update to Indonesian localisation (id) #38; updating the release notes
[mediawiki.git] / config / index.php
blob5443614ef2523c0ab4e3bc675d7f57b9354d1041
1 <?php
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/
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.
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.
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
22 error_reporting( E_ALL );
23 header( "Content-type: text/html; charset=utf-8" );
24 @ini_set( "display_errors", true );
26 # In case of errors, let output be clean.
27 $wgRequestTime = microtime( true );
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" );
37 # Define an entry point and include some files
38 define( "MEDIAWIKI", true );
39 define( "MEDIAWIKI_INSTALL", true );
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();
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" );
52 ## Databases we support:
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';
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';
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">
75 @import "../skins/monobook/main.css";
77 .env-check {
78 font-size: 90%;
79 margin: 1em 0 1em 2.5em;
82 .config-section {
83 margin-top: 2em;
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;
96 .config-input {
97 clear: left;
98 zoom: 100%; /* IE hack */
101 .config-section .config-desc {
102 clear: left;
103 margin: 0 0 2em 18em;
104 padding-top: 1em;
105 font-size: 85%;
108 .iput-text, .iput-password {
109 width: 14em;
110 margin-right: 1em;
113 .error {
114 color: red;
115 background-color: #fff;
116 font-weight: bold;
117 left: 1em;
118 font-size: 100%;
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;
131 ul.plain {
132 list-style-type: none;
133 list-style-image: none;
134 float: left;
135 margin: 0;
136 padding: 0;
139 .btn-install {
140 font-weight: bold;
141 font-size: 110%;
142 padding: .2em .3em;
145 .license {
146 font-size: 85%;
147 padding-top: 3em;
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';";
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";
171 // -->
172 </script>
173 </head>
175 <body>
176 <div id="globalWrapper">
177 <div id="column-content">
178 <div id="content">
179 <div id="bodyContent">
181 <h1>MediaWiki <?php print $wgVersion ?> Installation</h1>
183 <?php
185 /* Check for existing configurations and bug out! */
187 if( file_exists( "../LocalSettings.php" ) ) {
188 dieout( "<p><strong>Setup has completed, <a href='../index.php'>your wiki</a> is configured.</strong></p>
190 <p>Please delete the /config directory for extra security.</p></div></div></div></div>" );
193 if( file_exists( "./LocalSettings.php" ) ) {
194 writeSuccessMessage();
196 dieout( '' );
199 if( !is_writable( "." ) ) {
200 dieout( "<h2>Can't write config file, aborting</h2>
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>
207 <p>To make the directory writable on a Unix/Linux system:</p>
209 <pre>
210 cd <i>/path/to/wiki</i>
211 chmod a+w config
212 </pre>
214 <p>Afterwards retry to start the <a href=\"\">setup</a>.</p>" );
218 require_once( "install-utils.inc" );
219 require_once( "maintenance/updaters.inc" );
221 class ConfigData {
222 function getEncoded( $data ) {
223 # removing latin1 support, no need...
224 return $data;
226 function getSitename() { return $this->getEncoded( $this->Sitename ); }
227 function getSysopName() { return $this->getEncoded( $this->SysopName ); }
228 function getSysopPass() { return $this->getEncoded( $this->SysopPass ); }
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>
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 = "
248 $wgNoOutputBuffer = true;
249 $conf = new ConfigData;
251 install_version_checks();
253 print "<li>PHP " . phpversion() . " installed</li>\n";
255 ## Temporarily turn off all errors as we try to discover installed databases
256 $olderrnum = error_reporting(0);
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;
267 error_reporting($olderrornum);
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";
277 dieout( "</ul></ul>" );
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'];
287 print "</li>\n";
288 if (count($phpdatabases) != 1)
289 $DefaultDBtype = '';
291 if( ini_get( "register_globals" ) ) {
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
303 $fatal = false;
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
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
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
329 if( $fatal ) {
330 dieout( "</ul><p>Cannot install MediaWiki.</p>" );
333 if( ini_get( "safe_mode" ) ) {
334 $conf->safeMode = true;
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;
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;
363 print "</li>\n";
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." );
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." );
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." );
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) );
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.";
401 print "</li>\n";
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";
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";
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>";
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";
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>' );
433 $conf->diff3 = false;
434 $diff3locations = array( "/usr/bin", "/usr/local/bin", "/opt/csw/bin", "/usr/gnu/bin", "/usr/sfw/bin" ) + explode( $sep, getenv( "PATH" ) );
435 $diff3names = array( "gdiff3", "diff3", "diff3.exe" );
437 $diff3versioninfo = array( '$1 --version 2>&1', 'diff3 (GNU diffutils)' );
438 foreach ($diff3locations as $loc) {
439 $exe = locate_executable($loc, $diff3names, $diff3versioninfo);
440 if ($exe !== false) {
441 $conf->diff3 = $exe;
442 break;
446 if ($conf->diff3)
447 print "<li>Found GNU diff3: <tt>$conf->diff3</tt>.</li>";
448 else
449 print "<li>GNU diff3 not found.</li>";
451 $conf->ImageMagick = false;
452 $imcheck = array( "/usr/bin", "/opt/csw/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" );
453 foreach( $imcheck as $dir ) {
454 $im = "$dir/convert";
455 if( file_exists( $im ) ) {
456 print "<li>Found ImageMagick: <tt>$im</tt>; image thumbnailing will be enabled if you enable uploads.</li>\n";
457 $conf->ImageMagick = $im;
458 break;
462 $conf->HaveGD = function_exists( "imagejpeg" );
463 if( $conf->HaveGD ) {
464 print "<li>Found GD graphics library built-in";
465 if( !$conf->ImageMagick ) {
466 print ", image thumbnailing will be enabled if you enable uploads";
468 print ".</li>\n";
469 } else {
470 if( !$conf->ImageMagick ) {
471 print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n";
475 $conf->UseImageResize = $conf->HaveGD || $conf->ImageMagick;
477 $conf->IP = dirname( dirname( __FILE__ ) );
478 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP ) . "</tt></li>\n";
480 $conf->ScriptPath = preg_replace( '{^(.*)/config.*$}', '$1', $_SERVER["PHP_SELF"] ); # was SCRIPT_NAME
481 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath ) . "</tt></li>\n";
483 print "<li style='font-weight:bold;color:green;font-size:110%'>Environment checked. You can install MediaWiki.</li>\n";
484 $conf->posted = ($_SERVER["REQUEST_METHOD"] == "POST");
486 $conf->Sitename = ucfirst( importPost( "Sitename", "" ) );
487 $defaultEmail = empty( $_SERVER["SERVER_ADMIN"] )
488 ? 'root@localhost'
489 : $_SERVER["SERVER_ADMIN"];
490 $conf->EmergencyContact = importPost( "EmergencyContact", $defaultEmail );
491 $conf->DBtype = importPost( "DBtype", $DefaultDBtype );
494 <?php
495 $conf->DBserver = importPost( "DBserver", "localhost" );
496 $conf->DBname = importPost( "DBname", "wikidb" );
497 $conf->DBuser = importPost( "DBuser", "wikiuser" );
498 $conf->DBpassword = importPost( "DBpassword" );
499 $conf->DBpassword2 = importPost( "DBpassword2" );
500 $conf->SysopName = importPost( "SysopName", "WikiSysop" );
501 $conf->SysopPass = importPost( "SysopPass" );
502 $conf->SysopPass2 = importPost( "SysopPass2" );
503 $conf->RootUser = importPost( "RootUser", "root" );
504 $conf->RootPW = importPost( "RootPW", "-" );
506 ## MySQL specific:
507 $conf->DBprefix = importPost( "DBprefix" );
508 $conf->DBmysql5 = (importPost( "DBmysql5" ) == "true") ? "true" : "false";
509 $conf->LanguageCode = importPost( "LanguageCode", "en" );
511 ## Postgres specific:
512 $conf->DBport = importPost( "DBport", "5432" );
513 $conf->DBmwschema = importPost( "DBmwschema", "mediawiki" );
514 $conf->DBts2schema = importPost( "DBts2schema", "public" );
516 /* Check for validity */
517 $errs = array();
519 if( $conf->Sitename == "" || $conf->Sitename == "MediaWiki" || $conf->Sitename == "Mediawiki" ) {
520 $errs["Sitename"] = "Must not be blank or \"MediaWiki\"";
522 if( $conf->DBuser == "" ) {
523 $errs["DBuser"] = "Must not be blank";
525 if( $conf->DBpassword == "" ) {
526 $errs["DBpassword"] = "Must not be blank";
528 if( $conf->DBpassword != $conf->DBpassword2 ) {
529 $errs["DBpassword2"] = "Passwords don't match!";
531 if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix ) ) {
532 $errs["DBprefix"] = "Invalid table prefix";
535 if( $conf->SysopPass == "" ) {
536 $errs["SysopPass"] = "Must not be blank";
538 if( $conf->SysopPass != $conf->SysopPass2 ) {
539 $errs["SysopPass2"] = "Passwords don't match!";
542 $conf->License = importRequest( "License", "none" );
543 if( $conf->License == "gfdl" ) {
544 $conf->RightsUrl = "http://www.gnu.org/copyleft/fdl.html";
545 $conf->RightsText = "GNU Free Documentation License 1.2";
546 $conf->RightsCode = "gfdl";
547 $conf->RightsIcon = '${wgStylePath}/common/images/gnu-fdl.png';
548 } elseif( $conf->License == "none" ) {
549 $conf->RightsUrl = $conf->RightsText = $conf->RightsCode = $conf->RightsIcon = "";
550 } else {
551 $conf->RightsUrl = importRequest( "RightsUrl", "" );
552 $conf->RightsText = importRequest( "RightsText", "" );
553 $conf->RightsCode = importRequest( "RightsCode", "" );
554 $conf->RightsIcon = importRequest( "RightsIcon", "" );
557 $conf->Shm = importRequest( "Shm", "none" );
558 $conf->MCServers = importRequest( "MCServers" );
560 /* Test memcached servers */
562 if ( $conf->Shm == 'memcached' && $conf->MCServers ) {
563 $conf->MCServerArray = array_map( 'trim', explode( ',', $conf->MCServers ) );
564 foreach ( $conf->MCServerArray as $server ) {
565 $error = testMemcachedServer( $server );
566 if ( $error ) {
567 $errs["MCServers"] = $error;
568 break;
571 } else if ( $conf->Shm == 'memcached' ) {
572 $errs["MCServers"] = "Please specify at least one server if you wish to use memcached";
575 /* default values for installation */
576 $conf->Email = importRequest("Email", "email_enabled");
577 $conf->Emailuser = importRequest("Emailuser", "emailuser_enabled");
578 $conf->Enotif = importRequest("Enotif", "enotif_allpages");
579 $conf->Eauthent = importRequest("Eauthent", "eauthent_enabled");
581 if( $conf->posted && ( 0 == count( $errs ) ) ) {
582 do { /* So we can 'continue' to end prematurely */
583 $conf->Root = ($conf->RootPW != "");
585 /* Load up the settings and get installin' */
586 $local = writeLocalSettings( $conf );
587 echo "<p><b>Generating configuration file...</b></p>\n";
588 // for debugging: // echo "<pre>" . htmlspecialchars( $local ) . "</pre>\n";
590 $wgCommandLineMode = false;
591 chdir( ".." );
592 eval($local);
593 $conf->DBtypename = '';
594 foreach (array_keys($ourdb) as $db) {
595 if ($conf->DBtype === $db)
596 $conf->DBtypename = $ourdb[$db]['fullname'];
598 if ( ! strlen($conf->DBtype)) {
599 $errs["DBpicktype"] = "Please choose a database type";
600 continue;
603 if (! $conf->DBtypename) {
604 $errs["DBtype"] = "Unknown database type '$conf->DBtype'";
605 continue;
607 print "<li>Database type: {$conf->DBtypename}</li>\n";
608 $dbclass = 'Database'.ucfirst($conf->DBtype);
609 $wgDBtype = $conf->DBtype;
610 $wgDBadminuser = "root";
611 $wgDBadminpassword = $conf->RootPW;
613 ## Mysql specific:
614 $wgDBprefix = $conf->DBprefix;
616 ## Postgres specific:
617 $wgDBport = $conf->DBport;
618 $wgDBmwschema = $conf->DBmwschema;
619 $wgDBts2schema = $conf->DBts2schema;
621 $wgCommandLineMode = true;
622 $wgUseDatabaseMessages = false; /* FIXME: For database failure */
623 require_once( "includes/Setup.php" );
624 chdir( "config" );
626 require_once( "maintenance/InitialiseMessages.inc" );
628 $wgTitle = Title::newFromText( "Installation script" );
629 error_reporting( E_ALL );
630 print "<li>Loading class: $dbclass";
631 $dbc = new $dbclass;
633 if( $conf->DBtype == 'mysql' ) {
634 $mysqlOldClient = version_compare( mysql_get_client_info(), "4.1.0", "lt" );
635 if( $mysqlOldClient ) {
636 print "<li><b>PHP is linked with old MySQL client libraries. If you are
637 using a MySQL 4.1 server and have problems connecting to the database,
638 see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
639 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b></li>\n";
641 $ok = true; # Let's be optimistic
643 # Decide if we're going to use the superuser or the regular database user
644 if( $conf->RootPW == '-' ) {
645 # Regular user
646 $conf->Root = false;
647 $db_user = $wgDBuser;
648 $db_pass = $wgDBpassword;
649 } else {
650 # Superuser
651 $conf->Root = true;
652 $db_user = $conf->RootUser;
653 $db_pass = $conf->RootPW;
656 # Attempt to connect
657 echo( "<li>Attempting to connect to database server as $db_user..." );
658 $wgDatabase = Database::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 );
660 # Check the connection and respond to errors
661 if( $wgDatabase->isOpen() ) {
662 # Seems OK
663 $ok = true;
664 $wgDBadminuser = $db_user;
665 $wgDBadminpassword = $db_pass;
666 echo( "success.</li>\n" );
667 $wgDatabase->ignoreErrors( true );
668 $myver = $wgDatabase->getServerVersion();
669 } else {
670 # There were errors, report them and back out
671 $ok = false;
672 $errno = mysql_errno();
673 $errtx = htmlspecialchars( mysql_error() );
674 switch( $errno ) {
675 case 1045:
676 case 2000:
677 echo( "failed due to authentication errors. Check passwords.</li>" );
678 if( $conf->Root ) {
679 # The superuser details are wrong
680 $errs["RootUser"] = "Check username";
681 $errs["RootPW"] = "and password";
682 } else {
683 # The regular user details are wrong
684 $errs["DBuser"] = "Check username";
685 $errs["DBpassword"] = "and password";
687 break;
688 case 2002:
689 case 2003:
690 default:
691 # General connection problem
692 echo( "failed with error [$errno] $errtx.</li>\n" );
693 $errs["DBserver"] = "Connection failed";
694 break;
695 } # switch
696 } #conn. att.
698 if( !$ok ) { continue; }
700 } else /* not mysql */ {
701 error_reporting( E_ALL );
702 $wgSuperUser = '';
703 ## Possible connect as a superuser
704 if( $conf->RootPW != '-' and strlen($conf->RootPW)) {
705 $wgDBsuperuser = $conf->RootUser;
706 echo( "<li>Attempting to connect to database \"postgres\" as superuser \"$wgDBsuperuser\"..." );
707 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBsuperuser, $conf->RootPW, "postgres", 1);
708 if (!$wgDatabase->isOpen()) {
709 print " error: " . $wgDatabase->lastError() . "</li>\n";
710 $errs["DBserver"] = "Could not connect to database as superuser";
711 $errs["RootUser"] = "Check username";
712 $errs["RootPW"] = "and password";
713 continue;
716 echo( "<li>Attempting to connect to database \"$wgDBname\" as \"$wgDBuser\"..." );
717 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1);
718 if (!$wgDatabase->isOpen()) {
719 print " error: " . $wgDatabase->lastError() . "</li>\n";
720 } else {
721 $myver = $wgDatabase->getServerVersion();
725 if ( !$wgDatabase->isOpen() ) {
726 $errs["DBserver"] = "Couldn't connect to database";
727 continue;
730 print "<li>Connected to $myver";
731 if ($conf->DBtype == 'mysql') {
732 if( version_compare( $myver, "4.0.14" ) < 0 ) {
733 dieout( " -- mysql 4.0.14 or later required. Aborting." );
735 $mysqlNewAuth = version_compare( $myver, "4.1.0", "ge" );
736 if( $mysqlNewAuth && $mysqlOldClient ) {
737 print "; <b class='error'>You are using MySQL 4.1 server, but PHP is linked
738 to old client libraries; if you have trouble with authentication, see
739 <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
740 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>";
742 if( $wgDBmysql5 ) {
743 if( $mysqlNewAuth ) {
744 print "; enabling MySQL 4.1/5.0 charset mode";
745 } else {
746 print "; <b class='error'>MySQL 4.1/5.0 charset mode enabled,
747 but older version detected; will likely fail.</b>";
750 print "</li>\n";
752 @$sel = $wgDatabase->selectDB( $wgDBname );
753 if( $sel ) {
754 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
755 } else {
756 $err = mysql_errno();
757 if ( $err != 1049 ) {
758 print "<ul><li>Error selecting database $wgDBname: $err " .
759 htmlspecialchars( mysql_error() ) . "</li></ul>";
760 continue;
762 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
763 if( !$res ) {
764 print "<li>Couldn't create database <tt>" .
765 htmlspecialchars( $wgDBname ) .
766 "</tt>; try with root access or check your username/pass.</li>\n";
767 $errs["RootPW"] = "&lt;- Enter";
768 continue;
770 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
772 $wgDatabase->selectDB( $wgDBname );
774 else if ($conf->DBtype == 'postgres') {
775 if( version_compare( $myver, "PostgreSQL 8.0" ) < 0 ) {
776 dieout( " <b>Postgres 8.0 or later is required</b>. Aborting.</li></ul>" );
780 if( $wgDatabase->tableExists( "cur" ) || $wgDatabase->tableExists( "revision" ) ) {
781 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n";
783 # Create user if required (todo: other databases)
784 if ( $conf->Root && $conf->DBtype == 'mysql') {
785 $conn = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
786 if ( $conn->isOpen() ) {
787 print "<li>DB user account ok</li>\n";
788 $conn->close();
789 } else {
790 print "<li>Granting user permissions...";
791 if( $mysqlOldClient && $mysqlNewAuth ) {
792 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>";
794 print "</li>\n";
795 dbsource( "../maintenance/users.sql", $wgDatabase );
798 print "<pre>\n";
799 chdir( ".." );
800 flush();
801 do_all_updates();
802 chdir( "config" );
803 print "</pre>\n";
804 print "<li>Finished update checks.</li>\n";
805 } else {
806 # FIXME: Check for errors
807 print "<li>Creating tables...";
808 if ($conf->DBtype == 'mysql') {
809 if( $wgDBmysql5 ) {
810 print " using MySQL 5 table defs...";
811 dbsource( "../maintenance/mysql5/tables.sql", $wgDatabase );
812 } else {
813 print " using MySQL 4 table defs...";
814 dbsource( "../maintenance/tables.sql", $wgDatabase );
816 dbsource( "../maintenance/interwiki.sql", $wgDatabase );
817 } else if ($conf->DBtype == 'postgres') {
818 $wgDatabase->setup_database();
820 else {
821 $errs["DBtype"] = "Do not know how to handle database type '$conf->DBtype'";
822 continue;
825 print " done.</li>\n";
827 print "<li>Initializing data...";
828 $wgDatabase->insert( 'site_stats',
829 array ( 'ss_row_id' => 1,
830 'ss_total_views' => 0,
831 'ss_total_edits' => 0,
832 'ss_good_articles' => 0 ) );
834 # Set up the "regular user" account *if we can, and if we need to*
835 if( $conf->Root and $conf->DBtype == 'mysql') {
836 # See if we need to
837 $wgDatabase2 = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
838 if( $wgDatabase2->isOpen() ) {
839 # Nope, just close the test connection and continue
840 $wgDatabase2->close();
841 echo( "<li>User $wgDBuser exists. Skipping grants.</li>" );
842 } else {
843 # Yes, so run the grants
844 echo( "<li>Granting user permissions to $wgDBuser on $wgDBname..." );
845 dbsource( "../maintenance/users.sql", $wgDatabase );
846 echo( "success.</li>" );
850 if( $conf->SysopName ) {
851 $u = User::newFromName( $conf->getSysopName() );
852 if ( 0 == $u->idForName() ) {
853 $u->addToDatabase();
854 $u->setPassword( $conf->getSysopPass() );
855 $u->saveSettings();
857 $u->addGroup( "sysop" );
858 $u->addGroup( "bureaucrat" );
860 print "<li>Created sysop account <tt>" .
861 htmlspecialchars( $conf->SysopName ) . "</tt>.</li>\n";
862 } else {
863 print "<li>Could not create user - already exists!</li>\n";
865 } else {
866 print "<li>Skipped sysop account creation, no name given.</li>\n";
869 $titleobj = Title::newFromText( wfMsgNoDB( "mainpage" ) );
870 $article = new Article( $titleobj );
871 $newid = $article->insertOn( $wgDatabase );
872 $revision = new Revision( array(
873 'page' => $newid,
874 'text' => wfMsg( 'mainpagetext' ) . "\n\n" . wfMsg( 'mainpagedocfooter' ),
875 'comment' => '',
876 'user' => 0,
877 'user_text' => 'MediaWiki default',
878 ) );
879 $revid = $revision->insertOn( $wgDatabase );
880 $article->updateRevisionOn( $wgDatabase, $revision );
882 initialiseMessages( false, false, 'printListItem' );
885 /* Write out the config file now that all is well */
886 print "<p>Creating LocalSettings.php...</p>\n\n";
887 $localSettings = "<" . "?php$endl$local$endl?" . ">\r\n";
888 // Fix up a common line-ending problem (due to CVS on Windows)
889 $localSettings = str_replace( "\r\n", "\n", $localSettings );
890 $f = fopen( "LocalSettings.php", 'xt' );
892 if( $f == false ) {
893 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" .
894 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
895 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
897 if(fwrite( $f, $localSettings ) ) {
898 fclose( $f );
899 writeSuccessMessage();
900 } else {
901 fclose( $f );
902 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");
906 } while( false );
909 </ul>
912 <?php
914 if( count( $errs ) ) {
915 /* Display options form */
917 if( $conf->posted ) {
918 echo "<p class='error-top'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
922 <form action="index.php" name="config" method="post">
925 <h2>Site config</h2>
927 <div class="config-section">
928 <div class="config-input">
929 <?php
930 aField( $conf, "Sitename", "Wiki name:" );
932 </div>
933 <p class="config-desc">
934 Preferably a short word without punctuation, i.e. "Wikipedia".<br />
935 Will appear as the namespace name for "meta" pages, and throughout the interface.
936 </p>
938 <div class="config-input">
939 <?php
940 aField( $conf, "EmergencyContact", "Contact e-mail:" );
942 </div>
943 <p class="config-desc">
944 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.
945 </p>
947 <div class="config-input">
948 <label class='column' for="LanguageCode">Language:</label>
949 <select id="LanguageCode" name="LanguageCode">
951 <?php
952 $list = getLanguageList();
953 foreach( $list as $code => $name ) {
954 $sel = ($code == $conf->LanguageCode) ? 'selected="selected"' : '';
955 echo "\t\t<option value=\"$code\" $sel>$name</option>\n";
958 </select>
959 </div>
960 <p class="config-desc">
961 Select the language for your wiki's interface. Some localizations aren't fully complete. Unicode (UTF-8) used for all localizations.
962 </p>
964 <div class="config-input">
965 <label class='column'>Copyright/license:</label>
967 <ul class="plain">
968 <li><?php aField( $conf, "License", "No license metadata", "radio", "none" ); ?></li>
969 <li><?php aField( $conf, "License", "GNU Free Documentation License 1.2 (Wikipedia-compatible)", "radio", "gfdl" ); ?></li>
970 <li><?php
971 aField( $conf, "License", "A Creative Commons license - ", "radio", "cc" );
972 $partner = "MediaWiki";
973 $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/index.php?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
974 $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" );
975 $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" );
976 print "<a href=\"$ccApp\" target='_blank'>choose</a>";
978 <?php if( $conf->License == "cc" ) { ?>
979 <ul>
980 <li><?php aField( $conf, "RightsIcon", "<img src=\"" . htmlspecialchars( $conf->RightsIcon ) . "\" alt='icon' />", "hidden" ); ?></li>
981 <li><?php aField( $conf, "RightsText", htmlspecialchars( $conf->RightsText ), "hidden" ); ?></li>
982 <li><?php aField( $conf, "RightsCode", "code: " . htmlspecialchars( $conf->RightsCode ), "hidden" ); ?></li>
983 <li><?php aField( $conf, "RightsUrl", "<a href=\"" . htmlspecialchars( $conf->RightsUrl ) . "\">" . htmlspecialchars( $conf->RightsUrl ) . "</a>", "hidden" ); ?></li>
984 </ul>
985 <?php } ?>
986 </li>
987 </ul>
988 </div>
989 <p class="config-desc">
990 A notice, icon, and machine-readable copyright metadata will be displayed for the license you pick.
991 </p>
994 <div class="config-input">
995 <?php aField( $conf, "SysopName", "Admin username:" ) ?>
996 </div>
997 <div class="config-input">
998 <?php aField( $conf, "SysopPass", "Password:", "password" ) ?>
999 </div>
1000 <div class="config-input">
1001 <?php aField( $conf, "SysopPass2", "Password confirm:", "password" ) ?>
1002 </div>
1003 <p class="config-desc">
1004 An admin can lock/delete pages, block users from editing, and do other maintenance tasks.<br />
1005 A new account will be added only when creating a new wiki database.
1006 </p>
1008 <div class="config-input">
1009 <label class='column'>Shared memory caching:</label>
1011 <ul class="plain">
1012 <li><?php aField( $conf, "Shm", "No caching", "radio", "none" ); ?></li>
1013 <?php
1014 if ( $conf->turck ) {
1015 echo "<li>";
1016 aField( $conf, "Shm", "Turck MMCache", "radio", "turck" );
1017 echo "</li>";
1019 if ( $conf->apc ) {
1020 echo "<li>";
1021 aField( $conf, "Shm", "APC", "radio", "apc" );
1022 echo "</li>";
1024 if ( $conf->eaccel ) {
1025 echo "<li>";
1026 aField( $conf, "Shm", "eAccelerator", "radio", "eaccel" );
1027 echo "</li>";
1030 <li><?php aField( $conf, "Shm", "Memcached", "radio", "memcached" ); ?></li>
1031 </ul>
1032 <div style="clear:left"><?php aField( $conf, "MCServers", "Memcached servers:", "text" ) ?></div>
1033 </div>
1034 <p class="config-desc">
1035 Using a shared memory system such as Turck MMCache, APC, eAccelerator, or Memcached
1036 will speed up MediaWiki significantly. Memcached is the best solution but needs to be
1037 installed. Specify the server addresses and ports in a comma-separted list. Only
1038 use Turck shared memory if the wiki will be running on a single Apache server.
1039 </p>
1040 </div>
1042 <h2>E-mail, e-mail notification and authentication setup</h2>
1044 <div class="config-section">
1045 <div class="config-input">
1046 <label class='column'>E-mail features (global):</label>
1047 <ul class="plain">
1048 <li><?php aField( $conf, "Email", "Enabled", "radio", "email_enabled" ); ?></li>
1049 <li><?php aField( $conf, "Email", "Disabled", "radio", "email_disabled" ); ?></li>
1050 </ul>
1051 </div>
1052 <p class="config-desc">
1053 Use this to disable all e-mail functions (password reminders, user-to-user e-mail and e-mail notifications)
1054 if sending mail doesn't work on your server.
1055 </p>
1057 <div class="config-input">
1058 <label class='column'>User-to-user e-mail:</label>
1059 <ul class="plain">
1060 <li><?php aField( $conf, "Emailuser", "Enabled", "radio", "emailuser_enabled" ); ?></li>
1061 <li><?php aField( $conf, "Emailuser", "Disabled", "radio", "emailuser_disabled" ); ?></li>
1062 </ul>
1063 </div>
1064 <p class="config-desc">
1065 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.
1066 </p>
1067 <div class="config-input">
1068 <label class='column'>E-mail notification about changes:</label>
1069 <ul class="plain">
1070 <li><?php aField( $conf, "Enotif", "Disabled", "radio", "enotif_disabled" ); ?></li>
1071 <li><?php aField( $conf, "Enotif", "Enabled for changes to user discussion pages only", "radio", "enotif_usertalk" ); ?></li>
1072 <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>
1073 </ul>
1074 </div>
1075 <div class="config-desc">
1077 For this feature to work, an e-mail address must be present for the user account, and the notification
1078 options in the user's preferences must be enabled. Also note the
1079 authentication option below. When testing the feature, keep in mind that your own changes will never trigger notifications to be sent to yourself.</p>
1081 <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>
1082 </div>
1084 <div class="config-input">
1085 <label class='column'>E-mail address authentication:</label>
1086 <ul class="plain">
1087 <li><?php aField( $conf, "Eauthent", "Disabled", "radio", "eauthent_disabled" ); ?></li>
1088 <li><?php aField( $conf, "Eauthent", "Enabled", "radio", "eauthent_enabled" ); ?></li>
1089 </ul>
1090 </div>
1091 <div class="config-desc">
1092 <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
1093 change notification mails. Setting this option is <B>recommended</B> for public wikis because of potential abuse of the e-mail features above.</p>
1094 </div>
1096 </div>
1098 <h2>Database config</h2>
1100 <div class="config-section">
1101 <div class="config-input">
1102 <label class='column'>Database type:</label>
1103 <?php if (isset($errs['DBpicktype'])) print "<span class='error'>$errs[DBpicktype]</span>\n"; ?>
1104 <ul class='plain'><?php database_picker($conf) ?></ul>
1105 </div>
1107 <div class="config-input" style="clear:left"><?php
1108 aField( $conf, "DBserver", "Database host:" );
1109 ?></div>
1110 <p class="config-desc">
1111 If your database server isn't on your web server, enter the name or IP address here.
1112 </p>
1114 <div class="config-input"><?php
1115 aField( $conf, "DBname", "Database name:" );
1116 ?></div>
1117 <div class="config-input"><?php
1118 aField( $conf, "DBuser", "DB username:" );
1119 ?></div>
1120 <div class="config-input"><?php
1121 aField( $conf, "DBpassword", "DB password:", "password" );
1122 ?></div>
1123 <div class="config-input"><?php
1124 aField( $conf, "DBpassword2", "DB password confirm:", "password" );
1125 ?></div>
1126 <p class="config-desc">
1127 If you only have a single user account and database available,
1128 enter those here. If you have database root access (see below)
1129 you can specify new accounts/databases to be created. This account
1130 will not be created if it pre-exists. If this is the case, ensure that it
1131 has SELECT, INSERT, UPDATE and DELETE permissions on the MediaWiki database.
1132 </p>
1134 <div class="config-input">
1135 <?php
1136 aField( $conf, "RootUser", "Superuser account:", "superuser" );
1138 </div>
1139 <div class="config-input">
1140 <?php
1141 aField( $conf, "RootPW", "Superuser password:", "password" );
1143 </div>
1145 <p class="config-desc">
1146 If the database user specified above does not exist, or does not have access to create
1147 the database (if needed) or tables within it, please provide details of a superuser account,
1148 such as <strong>root</strong>, which does. Leave the password set to <strong>-</strong> if this is not needed.
1149 </p>
1151 <?php database_switcher('mysql'); ?>
1152 <div class="config-input"><?php
1153 aField( $conf, "DBprefix", "Database table prefix:" );
1154 ?></div>
1155 <div class="config-desc">
1156 <p>If you need to share one database between multiple wikis, or
1157 MediaWiki and another web application, you may choose to
1158 add a prefix to all the table names to avoid conflicts.</p>
1160 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
1161 </div>
1163 <div class="config-input"><label class="column">Database charset</label>
1164 <div>Select one:</div>
1165 <ul class="plain">
1166 <li><?php aField( $conf, "DBmysql5", "Backwards-compatible UTF-8", "radio", "false" ); ?></li>
1167 <li><?php aField( $conf, "DBmysql5", "Experimental MySQL 4.1/5.0 UTF-8", "radio", "true" ); ?></li>
1168 </ul>
1169 </div>
1170 <p class="config-desc">
1171 <b>EXPERIMENTAL:</b> You can enable explicit Unicode charset support
1172 for MySQL 4.1 and 5.0 servers. This is not well tested and may
1173 cause things to break. <b>If upgrading an older installation, leave
1174 in backwards-compatible mode.</b>
1175 </p>
1176 </div>
1178 <?php database_switcher('postgres'); ?>
1179 <div class="config-input"><?php
1180 aField( $conf, "DBport", "Database port:" );
1181 ?></div>
1182 <div class="config-input"><?php
1183 aField( $conf, "DBmwschema", "Schema for mediawiki:" );
1184 ?></div>
1185 <div class="config-input"><?php
1186 aField( $conf, "DBts2schema", "Schema for tsearch2:" );
1187 ?></div>
1188 <div class="config-desc">
1189 <p>The username specified above will have it's search path set to the above schemas,
1190 so it is recommended that you create a new user.</p>
1191 </div>
1192 </div>
1194 <div class="config-input" style="padding:2em 0 3em">
1195 <label class='column'>&nbsp;</label>
1196 <input type="submit" value="Install MediaWiki!" class="btn-install" />
1197 </div>
1199 </div>
1201 <script type="text/javascript">
1202 window.onload = toggleDBarea('<?php echo $conf->DBtype; ?>',
1203 <?php
1204 ## If they passed in a root user name, don't populate it on page load
1205 echo strlen(importPost('RootUser', '')) ? 0 : 1;
1206 ?>);
1207 </script>
1209 </form>
1211 <?php
1214 /* -------------------------------------------------------------------------------------- */
1215 function writeSuccessMessage() {
1216 if ( ini_get( 'safe_mode' ) && !ini_get( 'open_basedir' ) ) {
1217 echo <<<EOT
1218 <p>Installation successful!</p>
1219 <p>To complete the installation, please do the following:
1220 <ol>
1221 <li>Download config/LocalSettings.php with your FTP client or file manager</li>
1222 <li>Upload it to the parent directory</li>
1223 <li>Delete config/LocalSettings.php</li>
1224 <li>Start using <a href='../index.php'>your wiki</a>!
1225 </ol>
1226 <p>If you are in a shared hosting environment, do <strong>not</strong> just move LocalSettings.php
1227 remotely. LocalSettings.php is currently owned by the user your webserver is running under,
1228 which means that anyone on the same server can read your database password! Downloading
1229 it and uploading it again will hopefully change the ownership to a user ID specific to you.</p>
1230 EOT;
1231 } else {
1232 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
1233 <strong><a href='../index.php'>this link</a></strong> to your wiki.</p>\n";
1238 function escapePhpString( $string ) {
1239 return strtr( $string,
1240 array(
1241 "\n" => "\\n",
1242 "\r" => "\\r",
1243 "\t" => "\\t",
1244 "\\" => "\\\\",
1245 "\$" => "\\\$",
1246 "\"" => "\\\""
1250 function writeLocalSettings( $conf ) {
1251 $conf->UseImageResize = $conf->UseImageResize ? 'true' : 'false';
1252 $conf->PasswordSender = $conf->EmergencyContact;
1253 $zlib = ($conf->zlib ? "" : "# ");
1254 $magic = ($conf->ImageMagick ? "" : "# ");
1255 $convert = ($conf->ImageMagick ? $conf->ImageMagick : "/usr/bin/convert" );
1256 $pretty = ($conf->prettyURLs ? "" : "# ");
1257 $ugly = ($conf->prettyURLs ? "# " : "");
1258 $rights = ($conf->RightsUrl) ? "" : "# ";
1259 $hashedUploads = $conf->safeMode ? '' : '# ';
1261 switch ( $conf->Shm ) {
1262 case 'memcached':
1263 $cacheType = 'CACHE_MEMCACHED';
1264 $mcservers = var_export( $conf->MCServerArray, true );
1265 break;
1266 case 'turck':
1267 case 'apc':
1268 case 'eaccel':
1269 $cacheType = 'CACHE_ACCEL';
1270 $mcservers = 'array()';
1271 break;
1272 default:
1273 $cacheType = 'CACHE_NONE';
1274 $mcservers = 'array()';
1277 if ( $conf->Email == 'email_enabled' ) {
1278 $enableemail = 'true';
1279 $enableuseremail = ( $conf->Emailuser == 'emailuser_enabled' ) ? 'true' : 'false' ;
1280 $eauthent = ( $conf->Eauthent == 'eauthent_enabled' ) ? 'true' : 'false' ;
1281 switch ( $conf->Enotif ) {
1282 case 'enotif_usertalk':
1283 $enotifusertalk = 'true';
1284 $enotifwatchlist = 'false';
1285 break;
1286 case 'enotif_allpages':
1287 $enotifusertalk = 'true';
1288 $enotifwatchlist = 'true';
1289 break;
1290 default:
1291 $enotifusertalk = 'false';
1292 $enotifwatchlist = 'false';
1294 } else {
1295 $enableuseremail = 'false';
1296 $enableemail = 'false';
1297 $eauthent = 'false';
1298 $enotifusertalk = 'false';
1299 $enotifwatchlist = 'false';
1302 $file = @fopen( "/dev/urandom", "r" );
1303 if ( $file ) {
1304 $secretKey = bin2hex( fread( $file, 32 ) );
1305 fclose( $file );
1306 } else {
1307 $secretKey = "";
1308 for ( $i=0; $i<8; $i++ ) {
1309 $secretKey .= dechex(mt_rand(0, 0x7fffffff));
1311 print "<li>Warning: \$wgSecretKey key is insecure, generated with mt_rand(). Consider changing it manually.</li>\n";
1314 # Add slashes to strings for double quoting
1315 $slconf = array_map( "escapePhpString", get_object_vars( $conf ) );
1316 if( $conf->License == 'gfdl' ) {
1317 # Needs literal string interpolation for the current style path
1318 $slconf['RightsIcon'] = $conf->RightsIcon;
1321 $localsettings = "
1322 # This file was automatically generated by the MediaWiki installer.
1323 # If you make manual changes, please keep track in case you need to
1324 # recreate them later.
1326 # See includes/DefaultSettings.php for all configurable settings
1327 # and their default values, but don't forget to make changes in _this_
1328 # file, not there.
1330 # If you customize your file layout, set \$IP to the directory that contains
1331 # the other MediaWiki files. It will be used as a base to locate files.
1332 if( defined( 'MW_INSTALL_PATH' ) ) {
1333 \$IP = MW_INSTALL_PATH;
1334 } else {
1335 \$IP = dirname( __FILE__ );
1338 \$path = array( \$IP, \"\$IP/includes\", \"\$IP/languages\" );
1339 set_include_path( implode( PATH_SEPARATOR, \$path ) . PATH_SEPARATOR . get_include_path() );
1341 require_once( \"includes/DefaultSettings.php\" );
1343 # If PHP's memory limit is very low, some operations may fail.
1344 " . ($conf->raiseMemory ? '' : '# ' ) . "ini_set( 'memory_limit', '20M' );" . "
1346 if ( \$wgCommandLineMode ) {
1347 if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
1348 die( \"This script must be run from the command line\\n\" );
1350 } elseif ( empty( \$wgNoOutputBuffer ) ) {
1351 ## Compress output if the browser supports it
1352 {$zlib}if( !ini_get( 'zlib.output_compression' ) ) @ob_start( 'ob_gzhandler' );
1355 \$wgSitename = \"{$slconf['Sitename']}\";
1357 \$wgScriptPath = \"{$slconf['ScriptPath']}\";
1358 \$wgScript = \"\$wgScriptPath/index.php\";
1359 \$wgRedirectScript = \"\$wgScriptPath/redirect.php\";
1361 ## For more information on customizing the URLs please see:
1362 ## http://meta.wikimedia.org/wiki/Eliminating_index.php_from_the_url
1363 ## If using PHP as a CGI module, the ?title= style usually must be used.
1364 {$pretty}\$wgArticlePath = \"\$wgScript/\$1\";
1365 {$ugly}\$wgArticlePath = \"\$wgScript?title=\$1\";
1367 \$wgStylePath = \"\$wgScriptPath/skins\";
1368 \$wgStyleDirectory = \"\$IP/skins\";
1369 \$wgLogo = \"\$wgStylePath/common/images/wiki.png\";
1371 \$wgUploadPath = \"\$wgScriptPath/images\";
1372 \$wgUploadDirectory = \"\$IP/images\";
1374 \$wgEnableEmail = $enableemail;
1375 \$wgEnableUserEmail = $enableuseremail;
1377 \$wgEmergencyContact = \"{$slconf['EmergencyContact']}\";
1378 \$wgPasswordSender = \"{$slconf['PasswordSender']}\";
1380 ## For a detailed description of the following switches see
1381 ## http://meta.wikimedia.org/Enotif and http://meta.wikimedia.org/Eauthent
1382 ## There are many more options for fine tuning available see
1383 ## /includes/DefaultSettings.php
1384 ## UPO means: this is also a user preference option
1385 \$wgEnotifUserTalk = $enotifusertalk; # UPO
1386 \$wgEnotifWatchlist = $enotifwatchlist; # UPO
1387 \$wgEmailAuthentication = $eauthent;
1389 \$wgDBtype = \"{$slconf['DBtype']}\";
1390 \$wgDBserver = \"{$slconf['DBserver']}\";
1391 \$wgDBname = \"{$slconf['DBname']}\";
1392 \$wgDBuser = \"{$slconf['DBuser']}\";
1393 \$wgDBpassword = \"{$slconf['DBpassword']}\";
1394 \$wgDBport = \"{$slconf['DBport']}\";
1395 \$wgDBprefix = \"{$slconf['DBprefix']}\";
1397 # Schemas for Postgres
1398 \$wgDBmwschema = \"{$slconf['DBmwschema']}\";
1399 \$wgDBts2schema = \"{$slconf['DBts2schema']}\";
1401 # Experimental charset support for MySQL 4.1/5.0.
1402 \$wgDBmysql5 = {$conf->DBmysql5};
1404 ## Shared memory settings
1405 \$wgMainCacheType = $cacheType;
1406 \$wgMemCachedServers = $mcservers;
1408 ## To enable image uploads, make sure the 'images' directory
1409 ## is writable, then set this to true:
1410 \$wgEnableUploads = false;
1411 \$wgUseImageResize = {$conf->UseImageResize};
1412 {$magic}\$wgUseImageMagick = true;
1413 {$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
1415 ## If you want to use image uploads under safe mode,
1416 ## create the directories images/archive, images/thumb and
1417 ## images/temp, and make them all writable. Then uncomment
1418 ## this, if it's not already uncommented:
1419 {$hashedUploads}\$wgHashedUploadDirectory = false;
1421 ## If you have the appropriate support software installed
1422 ## you can enable inline LaTeX equations:
1423 \$wgUseTeX = false;
1424 \$wgMathPath = \"{\$wgUploadPath}/math\";
1425 \$wgMathDirectory = \"{\$wgUploadDirectory}/math\";
1426 \$wgTmpDirectory = \"{\$wgUploadDirectory}/tmp\";
1428 \$wgLocalInterwiki = \$wgSitename;
1430 \$wgLanguageCode = \"{$slconf['LanguageCode']}\";
1432 \$wgProxyKey = \"$secretKey\";
1434 ## Default skin: you can change the default skin. Use the internal symbolic
1435 ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook':
1436 \$wgDefaultSkin = 'monobook';
1438 ## For attaching licensing metadata to pages, and displaying an
1439 ## appropriate copyright notice / icon. GNU Free Documentation
1440 ## License and Creative Commons licenses are supported so far.
1441 {$rights}\$wgEnableCreativeCommonsRdf = true;
1442 \$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright
1443 \$wgRightsUrl = \"{$slconf['RightsUrl']}\";
1444 \$wgRightsText = \"{$slconf['RightsText']}\";
1445 \$wgRightsIcon = \"{$slconf['RightsIcon']}\";
1446 # \$wgRightsCode = \"{$slconf['RightsCode']}\"; # Not yet used
1448 \$wgDiff3 = \"{$slconf['diff3']}\";
1450 # When you make changes to this configuration file, this will make
1451 # sure that cached pages are cleared.
1452 \$configdate = gmdate( 'YmdHis', @filemtime( __FILE__ ) );
1453 \$wgCacheEpoch = max( \$wgCacheEpoch, \$configdate );
1454 "; ## End of setting the $localsettings string
1456 // Keep things in Unix line endings internally;
1457 // the system will write out as local text type.
1458 return str_replace( "\r\n", "\n", $localsettings );
1461 function dieout( $text ) {
1462 die( $text . "\n\n</body>\n</html>" );
1465 function importVar( &$var, $name, $default = "" ) {
1466 if( isset( $var[$name] ) ) {
1467 $retval = $var[$name];
1468 if ( get_magic_quotes_gpc() ) {
1469 $retval = stripslashes( $retval );
1471 } else {
1472 $retval = $default;
1474 return $retval;
1477 function importPost( $name, $default = "" ) {
1478 return importVar( $_POST, $name, $default );
1481 function importRequest( $name, $default = "" ) {
1482 return importVar( $_REQUEST, $name, $default );
1485 $radioCount = 0;
1487 function aField( &$conf, $field, $text, $type = "text", $value = "", $onclick = '' ) {
1488 global $radioCount;
1489 if( $type != "" ) {
1490 $xtype = "type=\"$type\"";
1491 } else {
1492 $xtype = "";
1495 $id = $field;
1496 $nolabel = ($type == "radio") || ($type == "hidden");
1498 if ($type == 'radio')
1499 $id .= $radioCount++;
1501 if( $nolabel ) {
1502 echo "\t\t<label>";
1503 } else {
1504 echo "\t\t<label class='column' for=\"$id\">$text</label>\n";
1507 if( $type == "radio" && $value == $conf->$field ) {
1508 $checked = "checked='checked'";
1509 } else {
1510 $checked = "";
1512 echo "\t\t<input $xtype name=\"$field\" id=\"$id\" class=\"iput-$type\" $checked ";
1513 if ($onclick) {
1514 echo " onclick='toggleDBarea(\"$value\",1)' " ;
1516 echo "value=\"";
1517 if( $type == "radio" ) {
1518 echo htmlspecialchars( $value );
1519 } else {
1520 echo htmlspecialchars( $conf->$field );
1524 echo "\" />\n";
1525 if( $nolabel ) {
1526 echo " $text</label>\n";
1529 global $errs;
1530 if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n";
1533 function getLanguageList() {
1534 global $wgLanguageNames;
1535 if( !isset( $wgLanguageNames ) ) {
1536 require_once( "languages/Names.php" );
1539 $codes = array();
1541 $d = opendir( "../languages/messages" );
1542 /* In case we are called from the root directory */
1543 if (!$d)
1544 $d = opendir( "languages/messages");
1545 while( false !== ($f = readdir( $d ) ) ) {
1546 $m = array();
1547 if( preg_match( '/Messages([A-Z][a-z_]+)\.php$/', $f, $m ) ) {
1548 $code = str_replace( '_', '-', strtolower( $m[1] ) );
1549 if( isset( $wgLanguageNames[$code] ) ) {
1550 $name = $code . ' - ' . $wgLanguageNames[$code];
1551 } else {
1552 $name = $code;
1554 $codes[$code] = $name;
1557 closedir( $d );
1558 ksort( $codes );
1559 return $codes;
1562 #Check for location of an executable
1563 # @param string $loc single location to check
1564 # @param array $names filenames to check for.
1565 # @param mixed $versioninfo array of details to use when checking version, use false for no version checking
1566 function locate_executable($loc, $names, $versioninfo = false) {
1567 if (!is_array($names))
1568 $names = array($names);
1570 foreach ($names as $name) {
1571 $command = "$loc".DIRECTORY_SEPARATOR."$name";
1572 if (file_exists($command)) {
1573 if (!$versioninfo)
1574 return $command;
1576 $file = str_replace('$1', $command, $versioninfo[0]);
1577 if (strstr(`$file`, $versioninfo[1]) !== false)
1578 return $command;
1581 return false;
1584 # Test a memcached server
1585 function testMemcachedServer( $server ) {
1586 $hostport = explode(":", $server);
1587 $errstr = false;
1588 $fp = false;
1589 if ( !function_exists( 'fsockopen' ) ) {
1590 $errstr = "Can't connect to memcached, fsockopen() not present";
1592 if ( !$errstr && count( $hostport ) != 2 ) {
1593 $errstr = 'Please specify host and port';
1594 var_dump( $hostport );
1596 if ( !$errstr ) {
1597 list( $host, $port ) = $hostport;
1598 $errno = 0;
1599 $fsockerr = '';
1601 $fp = @fsockopen( $host, $port, $errno, $fsockerr, 1.0 );
1602 if ( $fp === false ) {
1603 $errstr = "Cannot connect to memcached on $host:$port : $fsockerr";
1606 if ( !$errstr ) {
1607 $command = "version\r\n";
1608 $bytes = fwrite( $fp, $command );
1609 if ( $bytes != strlen( $command ) ) {
1610 $errstr = "Cannot write to memcached socket on $host:$port";
1613 if ( !$errstr ) {
1614 $expected = "VERSION ";
1615 $response = fread( $fp, strlen( $expected ) );
1616 if ( $response != $expected ) {
1617 $errstr = "Didn't get correct memcached response from $host:$port";
1620 if ( $fp ) {
1621 fclose( $fp );
1623 if ( !$errstr ) {
1624 echo "<li>Connected to memcached on $host:$port successfully";
1626 return $errstr;
1629 function database_picker($conf) {
1630 global $ourdb;
1631 print "\n";
1632 foreach(array_keys($ourdb) as $db) {
1633 if ($ourdb[$db]['havedriver']) {
1634 print "<li>";
1635 aField( $conf, "DBtype", $ourdb[$db]['fullname'], 'radio', $db, 'onclick');
1636 print "</li>\n";
1639 print "\n";
1642 function database_switcher($db) {
1643 global $ourdb;
1644 $color = $ourdb[$db]['bgcolor'];
1645 $full = $ourdb[$db]['fullname'];
1646 print "<div id='$db' style='display:none; background: $color'>\n";
1647 print "<h3>$full specific options:</h3>\n";
1650 function printListItem( $item ) {
1651 print "<li>$item</li>";
1656 <div class="license">
1657 <hr>
1658 <p>This program is free software; you can redistribute it and/or modify
1659 it under the terms of the GNU General Public License as published by
1660 the Free Software Foundation; either version 2 of the License, or
1661 (at your option) any later version.</p>
1663 <p>This program is distributed in the hope that it will be useful,
1664 but WITHOUT ANY WARRANTY; without even the implied warranty of
1665 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1666 GNU General Public License for more details.</p>
1668 <p>You should have received <a href="../COPYING">a copy of the GNU General Public License</a>
1669 along with this program; if not, write to the Free Software
1670 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1671 or <a href="http://www.gnu.org/copyleft/gpl.html">read it online</a></p>
1672 </div>
1674 </div></div></div>
1677 <div id="column-one">
1678 <div class="portlet" id="p-logo">
1679 <a style="background-image: url(../skins/common/images/mediawiki.png);"
1680 href="http://www.mediawiki.org/"
1681 title="Main Page"></a>
1682 </div>
1683 <script type="text/javascript"> if (window.isMSIE55) fixalpha(); </script>
1684 <div class='portlet'><div class='pBody'>
1685 <ul>
1686 <li><strong><a href="http://www.mediawiki.org/">MediaWiki home</a></strong></li>
1687 <li><a href="../README">Readme</a></li>
1688 <li><a href="../RELEASE-NOTES">Release notes</a></li>
1689 <li><a href="../docs/">Documentation</a></li>
1690 <li><a href="http://meta.wikipedia.org/wiki/MediaWiki_User's_Guide">User's Guide</a></li>
1691 <li><a href="http://meta.wikimedia.org/wiki/MediaWiki_FAQ">FAQ</a></li>
1692 </ul>
1693 <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>
1694 </div></div>
1695 </div>
1697 </div>
1699 </body>
1700 </html>