Improve installer:
[mediawiki.git] / config / index.php
blob449de55d85c2ba4c9aada35f365254a33667125e
1 <?php
2 # MediaWiki web-based config/installation
3 # Copyright (C) 2004 Brion Vibber <brion@pobox.com>
4 # http://www.mediawiki.org/
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with this program; if not, write to the Free Software Foundation, Inc.,
18 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 # http://www.gnu.org/copyleft/gpl.html
21 error_reporting( E_ALL );
22 header( "Content-type: text/html; charset=utf-8" );
23 @ini_set( "display_errors", true );
25 ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
26 "http://www.w3.org/TR/html4/loose.dtd">
27 <html>
28 <head>
29 <meta http-equiv="Content-type" content="text/html; charset=utf-8">
30 <title>MediaWiki installation</title>
31 <style type="text/css">
33 @import "../skins/monobook/main.css";
35 .env-check {
36 font-size: 90%;
37 margin: 1em 0 1em 2.5em;
40 .config-section {
41 margin-top: 2em;
44 .config-section label.column {
45 clear: left;
46 font-weight: bold;
47 width: 13em;
48 float: left;
49 text-align: right;
50 padding-right: 1em;
51 padding-top: .2em;
54 .config-input {
55 clear: left;
56 zoom: 100%; /* IE hack */
59 .config-section .config-desc {
60 clear: left;
61 margin: 0 0 2em 18em;
62 padding-top: 1em;
63 font-size: 85%;
66 .iput-text, .iput-password {
67 width: 14em;
68 margin-right: 1em;
71 .error {
72 color: red;
73 background-color: #fff;
74 font-weight: bold;
75 left: 1em;
76 font-size: 100%;
79 .error-top {
80 color: red;
81 background-color: #FFF0F0;
82 border: 2px solid red;
83 font-size: 130%;
84 font-weight: bold;
85 padding: 1em 1.5em;
86 margin: 2em 0 1em;
89 ul.plain {
90 list-style-type: none;
91 list-style-image: none;
92 float: left;
93 margin: 0;
94 padding: 0;
97 .btn-install {
98 font-weight: bold;
99 font-size: 110%;
100 padding: .2em .3em;
103 .license {
104 font-size: 85%;
105 padding-top: 3em;
108 </style>
109 </head>
111 <body>
112 <div id="globalWrapper">
113 <div id="column-content">
114 <div id="content">
115 <div id="bodyContent">
118 <?php
120 # Relative includes seem to break if a parent directory is not readable;
121 # this is common for public_html subdirs under user home directories.
123 # As a dirty hack, we'll try to set up the include path first.
125 $IP = dirname( dirname( __FILE__ ) );
126 $sep = PATH_SEPARATOR;
127 if( !ini_set( "include_path", ".$sep$IP$sep$IP/includes$sep$IP/languages" ) ) {
128 set_include_path( ".$sep$IP$sep$IP/includes$sep$IP/languages" );
132 define( "MEDIAWIKI", true );
133 define( "MEDIAWIKI_INSTALL", true );
134 require_once( "includes/Defines.php" );
135 require_once( "includes/DefaultSettings.php" );
136 require_once( "includes/MagicWord.php" );
137 require_once( "includes/Namespace.php" );
140 <h1>MediaWiki <?php print $wgVersion ?> installation</h1>
142 <?php
144 /* Check for existing configurations and bug out! */
146 if( file_exists( "../LocalSettings.php" ) ) {
147 dieout( " <p><strong>Setup has completed, <a href='../index.php'>your wiki</a> is configured.</strong></p>
149 <p>Please delete the /config directory for extra security.</p></div></div></div></div>" );
152 if( file_exists( "./LocalSettings.php" ) ) {
153 writeSuccessMessage();
155 dieout( '' );
158 if( !is_writable( "." ) ) {
159 dieout( "<h2>Can't write config file, aborting</h2>
161 <p>In order to configure the wiki you have to make the <tt>config</tt> subdirectory
162 writable by the web server. Once configuration is done you'll move the created
163 <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can
164 then remove the <tt>config</tt> subdirectory entirely.</p>
166 <p>To make the directory writable on a Unix/Linux system:</p>
168 <pre>
169 cd <i>/path/to/wiki</i>
170 chmod a+w config
171 </pre>" );
175 require_once( "install-utils.inc" );
176 require_once( "maintenance/updaters.inc" );
178 class ConfigData {
179 function getEncoded( $data ) {
180 # removing latin1 support, no need...
181 return $data;
183 function getSitename() { return $this->getEncoded( $this->Sitename ); }
184 function getSysopName() { return $this->getEncoded( $this->SysopName ); }
185 function getSysopPass() { return $this->getEncoded( $this->SysopPass ); }
190 <h2>Checking environment...</h2>
191 <p><em>Please include all of the lines below when reporting installation problems.</em></p>
192 <ul class="env-check">
193 <?php
194 $endl = "
196 $wgNoOutputBuffer = true;
197 $conf = new ConfigData;
199 install_version_checks();
201 print "<li>PHP " . phpversion() . " installed</li>\n";
203 if( ini_get( "register_globals" ) ) {
205 <li>
206 <div style="font-size:110%">
207 <strong class="error">Warning:</strong>
208 <strong>PHP's <tt><a href="http://php.net/register_globals">register_globals</a></tt> option is enabled. Disable it if you can.</strong>
209 </div>
210 MediaWiki will work, but your server is more exposed to PHP-based security vulnerabilities.
211 </li>
212 <?php
215 $fatal = false;
217 if( ini_get( "magic_quotes_runtime" ) ) {
218 $fatal = true;
219 ?><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>
220 This option corrupts data input unpredictably; you cannot install or use
221 MediaWiki unless this option is disabled.
222 <?php
225 if( ini_get( "magic_quotes_sybase" ) ) {
226 $fatal = true;
227 ?><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>
228 This option corrupts data input unpredictably; you cannot install or use
229 MediaWiki unless this option is disabled.
230 <?php
233 if( ini_get( "mbstring.func_overload" ) ) {
234 $fatal = true;
235 ?><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>
236 This option causes errors and may corrupt data unpredictably;
237 you cannot install or use MediaWiki unless this option is disabled.
238 <?php
241 if( $fatal ) {
242 dieout( "</ul><p>Cannot install Mediawiki.</p>" );
245 if( ini_get( "safe_mode" ) ) {
246 $conf->safeMode = true;
248 <li><b class='error'>Warning:</b> <strong>PHP's
249 <a href='http://www.php.net/features.safe-mode'>safe mode</a> is active.</strong>
250 You may have problems caused by this, particularly if using image uploads.
251 </li>
252 <?php
253 } else {
254 $conf->safeMode = false;
258 $sapi = php_sapi_name();
259 $conf->prettyURLs = true;
260 print "<li>PHP server API is $sapi; ";
261 switch( $sapi ) {
262 case "apache":
263 case "apache2handler":
264 print "ok, using pretty URLs (<tt>index.php/Page_Title</tt>)";
265 break;
266 default:
267 print "unknown; ";
268 case "cgi":
269 case "cgi-fcgi":
270 case "apache2filter":
271 case "isapi":
272 print "using ugly URLs (<tt>index.php?title=Page_Title</tt>)";
273 $conf->prettyURLs = false;
274 break;
276 print "</li>\n";
278 $conf->xml = function_exists( "utf8_encode" );
279 if( $conf->xml ) {
280 print "<li>Have XML / Latin1-UTF-8 conversion support.</li>\n";
281 } else {
282 dieout( "PHP's XML module is missing; the wiki requires functions in
283 this module and won't work in this configuration.
284 If you're running Mandrake, install the php-xml package." );
287 $memlimit = ini_get( "memory_limit" );
288 $conf->raiseMemory = false;
289 if( empty( $memlimit ) || $memlimit == -1 ) {
290 print "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n";
291 } else {
292 print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars( $memlimit ) . ". <strong>If this is too low, installation may fail!</strong> ";
293 $n = intval( $memlimit );
294 if( preg_match( '/^([0-9]+)[Mm]$/', trim( $memlimit ), $m ) ) {
295 $n = intval( $m[1] * (1024*1024) );
297 if( $n < 20*1024*1024 ) {
298 print "Attempting to raise limit to 20M... ";
299 if( false === ini_set( "memory_limit", "20M" ) ) {
300 print "failed.";
301 } else {
302 $conf->raiseMemory = true;
303 print "ok.";
306 print "</li>\n";
309 $conf->zlib = function_exists( "gzencode" );
310 if( $conf->zlib ) {
311 print "<li>Have zlib support; enabling output compression.</li>\n";
312 } else {
313 print "<li>No zlib support.</li>\n";
316 $conf->turck = function_exists( 'mmcache_get' );
317 if ( $conf->turck ) {
318 print "<li><a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> installed</li>\n";
320 $conf->eaccel = function_exists( 'eaccelerator_get' );
321 if ( $conf->eaccel ) {
322 $conf->turck = 'eaccelerator';
323 print "<li><a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> installed</li>\n";
325 if (!$conf->turck && !$conf->eaccel) {
326 print "<li>Neither <a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> nor <a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> are installed, " .
327 "can't use object caching functions</li>\n";
330 $conf->diff3 = false;
331 $diff3locations = array("/usr/bin", "/opt/csw/bin", "/usr/gnu/bin", "/usr/sfw/bin") + explode($sep, getenv("PATH"));
332 $diff3names = array("gdiff3", "diff3", "diff3.exe");
334 $diff3versioninfo = array('$1 --version 2>&1', 'diff3 (GNU diffutils)');
335 foreach ($diff3locations as $loc) {
336 $exe = locate_executable($loc, $diff3names, $diff3versioninfo);
337 if ($exe !== false) {
338 $conf->diff3 = $exe;
339 break;
343 if ($conf->diff3)
344 print "<li>Found GNU diff3: <tt>$conf->diff3</tt>.</li>";
345 else
346 print "<li>GNU diff3 not found.</li>";
348 $conf->ImageMagick = false;
349 $imcheck = array( "/usr/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" );
350 foreach( $imcheck as $dir ) {
351 $im = "$dir/convert";
352 if( file_exists( $im ) ) {
353 print "<li>Found ImageMagick: <tt>$im</tt>; image thumbnailing will be enabled if you enable uploads.</li>\n";
354 $conf->ImageMagick = $im;
355 break;
359 $conf->HaveGD = function_exists( "imagejpeg" );
360 if( $conf->HaveGD ) {
361 print "<li>Found GD graphics library built-in";
362 if( !$conf->ImageMagick ) {
363 print ", image thumbnailing will be enabled if you enable uploads";
365 print ".</li>\n";
366 } else {
367 if( !$conf->ImageMagick ) {
368 print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n";
372 $conf->UseImageResize = $conf->HaveGD || $conf->ImageMagick;
374 # $conf->IP = "/Users/brion/Sites/inplace";
375 $conf->IP = dirname( dirname( __FILE__ ) );
376 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP ) . "</tt></li>\n";
378 # $conf->ScriptPath = "/~brion/inplace";
379 $conf->ScriptPath = preg_replace( '{^(.*)/config.*$}', '$1', $_SERVER["PHP_SELF"] ); # was SCRIPT_NAME
380 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath ) . "</tt></li>\n";
382 print "<li style='font-weight:bold;color:green;font-size:110%'>Environment checked. You can install MediaWiki.</li>\n";
383 $conf->posted = ($_SERVER["REQUEST_METHOD"] == "POST");
385 $conf->Sitename = ucfirst( importPost( "Sitename", "" ) );
386 $defaultEmail = empty( $_SERVER["SERVER_ADMIN"] )
387 ? 'root@localhost'
388 : $_SERVER["SERVER_ADMIN"];
389 $conf->EmergencyContact = importPost( "EmergencyContact", $defaultEmail );
390 $conf->DBtype = importPost( "DBtype", "mysql" );
391 $conf->DBserver = importPost( "DBserver", "localhost" );
392 $conf->DBname = importPost( "DBname", "wikidb" );
393 $conf->DBuser = importPost( "DBuser", "wikiuser" );
394 $conf->DBpassword = importPost( "DBpassword" );
395 $conf->DBpassword2 = importPost( "DBpassword2" );
396 $conf->DBprefix = importPost( "DBprefix" );
397 $conf->DBmysql5 = (importPost( "DBmysql5" ) == "true") ? "true" : "false";
398 $conf->RootUser = importPost( "RootUser", "root" );
399 $conf->RootPW = importPost( "RootPW", "-" );
400 $conf->LanguageCode = importPost( "LanguageCode", "en" );
401 $conf->SysopName = importPost( "SysopName", "WikiSysop" );
402 $conf->SysopPass = importPost( "SysopPass" );
403 $conf->SysopPass2 = importPost( "SysopPass2" );
405 /* Check for validity */
406 $errs = array();
408 if( $conf->Sitename == "" || $conf->Sitename == "MediaWiki" || $conf->Sitename == "Mediawiki" ) {
409 $errs["Sitename"] = "Must not be blank or \"MediaWiki\"";
411 if( $conf->DBuser == "" ) {
412 $errs["DBuser"] = "Must not be blank";
414 if( $conf->DBpassword == "" ) {
415 $errs["DBpassword"] = "Must not be blank";
417 if( $conf->DBpassword != $conf->DBpassword2 ) {
418 $errs["DBpassword2"] = "Passwords don't match!";
420 if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix ) ) {
421 $errs["DBprefix"] = "Invalid table prefix";
424 if( $conf->SysopPass == "" ) {
425 $errs["SysopPass"] = "Must not be blank";
427 if( $conf->SysopPass != $conf->SysopPass2 ) {
428 $errs["SysopPass2"] = "Passwords don't match!";
431 $conf->License = importRequest( "License", "none" );
432 if( $conf->License == "gfdl" ) {
433 $conf->RightsUrl = "http://www.gnu.org/copyleft/fdl.html";
434 $conf->RightsText = "GNU Free Documentation License 1.2";
435 $conf->RightsCode = "gfdl";
436 $conf->RightsIcon = '${wgStylePath}/common/images/gnu-fdl.png';
437 } elseif( $conf->License == "none" ) {
438 $conf->RightsUrl = $conf->RightsText = $conf->RightsCode = $conf->RightsIcon = "";
439 } else {
440 $conf->RightsUrl = importRequest( "RightsUrl", "" );
441 $conf->RightsText = importRequest( "RightsText", "" );
442 $conf->RightsCode = importRequest( "RightsCode", "" );
443 $conf->RightsIcon = importRequest( "RightsIcon", "" );
446 $conf->Shm = importRequest( "Shm", "none" );
447 $conf->MCServers = importRequest( "MCServers" );
449 /* Test memcached servers */
451 if ( $conf->Shm == 'memcached' && $conf->MCServers ) {
452 $conf->MCServerArray = array_map( 'trim', explode( ',', $conf->MCServers ) );
453 foreach ( $conf->MCServerArray as $server ) {
454 $error = testMemcachedServer( $server );
455 if ( $error ) {
456 $errs["MCServers"] = $error;
457 break;
460 } else if ( $conf->Shm == 'memcached' ) {
461 $errs["MCServers"] = "Please specify at least one server if you wish to use memcached";
464 /* default values for installation */
465 $conf->Email =importRequest("Email", "email_enabled");
466 $conf->Emailuser=importRequest("Emailuser", "emailuser_enabled");
467 $conf->Enotif =importRequest("Enotif", "enotif_allpages");
468 $conf->Eauthent =importRequest("Eauthent", "eauthent_enabled");
470 if( $conf->posted && ( 0 == count( $errs ) ) ) {
471 do { /* So we can 'continue' to end prematurely */
472 $conf->Root = ($conf->RootPW != "");
474 /* Load up the settings and get installin' */
475 $local = writeLocalSettings( $conf );
476 $wgCommandLineMode = false;
477 chdir( ".." );
478 eval($local);
479 if (!in_array($conf->DBtype, array("mysql", "oracle"))) {
480 $errs["DBtype"] = "Unknown database type.";
481 continue;
483 print "<li>Database type: {$conf->DBtype}</li>\n";
484 $dbclass = 'Database'.ucfirst($conf->DBtype);
485 require_once("$dbclass.php");
486 $wgDBtype = $conf->DBtype;
487 $wgDBadminuser = "root";
488 $wgDBadminpassword = $conf->RootPW;
489 $wgDBprefix = $conf->DBprefix;
490 $wgCommandLineMode = true;
491 $wgUseDatabaseMessages = false; /* FIXME: For database failure */
492 require_once( "includes/Setup.php" );
493 chdir( "config" );
495 require_once( "maintenance/InitialiseMessages.inc" );
497 $wgTitle = Title::newFromText( "Installation script" );
498 $mysqlOldClient = version_compare( mysql_get_client_info(), "4.1.0", "lt" );
499 if( $mysqlOldClient ) {
500 print "<li><b>PHP is linked with old MySQL client libraries. If you are
501 using a MySQL 4.1 server and have problems connecting to the database,
502 see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
503 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b></li>\n";
505 $dbc = new $dbclass;
507 if( $conf->DBtype == 'mysql' ) {
508 $ok = true; # Let's be optimistic
510 # Decide if we're going to use the superuser or the regular database user
511 if( $conf->RootPW == '-' ) {
512 # Regular user
513 $conf->Root = false;
514 $db_user = $wgDBuser;
515 $db_pass = $wgDBpassword;
516 } else {
517 # Superuser
518 $conf->Root = true;
519 $db_user = $conf->RootUser;
520 $db_pass = $conf->RootPW;
523 # Attempt to connect
524 echo( "<li>Attempting to connect to database server as $db_user..." );
525 $wgDatabase = Database::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 );
527 # Check the connection and respond to errors
528 if( $wgDatabase->isOpen() ) {
529 # Seems OK
530 $ok = true;
531 $wgDBadminuser = $db_user;
532 $wgDBadminpassword = $wgDBpassword;
533 echo( "success.</li>\n" );
534 $wgDatabase->ignoreErrors( true );
535 $myver = mysql_get_server_info( $wgDatabase->mConn );
536 } else {
537 # There were errors, report them and back out
538 $ok = false;
539 $errno = mysql_errno();
540 $errtx = htmlspecialchars( mysql_error() );
541 switch( $errno ) {
542 case 1045:
543 case 2000:
544 echo( "failed due to authentication errors. Check passwords.</li>" );
545 if( $conf->Root ) {
546 # The superuser details are wrong
547 $errs["RootUser"] = "Check username";
548 $errs["RootPW"] = "and password";
549 } else {
550 # The regular user details are wrong
551 $errs["DBuser"] = "Check username";
552 $errs["DBpassword"] = "and password";
554 break;
555 case 2002:
556 case 2003:
557 default:
558 # General connection problem
559 echo( "failed with error [$errno] $errtx.</li>\n" );
560 $errs["DBserver"] = "Connection failed";
561 break;
562 } # switch
563 } #conn. att.
565 if( !$ok ) { continue; }
567 } else /* not mysql */ {
568 print "<li>Connecting to SQL server...";
569 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1);
570 if (!$wgDatabase->isOpen()) {
571 print " error: " . $wgDatabase->lastError() . "</li>\n";
572 } else {
573 $wgDatabase->ignoreErrors(true);
574 $myver = get_db_version();
578 if ( !$wgDatabase->isOpen() ) {
579 $errs["DBserver"] = "Couldn't connect to database";
580 continue;
583 print "<li>Connected to $myver";
584 if( version_compare( $myver, "4.0.0" ) < 0 ) {
585 die( " -- mysql 4.0 or later required. Aborting." );
587 $mysqlNewAuth = version_compare( $myver, "4.1.0", "ge" );
588 if( $mysqlNewAuth && $mysqlOldClient ) {
589 print "; <b class='error'>You are using MySQL 4.1 server, but PHP is linked
590 to old client libraries; if you have trouble with authentication, see
591 <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
592 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>";
594 if( $wgDBmysql5 ) {
595 if( $mysqlNewAuth ) {
596 print "; enabling MySQL 4.1/5.0 charset mode";
597 } else {
598 print "; <b class='error'>MySQL 4.1/5.0 charset mode enabled,
599 but older version detected; will likely fail.</b>";
602 print "</li>\n";
604 if ($conf->DBtype == 'mysql') {
605 @$sel = mysql_select_db( $wgDBname, $wgDatabase->mConn );
606 if( $sel ) {
607 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
608 } else {
609 $err = mysql_errno();
610 if ( $err != 1049 ) {
611 print "<ul><li>Error selecting database $wgDBname: $err " .
612 htmlspecialchars( mysql_error() ) . "</li></ul>";
613 continue;
615 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
616 if( !$res ) {
617 print "<li>Couldn't create database <tt>" .
618 htmlspecialchars( $wgDBname ) .
619 "</tt>; try with root access or check your username/pass.</li>\n";
620 $errs["RootPW"] = "&lt;- Enter";
621 continue;
623 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
625 $wgDatabase->selectDB( $wgDBname );
629 if( $wgDatabase->tableExists( "cur" ) || $wgDatabase->tableExists( "revision" ) ) {
630 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n";
632 # Create user if required
633 if ( $conf->Root ) {
634 $conn = Database::newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
635 if ( $conn->isOpen() ) {
636 print "<li>DB user account ok</li>\n";
637 $conn->close();
638 } else {
639 print "<li>Granting user permissions...";
640 if( $mysqlOldClient && $mysqlNewAuth ) {
641 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>";
643 print "</li>\n";
644 dbsource( "../maintenance/users.sql", $wgDatabase );
647 print "<pre>\n";
648 chdir( ".." );
649 flush();
650 do_all_updates();
651 chdir( "config" );
653 print "</pre>\n";
654 print "<li>Finished update checks.</li>\n";
655 } else {
656 # FIXME: Check for errors
657 print "<li>Creating tables...";
658 if ($conf->DBtype == 'mysql') {
659 if( $wgDBmysql5 ) {
660 print " using MySQL 5 table defs...";
661 dbsource( "../maintenance/mysql5/tables.sql", $wgDatabase );
662 } else {
663 print " using MySQL 4 table defs...";
664 dbsource( "../maintenance/tables.sql", $wgDatabase );
666 dbsource( "../maintenance/interwiki.sql", $wgDatabase );
667 } else {
668 dbsource( "../maintenance/oracle/tables.sql", $wgDatabase );
669 dbsource( "../maintenance/oracle/interwiki.sql", $wgDatabase );
672 print " done.</li>\n";
674 print "<li>Initializing data...";
675 $wgDatabase->insert( 'site_stats',
676 array( 'ss_row_id' => 1,
677 'ss_total_views' => 0,
678 'ss_total_edits' => 0,
679 'ss_good_articles' => 0 ) );
681 # Set up the "regular user" account *if we can, and if we need to*
682 if( $conf->Root ) {
683 # See if we need to
684 $wgDatabase2 = Database::newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, '', 1 );
685 if( $wgDatabase2->isOpen() ) {
686 # Nope, just close the test connection and continue
687 $wgDatabase2->close();
688 echo( "<li>User $wgDBuser exists. Skipping grants.</li>" );
689 } else {
690 # Yes, so run the grants
691 echo( "<li>Granting user permissions to $wgDBuser on $wgDBname..." );
692 dbsource( "../maintenance/users.sql", $wgDatabase );
693 echo( "success.</li>" );
697 if( $conf->SysopName ) {
698 $u = User::newFromName( $conf->getSysopName() );
699 if ( 0 == $u->idForName() ) {
700 $u->addToDatabase();
701 $u->setPassword( $conf->getSysopPass() );
702 $u->saveSettings();
704 $u->addGroup( "sysop" );
705 $u->addGroup( "bureaucrat" );
707 print "<li>Created sysop account <tt>" .
708 htmlspecialchars( $conf->SysopName ) . "</tt>.</li>\n";
709 } else {
710 print "<li>Could not create user - already exists!</li>\n";
712 } else {
713 print "<li>Skipped sysop account creation, no name given.</li>\n";
716 $titleobj = Title::newFromText( wfMsgNoDB( "mainpage" ) );
717 $article = new Article( $titleobj );
718 $newid = $article->insertOn( $wgDatabase );
719 $revision = new Revision( array(
720 'page' => $newid,
721 'text' => wfMsg( 'mainpagetext' ) . "\n\n" . wfMsg( 'mainpagedocfooter' ),
722 'comment' => '',
723 'user' => 0,
724 'user_text' => 'MediaWiki default',
725 ) );
726 $revid = $revision->insertOn( $wgDatabase );
727 $article->updateRevisionOn( $wgDatabase, $revision );
729 print "<li><pre>";
730 initialiseMessages();
731 print "</pre></li>\n";
734 /* Write out the config file now that all is well */
735 print "<p>Creating LocalSettings.php...</p>\n\n";
736 $localSettings = "<" . "?php$endl$local$endl?" . ">";
737 // Fix up a common line-ending problem (due to CVS on Windows)
738 $localSettings = str_replace( "\r\n", "\n", $localSettings );
740 if( version_compare( phpversion(), "4.3.2" ) >= 0 ) {
741 $xt = "xt"; # Refuse to overwrite an existing file
742 } else {
743 $xt = "wt"; # 'x' is not available prior to PHP 4.3.2. We did check above, but race conditions blah blah
745 $f = fopen( "LocalSettings.php", $xt );
747 if( $f == false ) {
748 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" .
749 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
750 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
752 if(fwrite( $f, $localSettings ) ) {
753 fclose( $f );
754 writeSuccessMessage();
755 } else {
756 fclose( $f );
757 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");
761 } while( false );
764 </ul>
767 <?php
769 if( count( $errs ) ) {
770 /* Display options form */
772 if( $conf->posted ) {
773 echo "<p class='error-top'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
777 <form action="index.php" name="config" method="post">
780 <h2>Site config</h2>
782 <div class="config-section">
783 <div class="config-input">
784 <?php
785 aField( $conf, "Sitename", "Wiki name:" );
787 </div>
788 <p class="config-desc">
789 Preferably a short word without punctuation, i.e. "Wikipedia".<br>
790 Will appear as the namespace name for "meta" pages, and throughout the interface.
791 </p>
793 <div class="config-input">
794 <?php
795 aField( $conf, "EmergencyContact", "Contact e-mail:" );
797 </div>
798 <p class="config-desc">
799 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.
800 </p>
802 <div class="config-input">
803 <label class='column' for="LanguageCode">Language:</label>
804 <select id="LanguageCode" name="LanguageCode">
806 <?php
807 $list = getLanguageList();
808 foreach( $list as $code => $name ) {
809 $sel = ($code == $conf->LanguageCode) ? 'selected="selected"' : '';
810 echo "\t\t<option value=\"$code\" $sel>$name</option>\n";
813 </select>
814 </div>
815 <p class="config-desc">
816 Select the language for your wiki's interface. Some localizations aren't fully complete. Unicode (UTF-8) used for all localizations.
817 </p>
819 <div class="config-input">
820 <label class='column'>Copyright/license:</label>
822 <ul class="plain">
823 <li><?php aField( $conf, "License", "No license metadata", "radio", "none" ); ?></li>
824 <li><?php aField( $conf, "License", "GNU Free Documentation License 1.2 (Wikipedia-compatible)", "radio", "gfdl" ); ?></li>
825 <li><?php
826 aField( $conf, "License", "A Creative Commons license - ", "radio", "cc" );
827 $partner = "MediaWiki";
828 $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/index.php?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
829 $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" );
830 $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" );
831 print "<a href=\"$ccApp\" target='_blank'>choose</a>";
833 <?php if( $conf->License == "cc" ) { ?>
834 <ul>
835 <li><?php aField( $conf, "RightsIcon", "<img src=\"" . htmlspecialchars( $conf->RightsIcon ) . "\" alt='icon' />", "hidden" ); ?></li>
836 <li><?php aField( $conf, "RightsText", htmlspecialchars( $conf->RightsText ), "hidden" ); ?></li>
837 <li><?php aField( $conf, "RightsCode", "code: " . htmlspecialchars( $conf->RightsCode ), "hidden" ); ?></li>
838 <li><?php aField( $conf, "RightsUrl", "<a href=\"" . htmlspecialchars( $conf->RightsUrl ) . "\">" . htmlspecialchars( $conf->RightsUrl ) . "</a>", "hidden" ); ?></li>
839 </ul>
840 <?php } ?>
841 </li>
842 </ul>
843 </div>
844 <p class="config-desc">
845 A notice, icon, and machine-readable copyright metadata will be displayed for the license you pick.
846 </p>
849 <div class="config-input">
850 <?php aField( $conf, "SysopName", "Admin username:" ) ?>
851 </div>
852 <div class="config-input">
853 <?php aField( $conf, "SysopPass", "Password:", "password" ) ?>
854 </div>
855 <div class="config-input">
856 <?php aField( $conf, "SysopPass2", "Password confirm:", "password" ) ?>
857 </div>
858 <p class="config-desc">
859 An admin can lock/delete pages, block users from editing, and other maintenance tasks.<br>
860 A new account will be added only when creating a new wiki database.
861 </p>
863 <div class="config-input">
864 <label class='column'>Shared memory caching:</label>
866 <ul class="plain">
867 <li><?php aField( $conf, "Shm", "No caching", "radio", "none" ); ?></li>
868 <?php
869 if ( $conf->turck ) {
870 echo "<li>";
871 aField( $conf, "Shm", "Turck MMCache", "radio", "turck" );
872 echo "</li>";
875 <?php
876 if ( $conf->eaccel ) {
877 echo "<li>";
878 aField( $conf, "Shm", "eAccelerator", "radio", "eaccel" );
879 echo "</li>";
882 <li><?php aField( $conf, "Shm", "Memcached", "radio", "memcached" ); ?></li>
883 </ul>
884 <div style="clear:left"><?php aField( $conf, "MCServers", "Memcached servers:", "text" ) ?></div>
885 </div>
886 <p class="config-desc">
887 Using a shared memory system such as Turck MMCache, eAccelerator, or Memcached will speed
888 up MediaWiki significantly. Memcached is the best solution but needs to be
889 installed. Specify the server addresses and ports in a comma-separted list. Only
890 use Turck shared memory if the wiki will be running on a single Apache server.
891 </p>
892 </div>
894 <h2>E-mail, e-mail notification and authentication setup</h2>
896 <div class="config-section">
897 <div class="config-input">
898 <label class='column'>E-mail (general):</label>
899 <ul class="plain">
900 <li><?php aField( $conf, "Email", "Enabled", "radio", "email_enabled" ); ?></li>
901 <li><?php aField( $conf, "Email", "Disabled", "radio", "email_disabled" ); ?></li>
902 </ul>
903 </div>
904 <p class="config-desc">
905 Use this to disable all e-mail functions (send a password reminder, user-to-user e-mail and e-mail notification),
906 if sending e-mails on your server doesn't work.
907 </p>
908 <div class="config-input">
909 <label class='column'>User-to-user e-mail:</label>
910 <ul class="plain">
911 <li><?php aField( $conf, "Emailuser", "Enabled", "radio", "emailuser_enabled" ); ?></li>
912 <li><?php aField( $conf, "Emailuser", "Disabled", "radio", "emailuser_disabled" ); ?></li>
913 </ul>
914 </div>
915 <p class="config-desc">
916 Use this to disable only the user-to-user e-mail function (EmailUser).
917 </p>
918 <div class="config-input">
919 <label class='column'>E-mail notification:</label>
920 <ul class="plain">
921 <li><?php aField( $conf, "Enotif", "Disabled", "radio", "enotif_disabled" ); ?></li>
922 <li><?php aField( $conf, "Enotif", "Enabled for user_talk changes only", "radio", "enotif_usertalk" ); ?></li>
923 <li><?php aField( $conf, "Enotif", "Enabled for user_talk and watch list changes (not recommended for large wikis)", "radio", "enotif_allpages" ); ?></li>
924 </ul>
925 </div>
926 <div class="config-desc">
928 E-mail notification sends a notification e-mail to a user, when the user_talk page is changed
929 and/or when watch-listed pages are changed, depending on the above settings.
930 When testing this feature, be reminded, that obviously an e-mail address must be present in your preferences
931 and that your own changes never trigger notifications to be sent to yourself.</p>
933 <p>Users get corresponding options to select or deselect in their users' preferences.
934 The user options are not shown on the preference page, if e-mail notification is disabled.</p>
936 <p>There are additional options for fine tuning in /includes/DefaultSettings.php .</p>
937 </div>
939 <div class="config-input">
940 <label class='column'>E-mail authentication:</label>
941 <ul class="plain">
942 <li><?php aField( $conf, "Eauthent", "Disabled", "radio", "eauthent_disabled" ); ?></li>
943 <li><?php aField( $conf, "Eauthent", "Enabled", "radio", "eauthent_enabled" ); ?></li>
944 </ul>
945 </div>
946 <div class="config-desc">
947 <p>E-mail address authentication uses a scheme to authenticate e-mail addresses of the users. The user who initially enters or changes his/her stored e-mail address
948 gets a link with a token mailed to that address. The stored e-mail address is authenticated at the moment the user comes back to the wiki via the link.</p>
950 <p>The e-mail address stays authenticated as long as the user does not change it; the time of authentication is indicated
951 on the user preference page.</p>
953 <p>If the option is enabled, only authenticated e-mail addresses can receive EmailUser mails and/or
954 e-mail notification mails.</p>
955 </div>
957 </div>
959 <h2>Database config</h2>
961 <div class="config-section">
962 <div class="config-input">
963 <label class='column'>Database type:</label>
964 <ul class='plain'>
965 <li><?php aField( $conf, "DBtype", "MySQL", "radio", "mysql"); ?></li>
966 <li><?php aField( $conf, "DBtype", "Oracle", "radio", "oracle" ); ?></li>
967 </ul>
968 </div>
970 <div class="config-input" style="clear:left"><?php
971 aField( $conf, "DBserver", "SQL server host:" );
972 ?></div>
973 <p class="config-desc">
974 If your database server isn't on your web server, enter the name
975 or IP address here. MySQL only.
976 </p>
978 <div class="config-input"><?php
979 aField( $conf, "DBname", "Database name:" );
980 ?></div>
981 <div class="config-desc">
982 If using Oracle, set this to your connection identifier.
983 </div>
984 <div class="config-input"><?php
985 aField( $conf, "DBuser", "DB username:" );
986 ?></div>
987 <div class="config-input"><?php
988 aField( $conf, "DBpassword", "DB password:", "password" );
989 ?></div>
990 <div class="config-input"><?php
991 aField( $conf, "DBpassword2", "DB password confirm:", "password" );
992 ?></div>
993 <p class="config-desc">
994 If you only have a single user account and database available,
995 enter those here. If you have database root access (see below)
996 you can specify new accounts/databases to be created.
997 </p>
999 This account will not be created if it pre-exists. If this is the case, ensure that it
1000 has SELECT, INSERT, UPDATE and DELETE permissions on the MediaWiki database.
1001 </p>
1003 <div class="config-input"><?php
1004 aField( $conf, "DBprefix", "Database table prefix:" );
1005 ?></div>
1006 <div class="config-desc">
1007 <p>If you need to share one database between multiple wikis, or
1008 MediaWiki and another web application, you may choose to
1009 add a prefix to all the table names to avoid conflicts.</p>
1011 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
1012 </div>
1014 <div class="config-input"><label class="column">Database charset</label>
1015 <div>Select one:</div>
1016 <ul class="plain">
1017 <li><?php aField( $conf, "DBmysql5", "Backwards-compatible UTF-8", "radio", "false" ); ?></li>
1018 <li><?php aField( $conf, "DBmysql5", "Experimental MySQL 4.1/5.0 UTF-8", "radio", "true" ); ?></li>
1019 </ul>
1020 </div>
1021 <p class="config-desc">
1022 <b>EXPERIMENTAL:</b> You can enable explicit Unicode charset support
1023 for MySQL 4.1 and 5.0 servers. This is not well tested and may
1024 cause things to break. <b>If upgrading an older installation, leave
1025 in backwards-compatible mode.</b>
1026 </p>
1028 <div class="config-input">
1029 <?php
1030 aField( $conf, "RootUser", "Superuser account:", "superuser" );
1032 </div>
1033 <div class="config-input">
1034 <?php
1035 aField( $conf, "RootPW", "Superuser password:", "password" );
1037 </div>
1039 <p class="config-desc">
1040 If the database user specified above does not exist, or does not have access to create
1041 the database (if needed) or tables within it, please provide details of a superuser account,
1042 such as <strong>root</strong>, which does. Leave the password set to <strong>-</strong> if this is not needed.
1043 </p>
1045 <div class="config-input" style="padding:2em 0 3em">
1046 <label class='column'>&nbsp;</label>
1047 <input type="submit" value="Install MediaWiki!" class="btn-install" />
1048 </div>
1050 </div>
1052 </form>
1054 <?php
1057 /* -------------------------------------------------------------------------------------- */
1058 function writeSuccessMessage() {
1059 if ( ini_get( 'safe_mode' ) && !ini_get( 'open_basedir' ) ) {
1060 echo <<<EOT
1061 <p>Installation successful!</p>
1062 <p>To complete the installation, please do the following:
1063 <ol>
1064 <li>Download config/LocalSettings.php with your FTP client or file manager</li>
1065 <li>Upload it to the parent directory</li>
1066 <li>Delete config/LocalSettings.php</li>
1067 <li>Start using <a href='../index.php'>your wiki</a>!
1068 </ol>
1069 <p>If you are in a shared hosting environment, do <strong>not</strong> just move LocalSettings.php
1070 remotely. LocalSettings.php is currently owned by the user your webserver is running under,
1071 which means that anyone on the same server can read your database password! Downloading
1072 it and uploading it again will hopefully change the ownership to a user ID specific to you.</p>
1073 EOT;
1074 } else {
1075 echo "<p>Installation successful! Move the config/LocalSettings.php file into the parent directory, then follow
1076 <a href='../index.php'>this link</a> to your wiki.</p>\n";
1081 function escapePhpString( $string ) {
1082 return strtr( $string,
1083 array(
1084 "\n" => "\\n",
1085 "\r" => "\\r",
1086 "\t" => "\\t",
1087 "\\" => "\\\\",
1088 "\$" => "\\\$",
1089 "\"" => "\\\""
1093 function writeLocalSettings( $conf ) {
1094 $conf->UseImageResize = $conf->UseImageResize ? 'true' : 'false';
1095 $conf->PasswordSender = $conf->EmergencyContact;
1096 $zlib = ($conf->zlib ? "" : "# ");
1097 $magic = ($conf->ImageMagick ? "" : "# ");
1098 $convert = ($conf->ImageMagick ? $conf->ImageMagick : "/usr/bin/convert" );
1099 $pretty = ($conf->prettyURLs ? "" : "# ");
1100 $ugly = ($conf->prettyURLs ? "# " : "");
1101 $rights = ($conf->RightsUrl) ? "" : "# ";
1102 $hashedUploads = $conf->safeMode ? '' : '# ';
1104 switch ( $conf->Shm ) {
1105 case 'memcached':
1106 $cacheType = 'CACHE_MEMCACHED';
1107 $mcservers = var_export( $conf->MCServerArray, true );
1108 break;
1109 case 'turck':
1110 case 'eaccel':
1111 $cacheType = 'CACHE_ACCEL';
1112 $mcservers = 'array()';
1113 break;
1114 default:
1115 $cacheType = 'CACHE_NONE';
1116 $mcservers = 'array()';
1119 if ( $conf->Email == 'email_enabled' ) {
1120 $enableemail = 'true';
1121 $enableuseremail = ( $conf->Emailuser == 'emailuser_enabled' ) ? 'true' : 'false' ;
1122 $eauthent = ( $conf->Eauthent == 'eauthent_enabled' ) ? 'true' : 'false' ;
1123 switch ( $conf->Enotif ) {
1124 case 'enotif_usertalk':
1125 $enotifusertalk = 'true';
1126 $enotifwatchlist = 'false';
1127 break;
1128 case 'enotif_allpages':
1129 $enotifusertalk = 'true';
1130 $enotifwatchlist = 'true';
1131 break;
1132 default:
1133 $enotifusertalk = 'false';
1134 $enotifwatchlist = 'false';
1136 } else {
1137 $enableuseremail = 'false';
1138 $enableemail = 'false';
1139 $eauthent = 'false';
1140 $enotifusertalk = 'false';
1141 $enotifwatchlist = 'false';
1144 $file = @fopen( "/dev/urandom", "r" );
1145 if ( $file ) {
1146 $secretKey = bin2hex( fread( $file, 32 ) );
1147 fclose( $file );
1148 } else {
1149 $secretKey = "";
1150 for ( $i=0; $i<8; $i++ ) {
1151 $secretKey .= dechex(mt_rand(0, 0x7fffffff));
1153 print "<li>Warning: \$wgSecretKey key is insecure, generated with mt_rand(). Consider changing it manually.</li>\n";
1156 # Add slashes to strings for double quoting
1157 $slconf = array_map( "escapePhpString", get_object_vars( $conf ) );
1158 if( $conf->License == 'gfdl' ) {
1159 # Needs literal string interpolation for the current style path
1160 $slconf['RightsIcon'] = $conf->RightsIcon;
1163 $sep = PATH_SEPARATOR;
1164 $localsettings = "
1165 # This file was automatically generated by the MediaWiki installer.
1166 # If you make manual changes, please keep track in case you need to
1167 # recreate them later.
1169 # See includes/DefaultSettings.php for all configurable settings
1170 # and their default values, but don't forget to make changes in _this_
1171 # file, not there.
1173 \$IP = \"{$slconf['IP']}\";
1174 if( !ini_set( \"include_path\", \".$sep\$IP$sep\$IP/includes$sep\$IP/languages\" ) ) {
1175 set_include_path( \".$sep\$IP$sep\$IP/includes$sep\$IP/languages\" );
1177 require_once( \"includes/DefaultSettings.php\" );
1179 # If PHP's memory limit is very low, some operations may fail.
1180 " . ($conf->raiseMemory ? '' : '# ' ) . "ini_set( 'memory_limit', '20M' );" . "
1182 if ( \$wgCommandLineMode ) {
1183 if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
1184 die( \"This script must be run from the command line\\n\" );
1186 } elseif ( empty( \$wgNoOutputBuffer ) ) {
1187 ## Compress output if the browser supports it
1188 {$zlib}if( !ini_get( 'zlib.output_compression' ) ) @ob_start( 'ob_gzhandler' );
1191 \$wgSitename = \"{$slconf['Sitename']}\";
1193 \$wgScriptPath = \"{$slconf['ScriptPath']}\";
1194 \$wgScript = \"\$wgScriptPath/index.php\";
1195 \$wgRedirectScript = \"\$wgScriptPath/redirect.php\";
1197 ## If using PHP as a CGI module, use the ugly URLs
1198 {$pretty}\$wgArticlePath = \"\$wgScript/\$1\";
1199 {$ugly}\$wgArticlePath = \"\$wgScript?title=\$1\";
1201 \$wgStylePath = \"\$wgScriptPath/skins\";
1202 \$wgStyleDirectory = \"\$IP/skins\";
1203 \$wgLogo = \"\$wgStylePath/common/images/wiki.png\";
1205 \$wgUploadPath = \"\$wgScriptPath/images\";
1206 \$wgUploadDirectory = \"\$IP/images\";
1208 \$wgEnableEmail = $enableemail;
1209 \$wgEnableUserEmail = $enableuseremail;
1211 \$wgEmergencyContact = \"{$slconf['EmergencyContact']}\";
1212 \$wgPasswordSender = \"{$slconf['PasswordSender']}\";
1214 ## For a detailed description of the following switches see
1215 ## http://meta.wikimedia.org/Enotif and http://meta.wikimedia.org/Eauthent
1216 ## There are many more options for fine tuning available see
1217 ## /includes/DefaultSettings.php
1218 ## UPO means: this is also a user preference option
1219 \$wgEnotifUserTalk = $enotifusertalk; # UPO
1220 \$wgEnotifWatchlist = $enotifwatchlist; # UPO
1221 \$wgEmailAuthentication = $eauthent;
1223 \$wgDBserver = \"{$slconf['DBserver']}\";
1224 \$wgDBname = \"{$slconf['DBname']}\";
1225 \$wgDBuser = \"{$slconf['DBuser']}\";
1226 \$wgDBpassword = \"{$slconf['DBpassword']}\";
1227 \$wgDBprefix = \"{$slconf['DBprefix']}\";
1228 \$wgDBtype = \"{$slconf['DBtype']}\";
1230 # Experimental charset support for MySQL 4.1/5.0.
1231 \$wgDBmysql5 = {$conf->DBmysql5};
1233 ## Shared memory settings
1234 \$wgMainCacheType = $cacheType;
1235 \$wgMemCachedServers = $mcservers;
1237 ## To enable image uploads, make sure the 'images' directory
1238 ## is writable, then uncomment this:
1239 # \$wgEnableUploads = true;
1240 \$wgUseImageResize = {$conf->UseImageResize};
1241 {$magic}\$wgUseImageMagick = true;
1242 {$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
1244 ## If you want to use image uploads under safe mode,
1245 ## create the directories images/archive, images/thumb and
1246 ## images/temp, and make them all writable. Then uncomment
1247 ## this, if it's not already uncommented:
1248 {$hashedUploads}\$wgHashedUploadDirectory = false;
1250 ## If you have the appropriate support software installed
1251 ## you can enable inline LaTeX equations:
1252 # \$wgUseTeX = true;
1253 \$wgMathPath = \"{\$wgUploadPath}/math\";
1254 \$wgMathDirectory = \"{\$wgUploadDirectory}/math\";
1255 \$wgTmpDirectory = \"{\$wgUploadDirectory}/tmp\";
1257 \$wgLocalInterwiki = \$wgSitename;
1259 \$wgLanguageCode = \"{$slconf['LanguageCode']}\";
1261 \$wgProxyKey = \"$secretKey\";
1263 ## Default skin: you can change the default skin. Use the internal symbolic
1264 ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook':
1265 # \$wgDefaultSkin = 'monobook';
1267 ## For attaching licensing metadata to pages, and displaying an
1268 ## appropriate copyright notice / icon. GNU Free Documentation
1269 ## License and Creative Commons licenses are supported so far.
1270 {$rights}\$wgEnableCreativeCommonsRdf = true;
1271 \$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright
1272 \$wgRightsUrl = \"{$slconf['RightsUrl']}\";
1273 \$wgRightsText = \"{$slconf['RightsText']}\";
1274 \$wgRightsIcon = \"{$slconf['RightsIcon']}\";
1275 # \$wgRightsCode = \"{$slconf['RightsCode']}\"; # Not yet used
1277 \$wgDiff3 = \"{$slconf['diff3']}\";
1279 // Keep things in Unix line endings internally;
1280 // the system will write out as local text type.
1281 return str_replace( "\r\n", "\n", $localsettings );
1284 function dieout( $text ) {
1285 die( $text . "\n\n</body>\n</html>" );
1288 function importVar( &$var, $name, $default = "" ) {
1289 if( isset( $var[$name] ) ) {
1290 $retval = $var[$name];
1291 if ( get_magic_quotes_gpc() ) {
1292 $retval = stripslashes( $retval );
1294 } else {
1295 $retval = $default;
1297 return $retval;
1300 function importPost( $name, $default = "" ) {
1301 return importVar( $_POST, $name, $default );
1304 function importRequest( $name, $default = "" ) {
1305 return importVar( $_REQUEST, $name, $default );
1308 $radioCount = 0;
1310 function aField( &$conf, $field, $text, $type = "text", $value = "" ) {
1311 global $radioCount;
1312 if( $type != "" ) {
1313 $xtype = "type=\"$type\"";
1314 } else {
1315 $xtype = "";
1318 if(!(isset($id)) or ($id == "") ) $id = $field;
1319 $nolabel = ($type == "radio") || ($type == "hidden");
1321 if ($type == 'radio')
1322 $id .= $radioCount++;
1324 if( $nolabel ) {
1325 echo "\t\t<label>";
1326 } else {
1327 echo "\t\t<label class='column' for=\"$id\">$text</label>\n";
1330 if( $type == "radio" && $value == $conf->$field ) {
1331 $checked = "checked='checked'";
1332 } else {
1333 $checked = "";
1335 echo "\t\t<input $xtype name=\"$field\" id=\"$id\" class=\"iput-$type\" $checked value=\"";
1336 if( $type == "radio" ) {
1337 echo htmlspecialchars( $value );
1338 } else {
1339 echo htmlspecialchars( $conf->$field );
1341 echo "\" />\n";
1342 if( $nolabel ) {
1343 echo " $text</label>\n";
1346 global $errs;
1347 if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n";
1350 function getLanguageList() {
1351 global $wgLanguageNames;
1352 if( !isset( $wgLanguageNames ) ) {
1353 $wgContLanguageCode = "xxx";
1354 function wfLocalUrl( $x ) { return $x; }
1355 function wfLocalUrlE( $x ) { return $x; }
1356 require_once( "languages/Names.php" );
1359 $codes = array();
1361 $d = opendir( "../languages" );
1362 while( false !== ($f = readdir( $d ) ) ) {
1363 $m = array();
1364 if( preg_match( '/Language([A-Z][a-z_]+)\.php$/', $f, $m ) ) {
1365 $code = str_replace( '_', '-', strtolower( $m[1] ) );
1366 if( isset( $wgLanguageNames[$code] ) ) {
1367 $name = $code . ' - ' . $wgLanguageNames[$code];
1368 } else {
1369 $name = $code;
1371 $codes[$code] = $name;
1374 closedir( $d );
1375 ksort( $codes );
1376 return $codes;
1379 #Check for location of an executable
1380 # @param string $loc single location to check
1381 # @param array $names filenames to check for.
1382 # @param mixed $versioninfo array of details to use when checking version, use false for no version checking
1383 function locate_executable($loc, $names, $versioninfo = false) {
1384 if (!is_array($names))
1385 $names = array($names);
1387 foreach ($names as $name) {
1388 $command = "$loc".DIRECTORY_SEPARATOR."$name";
1389 if (file_exists($command)) {
1390 if (!$versioninfo)
1391 return $command;
1393 $file = str_replace('$1', $command, $versioninfo[0]);
1394 if (strstr(`$file`, $versioninfo[1]) !== false)
1395 return $command;
1398 return false;
1401 function get_db_version() {
1402 global $wgDatabase, $conf;
1403 if ($conf->DBtype == 'mysql')
1404 return mysql_get_server_info( $wgDatabase->mConn );
1405 else if ($conf->DBtype == 'oracle')
1406 return oci_server_version($wgDatabase->mConn);
1409 # Test a memcached server
1410 function testMemcachedServer( $server ) {
1411 $hostport = explode(":", $server);
1412 $errstr = false;
1413 $fp = false;
1414 if ( !function_exists( 'fsockopen' ) ) {
1415 $errstr = "Can't connect to memcached, fsockopen() not present";
1417 if ( !$errstr && count( $hostport ) != 2 ) {
1418 $errstr = 'Please specify host and port';
1419 var_dump( $hostport );
1421 if ( !$errstr ) {
1422 list( $host, $port ) = $hostport;
1423 $errno = 0;
1424 $fsockerr = '';
1426 $fp = @fsockopen( $host, $port, $errno, $fsockerr, 1.0 );
1427 if ( $fp === false ) {
1428 $errstr = "Cannot connect to memcached on $host:$port : $fsockerr";
1431 if ( !$errstr ) {
1432 $command = "version\r\n";
1433 $bytes = fwrite( $fp, $command );
1434 if ( $bytes != strlen( $command ) ) {
1435 $errstr = "Cannot write to memcached socket on $host:$port";
1438 if ( !$errstr ) {
1439 $expected = "VERSION ";
1440 $response = fread( $fp, strlen( $expected ) );
1441 if ( $response != $expected ) {
1442 $errstr = "Didn't get correct memcached response from $host:$port";
1445 if ( $fp ) {
1446 fclose( $fp );
1448 if ( !$errstr ) {
1449 echo "<li>Connected to memcached on $host:$port successfully";
1451 return $errstr;
1455 <div class="license">
1456 <hr>
1457 <p>This program is free software; you can redistribute it and/or modify
1458 it under the terms of the GNU General Public License as published by
1459 the Free Software Foundation; either version 2 of the License, or
1460 (at your option) any later version.</p>
1462 <p>This program is distributed in the hope that it will be useful,
1463 but WITHOUT ANY WARRANTY; without even the implied warranty of
1464 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1465 GNU General Public License for more details.</p>
1467 <p>You should have received <a href="../COPYING">a copy of the GNU General Public License</a>
1468 along with this program; if not, write to the Free Software
1469 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1470 or <a href="http://www.gnu.org/copyleft/gpl.html">read it online</a></p>
1471 </div>
1473 </div></div></div>
1476 <div id="column-one">
1477 <div class="portlet" id="p-logo">
1478 <a style="background-image: url(../skins/common/images/mediawiki.png);"
1479 href="http://www.mediawiki.org/"
1480 title="Main Page"></a>
1481 </div>
1482 <script type="text/javascript"> if (window.isMSIE55) fixalpha(); </script>
1483 <div class='portlet'><div class='pBody'>
1484 <ul>
1485 <li><strong><a href="http://www.mediawiki.org/">MediaWiki home</a></strong></li>
1486 <li><a href="../README">Readme</a></li>
1487 <li><a href="../RELEASE-NOTES">Release notes</a></li>
1488 <li><a href="../docs/">Documentation</a></li>
1489 <li><a href="http://meta.wikipedia.org/wiki/MediaWiki_User's_Guide">User's Guide</a></li>
1490 <li><a href="http://meta.wikimedia.org/wiki/MediaWiki_FAQ">FAQ</a></li>
1491 </ul>
1492 <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>
1493 </div></div>
1494 </div>
1496 </div>
1498 </body>
1499 </html>