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