00001 <?php
00002
00003 # MediaWiki web-based config/installation
00004 # Copyright (C) 2004 Brion Vibber <brion@pobox.com>, 2006 Rob Church <robchur@gmail.com>
00005 # http://www.mediawiki.org/
00006 #
00007 # This program is free software; you can redistribute it and/or modify
00008 # it under the terms of the GNU General Public License as published by
00009 # the Free Software Foundation; either version 2 of the License, or
00010 # (at your option) any later version.
00011 #
00012 # This program is distributed in the hope that it will be useful,
00013 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00015 # GNU General Public License for more details.
00016 #
00017 # You should have received a copy of the GNU General Public License along
00018 # with this program; if not, write to the Free Software Foundation, Inc.,
00019 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020 # http://www.gnu.org/copyleft/gpl.html
00021
00022 error_reporting( E_ALL );
00023 header( "Content-type: text/html; charset=utf-8" );
00024 @ini_set( "display_errors", true );
00025
00026 # In case of errors, let output be clean.
00027 $wgRequestTime = microtime( true );
00028
00029 # Attempt to set up the include path, to fix problems with relative includes
00030 $IP = dirname( dirname( __FILE__ ) );
00031 define( 'MW_INSTALL_PATH', $IP );
00032
00033 # Define an entry point and include some files
00034 define( "MEDIAWIKI", true );
00035 define( "MEDIAWIKI_INSTALL", true );
00036 define( "TEXTSEARCH_COMPAT", true );
00037
00038
00039
00040 require_once( "$IP/install-utils.inc" );
00041 install_version_checks();
00042
00043 require_once( "$IP/includes/Defines.php" );
00044 require_once( "$IP/includes/DefaultSettings.php" );
00045 require_once( "$IP/includes/AutoLoader.php" );
00046 require_once( "$IP/includes/MagicWord.php" );
00047 require_once( "$IP/includes/Namespace.php" );
00048 require_once( "$IP/includes/ProfilerStub.php" );
00049 require_once( "$IP/includes/GlobalFunctions.php" );
00050 require_once( "$IP/includes/Hooks.php" );
00051 require_once( "$IP/includes/Exception.php" );
00052
00053 # If we get an exception, the user needs to know
00054 # all the details
00055 $wgShowExceptionDetails = true;
00056 $wgShowSQLErrors = true;
00057 wfInstallExceptionHandler();
00058 ## Databases we support:
00059
00060 $ourdb = array();
00061 $ourdb['mysql']['fullname'] = 'MySQL';
00062 $ourdb['mysql']['havedriver'] = 0;
00063 $ourdb['mysql']['compile'] = 'mysql';
00064 $ourdb['mysql']['bgcolor'] = '#ffe5a7';
00065 $ourdb['mysql']['rootuser'] = 'root';
00066
00067 $ourdb['postgres']['fullname'] = 'PostgreSQL';
00068 $ourdb['postgres']['havedriver'] = 0;
00069 $ourdb['postgres']['compile'] = 'pgsql';
00070 $ourdb['postgres']['bgcolor'] = '#aaccff';
00071 $ourdb['postgres']['rootuser'] = 'postgres';
00072
00073 $ourdb['sqlite']['fullname'] = 'SQLite';
00074 $ourdb['sqlite']['havedriver'] = 0;
00075 $ourdb['sqlite']['compile'] = 'pdo_sqlite';
00076 $ourdb['sqlite']['bgcolor'] = '#b1ebb1';
00077 $ourdb['sqlite']['rootuser'] = '';
00078
00079 $ourdb['mssql']['fullname'] = 'MSSQL';
00080 $ourdb['mssql']['havedriver'] = 0;
00081 $ourdb['mssql']['compile'] = 'mssql not ready'; # Change to 'mssql' after includes/DatabaseMssql.php added;
00082 $ourdb['mssql']['bgcolor'] = '#ffc0cb';
00083 $ourdb['mssql']['rootuser'] = 'administrator';
00084
00085 $ourdb['ibm_db2']['fullname'] = 'DB2';
00086 $ourdb['ibm_db2']['havedriver'] = 0;
00087 $ourdb['ibm_db2']['compile'] = 'ibm_db2';
00088 $ourdb['ibm_db2']['bgcolor'] = '#ffeba1';
00089 $ourdb['ibm_db2']['rootuser'] = 'db2admin';
00090
00091 ?>
00092 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
00093 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
00094 <head>
00095 <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
00096 <meta name="robots" content="noindex,nofollow"/>
00097 <title>MediaWiki <?php echo htmlspecialchars( $wgVersion ); ?> Installation</title>
00098 <style type="text/css">
00099
00100 @import "../skins/monobook/main.css";
00101
00102 .env-check {
00103 font-size: 90%;
00104 margin: 1em 0 1em 2.5em;
00105 }
00106
00107 .config-section {
00108 margin-top: 2em;
00109 }
00110
00111 .config-section label.column {
00112 clear: left;
00113 font-weight: bold;
00114 width: 13em;
00115 float: left;
00116 text-align: right;
00117 padding-right: 1em;
00118 padding-top: .2em;
00119 }
00120
00121 .config-input {
00122 clear: left;
00123 zoom: 100%;
00124 }
00125
00126 .config-section .config-desc {
00127 clear: left;
00128 margin: 0 0 2em 18em;
00129 padding-top: 1em;
00130 font-size: 85%;
00131 }
00132
00133 .iput-text, .iput-password {
00134 width: 14em;
00135 margin-right: 1em;
00136 }
00137
00138 .error {
00139 color: red;
00140 background-color: #fff;
00141 font-weight: bold;
00142 left: 1em;
00143 font-size: 100%;
00144 }
00145
00146 .error-top {
00147 color: red;
00148 background-color: #FFF0F0;
00149 border: 2px solid red;
00150 font-size: 130%;
00151 font-weight: bold;
00152 padding: 1em 1.5em;
00153 margin: 2em 0 1em;
00154 }
00155
00156 ul.plain {
00157 list-style-type: none;
00158 list-style-image: none;
00159 float: left;
00160 margin: 0;
00161 padding: 0;
00162 }
00163
00164 .btn-install {
00165 font-weight: bold;
00166 font-size: 110%;
00167 padding: .2em .3em;
00168 }
00169
00170 .license {
00171 font-size: 85%;
00172 padding-top: 3em;
00173 }
00174
00175 span.success-message {
00176 font-weight: bold;
00177 font-size: 110%;
00178 color: green;
00179 }
00180 .success-box {
00181 font-size: 130%;
00182 }
00183
00184 </style>
00185 <script type="text/javascript">
00186 <!--
00187 function hideall() {
00188 <?php foreach (array_keys($ourdb) as $db) {
00189 echo "\n var i = document.getElementById('$db'); if (i) i.style.display='none';";
00190 }
00191 ?>
00192
00193 }
00194 function toggleDBarea(id,defaultroot) {
00195 hideall();
00196 var dbarea = document.getElementById(id);
00197 if (dbarea) dbarea.style.display = (dbarea.style.display == 'none') ? 'block' : 'none';
00198 var db = document.getElementById('RootUser');
00199 if (defaultroot) {
00200 <?php foreach (array_keys($ourdb) as $db) {
00201 echo " if (id == '$db') { db.value = '".$ourdb[$db]['rootuser']."';}\n";
00202 }?>
00203 }
00204 }
00205
00206 </script>
00207 </head>
00208
00209 <body>
00210 <div id="globalWrapper">
00211 <div id="column-content">
00212 <div id="content">
00213 <div id="bodyContent">
00214
00215 <h1>MediaWiki <?php print htmlspecialchars( $wgVersion ) ?> Installation</h1>
00216
00217 <?php
00218 $mainListOpened = false; # Is the main list (environement checking) opend ? Used by dieout
00219
00220
00221
00222 if( file_exists( "../LocalSettings.php" ) ) {
00223 $script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php';
00224 dieout( "<p><strong>Setup has completed, <a href='../$script'>your wiki</a> is configured.</strong></p>
00225 <p>Please delete the /config directory for extra security.</p>" );
00226 }
00227
00228 if( file_exists( "./LocalSettings.php" ) ) {
00229 writeSuccessMessage();
00230 dieout( '' );
00231 }
00232
00233 if( !is_writable( "." ) ) {
00234 dieout( "<h2>Can't write config file, aborting</h2>
00235
00236 <p>In order to configure the wiki you have to make the <tt>config</tt> subdirectory
00237 writable by the web server. Once configuration is done you'll move the created
00238 <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can
00239 then remove the <tt>config</tt> subdirectory entirely.</p>
00240
00241 <p>To make the directory writable on a Unix/Linux system:</p>
00242
00243 <pre>
00244 cd <i>/path/to/wiki</i>
00245 chmod a+w config
00246 </pre>
00247
00248 <p>Afterwards retry to start the <a href=\"\">setup</a>.</p>" );
00249 }
00250
00251
00252 require_once( "$IP/install-utils.inc" );
00253 require_once( "$IP/maintenance/updaters.inc" );
00254
00255 class ConfigData {
00256 function getEncoded( $data ) {
00257 # removing latin1 support, no need...
00258 return $data;
00259 }
00260 function getSitename() { return $this->getEncoded( $this->Sitename ); }
00261 function getSysopName() { return $this->getEncoded( $this->SysopName ); }
00262 function getSysopPass() { return $this->getEncoded( $this->SysopPass ); }
00263
00264 function setSchema( $schema, $engine ) {
00265 $this->DBschema = $schema;
00266 if ( !preg_match( '/^\w*$/', $engine ) ){
00267 $engine = 'InnoDB';
00268 }
00269 switch ( $this->DBschema ) {
00270 case 'mysql5':
00271 $this->DBTableOptions = "ENGINE=$engine, DEFAULT CHARSET=utf8";
00272 $this->DBmysql5 = 'true';
00273 break;
00274 case 'mysql5-binary':
00275 $this->DBTableOptions = "ENGINE=$engine, DEFAULT CHARSET=binary";
00276 $this->DBmysql5 = 'true';
00277 break;
00278 default:
00279 $this->DBTableOptions = "TYPE=$engine";
00280 $this->DBmysql5 = 'false';
00281 }
00282 $this->DBengine = $engine;
00283
00284 # Set the global for use during install
00285 global $wgDBTableOptions;
00286 $wgDBTableOptions = $this->DBTableOptions;
00287 }
00288 }
00289
00290 ?>
00291
00292 <ul>
00293 <li>
00294 <b>Don't forget security updates!</b> Keep an eye on the
00295 <a href="http://lists.wikimedia.org/mailman/listinfo/mediawiki-announce">low-traffic
00296 release announcements mailing list</a>.
00297 </li>
00298 </ul>
00299
00300
00301 <h2>Checking environment...</h2>
00302 <p><em>Please include all of the lines below when reporting installation problems.</em></p>
00303 <ul class="env-check">
00304 <?php
00305 $mainListOpened = true;
00306
00307 $endl = "
00308 ";
00309 define( 'MW_NO_OUTPUT_BUFFER', 1 );
00310 $conf = new ConfigData;
00311
00312 install_version_checks();
00313 $self = 'Installer'; # Maintenance script name, to please Setup.php
00314
00315 print "<li>PHP " . htmlspecialchars( phpversion() ) . " installed</li>\n";
00316
00317 error_reporting( 0 );
00318 $phpdatabases = array();
00319 foreach (array_keys($ourdb) as $db) {
00320 $compname = $ourdb[$db]['compile'];
00321 if( extension_loaded( $compname ) || ( mw_have_dl() && dl( "{$compname}." . PHP_SHLIB_SUFFIX ) ) ) {
00322 array_push($phpdatabases, $db);
00323 $ourdb[$db]['havedriver'] = 1;
00324 }
00325 }
00326 error_reporting( E_ALL );
00327
00328 if (!$phpdatabases) {
00329 print "Could not find a suitable database driver!<ul>";
00330 foreach (array_keys($ourdb) AS $db) {
00331 $comp = $ourdb[$db]['compile'];
00332 $full = $ourdb[$db]['fullname'];
00333 print "<li>For <b>$full</b>, compile PHP using <b>--with-$comp</b>, "
00334 ."or install the $comp.so module</li>\n";
00335 }
00336 echo '</ul>';
00337 dieout( '' );
00338 }
00339
00340 print "<li>Found database drivers for:";
00341 $DefaultDBtype = '';
00342 foreach (array_keys($ourdb) AS $db) {
00343 if ($ourdb[$db]['havedriver']) {
00344 if ( $DefaultDBtype == '' ) {
00345 $DefaultDBtype = $db;
00346 }
00347 print " ".$ourdb[$db]['fullname'];
00348 }
00349 }
00350 print "</li>\n";
00351
00352 if( wfIniGetBool( "register_globals" ) ) {
00353 ?>
00354 <li>
00355 <div style="font-size:110%">
00356 <strong class="error">Warning:</strong>
00357 <strong>PHP's <tt><a href="http://php.net/register_globals">register_globals</a></tt> option is enabled. Disable it if you can.</strong>
00358 </div>
00359 MediaWiki will work, but your server is more exposed to PHP-based security vulnerabilities.
00360 </li>
00361 <?php
00362 }
00363
00364 $fatal = false;
00365
00366 if( wfIniGetBool( "magic_quotes_runtime" ) ) {
00367 $fatal = true;
00368 ?><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>
00369 This option corrupts data input unpredictably; you cannot install or use
00370 MediaWiki unless this option is disabled.</li>
00371 <?php
00372 }
00373
00374 if( wfIniGetBool( "magic_quotes_sybase" ) ) {
00375 $fatal = true;
00376 ?><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>
00377 This option corrupts data input unpredictably; you cannot install or use
00378 MediaWiki unless this option is disabled.</li>
00379 <?php
00380 }
00381
00382 if( wfIniGetBool( "mbstring.func_overload" ) ) {
00383 $fatal = true;
00384 ?><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>
00385 This option causes errors and may corrupt data unpredictably;
00386 you cannot install or use MediaWiki unless this option is disabled.</li>
00387 <?php
00388 }
00389
00390 if( wfIniGetBool( "zend.ze1_compatibility_mode" ) ) {
00391 $fatal = true;
00392 ?><li class="error"><strong>Fatal: <a href="http://www.php.net/manual/en/ini.core.php">zend.ze1_compatibility_mode</a> is active!</strong>
00393 This option causes horrible bugs with MediaWiki; you cannot install or use
00394 MediaWiki unless this option is disabled.</li>
00395 <?php
00396 }
00397
00398
00399 if( $fatal ) {
00400 dieout( "Cannot install MediaWiki." );
00401 }
00402
00403 if( wfIniGetBool( "safe_mode" ) ) {
00404 $conf->safeMode = true;
00405 ?>
00406 <li><b class='error'>Warning:</b> <strong>PHP's
00407 <a href='http:
00408 You may have problems caused by this, particularly if using image uploads.
00409 </li>
00410 <?php
00411 } else {
00412 $conf->safeMode = false;
00413 }
00414
00415 $sapi = htmlspecialchars( php_sapi_name() );
00416 print "<li>PHP server API is $sapi; ";
00417 $script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php';
00418 if( $wgUsePathInfo ) {
00419 print "ok, using pretty URLs (<tt>$script/Page_Title</tt>)";
00420 } else {
00421 print "using ugly URLs (<tt>$script?title=Page_Title</tt>)";
00422 }
00423 print "</li>\n";
00424
00425 $conf->xml = function_exists( "utf8_encode" );
00426 if( $conf->xml ) {
00427 print "<li>Have XML / Latin1-UTF-8 conversion support.</li>\n";
00428 } else {
00429 dieout( "PHP's XML module is missing; the wiki requires functions in
00430 this module and won't work in this configuration.
00431 If you're running Mandrake, install the php-xml package." );
00432 }
00433
00434 # Check for session support
00435 if( !function_exists( 'session_name' ) )
00436 dieout( "PHP's session module is missing. MediaWiki requires session support in order to function." );
00437
00438 # session.save_path doesn't *have* to be set, but if it is, and it's
00439 # not valid/writable/etc. then it can cause problems
00440 $sessionSavePath = mw_get_session_save_path();
00441 $ssp = htmlspecialchars( $sessionSavePath );
00442 # Warn the user if it's not set, but let them proceed
00443 if( !$sessionSavePath ) {
00444 print "<li><strong>Warning:</strong> A value for <tt>session.save_path</tt>
00445 has not been set in PHP.ini. If the default value causes problems with
00446 saving session data, set it to a valid path which is read/write/execute
00447 for the user your web server is running under.</li>";
00448 } elseif ( is_dir( $sessionSavePath ) && is_writable( $sessionSavePath ) ) {
00449 # All good? Let the user know
00450 print "<li>Session save path (<tt>{$ssp}</tt>) appears to be valid.</li>";
00451 } else {
00452 # Something not right? Warn the user, but let them proceed
00453 print "<li><strong>Warning:</strong> Your <tt>session.save_path</tt> value (<tt>{$ssp}</tt>)
00454 appears to be invalid or is not writable. PHP needs to be able to save data to
00455 this location for correct session operation.</li>";
00456 }
00457
00458 # Check for PCRE support
00459 if( !function_exists( 'preg_match' ) )
00460 dieout( "The PCRE support module appears to be missing. MediaWiki requires the
00461 Perl-compatible regular expression functions." );
00462
00463 $memlimit = ini_get( "memory_limit" );
00464 $conf->raiseMemory = false;
00465 if( empty( $memlimit ) || $memlimit == -1 ) {
00466 print "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n";
00467 } else {
00468 print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars( $memlimit ) . ". ";
00469 $n = intval( $memlimit );
00470 if( preg_match( '/^([0-9]+)[Mm]$/', trim( $memlimit ), $m ) ) {
00471 $n = intval( $m[1] * (1024*1024) );
00472 }
00473 if( $n < 20*1024*1024 ) {
00474 print "Attempting to raise limit to 20M... ";
00475 if( false === ini_set( "memory_limit", "20M" ) ) {
00476 print "failed.<br /><b>" . htmlspecialchars( $memlimit ) . " seems too low, installation may fail!</b>";
00477 } else {
00478 $conf->raiseMemory = true;
00479 print "ok.";
00480 }
00481 }
00482 print "</li>\n";
00483 }
00484
00485 $conf->turck = function_exists( 'mmcache_get' );
00486 if ( $conf->turck ) {
00487 print "<li><a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> installed</li>\n";
00488 }
00489
00490 $conf->xcache = function_exists( 'xcache_get' );
00491 if( $conf->xcache )
00492 print "<li><a href=\"http://trac.lighttpd.net/xcache/\">XCache</a> installed</li>\n";
00493
00494 $conf->apc = function_exists('apc_fetch');
00495 if ($conf->apc ) {
00496 print "<li><a href=\"http://www.php.net/apc\">APC</a> installed</li>\n";
00497 }
00498
00499 $conf->eaccel = function_exists( 'eaccelerator_get' );
00500 if ( $conf->eaccel ) {
00501 $conf->turck = 'eaccelerator';
00502 print "<li><a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> installed</li>\n";
00503 }
00504
00505 $conf->dba = function_exists( 'dba_open' );
00506
00507 if( !( $conf->turck || $conf->eaccel || $conf->apc || $conf->xcache ) ) {
00508 echo( '<li>Couldn\'t find <a href="http://turck-mmcache.sourceforge.net">Turck MMCache</a>,
00509 <a href="http://eaccelerator.sourceforge.net">eAccelerator</a>,
00510 <a href="http://www.php.net/apc">APC</a> or <a href="http://trac.lighttpd.net/xcache/">XCache</a>;
00511 cannot use these for object caching.</li>' );
00512 }
00513
00514 $conf->diff3 = false;
00515 $diff3locations = array_merge(
00516 array(
00517 "/usr/bin",
00518 "/usr/local/bin",
00519 "/opt/csw/bin",
00520 "/usr/gnu/bin",
00521 "/usr/sfw/bin" ),
00522 explode( PATH_SEPARATOR, getenv( "PATH" ) ) );
00523 $diff3names = array( "gdiff3", "diff3", "diff3.exe" );
00524
00525 $diff3versioninfo = array( '$1 --version 2>&1', 'diff3 (GNU diffutils)' );
00526 foreach ($diff3locations as $loc) {
00527 $exe = locate_executable($loc, $diff3names, $diff3versioninfo);
00528 if ($exe !== false) {
00529 $conf->diff3 = $exe;
00530 break;
00531 }
00532 }
00533
00534 if ($conf->diff3)
00535 print "<li>Found GNU diff3: <tt>$conf->diff3</tt>.</li>";
00536 else
00537 print "<li>GNU diff3 not found.</li>";
00538
00539 $conf->ImageMagick = false;
00540 $imcheck = array( "/usr/bin", "/opt/csw/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" );
00541 foreach( $imcheck as $dir ) {
00542 $im = "$dir/convert";
00543 if( @file_exists( $im ) ) {
00544 print "<li>Found ImageMagick: <tt>$im</tt>; image thumbnailing will be enabled if you enable uploads.</li>\n";
00545 $conf->ImageMagick = $im;
00546 break;
00547 }
00548 }
00549
00550 $conf->HaveGD = function_exists( "imagejpeg" );
00551 if( $conf->HaveGD ) {
00552 print "<li>Found GD graphics library built-in";
00553 if( !$conf->ImageMagick ) {
00554 print ", image thumbnailing will be enabled if you enable uploads";
00555 }
00556 print ".</li>\n";
00557 } else {
00558 if( !$conf->ImageMagick ) {
00559 print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n";
00560 }
00561 }
00562
00563 $conf->IP = dirname( dirname( __FILE__ ) );
00564 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP ) . "</tt></li>\n";
00565
00566
00567
00568
00569
00570 $path = ($_SERVER["PHP_SELF"] === '')
00571 ? $_SERVER["SCRIPT_NAME"]
00572 : $_SERVER["PHP_SELF"];
00573
00574 $conf->ScriptPath = preg_replace( '{^(.*)/config.*$}', '$1', $path );
00575 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath ) . "</tt></li>\n";
00576
00577
00578
00579
00580 $conf->ScriptExtension = '.php';
00581 if (defined('MW_INSTALL_PHP5_EXT')) {
00582 $conf->ScriptExtension = '.php5';
00583 print "<li>Installing MediaWiki with <tt>php5</tt> file extensions</li>\n";
00584 } else {
00585 print "<li>Installing MediaWiki with <tt>php</tt> file extensions</li>\n";
00586 }
00587
00588
00589 print "<li style='font-weight:bold;color:green;font-size:110%'>Environment checked. You can install MediaWiki.</li>\n";
00590 $conf->posted = ($_SERVER["REQUEST_METHOD"] == "POST");
00591
00592 $conf->Sitename = ucfirst( importPost( "Sitename", "" ) );
00593 $defaultEmail = empty( $_SERVER["SERVER_ADMIN"] )
00594 ? 'root@localhost'
00595 : $_SERVER["SERVER_ADMIN"];
00596 $conf->EmergencyContact = importPost( "EmergencyContact", $defaultEmail );
00597 $conf->DBtype = importPost( "DBtype", $DefaultDBtype );
00598 if ( !isset( $ourdb[$conf->DBtype] ) ) {
00599 $conf->DBtype = $DefaultDBtype;
00600 }
00601
00602 $conf->DBserver = importPost( "DBserver", "localhost" );
00603 $conf->DBname = importPost( "DBname", "wikidb13" );
00604 $conf->DBuser = importPost( "DBuser", "www" );
00605 $conf->DBpassword = importPost( "DBpassword" );
00606 $conf->DBpassword2 = importPost( "DBpassword2" );
00607 $conf->SysopName = importPost( "SysopName", "WikiSysop" );
00608 $conf->SysopPass = importPost( "SysopPass" );
00609 $conf->SysopPass2 = importPost( "SysopPass2" );
00610 $conf->RootUser = importPost( "RootUser", "root" );
00611 $conf->RootPW = importPost( "RootPW", "" );
00612 $useRoot = importCheck( 'useroot', false );
00613 $conf->LanguageCode = importPost( "LanguageCode", "en" );
00614 ## MySQL specific:
00615 $conf->DBprefix = importPost( "DBprefix" );
00616 $conf->setSchema(
00617 importPost( "DBschema", "mysql5-binary" ),
00618 importPost( "DBengine", "InnoDB" ) );
00619
00620 ## Postgres specific:
00621 $conf->DBport = importPost( "DBport", "5432" );
00622 $conf->DBmwschema = importPost( "DBmwschema", "mediawiki" );
00623 $conf->DBts2schema = importPost( "DBts2schema", "public" );
00624
00625 ## SQLite specific
00626 $conf->SQLiteDataDir = importPost( "SQLiteDataDir", "" );
00627
00628 ## MSSQL specific
00629
00630 $conf->DBprefix2 = importPost( "DBprefix2" );
00631
00632 ## DB2 specific:
00633
00634 $conf->DBport_db2 = importPost( "DBport_db2", "50000" );
00635 $conf->DBmwschema = importPost( "DBmwschema", "mediawiki" );
00636 $conf->DBcataloged = importPost( "DBcataloged", "cataloged" );
00637
00638 $conf->ShellLocale = getShellLocale( $conf->LanguageCode );
00639
00640
00641 $errs = array();
00642
00643 if( preg_match( '/^$|^mediawiki$|#/i', $conf->Sitename ) ) {
00644 $errs["Sitename"] = "Must not be blank or \"MediaWiki\" and may not contain \"#\"";
00645 }
00646 if( $conf->DBuser == "" ) {
00647 $errs["DBuser"] = "Must not be blank";
00648 }
00649 if( ($conf->DBtype == 'mysql') && (strlen($conf->DBuser) > 16) ) {
00650 $errs["DBuser"] = "Username too long";
00651 }
00652 if( $conf->DBpassword == "" && $conf->DBtype != "postgres" ) {
00653 $errs["DBpassword"] = "Must not be blank";
00654 }
00655 if( $conf->DBpassword != $conf->DBpassword2 ) {
00656 $errs["DBpassword2"] = "Passwords don't match!";
00657 }
00658 if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix ) ) {
00659 $errs["DBprefix"] = "Invalid table prefix";
00660 } else {
00661 untaint( $conf->DBprefix, TC_MYSQL );
00662 }
00663
00664 error_reporting( E_ALL );
00665
00672 $wgContLang = Language::factory( 'en' );
00673 $wgLang = $wgContLang;
00674
00679 $wgAuth = new AuthPlugin();
00680
00685 if( $conf->SysopName ) {
00686 # Check that the user can be created
00687 $u = User::newFromName( $conf->SysopName );
00688 if( is_a($u, 'User') ) {
00689 # Various password checks
00690 if( $conf->SysopPass != '' ) {
00691 if( $conf->SysopPass == $conf->SysopPass2 ) {
00692 if( !$u->isValidPassword( $conf->SysopPass ) ) {
00693 $errs['SysopPass'] = "Bad password";
00694 }
00695 } else {
00696 $errs['SysopPass2'] = "Passwords don't match";
00697 }
00698 } else {
00699 $errs['SysopPass'] = "Cannot be blank";
00700 }
00701 unset( $u );
00702 } else {
00703 $errs['SysopName'] = "Bad username";
00704 }
00705 }
00706
00707 $conf->License = importRequest( "License", "none" );
00708 if( $conf->License == "gfdl1_2" ) {
00709 $conf->RightsUrl = "http://www.gnu.org/licenses/old-licenses/fdl-1.2.txt";
00710 $conf->RightsText = "GNU Free Documentation License 1.2";
00711 $conf->RightsCode = "gfdl1_2";
00712 $conf->RightsIcon = '${wgScriptPath}/skins/common/images/gnu-fdl.png';
00713 } elseif( $conf->License == "gfdl1_3" ) {
00714 $conf->RightsUrl = "http://www.gnu.org/copyleft/fdl.html";
00715 $conf->RightsText = "GNU Free Documentation License 1.3";
00716 $conf->RightsCode = "gfdl1_3";
00717 $conf->RightsIcon = '${wgScriptPath}/skins/common/images/gnu-fdl.png';
00718 } elseif( $conf->License == "none" ) {
00719 $conf->RightsUrl = $conf->RightsText = $conf->RightsCode = $conf->RightsIcon = "";
00720 } elseif( $conf->License == "pd" ) {
00721 $conf->RightsUrl = "http://creativecommons.org/licenses/publicdomain/";
00722 $conf->RightsText = "Public Domain";
00723 $conf->RightsCode = "pd";
00724 $conf->RightsIcon = '${wgScriptPath}/skins/common/images/public-domain.png';
00725 } else {
00726 $conf->RightsUrl = importRequest( "RightsUrl", "" );
00727 $conf->RightsText = importRequest( "RightsText", "" );
00728 $conf->RightsCode = importRequest( "RightsCode", "" );
00729 $conf->RightsIcon = importRequest( "RightsIcon", "" );
00730 }
00731
00732 $conf->Shm = importRequest( "Shm", "none" );
00733 $conf->MCServers = importRequest( "MCServers" );
00734
00735
00736
00737 if ( $conf->Shm == 'memcached' && $conf->MCServers ) {
00738 $conf->MCServerArray = wfArrayMap( 'trim', explode( ',', $conf->MCServers ) );
00739 foreach ( $conf->MCServerArray as $server ) {
00740 $error = testMemcachedServer( $server );
00741 if ( $error ) {
00742 $errs["MCServers"] = $error;
00743 break;
00744 }
00745 }
00746 } else if ( $conf->Shm == 'memcached' ) {
00747 $errs["MCServers"] = "Please specify at least one server if you wish to use memcached";
00748 }
00749
00750
00751 $conf->Email = importRequest("Email", "email_enabled");
00752 $conf->Emailuser = importRequest("Emailuser", "emailuser_enabled");
00753 $conf->Enotif = importRequest("Enotif", "enotif_allpages");
00754 $conf->Eauthent = importRequest("Eauthent", "eauthent_enabled");
00755
00756 if( $conf->posted && ( 0 == count( $errs ) ) ) {
00757 do {
00758 $conf->Root = ($conf->RootPW != "");
00759
00760
00761 $local = writeLocalSettings( $conf );
00762 echo "<li style=\"list-style: none\">\n";
00763 echo "<p><b>Generating configuration file...</b></p>\n";
00764 echo "</li>\n";
00765
00766 $wgCommandLineMode = false;
00767 chdir( ".." );
00768 $ok = eval( $local );
00769 if( $ok === false ) {
00770 dieout( "<p>Errors in generated configuration; " .
00771 "most likely due to a bug in the installer... " .
00772 "Config file was: </p>" .
00773 "<pre>" .
00774 htmlspecialchars( $local ) .
00775 "</pre>" );
00776 }
00777 $conf->DBtypename = '';
00778 foreach (array_keys($ourdb) as $db) {
00779 if ($conf->DBtype === $db)
00780 $conf->DBtypename = $ourdb[$db]['fullname'];
00781 }
00782 if ( ! strlen($conf->DBtype)) {
00783 $errs["DBpicktype"] = "Please choose a database type";
00784 continue;
00785 }
00786
00787 if (! $conf->DBtypename) {
00788 $errs["DBtype"] = "Unknown database type '$conf->DBtype'";
00789 continue;
00790 }
00791 print "<li>Database type: " . htmlspecialchars( $conf->DBtypename ) . "</li>\n";
00792 $dbclass = 'Database'.ucfirst($conf->DBtype);
00793 $wgDBtype = $conf->DBtype;
00794 $wgDBadminuser = "root";
00795 $wgDBadminpassword = $conf->RootPW;
00796
00797 ## Mysql specific:
00798 $wgDBprefix = $conf->DBprefix;
00799
00800 ## Postgres specific:
00801 $wgDBport = $conf->DBport;
00802 $wgDBmwschema = $conf->DBmwschema;
00803 $wgDBts2schema = $conf->DBts2schema;
00804
00805 if( $conf->DBprefix2 != '' ) {
00806
00807 $wgDBprefix = $conf->DBprefix2;
00808 }
00809
00810 ## DB2 specific:
00811 $wgDBcataloged = $conf->DBcataloged;
00812
00813 $wgCommandLineMode = true;
00814 if (! defined ( 'STDERR' ) )
00815 define( 'STDERR', fopen("php://stderr", "wb"));
00816 $wgUseDatabaseMessages = false;
00817 require_once( "$IP/includes/Setup.php" );
00818 chdir( "config" );
00819
00820 $wgTitle = Title::newFromText( "Installation script" );
00821 error_reporting( E_ALL );
00822 print "<li>Loading class: " . htmlspecialchars( $dbclass ) . "</li>\n";
00823 if ( $conf->DBtype != 'sqlite' ) {
00824 $dbc = new $dbclass;
00825 }
00826
00827 if( $conf->DBtype == 'mysql' ) {
00828 $mysqlOldClient = version_compare( mysql_get_client_info(), "4.1.0", "lt" );
00829 if( $mysqlOldClient ) {
00830 print "<li><b>PHP is linked with old MySQL client libraries. If you are
00831 using a MySQL 4.1 server and have problems connecting to the database,
00832 see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
00833 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b></li>\n";
00834 }
00835 $ok = true; # Let's be optimistic
00836
00837 # Decide if we're going to use the superuser or the regular database user
00838 $conf->Root = $useRoot;
00839 if( $conf->Root ) {
00840 $db_user = $conf->RootUser;
00841 $db_pass = $conf->RootPW;
00842 } else {
00843 $db_user = $wgDBuser;
00844 $db_pass = $wgDBpassword;
00845 }
00846
00847 # Attempt to connect
00848 echo( "<li>Attempting to connect to database server as " . htmlspecialchars( $db_user ) . "..." );
00849 $wgDatabase = Database::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 );
00850
00851 # Check the connection and respond to errors
00852 if( $wgDatabase->isOpen() ) {
00853 # Seems OK
00854 $ok = true;
00855 $wgDBadminuser = $db_user;
00856 $wgDBadminpassword = $db_pass;
00857 echo( "success.</li>\n" );
00858 $wgDatabase->ignoreErrors( true );
00859 $myver = $wgDatabase->getServerVersion();
00860 } else {
00861 # There were errors, report them and back out
00862 $ok = false;
00863 $errno = mysql_errno();
00864 $errtx = htmlspecialchars( mysql_error() );
00865 switch( $errno ) {
00866 case 1045:
00867 case 2000:
00868 echo( "failed due to authentication errors. Check passwords.</li>" );
00869 if( $conf->Root ) {
00870 # The superuser details are wrong
00871 $errs["RootUser"] = "Check username";
00872 $errs["RootPW"] = "and password";
00873 } else {
00874 # The regular user details are wrong
00875 $errs["DBuser"] = "Check username";
00876 $errs["DBpassword"] = "and password";
00877 }
00878 break;
00879 case 2002:
00880 case 2003:
00881 default:
00882 # General connection problem
00883 echo( htmlspecialchars( "failed with error [$errno] $errtx." ) . "</li>\n" );
00884 $errs["DBserver"] = "Connection failed";
00885 break;
00886 } # switch
00887 } #conn. att.
00888
00889 if( !$ok ) { continue; }
00890 }
00891 else if( $conf->DBtype == 'ibm_db2' ) {
00892 if( $useRoot ) {
00893 $db_user = $conf->RootUser;
00894 $db_pass = $conf->RootPW;
00895 } else {
00896 $db_user = $wgDBuser;
00897 $db_pass = $wgDBpassword;
00898 }
00899
00900 echo( "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) .
00901 "\" as \"" . htmlspecialchars( $db_user ) . "\"..." );
00902 $wgDatabase = $dbc->newFromParams($wgDBserver, $db_user, $db_pass, $wgDBname, 1);
00903 if (!$wgDatabase->isOpen()) {
00904 print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
00905 } else {
00906 $myver = $wgDatabase->getServerVersion();
00907 }
00908 if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname);
00909
00910 } elseif ( $conf->DBtype == 'sqlite' ) {
00911 if ("$wgSQLiteDataDir" == '') {
00912 $wgSQLiteDataDir = dirname($_SERVER['DOCUMENT_ROOT']).'/data';
00913 }
00914 echo "<li>Attempting to connect to SQLite database at \"" .
00915 htmlspecialchars( $wgSQLiteDataDir ) . "\"";
00916 if ( !is_dir( $wgSQLiteDataDir ) ) {
00917 if ( is_writable( dirname( $wgSQLiteDataDir ) ) ) {
00918 $ok = wfMkdirParents( $wgSQLiteDataDir, $wgSQLiteDataDirMode );
00919 } else {
00920 $ok = false;
00921 }
00922 if ( !$ok ) {
00923 echo ": cannot create data directory</li>";
00924 $errs['SQLiteDataDir'] = 'Enter a valid data directory';
00925 continue;
00926 }
00927 }
00928 if ( !is_writable( $wgSQLiteDataDir ) ) {
00929 echo ": data directory not writable</li>";
00930 $errs['SQLiteDataDir'] = 'Enter a writable data directory';
00931 continue;
00932 }
00933 $dataFile = "$wgSQLiteDataDir/$wgDBname.sqlite";
00934 if ( file_exists( $dataFile ) && !is_writable( $dataFile ) ) {
00935 echo ": data file not writable</li>";
00936 $errs['SQLiteDataDir'] = "$wgDBname.sqlite is not writable";
00937 continue;
00938 }
00939 $wgDatabase = new DatabaseSqlite( false, false, false, $wgDBname, 1 );
00940 if (!$wgDatabase->isOpen()) {
00941 print ": error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
00942 $errs['SQLiteDataDir'] = 'Could not connect to database';
00943 continue;
00944 } else {
00945 $myver = $wgDatabase->getServerVersion();
00946 }
00947 if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname);
00948 echo "ok</li>\n";
00949 } else { # not mysql
00950 error_reporting( E_ALL );
00951 $wgSuperUser = '';
00952 ## Possible connect as a superuser
00953
00954 if( $useRoot && $conf->DBtype == 'postgres' ) {
00955 $wgDBsuperuser = $conf->RootUser;
00956 echo( "<li>Attempting to connect to database \"postgres\" as superuser \"" .
00957 htmlspecialchars( $wgDBsuperuser ) . "\"..." );
00958 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBsuperuser, $conf->RootPW, "postgres", 1);
00959 if (!$wgDatabase->isOpen()) {
00960 print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
00961 $errs["DBserver"] = "Could not connect to database as superuser";
00962 $errs["RootUser"] = "Check username";
00963 $errs["RootPW"] = "and password";
00964 continue;
00965 }
00966 $wgDatabase->initial_setup($conf->RootPW, 'postgres');
00967 }
00968 echo( "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) .
00969 "\" as \"" . htmlspecialchars( $wgDBuser ) . "\"..." );
00970 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1);
00971 if (!$wgDatabase->isOpen()) {
00972 print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
00973 } else {
00974 $myver = $wgDatabase->getServerVersion();
00975 }
00976 if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname);
00977 }
00978
00979 if ( !$wgDatabase->isOpen() ) {
00980 $errs["DBserver"] = "Couldn't connect to database";
00981 continue;
00982 }
00983
00984 print "<li>Connected to " . htmlspecialchars( "{$conf->DBtype} $myver" );
00985 if ($conf->DBtype == 'mysql') {
00986 if( version_compare( $myver, "4.0.14" ) < 0 ) {
00987 print "</li>\n";
00988 dieout( "-- mysql 4.0.14 or later required. Aborting." );
00989 }
00990 $mysqlNewAuth = version_compare( $myver, "4.1.0", "ge" );
00991 if( $mysqlNewAuth && $mysqlOldClient ) {
00992 print "; <b class='error'>You are using MySQL 4.1 server, but PHP is linked
00993 to old client libraries; if you have trouble with authentication, see
00994 <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
00995 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>";
00996 }
00997 if( $wgDBmysql5 ) {
00998 if( $mysqlNewAuth ) {
00999 print "; enabling MySQL 4.1/5.0 charset mode";
01000 } else {
01001 print "; <b class='error'>MySQL 4.1/5.0 charset mode enabled,
01002 but older version detected; will likely fail.</b>";
01003 }
01004 }
01005 print "</li>\n";
01006
01007 @$sel = $wgDatabase->selectDB( $wgDBname );
01008 if( $sel ) {
01009 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
01010 } else {
01011 $err = mysql_errno();
01012 $databaseSafe = htmlspecialchars( $wgDBname );
01013 if( $err == 1102 ) {
01014 print "<ul><li><strong>{$databaseSafe}</strong> is not a valid database name.</li></ul>";
01015 continue;
01016 } elseif( $err != 1049 ) {
01017 print "<ul><li>Error selecting database <strong>{$databaseSafe}</strong>: {$err} ";
01018 print htmlspecialchars( mysql_error() ) . "</li></ul>";
01019 continue;
01020 }
01021 print "<li>Attempting to create database...</li>";
01022 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
01023 if( !$res ) {
01024 print "<li>Couldn't create database <tt>" .
01025 htmlspecialchars( $wgDBname ) .
01026 "</tt>; try with root access or check your username/pass.</li>\n";
01027 $errs["RootPW"] = "<- Enter";
01028 continue;
01029 }
01030 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
01031 }
01032 $wgDatabase->selectDB( $wgDBname );
01033 }
01034 else if ($conf->DBtype == 'postgres') {
01035 if( version_compare( $myver, "8.0" ) < 0 ) {
01036 dieout( "<b>Postgres 8.0 or later is required</b>. Aborting." );
01037 }
01038 }
01039
01040 if( $wgDatabase->tableExists( "cur" ) || $wgDatabase->tableExists( "revision" ) ) {
01041 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n";
01042
01043 if ( $conf->DBtype == 'mysql') {
01044 # Determine existing default character set
01045 if ( $wgDatabase->tableExists( "revision" ) ) {
01046 $revision = $wgDatabase->escapeLike( $conf->DBprefix . 'revision' );
01047 $res = $wgDatabase->query( "SHOW TABLE STATUS LIKE '$revision'" );
01048 $row = $wgDatabase->fetchObject( $res );
01049 if ( !$row ) {
01050 echo "<li>SHOW TABLE STATUS query failed!</li>\n";
01051 $existingSchema = false;
01052 $existingEngine = false;
01053 } else {
01054 if ( preg_match( '/^latin1/', $row->Collation ) ) {
01055 $existingSchema = 'mysql4';
01056 } elseif ( preg_match( '/^utf8/', $row->Collation ) ) {
01057 $existingSchema = 'mysql5';
01058 } elseif ( preg_match( '/^binary/', $row->Collation ) ) {
01059 $existingSchema = 'mysql5-binary';
01060 } else {
01061 $existingSchema = false;
01062 echo "<li><strong>Warning:</strong> Unrecognised existing collation</li>\n";
01063 }
01064 if ( isset( $row->Engine ) ) {
01065 $existingEngine = $row->Engine;
01066 } else {
01067 $existingEngine = $row->Type;
01068 }
01069 }
01070 if ( $existingSchema && $existingSchema != $conf->DBschema ) {
01071 $encExisting = htmlspecialchars( $existingSchema );
01072 $encRequested = htmlspecialchars( $conf->DBschema );
01073 print "<li><strong>Warning:</strong> you requested the $encRequested schema, " .
01074 "but the existing database has the $encExisting schema. This upgrade script ".
01075 "can't convert it, so it will remain $encExisting.</li>\n";
01076 $conf->setSchema( $existingSchema, $conf->DBengine );
01077 }
01078 if ( $existingEngine && $existingEngine != $conf->DBengine ) {
01079 $encExisting = htmlspecialchars( $existingEngine );
01080 $encRequested = htmlspecialchars( $conf->DBengine );
01081 print "<li><strong>Warning:</strong> you requested the $encRequested storage " .
01082 "engine, but the existing database uses the $encExisting engine. This upgrade " .
01083 "script can't convert it, so it will remain $encExisting.</li>\n";
01084 $conf->setSchema( $conf->DBschema, $existingEngine );
01085 }
01086 }
01087
01088 # Create user if required
01089 if ( $conf->Root ) {
01090 $conn = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
01091 if ( $conn->isOpen() ) {
01092 print "<li>DB user account ok</li>\n";
01093 $conn->close();
01094 } else {
01095 print "<li>Granting user permissions...";
01096 if( $mysqlOldClient && $mysqlNewAuth ) {
01097 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>";
01098 }
01099 print "</li>\n";
01100 dbsource( "../maintenance/users.sql", $wgDatabase );
01101 }
01102 }
01103 }
01104 print "</ul><pre>\n";
01105 chdir( ".." );
01106 flush();
01107 do_all_updates();
01108 chdir( "config" );
01109 print "</pre>\n";
01110 print "<ul><li>Finished update checks.</li>\n";
01111 } else {
01112 # Determine available storage engines if possible
01113 if ( $conf->DBtype == 'mysql' && version_compare( $myver, "4.1.2", "ge" ) ) {
01114 $res = $wgDatabase->query( 'SHOW ENGINES' );
01115 $found = false;
01116 while ( $row = $wgDatabase->fetchObject( $res ) ) {
01117 if ( $row->Engine == $conf->DBengine ) {
01118 $found = true;
01119 break;
01120 }
01121 }
01122 $wgDatabase->freeResult( $res );
01123 if ( !$found && $conf->DBengine != 'MyISAM' ) {
01124 echo "<li><strong>Warning:</strong> " . htmlspecialchars( $conf->DBengine ) .
01125 " storage engine not available, " .
01126 "using MyISAM instead</li>\n";
01127 $conf->setSchema( $conf->DBschema, 'MyISAM' );
01128 }
01129 }
01130
01131 # FIXME: Check for errors
01132 print "<li>Creating tables...";
01133 if ($conf->DBtype == 'mysql') {
01134 dbsource( "../maintenance/tables.sql", $wgDatabase );
01135 dbsource( "../maintenance/interwiki.sql", $wgDatabase );
01136 } elseif (is_callable(array($wgDatabase, 'setup_database'))) {
01137 $wgDatabase->setup_database();
01138 }
01139 else {
01140 $errs["DBtype"] = "Do not know how to handle database type '$conf->DBtype'";
01141 continue;
01142 }
01143
01144 print " done.</li>\n";
01145
01146 print "<li>Initializing statistics...</li>\n";
01147 $wgDatabase->insert( 'site_stats',
01148 array ( 'ss_row_id' => 1,
01149 'ss_total_views' => 0,
01150 'ss_total_edits' => 1, # Main page first edit
01151 'ss_good_articles' => 0, # Main page is not a good article - no internal link
01152 'ss_total_pages' => 1, # Main page
01153 'ss_users' => $conf->SysopName ? 1 : 0, # Sysop account, if created
01154 'ss_admins' => $conf->SysopName ? 1 : 0, # Sysop account, if created
01155 'ss_images' => 0 ) );
01156
01157 # Set up the "regular user" account *if we can, and if we need to*
01158 if( $conf->Root and $conf->DBtype == 'mysql') {
01159 # See if we need to
01160 $wgDatabase2 = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
01161 if( $wgDatabase2->isOpen() ) {
01162 # Nope, just close the test connection and continue
01163 $wgDatabase2->close();
01164 echo( "<li>User " . htmlspecialchars( $wgDBuser ) . " exists. Skipping grants.</li>\n" );
01165 } else {
01166 # Yes, so run the grants
01167 echo( "<li>" . htmlspecialchars( "Granting user permissions to $wgDBuser on $wgDBname..." ) );
01168 dbsource( "../maintenance/users.sql", $wgDatabase );
01169 echo( "success.</li>\n" );
01170 }
01171 }
01172
01173 if( $conf->SysopName ) {
01174 $u = User::newFromName( $conf->getSysopName() );
01175 if ( !$u ) {
01176 print "<li><strong class=\"error\">Warning:</strong> Skipped sysop account creation - invalid username!</li>\n";
01177 }
01178 else if ( 0 == $u->idForName() ) {
01179 $u->addToDatabase();
01180 $u->setPassword( $conf->getSysopPass() );
01181 $u->saveSettings();
01182
01183 $u->addGroup( "sysop" );
01184 $u->addGroup( "bureaucrat" );
01185
01186 print "<li>Created sysop account <tt>" .
01187 htmlspecialchars( $conf->SysopName ) . "</tt>.</li>\n";
01188 } else {
01189 print "<li>Could not create user - already exists!</li>\n";
01190 }
01191 } else {
01192 print "<li>Skipped sysop account creation, no name given.</li>\n";
01193 }
01194
01195 $titleobj = Title::newFromText( wfMsgNoDB( "mainpage" ) );
01196 $article = new Article( $titleobj );
01197 $newid = $article->insertOn( $wgDatabase );
01198 $revision = new Revision( array(
01199 'page' => $newid,
01200 'text' => wfMsg( 'mainpagetext' ) . "\n\n" . wfMsgNoTrans( 'mainpagedocfooter' ),
01201 'comment' => '',
01202 'user' => 0,
01203 'user_text' => 'MediaWiki default',
01204 ) );
01205 $revid = $revision->insertOn( $wgDatabase );
01206 $article->updateRevisionOn( $wgDatabase, $revision );
01207 }
01208
01209 $wgDatabase->commit();
01210
01211
01212 print "<li style=\"list-style: none\">\n";
01213 print "<p>Creating LocalSettings.php...</p>\n\n";
01214 $localSettings = "<" . "?php$endl$local";
01215
01216 $localSettings = str_replace( "\r\n", "\n", $localSettings );
01217 $f = fopen( "LocalSettings.php", 'xt' );
01218
01219 if( $f == false ) {
01220 print( "</li>\n" );
01221 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" .
01222 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
01223 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
01224 }
01225 if(fwrite( $f, $localSettings ) ) {
01226 fclose( $f );
01227 print "<hr/>\n";
01228 writeSuccessMessage();
01229 print "</li>\n";
01230 } else {
01231 fclose( $f );
01232 dieout( "<p class='error'>An error occured while writing the config/LocalSettings.php file. Check user rights and disk space then try again.</p></li>\n" );
01233 }
01234
01235 } while( false );
01236 }
01237
01238 print "</ul>\n";
01239 $mainListOpened = false;
01240
01241 if( count( $errs ) ) {
01242
01243
01244 if( $conf->posted ) {
01245 echo "<p class='error-top'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
01246 }
01247 ?>
01248
01249 <form action="<?php echo defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php'; ?>" name="config" method="post">
01250
01251 <h2>Site config</h2>
01252
01253 <div class="config-section">
01254 <div class="config-input">
01255 <?php aField( $conf, "Sitename", "Wiki name:" ); ?>
01256 </div>
01257 <p class="config-desc">
01258 Preferably a short word without punctuation, i.e. "Wikipedia".<br />
01259 Will appear as the namespace name for "meta" pages, and throughout the interface.
01260 </p>
01261 <div class="config-input"><?php aField( $conf, "EmergencyContact", "Contact e-mail:" ); ?></div>
01262 <p class="config-desc">
01263 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.
01264 </p>
01265
01266 <div class="config-input">
01267 <label class='column' for="LanguageCode">Language:</label>
01268 <select id="LanguageCode" name="LanguageCode"><?php
01269 $list = getLanguageList();
01270 foreach( $list as $code => $name ) {
01271 $sel = ($code == $conf->LanguageCode) ? 'selected="selected"' : '';
01272 $encCode = htmlspecialchars( $code );
01273 $encName = htmlspecialchars( $name );
01274 echo "\n\t\t<option value=\"$encCode\" $sel>$encName</option>";
01275 }
01276 echo "\n";
01277 ?>
01278 </select>
01279 </div>
01280 <p class="config-desc">
01281 Select the language for your wiki's interface. Some localizations aren't fully complete. Unicode (UTF-8) is used for all localizations.
01282 </p>
01283
01284 <div class="config-input">
01285 <label class='column'>Copyright/license:</label>
01286
01287 <ul class="plain">
01288 <li><?php aField( $conf, "License", "No license metadata", "radio", "none" ); ?></li>
01289 <li><?php aField( $conf, "License", "Public Domain", "radio", "pd" ); ?></li>
01290 <li><?php aField( $conf, "License", "GNU Free Documentation License 1.2 (Wikipedia-compatible)", "radio", "gfdl1_2" ); ?></li>
01291 <li><?php aField( $conf, "License", "GNU Free Documentation License 1.3", "radio", "gfdl1_3" ); ?></li>
01292 <li><?php
01293 aField( $conf, "License", "A Creative Commons license - ", "radio", "cc" );
01294 $partner = "MediaWiki";
01295 $script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php';
01296 $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/$script?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
01297 $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" );
01298 $ccApp = htmlspecialchars( "http:
01299 print "<a href=\"$ccApp\" target='_blank'>choose</a>";
01300 if( $conf->License == "cc" ) { ?>
01301 <ul>
01302 <li><?php aField( $conf, "RightsIcon", "<img src=\"" . htmlspecialchars( $conf->RightsIcon ) . "\" alt='(Creative Commons icon)' />", "hidden" ); ?></li>
01303 <li><?php aField( $conf, "RightsText", htmlspecialchars( $conf->RightsText ), "hidden" ); ?></li>
01304 <li><?php aField( $conf, "RightsCode", "code: " . htmlspecialchars( $conf->RightsCode ), "hidden" ); ?></li>
01305 <li><?php aField( $conf, "RightsUrl", "<a href=\"" . htmlspecialchars( $conf->RightsUrl ) . "\">" . htmlspecialchars( $conf->RightsUrl ) . "</a>", "hidden" ); ?></li>
01306 </ul>
01307 <?php } ?>
01308 </li>
01309 </ul>
01310 </div>
01311 <p class="config-desc">
01312 A notice, icon, and machine-readable copyright metadata will be displayed for the license you pick.
01313 </p>
01314
01315
01316 <div class="config-input">
01317 <?php aField( $conf, "SysopName", "Admin username:" ) ?>
01318 </div>
01319 <div class="config-input">
01320 <?php aField( $conf, "SysopPass", "Password:", "password" ) ?>
01321 </div>
01322 <div class="config-input">
01323 <?php aField( $conf, "SysopPass2", "Password confirm:", "password" ) ?>
01324 </div>
01325 <p class="config-desc">
01326 An admin can lock/delete pages, block users from editing, and do other maintenance tasks.<br />
01327 A new account will be added only when creating a new wiki database.
01328 <br /><br />
01329 The password cannot be the same as the username.
01330 </p>
01331
01332 <div class="config-input">
01333 <label class='column'>Object caching:</label>
01334
01335 <ul class="plain">
01336 <li><?php aField( $conf, "Shm", "No caching", "radio", "none" ); ?></li>
01337 <?php
01338 if ( $conf->turck ) {
01339 echo "<li>";
01340 aField( $conf, "Shm", "Turck MMCache", "radio", "turck" );
01341 echo "</li>\n";
01342 }
01343 if( $conf->xcache ) {
01344 echo "<li>";
01345 aField( $conf, 'Shm', 'XCache', 'radio', 'xcache' );
01346 echo "</li>\n";
01347 }
01348 if ( $conf->apc ) {
01349 echo "<li>";
01350 aField( $conf, "Shm", "APC", "radio", "apc" );
01351 echo "</li>\n";
01352 }
01353 if ( $conf->eaccel ) {
01354 echo "<li>";
01355 aField( $conf, "Shm", "eAccelerator", "radio", "eaccel" );
01356 echo "</li>\n";
01357 }
01358 if ( $conf->dba ) {
01359 echo "<li>";
01360 aField( $conf, "Shm", "DBA (not recommended)", "radio", "dba" );
01361 echo "</li>";
01362 }
01363 ?>
01364 <li><?php aField( $conf, "Shm", "Memcached", "radio", "memcached" ); ?></li>
01365 </ul>
01366 <div style="clear:left"><?php aField( $conf, "MCServers", "Memcached servers:", "text" ) ?></div>
01367 </div>
01368 <p class="config-desc">
01369 An object caching system such as memcached will provide a significant performance boost,
01370 but needs to be installed. Provide the server addresses and ports in a comma-separated list.
01371 <br /><br />
01372 MediaWiki can also detect and support eAccelerator, Turck MMCache, APC, and XCache, but
01373 these should not be used if the wiki will be running on multiple application servers.
01374 <br/><br/>
01375 DBA (Berkeley-style DB) is generally slower than using no cache at all, and is only
01376 recommended for testing.
01377 </p>
01378 </div>
01379
01380 <h2>E-mail, e-mail notification and authentication setup</h2>
01381
01382 <div class="config-section">
01383 <div class="config-input">
01384 <label class='column'>E-mail features (global):</label>
01385 <ul class="plain">
01386 <li><?php aField( $conf, "Email", "Enabled", "radio", "email_enabled" ); ?></li>
01387 <li><?php aField( $conf, "Email", "Disabled", "radio", "email_disabled" ); ?></li>
01388 </ul>
01389 </div>
01390 <p class="config-desc">
01391 Use this to disable all e-mail functions (password reminders, user-to-user e-mail, and e-mail notifications)
01392 if sending mail doesn't work on your server.
01393 </p>
01394
01395 <div class="config-input">
01396 <label class='column'>User-to-user e-mail:</label>
01397 <ul class="plain">
01398 <li><?php aField( $conf, "Emailuser", "Enabled", "radio", "emailuser_enabled" ); ?></li>
01399 <li><?php aField( $conf, "Emailuser", "Disabled", "radio", "emailuser_disabled" ); ?></li>
01400 </ul>
01401 </div>
01402 <p class="config-desc">
01403 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.
01404 </p>
01405 <div class="config-input">
01406 <label class='column'>E-mail notification about changes:</label>
01407 <ul class="plain">
01408 <li><?php aField( $conf, "Enotif", "Disabled", "radio", "enotif_disabled" ); ?></li>
01409 <li><?php aField( $conf, "Enotif", "Enabled for changes to user discussion pages only", "radio", "enotif_usertalk" ); ?></li>
01410 <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>
01411 </ul>
01412 </div>
01413 <div class="config-desc">
01414 <p>
01415 For this feature to work, an e-mail address must be present for the user account, and the notification
01416 options in the user's preferences must be enabled. Also note the
01417 authentication option below. When testing the feature, keep in mind that your own changes will never trigger notifications to be sent to yourself.</p>
01418
01419 <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>
01420 </div>
01421
01422 <div class="config-input">
01423 <label class='column'>E-mail address authentication:</label>
01424 <ul class="plain">
01425 <li><?php aField( $conf, "Eauthent", "Disabled", "radio", "eauthent_disabled" ); ?></li>
01426 <li><?php aField( $conf, "Eauthent", "Enabled", "radio", "eauthent_enabled" ); ?></li>
01427 </ul>
01428 </div>
01429 <div class="config-desc">
01430 <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
01431 change notification mails. Setting this option is <b>recommended</b> for public wikis because of potential abuse of the e-mail features above.</p>
01432 </div>
01433
01434 </div>
01435
01436 <h2>Database config</h2>
01437
01438 <div class="config-section">
01439 <div class="config-input">
01440 <label class='column'>Database type:</label>
01441 <?php
01442 if (isset($errs['DBpicktype'])) {
01443 print "\t<span class='error'>" . htmlspecialchars( $errs['DBpicktype'] ) . "</span>\n";
01444 }
01445 ?>
01446 <ul class='plain'><?php
01447 database_picker($conf);
01448 ?></ul>
01449 </div>
01450
01451 <div class="config-input" style="clear:left">
01452 <?php aField( $conf, "DBserver", "Database host:" ); ?>
01453 </div>
01454 <p class="config-desc">
01455 If your database server isn't on your web server, enter the name or IP address here.
01456 </p>
01457
01458 <div class="config-input"><?php aField( $conf, "DBname", "Database name:" ); ?></div>
01459 <div class="config-input"><?php aField( $conf, "DBuser", "DB username:" ); ?></div>
01460 <div class="config-input"><?php aField( $conf, "DBpassword", "DB password:", "password" ); ?></div>
01461 <div class="config-input"><?php aField( $conf, "DBpassword2", "DB password confirm:", "password" ); ?></div>
01462 <p class="config-desc">
01463 If you only have a single user account and database available,
01464 enter those here. If you have database root access (see below)
01465 you can specify new accounts/databases to be created. This account
01466 will not be created if it pre-exists. If this is the case, ensure that it
01467 has SELECT, INSERT, UPDATE, and DELETE permissions on the MediaWiki database.
01468 </p>
01469
01470 <div class="config-input">
01471 <label class="column">Superuser account:</label>
01472 <input type="checkbox" name="useroot" id="useroot" <?php if( $useRoot ) { ?>checked="checked" <?php } ?> />
01473 <label for="useroot">Use superuser account</label>
01474 </div>
01475 <div class="config-input"><?php aField( $conf, "RootUser", "Superuser name:", "text" ); ?></div>
01476 <div class="config-input"><?php aField( $conf, "RootPW", "Superuser password:", "password" ); ?></div>
01477
01478 <p class="config-desc">
01479 If the database user specified above does not exist, or does not have access to create
01480 the database (if needed) or tables within it, please check the box and provide details
01481 of a superuser account, such as <strong>root</strong>, which does.
01482 </p>
01483
01484 <?php database_switcher('mysql'); ?>
01485 <div class="config-input"><?php aField( $conf, "DBprefix", "Database table prefix:" ); ?></div>
01486 <div class="config-desc">
01487 <p>If you need to share one database between multiple wikis, or
01488 between MediaWiki and another web application, you may choose to
01489 add a prefix to all the table names to avoid conflicts.</p>
01490
01491 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
01492 </div>
01493
01494 <div class="config-input"><label class="column">Storage Engine</label>
01495 <div>Select one:</div>
01496 <ul class="plain">
01497 <li><?php aField( $conf, "DBengine", "InnoDB", "radio", "InnoDB" ); ?></li>
01498 <li><?php aField( $conf, "DBengine", "MyISAM", "radio", "MyISAM" ); ?></li>
01499 </ul>
01500 </div>
01501 <p class="config-desc">
01502 InnoDB is best for public web installations, since it has good concurrency
01503 support. MyISAM may be faster in single-user installations. MyISAM databases
01504 tend to get corrupted more often than InnoDB databases.
01505 </p>
01506 <div class="config-input"><label class="column">Database character set</label>
01507 <div>Select one:</div>
01508 <ul class="plain">
01509 <li><?php aField( $conf, "DBschema", "MySQL 4.1/5.0 binary", "radio", "mysql5-binary" ); ?></li>
01510 <li><?php aField( $conf, "DBschema", "MySQL 4.1/5.0 UTF-8", "radio", "mysql5" ); ?></li>
01511 <li><?php aField( $conf, "DBschema", "MySQL 4.0 backwards-compatible UTF-8", "radio", "mysql4" ); ?></li>
01512 </ul>
01513 </div>
01514 <p class="config-desc">
01515 This option is ignored on upgrade, the same character set will be kept.
01516 <br/><br/>
01517 <b>WARNING:</b> If you use <b>backwards-compatible UTF-8</b> on MySQL 4.1+, and subsequently back up the database with <tt>mysqldump</tt>, it may destroy all non-ASCII characters, irreversibly corrupting your backups!.
01518 <br/><br/>
01519 In <b>binary mode</b>, MediaWiki stores UTF-8 text to the database in binary fields. This is more efficient than MySQL's UTF-8 mode, and allows you to use the full range of Unicode characters. In <b>UTF-8 mode</b>, MySQL will know what character set your data is in, and can present and convert it appropriately, but it won't let you store characters above the <a target="_blank" href="http://en.wikipedia.org/wiki/Mapping_of_Unicode_character_planes">Basic Multilingual Plane</a>.
01520 </p>
01521 </fieldset>
01522
01523 <?php database_switcher('postgres'); ?>
01524 <div class="config-input"><?php aField( $conf, "DBport", "Database port:" ); ?></div>
01525 <div class="config-input"><?php aField( $conf, "DBmwschema", "Schema for mediawiki:" ); ?></div>
01526 <div class="config-input"><?php aField( $conf, "DBts2schema", "Schema for tsearch2:" ); ?></div>
01527 <div class="config-desc">
01528 <p>The username specified above (at "DB username") will have its search path set to the above schemas,
01529 so it is recommended that you create a new user. The above schemas are generally correct:
01530 only change them if you are sure you need to.</p>
01531 </div>
01532 </fieldset>
01533
01534 <?php database_switcher('sqlite'); ?>
01535 <div class="config-desc">
01536 <b>NOTE:</b> SQLite only uses the <i>Database name</i> setting above, the user, password and root settings are ignored.
01537 </div>
01538 <div class="config-input"><?php
01539 aField( $conf, "SQLiteDataDir", "SQLite data directory:" );
01540 ?></div>
01541 <div class="config-desc">
01542 <p>SQLite stores table data into files in the filesystem.
01543 If you do not provide an explicit path, a "data" directory in
01544 the parent of your document root will be used.</p>
01545
01546 <p>This directory must exist and be writable by the web server.</p>
01547 </div>
01548 </fieldset>
01549
01550 <?php database_switcher('mssql'); ?>
01551 <div class="config-input"><?php
01552 aField( $conf, "DBprefix2", "Database table prefix:" );
01553 ?></div>
01554 <div class="config-desc">
01555 <p>If you need to share one database between multiple wikis, or
01556 between MediaWiki and another web application, you may choose to
01557 add a prefix to all the table names to avoid conflicts.</p>
01558
01559 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
01560 </div>
01561 </fieldset>
01562
01563 <?php database_switcher('ibm_db2'); ?>
01564 <div class="config-input"><?php
01565 aField( $conf, "DBport_db2", "Database port:" );
01566 ?></div>
01567 <div class="config-input"><?php
01568 aField( $conf, "DBmwschema", "Schema for mediawiki:" );
01569 ?></div>
01570 <div>Select one:</div>
01571 <ul class="plain">
01572 <li><?php aField( $conf, "DBcataloged", "Cataloged (DB2 installed locally)", "radio", "cataloged" ); ?></li>
01573 <li><?php aField( $conf, "DBcataloged", "Uncataloged (remote DB2 through ODBC)", "radio", "uncataloged" ); ?></li>
01574 </ul>
01575 <div class="config-desc">
01576 <p>If you need to share one database between multiple wikis, or
01577 between MediaWiki and another web application, you may specify
01578 a different schema to avoid conflicts.</p>
01579 </div>
01580 </fieldset>
01581
01582 <div class="config-input" style="padding:2em 0 3em">
01583 <label class='column'> </label>
01584 <input type="submit" value="Install MediaWiki!" class="btn-install" />
01585 </div>
01586 </div>
01587 </form>
01588 <script type="text/javascript">
01589 window.onload = toggleDBarea( <?php echo Xml::encodeJsVar( $conf->DBtype ); ?>,
01590 <?php
01591 ## If they passed in a root user name, don't populate it on page load
01592 echo strlen(importPost('RootUser', '')) ? 0 : 1;
01593 ?>);
01594 </script>
01595 <?php
01596 }
01597
01598
01599 function writeSuccessMessage() {
01600 $script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php';
01601 if ( wfIniGetBool( 'safe_mode' ) && !ini_get( 'open_basedir' ) ) {
01602 echo <<<EOT
01603 <div class="success-box">
01604 <p>Installation successful!</p>
01605 <p>To complete the installation, please do the following:
01606 <ol>
01607 <li>Download config/LocalSettings.php with your FTP client or file manager</li>
01608 <li>Upload it to the parent directory</li>
01609 <li>Delete config/LocalSettings.php</li>
01610 <li>Start using <a href='../$script'>your wiki</a>!
01611 </ol>
01612 <p>If you are in a shared hosting environment, do <strong>not</strong> just move LocalSettings.php
01613 remotely. LocalSettings.php is currently owned by the user your webserver is running under,
01614 which means that anyone on the same server can read your database password! Downloading
01615 it and uploading it again will hopefully change the ownership to a user ID specific to you.</p>
01616 </div>
01617 EOT;
01618 } else {
01619 echo <<<EOT
01620 <div class="success-box">
01621 <p>
01622 <span class="success-message">Installation successful!</span>
01623 Move the <tt>config/LocalSettings.php</tt> file to the parent directory, then follow
01624 <a href="../$script"> this link</a> to your wiki.</p>
01625 <p>You should change file permissions for <tt>LocalSettings.php</tt> as required to
01626 prevent other users on the server reading passwords and altering configuration data.</p>
01627 </div>
01628 EOT;
01629 }
01630 }
01631
01632
01633 function escapePhpString( $string ) {
01634 if ( is_array( $string ) || is_object( $string ) ) {
01635 return false;
01636 }
01637 return strtr( $string,
01638 array(
01639 "\n" => "\\n",
01640 "\r" => "\\r",
01641 "\t" => "\\t",
01642 "\\" => "\\\\",
01643 "\$" => "\\\$",
01644 "\"" => "\\\""
01645 ));
01646 }
01647
01648 function writeLocalSettings( $conf ) {
01649 $conf->PasswordSender = $conf->EmergencyContact;
01650 $magic = ($conf->ImageMagick ? "" : "# ");
01651 $convert = ($conf->ImageMagick ? $conf->ImageMagick : "/usr/bin/convert" );
01652 $rights = ($conf->RightsUrl) ? "" : "# ";
01653 $hashedUploads = $conf->safeMode ? '' : '# ';
01654
01655 if ( $conf->ShellLocale ) {
01656 $locale = '';
01657 } else {
01658 $locale = '# ';
01659 $conf->ShellLocale = 'en_US.UTF-8';
01660 }
01661
01662 switch ( $conf->Shm ) {
01663 case 'memcached':
01664 $cacheType = 'CACHE_MEMCACHED';
01665 $mcservers = var_export( $conf->MCServerArray, true );
01666 break;
01667 case 'turck':
01668 case 'xcache':
01669 case 'apc':
01670 case 'eaccel':
01671 $cacheType = 'CACHE_ACCEL';
01672 $mcservers = 'array()';
01673 break;
01674 case 'dba':
01675 $cacheType = 'CACHE_DBA';
01676 $mcservers = 'array()';
01677 break;
01678 default:
01679 $cacheType = 'CACHE_NONE';
01680 $mcservers = 'array()';
01681 }
01682
01683 if ( $conf->Email == 'email_enabled' ) {
01684 $enableemail = 'true';
01685 $enableuseremail = ( $conf->Emailuser == 'emailuser_enabled' ) ? 'true' : 'false' ;
01686 $eauthent = ( $conf->Eauthent == 'eauthent_enabled' ) ? 'true' : 'false' ;
01687 switch ( $conf->Enotif ) {
01688 case 'enotif_usertalk':
01689 $enotifusertalk = 'true';
01690 $enotifwatchlist = 'false';
01691 break;
01692 case 'enotif_allpages':
01693 $enotifusertalk = 'true';
01694 $enotifwatchlist = 'true';
01695 break;
01696 default:
01697 $enotifusertalk = 'false';
01698 $enotifwatchlist = 'false';
01699 }
01700 } else {
01701 $enableuseremail = 'false';
01702 $enableemail = 'false';
01703 $eauthent = 'false';
01704 $enotifusertalk = 'false';
01705 $enotifwatchlist = 'false';
01706 }
01707
01708 $file = @fopen( "/dev/urandom", "r" );
01709 if ( $file ) {
01710 $secretKey = bin2hex( fread( $file, 32 ) );
01711 fclose( $file );
01712 } else {
01713 $secretKey = "";
01714 for ( $i=0; $i<8; $i++ ) {
01715 $secretKey .= dechex(mt_rand(0, 0x7fffffff));
01716 }
01717 print "<li>Warning: \$wgSecretKey key is insecure, generated with mt_rand(). Consider changing it manually.</li>\n";
01718 }
01719
01720 # Add slashes to strings for double quoting
01721 $slconf = wfArrayMap( "escapePhpString", get_object_vars( $conf ) );
01722 if( $conf->License == 'gfdl1_2' || $conf->License == 'pd' || $conf->License == 'gfdl1_3' ) {
01723 # Needs literal string interpolation for the current style path
01724 $slconf['RightsIcon'] = $conf->RightsIcon;
01725 }
01726
01727 if( $conf->DBtype == 'mysql' ) {
01728 $dbsettings =
01729 "# MySQL specific settings
01730 \$wgDBprefix = \"{$slconf['DBprefix']}\";
01731
01732 # MySQL table options to use during installation or update
01733 \$wgDBTableOptions = \"{$slconf['DBTableOptions']}\";
01734
01735 # Experimental charset support for MySQL 4.1/5.0.
01736 \$wgDBmysql5 = {$conf->DBmysql5};";
01737 } elseif( $conf->DBtype == 'postgres' ) {
01738 $dbsettings =
01739 "# Postgres specific settings
01740 \$wgDBport = \"{$slconf['DBport']}\";
01741 \$wgDBmwschema = \"{$slconf['DBmwschema']}\";
01742 \$wgDBts2schema = \"{$slconf['DBts2schema']}\";";
01743 } elseif( $conf->DBtype == 'sqlite' ) {
01744 $dbsettings =
01745 "# SQLite-specific settings
01746 \$wgSQLiteDataDir = \"{$slconf['SQLiteDataDir']}\";";
01747 } elseif( $conf->DBtype == 'mssql' ) {
01748 $dbsettings =
01749 "# MSSQL specific settings
01750 \$wgDBprefix = \"{$slconf['DBprefix2']}\";";
01751 } elseif( $conf->DBtype == 'ibm_db2' ) {
01752 $dbsettings =
01753 "# DB2 specific settings
01754 \$wgDBport_db2 = \"{$slconf['DBport_db2']}\";
01755 \$wgDBmwschema = \"{$slconf['DBmwschema']}\";
01756 \$wgDBcataloged = \"{$slconf['DBcataloged']}\";";
01757 } else {
01758
01759 $dbsettings = '';
01760 }
01761
01762
01763 $localsettings = "
01764 # This file was automatically generated by the MediaWiki installer.
01765 # If you make manual changes, please keep track in case you need to
01766 # recreate them later.
01767 #
01768 # See includes/DefaultSettings.php for all configurable settings
01769 # and their default values, but don't forget to make changes in _this_
01770 # file, not there.
01771 #
01772 # Further documentation for configuration settings may be found at:
01773 # http://www.mediawiki.org/wiki/Manual:Configuration_settings
01774
01775 # If you customize your file layout, set \$IP to the directory that contains
01776 # the other MediaWiki files. It will be used as a base to locate files.
01777 if( defined( 'MW_INSTALL_PATH' ) ) {
01778 \$IP = MW_INSTALL_PATH;
01779 } else {
01780 \$IP = dirname( __FILE__ );
01781 }
01782
01783 \$path = array( \$IP, \"\$IP/includes\", \"\$IP/languages\" );
01784 set_include_path( implode( PATH_SEPARATOR, \$path ) . PATH_SEPARATOR . get_include_path() );
01785
01786 require_once( \"\$IP/includes/DefaultSettings.php\" );
01787
01788 # If PHP's memory limit is very low, some operations may fail.
01789 " . ($conf->raiseMemory ? '' : '# ' ) . "ini_set( 'memory_limit', '20M' );" . "
01790
01791 if ( \$wgCommandLineMode ) {
01792 if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
01793 die( \"This script must be run from the command line\\n\" );
01794 }
01795 }
01796 ## Uncomment this to disable output compression
01797 # \$wgDisableOutputCompression = true;
01798
01799 \$wgSitename = \"{$slconf['Sitename']}\";
01800
01801 ## The URL base path to the directory containing the wiki;
01802 ## defaults for all runtime URL paths are based off of this.
01803 ## For more information on customizing the URLs please see:
01804 ## http://www.mediawiki.org/wiki/Manual:Short_URL
01805 \$wgScriptPath = \"{$slconf['ScriptPath']}\";
01806 \$wgScriptExtension = \"{$slconf['ScriptExtension']}\";
01807
01808 ## UPO means: this is also a user preference option
01809
01810 \$wgEnableEmail = $enableemail;
01811 \$wgEnableUserEmail = $enableuseremail; # UPO
01812
01813 \$wgEmergencyContact = \"{$slconf['EmergencyContact']}\";
01814 \$wgPasswordSender = \"{$slconf['PasswordSender']}\";
01815
01816 \$wgEnotifUserTalk = $enotifusertalk; # UPO
01817 \$wgEnotifWatchlist = $enotifwatchlist; # UPO
01818 \$wgEmailAuthentication = $eauthent;
01819
01820 ## Database settings
01821 \$wgDBtype = \"{$slconf['DBtype']}\";
01822 \$wgDBserver = \"{$slconf['DBserver']}\";
01823 \$wgDBname = \"{$slconf['DBname']}\";
01824 \$wgDBuser = \"{$slconf['DBuser']}\";
01825 \$wgDBpassword = \"{$slconf['DBpassword']}\";
01826
01827 {$dbsettings}
01828
01829 ## Shared memory settings
01830 \$wgMainCacheType = $cacheType;
01831 \$wgMemCachedServers = $mcservers;
01832
01833 ## To enable image uploads, make sure the 'images' directory
01834 ## is writable, then set this to true:
01835 \$wgEnableUploads = false;
01836 {$magic}\$wgUseImageMagick = true;
01837 {$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
01838
01839 ## If you use ImageMagick (or any other shell command) on a
01840 ## Linux server, this will need to be set to the name of an
01841 ## available UTF-8 locale
01842 {$locale}\$wgShellLocale = \"{$slconf['ShellLocale']}\";
01843
01844 ## If you want to use image uploads under safe mode,
01845 ## create the directories images/archive, images/thumb and
01846 ## images/temp, and make them all writable. Then uncomment
01847 ## this, if it's not already uncommented:
01848 {$hashedUploads}\$wgHashedUploadDirectory = false;
01849
01850 ## If you have the appropriate support software installed
01851 ## you can enable inline LaTeX equations:
01852 \$wgUseTeX = false;
01853
01854 \$wgLocalInterwiki = strtolower( \$wgSitename );
01855
01856 \$wgLanguageCode = \"{$slconf['LanguageCode']}\";
01857
01858 \$wgSecretKey = \"$secretKey\";
01859
01860 ## Default skin: you can change the default skin. Use the internal symbolic
01861 ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook':
01862 \$wgDefaultSkin = 'monobook';
01863
01864 ## For attaching licensing metadata to pages, and displaying an
01865 ## appropriate copyright notice / icon. GNU Free Documentation
01866 ## License and Creative Commons licenses are supported so far.
01867 {$rights}\$wgEnableCreativeCommonsRdf = true;
01868 \$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright
01869 \$wgRightsUrl = \"{$slconf['RightsUrl']}\";
01870 \$wgRightsText = \"{$slconf['RightsText']}\";
01871 \$wgRightsIcon = \"{$slconf['RightsIcon']}\";
01872 # \$wgRightsCode = \"{$slconf['RightsCode']}\"; # Not yet used
01873
01874 \$wgDiff3 = \"{$slconf['diff3']}\";
01875
01876 # When you make changes to this configuration file, this will make
01877 # sure that cached pages are cleared.
01878 \$wgCacheEpoch = max( \$wgCacheEpoch, gmdate( 'YmdHis', @filemtime( __FILE__ ) ) );
01879 "; ## End of setting the $localsettings string
01880
01881
01882
01883 return str_replace( "\r\n", "\n", $localsettings );
01884 }
01885
01886 function dieout( $text ) {
01887 global $mainListOpened;
01888 if( $mainListOpened ) echo( "</ul>" );
01889 if( $text != '' && substr( $text, 0, 2 ) != '<p' && substr( $text, 0, 2 ) != '<h' ){
01890 echo "<p>$text</p>\n";
01891 } else {
01892 echo $text;
01893 }
01894 die( "\n\n</div>\n</div>\n</div>\n</div>\n</body>\n</html>" );
01895 }
01896
01897 function importVar( &$var, $name, $default = "" ) {
01898 if( isset( $var[$name] ) ) {
01899 $retval = $var[$name];
01900 if ( get_magic_quotes_gpc() ) {
01901 $retval = stripslashes( $retval );
01902 }
01903 } else {
01904 $retval = $default;
01905 }
01906 taint( $retval );
01907 return $retval;
01908 }
01909
01910 function importPost( $name, $default = "" ) {
01911 return importVar( $_POST, $name, $default );
01912 }
01913
01914 function importCheck( $name ) {
01915 return isset( $_POST[$name] );
01916 }
01917
01918 function importRequest( $name, $default = "" ) {
01919 return importVar( $_REQUEST, $name, $default );
01920 }
01921
01922 function aField( &$conf, $field, $text, $type = "text", $value = "", $onclick = '' ) {
01923 static $radioCount = 0;
01924 if( $type != "" ) {
01925 $xtype = "type=\"$type\"";
01926 } else {
01927 $xtype = "";
01928 }
01929
01930 $id = $field;
01931 $nolabel = ($type == "radio") || ($type == "hidden");
01932
01933 if ($type == 'radio')
01934 $id .= $radioCount++;
01935
01936 if( !$nolabel ) {
01937 echo "<label class='column' for=\"$id\">$text</label>";
01938 }
01939
01940 if( $type == "radio" && $value == $conf->$field ) {
01941 $checked = "checked='checked'";
01942 } else {
01943 $checked = "";
01944 }
01945 echo "<input $xtype name=\"$field\" id=\"$id\" class=\"iput-$type\" $checked ";
01946 if ($onclick) {
01947 echo " onclick='toggleDBarea(\"$value\",1)' " ;
01948 }
01949 echo "value=\"";
01950 if( $type == "radio" ) {
01951 echo htmlspecialchars( $value );
01952 } else {
01953 echo htmlspecialchars( $conf->$field );
01954 }
01955
01956
01957 echo "\" />";
01958 if( $nolabel ) {
01959 echo "<label for=\"$id\">$text</label>";
01960 }
01961
01962 global $errs;
01963 if(isset($errs[$field])) {
01964 echo "<span class='error'>" . htmlspecialchars( $errs[$field] ) . "</span>\n";
01965 }
01966 }
01967
01968 function getLanguageList() {
01969 global $wgLanguageNames, $IP;
01970 if( !isset( $wgLanguageNames ) ) {
01971 require_once( "$IP/languages/Names.php" );
01972 }
01973
01974 $codes = array();
01975
01976 $d = opendir( "../languages/messages" );
01977
01978 if (!$d)
01979 $d = opendir( "languages/messages");
01980 while( false !== ($f = readdir( $d ) ) ) {
01981 $m = array();
01982 if( preg_match( '/Messages([A-Z][a-z_]+)\.php$/', $f, $m ) ) {
01983 $code = str_replace( '_', '-', strtolower( $m[1] ) );
01984 if( isset( $wgLanguageNames[$code] ) ) {
01985 $name = $code . ' - ' . $wgLanguageNames[$code];
01986 } else {
01987 $name = $code;
01988 }
01989 $codes[$code] = $name;
01990 }
01991 }
01992 closedir( $d );
01993 ksort( $codes );
01994 return $codes;
01995 }
01996
01997 #Check for location of an executable
01998 # @param string $loc single location to check
01999 # @param array $names filenames to check for.
02000 # @param mixed $versioninfo array of details to use when checking version, use false for no version checking
02001 function locate_executable($loc, $names, $versioninfo = false) {
02002 if (!is_array($names))
02003 $names = array($names);
02004
02005 foreach ($names as $name) {
02006 $command = "$loc".DIRECTORY_SEPARATOR."$name";
02007 if (@file_exists($command)) {
02008 if (!$versioninfo)
02009 return $command;
02010
02011 $file = str_replace('$1', $command, $versioninfo[0]);
02012 if (strstr(`$file`, $versioninfo[1]) !== false)
02013 return $command;
02014 }
02015 }
02016 return false;
02017 }
02018
02019 # Test a memcached server
02020 function testMemcachedServer( $server ) {
02021 $hostport = explode(":", $server);
02022 $errstr = false;
02023 $fp = false;
02024 if ( !function_exists( 'fsockopen' ) ) {
02025 $errstr = "Can't connect to memcached, fsockopen() not present";
02026 }
02027 if ( !$errstr && count( $hostport ) != 2 ) {
02028 $errstr = 'Please specify host and port';
02029 }
02030 if ( !$errstr ) {
02031 list( $host, $port ) = $hostport;
02032 $errno = 0;
02033 $fsockerr = '';
02034
02035 $fp = @fsockopen( $host, $port, $errno, $fsockerr, 1.0 );
02036 if ( $fp === false ) {
02037 $errstr = "Cannot connect to memcached on $host:$port : $fsockerr";
02038 }
02039 }
02040 if ( !$errstr ) {
02041 $command = "version\r\n";
02042 $bytes = fwrite( $fp, $command );
02043 if ( $bytes != strlen( $command ) ) {
02044 $errstr = "Cannot write to memcached socket on $host:$port";
02045 }
02046 }
02047 if ( !$errstr ) {
02048 $expected = "VERSION ";
02049 $response = fread( $fp, strlen( $expected ) );
02050 if ( $response != $expected ) {
02051 $errstr = "Didn't get correct memcached response from $host:$port";
02052 }
02053 }
02054 if ( $fp ) {
02055 fclose( $fp );
02056 }
02057 if ( !$errstr ) {
02058 echo "<li>Connected to memcached on " . htmlspecialchars( "$host:$port" ) ." successfully</li>";
02059 }
02060 return $errstr;
02061 }
02062
02063 function database_picker($conf) {
02064 global $ourdb;
02065 print "\n";
02066 foreach(array_keys($ourdb) as $db) {
02067 if ($ourdb[$db]['havedriver']) {
02068 print "\t<li>";
02069 aField( $conf, "DBtype", $ourdb[$db]['fullname'], 'radio', $db, 'onclick');
02070 print "</li>\n";
02071 }
02072 }
02073 print "\n\t";
02074 }
02075
02076 function database_switcher($db) {
02077 global $ourdb;
02078 $color = $ourdb[$db]['bgcolor'];
02079 $full = $ourdb[$db]['fullname'];
02080 print "<fieldset id='$db'><legend>$full specific options</legend>\n";
02081 }
02082
02083 function printListItem( $item ) {
02084 print "<li>$item</li>";
02085 }
02086
02087 # Determine a suitable value for $wgShellLocale
02088 function getShellLocale( $wikiLang ) {
02089 # Give up now if we're in safe mode or open_basedir
02090 # It's theoretically possible but tricky to work with
02091 if ( wfIniGetBool( "safe_mode" ) || ini_get( 'open_basedir' ) ) {
02092 return false;
02093 }
02094
02095 $os = php_uname( 's' );
02096 $supported = array( 'Linux', 'SunOS', 'HP-UX' ); # Tested these
02097 if ( !in_array( $os, $supported ) ) {
02098 return false;
02099 }
02100
02101 # Get a list of available locales
02102 $lines = $ret = false;
02103 exec( '/usr/bin/locale -a', $lines, $ret );
02104 if ( $ret ) {
02105 return false;
02106 }
02107
02108 $lines = wfArrayMap( 'trim', $lines );
02109 $candidatesByLocale = array();
02110 $candidatesByLang = array();
02111 foreach ( $lines as $line ) {
02112 if ( $line === '' ) {
02113 continue;
02114 }
02115 if ( !preg_match( '/^([a-zA-Z]+)(_[a-zA-Z]+|)\.(utf8|UTF-8)(@[a-zA-Z_]*|)$/i', $line, $m ) ) {
02116 continue;
02117 }
02118 list( $all, $lang, $territory, $charset, $modifier ) = $m;
02119 $candidatesByLocale[$m[0]] = $m;
02120 $candidatesByLang[$lang][] = $m;
02121 }
02122
02123 # Try the current value of LANG
02124 if ( isset( $candidatesByLocale[ getenv( 'LANG' ) ] ) ) {
02125 return getenv( 'LANG' );
02126 }
02127
02128 # Try the most common ones
02129 $commonLocales = array( 'en_US.UTF-8', 'en_US.utf8', 'de_DE.UTF-8', 'de_DE.utf8' );
02130 foreach ( $commonLocales as $commonLocale ) {
02131 if ( isset( $candidatesByLocale[$commonLocale] ) ) {
02132 return $commonLocale;
02133 }
02134 }
02135
02136 # Is there an available locale in the Wiki's language?
02137 if ( isset( $candidatesByLang[$wikiLang] ) ) {
02138 $m = reset( $candidatesByLang[$wikiLang] );
02139 return $m[0];
02140 }
02141
02142 # Are there any at all?
02143 if ( count( $candidatesByLocale ) ) {
02144 $m = reset( $candidatesByLocale );
02145 return $m[0];
02146 }
02147
02148 # Give up
02149 return false;
02150 }
02151
02152 function wfArrayMap( $function, $input ) {
02153 $ret = array_map( $function, $input );
02154 foreach ( $ret as $key => $value ) {
02155 $taint = istainted( $input[$key] );
02156 if ( $taint ) {
02157 taint( $ret[$key], $taint );
02158 }
02159 }
02160 return $ret;
02161 }
02162
02163 ?>
02164
02165 <div class="license">
02166 <hr/>
02167 <p>This program is free software; you can redistribute it and/or modify
02168 it under the terms of the GNU General Public License as published by
02169 the Free Software Foundation; either version 2 of the License, or
02170 (at your option) any later version.</p>
02171
02172 <p>This program is distributed in the hope that it will be useful,
02173 but WITHOUT ANY WARRANTY; without even the implied warranty of
02174 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
02175 GNU General Public License for more details.</p>
02176
02177 <p>You should have received <a href="../COPYING">a copy of the GNU General Public License</a>
02178 along with this program; if not, write to the Free Software
02179 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
02180 or <a href="http://www.gnu.org/copyleft/gpl.html">read it online</a></p>
02181 </div>
02182
02183 </div></div></div>
02184
02185
02186 <div id="column-one">
02187 <div class="portlet" id="p-logo">
02188 <a style="background-image: url(../skins/common/images/mediawiki.png);"
02189 href="../"
02190 title="Main Page"></a>
02191 </div>
02192 <script type="text/javascript"> if (window.isMSIE55) fixalpha(); </script>
02193 <div class='portlet'><div class='pBody'>
02194 <ul>
02195 <li><a href="../README">Readme</a></li>
02196 <li><a href="../RELEASE-NOTES">Release notes</a></li>
02197 <li><a href="../docs/">Documentation</a></li>
02198 <li><a href="http://www.mediawiki.org/wiki/Help:Contents">User's Guide</a></li>
02199 <li><a href="http://www.mediawiki.org/wiki/Manual:Contents">Administrator's Guide</a></li>
02200 <li><a href="http://www.mediawiki.org/wiki/Manual:FAQ">FAQ</a></li>
02201 </ul>
02202 <p style="font-size:90%;margin-top:1em">MediaWiki is Copyright © 2001-2009 by Magnus Manske, Brion Vibber,
02203 Lee Daniel Crocker, Tim Starling, Erik Möller, Gabriel Wicke, Ævar Arnfjörð Bjarmason, Niklas Laxström,
02204 Domas Mituzas, Rob Church, Yuri Astrakhan, Aryeh Gregor, Aaron Schulz and others.</p>
02205 </div></div>
02206 </div>
02207
02208 </div>
02209
02210 </body>
02211 </html>