Index: trunk/phase3/config/Installer.php |
— | — | @@ -0,0 +1,2330 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +# MediaWiki web-based config/installation |
| 5 | +# Copyright (C) 2004 Brion Vibber <brion@pobox.com>, 2006 Rob Church <robchur@gmail.com> |
| 6 | +# http://www.mediawiki.org/ |
| 7 | +# |
| 8 | +# This program is free software; you can redistribute it and/or modify |
| 9 | +# it under the terms of the GNU General Public License as published by |
| 10 | +# the Free Software Foundation; either version 2 of the License, or |
| 11 | +# (at your option) any later version. |
| 12 | +# |
| 13 | +# This program is distributed in the hope that it will be useful, |
| 14 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | +# GNU General Public License for more details. |
| 17 | +# |
| 18 | +# You should have received a copy of the GNU General Public License along |
| 19 | +# with this program; if not, write to the Free Software Foundation, Inc., |
| 20 | +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 21 | +# http://www.gnu.org/copyleft/gpl.html |
| 22 | + |
| 23 | +if( !defined( 'MEDIAWIKI_INSTALL' ) ) { |
| 24 | + die( 'Not an entry point.' ); |
| 25 | +} |
| 26 | + |
| 27 | +error_reporting( E_ALL | E_STRICT ); |
| 28 | +header( "Content-type: text/html; charset=utf-8" ); |
| 29 | +@ini_set( "display_errors", true ); |
| 30 | + |
| 31 | +# In case of errors, let output be clean. |
| 32 | +$wgRequestTime = microtime( true ); |
| 33 | + |
| 34 | +// Run version checks before including other files |
| 35 | +// so people don't see a scary parse error. |
| 36 | +require_once( "$IP/install-utils.inc" ); |
| 37 | +install_version_checks(); |
| 38 | + |
| 39 | +require_once( "$IP/includes/Defines.php" ); |
| 40 | +require_once( "$IP/includes/DefaultSettings.php" ); |
| 41 | +require_once( "$IP/includes/AutoLoader.php" ); |
| 42 | +require_once( "$IP/includes/MagicWord.php" ); |
| 43 | +require_once( "$IP/includes/Namespace.php" ); |
| 44 | +require_once( "$IP/includes/ProfilerStub.php" ); |
| 45 | +require_once( "$IP/includes/GlobalFunctions.php" ); |
| 46 | +require_once( "$IP/includes/Hooks.php" ); |
| 47 | +require_once( "$IP/includes/Exception.php" ); |
| 48 | + |
| 49 | +# If we get an exception, the user needs to know |
| 50 | +# all the details |
| 51 | +$wgShowExceptionDetails = true; |
| 52 | +$wgShowSQLErrors = true; |
| 53 | +wfInstallExceptionHandler(); |
| 54 | +## Databases we support: |
| 55 | + |
| 56 | +$ourdb = array(); |
| 57 | +$ourdb['mysql']['fullname'] = 'MySQL'; |
| 58 | +$ourdb['mysql']['havedriver'] = 0; |
| 59 | +$ourdb['mysql']['compile'] = 'mysql'; |
| 60 | +$ourdb['mysql']['bgcolor'] = '#ffe5a7'; |
| 61 | +$ourdb['mysql']['rootuser'] = 'root'; |
| 62 | + |
| 63 | +$ourdb['postgres']['fullname'] = 'PostgreSQL'; |
| 64 | +$ourdb['postgres']['havedriver'] = 0; |
| 65 | +$ourdb['postgres']['compile'] = 'pgsql'; |
| 66 | +$ourdb['postgres']['bgcolor'] = '#aaccff'; |
| 67 | +$ourdb['postgres']['rootuser'] = 'postgres'; |
| 68 | + |
| 69 | +$ourdb['sqlite']['fullname'] = 'SQLite'; |
| 70 | +$ourdb['sqlite']['havedriver'] = 0; |
| 71 | +$ourdb['sqlite']['compile'] = 'pdo_sqlite'; |
| 72 | +$ourdb['sqlite']['bgcolor'] = '#b1ebb1'; |
| 73 | +$ourdb['sqlite']['rootuser'] = ''; |
| 74 | + |
| 75 | +$ourdb['mssql']['fullname'] = 'MSSQL'; |
| 76 | +$ourdb['mssql']['havedriver'] = 0; |
| 77 | +$ourdb['mssql']['compile'] = 'mssql not ready'; # Change to 'mssql' after includes/DatabaseMssql.php added; |
| 78 | +$ourdb['mssql']['bgcolor'] = '#ffc0cb'; |
| 79 | +$ourdb['mssql']['rootuser'] = 'administrator'; |
| 80 | + |
| 81 | +$ourdb['ibm_db2']['fullname'] = 'DB2'; |
| 82 | +$ourdb['ibm_db2']['havedriver'] = 0; |
| 83 | +$ourdb['ibm_db2']['compile'] = 'ibm_db2'; |
| 84 | +$ourdb['ibm_db2']['bgcolor'] = '#ffeba1'; |
| 85 | +$ourdb['ibm_db2']['rootuser'] = 'db2admin'; |
| 86 | + |
| 87 | +$ourdb['oracle']['fullname'] = 'Oracle'; |
| 88 | +$ourdb['oracle']['havedriver'] = 0; |
| 89 | +$ourdb['oracle']['compile'] = 'oci8'; |
| 90 | +$ourdb['oracle']['bgcolor'] = '#ffeba1'; |
| 91 | +$ourdb['oracle']['rootuser'] = ''; |
| 92 | + |
| 93 | +?> |
| 94 | +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 95 | +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr"> |
| 96 | +<head> |
| 97 | + <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> |
| 98 | + <meta name="robots" content="noindex,nofollow"/> |
| 99 | + <title>MediaWiki <?php echo htmlspecialchars( $wgVersion ); ?> Installation</title> |
| 100 | + <style type="text/css"> |
| 101 | + |
| 102 | + @import "../skins/monobook/main.css"; |
| 103 | + |
| 104 | + .env-check { |
| 105 | + font-size: 90%; |
| 106 | + margin: 1em 0 1em 2.5em; |
| 107 | + } |
| 108 | + |
| 109 | + .config-section { |
| 110 | + margin-top: 2em; |
| 111 | + } |
| 112 | + |
| 113 | + .config-section label.column { |
| 114 | + clear: left; |
| 115 | + font-weight: bold; |
| 116 | + width: 13em; |
| 117 | + float: left; |
| 118 | + text-align: right; |
| 119 | + padding-right: 1em; |
| 120 | + padding-top: .2em; |
| 121 | + } |
| 122 | + |
| 123 | + .config-input { |
| 124 | + clear: left; |
| 125 | + zoom: 100%; /* IE hack */ |
| 126 | + } |
| 127 | + |
| 128 | + .config-section .config-desc { |
| 129 | + clear: left; |
| 130 | + margin: 0 0 2em 18em; |
| 131 | + padding-top: 1em; |
| 132 | + font-size: 85%; |
| 133 | + } |
| 134 | + |
| 135 | + .iput-text, .iput-password { |
| 136 | + width: 14em; |
| 137 | + margin-right: 1em; |
| 138 | + } |
| 139 | + |
| 140 | + .error { |
| 141 | + color: red; |
| 142 | + background-color: #fff; |
| 143 | + font-weight: bold; |
| 144 | + left: 1em; |
| 145 | + font-size: 100%; |
| 146 | + } |
| 147 | + |
| 148 | + .error-top { |
| 149 | + color: red; |
| 150 | + background-color: #FFF0F0; |
| 151 | + border: 2px solid red; |
| 152 | + font-size: 130%; |
| 153 | + font-weight: bold; |
| 154 | + padding: 1em 1.5em; |
| 155 | + margin: 2em 0 1em; |
| 156 | + } |
| 157 | + |
| 158 | + ul.plain { |
| 159 | + list-style-type: none; |
| 160 | + list-style-image: none; |
| 161 | + float: left; |
| 162 | + margin: 0; |
| 163 | + padding: 0; |
| 164 | + } |
| 165 | + |
| 166 | + .btn-install { |
| 167 | + font-weight: bold; |
| 168 | + font-size: 110%; |
| 169 | + padding: .2em .3em; |
| 170 | + } |
| 171 | + |
| 172 | + .license { |
| 173 | + font-size: 85%; |
| 174 | + padding-top: 3em; |
| 175 | + } |
| 176 | + |
| 177 | + span.success-message { |
| 178 | + font-weight: bold; |
| 179 | + font-size: 110%; |
| 180 | + color: green; |
| 181 | + } |
| 182 | + .success-box { |
| 183 | + font-size: 130%; |
| 184 | + } |
| 185 | + |
| 186 | + </style> |
| 187 | + <script type="text/javascript"> |
| 188 | + <!-- |
| 189 | + function hideall() { |
| 190 | + <?php foreach (array_keys($ourdb) as $db) { |
| 191 | + echo "\n var i = document.getElementById('$db'); if (i) i.style.display='none';"; |
| 192 | + } |
| 193 | + ?> |
| 194 | + |
| 195 | + } |
| 196 | + function toggleDBarea(id,defaultroot) { |
| 197 | + hideall(); |
| 198 | + var dbarea = document.getElementById(id); |
| 199 | + if (dbarea) dbarea.style.display = (dbarea.style.display == 'none') ? 'block' : 'none'; |
| 200 | + var db = document.getElementById('RootUser'); |
| 201 | + if (defaultroot) { |
| 202 | +<?php foreach (array_keys($ourdb) as $db) { |
| 203 | + echo " if (id == '$db') { db.value = '".$ourdb[$db]['rootuser']."';}\n"; |
| 204 | +}?> |
| 205 | + } |
| 206 | + } |
| 207 | + // --> |
| 208 | + </script> |
| 209 | +</head> |
| 210 | + |
| 211 | +<body> |
| 212 | +<div id="globalWrapper"> |
| 213 | +<div id="column-content"> |
| 214 | +<div id="content"> |
| 215 | +<div id="bodyContent"> |
| 216 | + |
| 217 | +<h1>MediaWiki <?php print htmlspecialchars( $wgVersion ) ?> Installation</h1> |
| 218 | + |
| 219 | +<?php |
| 220 | +$mainListOpened = false; # Is the main list (environement checking) opend ? Used by dieout |
| 221 | + |
| 222 | +/* Check for existing configurations and bug out! */ |
| 223 | + |
| 224 | +if( file_exists( "../LocalSettings.php" ) ) { |
| 225 | + $script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php'; |
| 226 | + dieout( "<p><strong>Setup has completed, <a href='../$script'>your wiki</a> is configured.</strong></p> |
| 227 | + <p>Please delete the /config directory for extra security.</p>" ); |
| 228 | +} |
| 229 | + |
| 230 | +if( file_exists( "./LocalSettings.php" ) ) { |
| 231 | + writeSuccessMessage(); |
| 232 | + dieout( '' ); |
| 233 | +} |
| 234 | + |
| 235 | +if( !is_writable( "." ) ) { |
| 236 | + dieout( "<h2>Can't write config file, aborting</h2> |
| 237 | + |
| 238 | + <p>In order to configure the wiki you have to make the <tt>config</tt> subdirectory |
| 239 | + writable by the web server. Once configuration is done you'll move the created |
| 240 | + <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can |
| 241 | + then remove the <tt>config</tt> subdirectory entirely.</p> |
| 242 | + |
| 243 | + <p>To make the directory writable on a Unix/Linux system:</p> |
| 244 | + |
| 245 | + <pre> |
| 246 | + cd <i>" . htmlspecialchars( dirname( dirname( __FILE__ ) ) ) . "</i> |
| 247 | + chmod a+w config |
| 248 | + </pre> |
| 249 | + |
| 250 | + <p>Afterwards retry to start the <a href=\"\">setup</a>.</p>" ); |
| 251 | +} |
| 252 | + |
| 253 | + |
| 254 | +require_once( "$IP/install-utils.inc" ); |
| 255 | +require_once( "$IP/maintenance/updaters.inc" ); |
| 256 | + |
| 257 | +class ConfigData { |
| 258 | + function getEncoded( $data ) { |
| 259 | + # removing latin1 support, no need... |
| 260 | + return $data; |
| 261 | + } |
| 262 | + function getSitename() { return $this->getEncoded( $this->Sitename ); } |
| 263 | + function getSysopName() { return $this->getEncoded( $this->SysopName ); } |
| 264 | + function getSysopPass() { return $this->getEncoded( $this->SysopPass ); } |
| 265 | + |
| 266 | + function setSchema( $schema, $engine ) { |
| 267 | + $this->DBschema = $schema; |
| 268 | + if ( !preg_match( '/^\w*$/', $engine ) ){ |
| 269 | + $engine = 'InnoDB'; |
| 270 | + } |
| 271 | + switch ( $this->DBschema ) { |
| 272 | + case 'mysql5': |
| 273 | + $this->DBTableOptions = "ENGINE=$engine, DEFAULT CHARSET=utf8"; |
| 274 | + $this->DBmysql5 = 'true'; |
| 275 | + break; |
| 276 | + case 'mysql5-binary': |
| 277 | + $this->DBTableOptions = "ENGINE=$engine, DEFAULT CHARSET=binary"; |
| 278 | + $this->DBmysql5 = 'true'; |
| 279 | + break; |
| 280 | + default: |
| 281 | + $this->DBTableOptions = "TYPE=$engine"; |
| 282 | + $this->DBmysql5 = 'false'; |
| 283 | + } |
| 284 | + $this->DBengine = $engine; |
| 285 | + |
| 286 | + # Set the global for use during install |
| 287 | + global $wgDBTableOptions; |
| 288 | + $wgDBTableOptions = $this->DBTableOptions; |
| 289 | + } |
| 290 | +} |
| 291 | + |
| 292 | +?> |
| 293 | + |
| 294 | +<ul> |
| 295 | + <li> |
| 296 | + <b>Don't forget security updates!</b> Keep an eye on the |
| 297 | + <a href="http://lists.wikimedia.org/mailman/listinfo/mediawiki-announce">low-traffic |
| 298 | + release announcements mailing list</a>. |
| 299 | + </li> |
| 300 | +</ul> |
| 301 | + |
| 302 | + |
| 303 | +<h2>Checking environment...</h2> |
| 304 | +<p><em>Please include all of the lines below when reporting installation problems.</em></p> |
| 305 | +<ul class="env-check"> |
| 306 | +<?php |
| 307 | +$mainListOpened = true; |
| 308 | + |
| 309 | +$endl = " |
| 310 | +"; |
| 311 | +define( 'MW_NO_OUTPUT_BUFFER', 1 ); |
| 312 | +$conf = new ConfigData; |
| 313 | + |
| 314 | +install_version_checks(); |
| 315 | +$self = 'Installer'; # Maintenance script name, to please Setup.php |
| 316 | + |
| 317 | +print "<li>PHP " . htmlspecialchars( phpversion() ) . " installed</li>\n"; |
| 318 | + |
| 319 | +error_reporting( 0 ); |
| 320 | +$phpdatabases = array(); |
| 321 | +foreach (array_keys($ourdb) as $db) { |
| 322 | + $compname = $ourdb[$db]['compile']; |
| 323 | + if( extension_loaded( $compname ) || ( mw_have_dl() && dl( "{$compname}." . PHP_SHLIB_SUFFIX ) ) ) { |
| 324 | + array_push($phpdatabases, $db); |
| 325 | + $ourdb[$db]['havedriver'] = 1; |
| 326 | + } |
| 327 | +} |
| 328 | +error_reporting( E_ALL | E_STRICT ); |
| 329 | + |
| 330 | +if (!$phpdatabases) { |
| 331 | + print "Could not find a suitable database driver!<ul>"; |
| 332 | + foreach (array_keys($ourdb) AS $db) { |
| 333 | + $comp = $ourdb[$db]['compile']; |
| 334 | + $full = $ourdb[$db]['fullname']; |
| 335 | + print "<li>For <b>$full</b>, compile PHP using <b>--with-$comp</b>, " |
| 336 | + ."or install the $comp.so module</li>\n"; |
| 337 | + } |
| 338 | + echo '</ul>'; |
| 339 | + dieout( '' ); |
| 340 | +} |
| 341 | + |
| 342 | +print "<li>Found database drivers for:"; |
| 343 | +$DefaultDBtype = ''; |
| 344 | +foreach (array_keys($ourdb) AS $db) { |
| 345 | + if ($ourdb[$db]['havedriver']) { |
| 346 | + if ( $DefaultDBtype == '' ) { |
| 347 | + $DefaultDBtype = $db; |
| 348 | + } |
| 349 | + print " ".$ourdb[$db]['fullname']; |
| 350 | + } |
| 351 | +} |
| 352 | +print "</li>\n"; |
| 353 | + |
| 354 | +if( wfIniGetBool( "register_globals" ) ) { |
| 355 | + ?> |
| 356 | + <li> |
| 357 | + <div style="font-size:110%"> |
| 358 | + <strong class="error">Warning:</strong> |
| 359 | + <strong>PHP's <tt><a href="http://php.net/register_globals">register_globals</a></tt> option is enabled. Disable it if you can.</strong> |
| 360 | + </div> |
| 361 | + MediaWiki will work, but your server is more exposed to PHP-based security vulnerabilities. |
| 362 | + </li> |
| 363 | + <?php |
| 364 | +} |
| 365 | + |
| 366 | +$fatal = false; |
| 367 | + |
| 368 | +if( wfIniGetBool( "magic_quotes_runtime" ) ) { |
| 369 | + $fatal = true; |
| 370 | + ?><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> |
| 371 | + This option corrupts data input unpredictably; you cannot install or use |
| 372 | + MediaWiki unless this option is disabled.</li> |
| 373 | + <?php |
| 374 | +} |
| 375 | + |
| 376 | +if( wfIniGetBool( "magic_quotes_sybase" ) ) { |
| 377 | + $fatal = true; |
| 378 | + ?><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> |
| 379 | + This option corrupts data input unpredictably; you cannot install or use |
| 380 | + MediaWiki unless this option is disabled.</li> |
| 381 | + <?php |
| 382 | +} |
| 383 | + |
| 384 | +if( wfIniGetBool( "mbstring.func_overload" ) ) { |
| 385 | + $fatal = true; |
| 386 | + ?><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> |
| 387 | + This option causes errors and may corrupt data unpredictably; |
| 388 | + you cannot install or use MediaWiki unless this option is disabled.</li> |
| 389 | + <?php |
| 390 | +} |
| 391 | + |
| 392 | +if( wfIniGetBool( "zend.ze1_compatibility_mode" ) ) { |
| 393 | + $fatal = true; |
| 394 | + ?><li class="error"><strong>Fatal: <a href="http://www.php.net/manual/en/ini.core.php">zend.ze1_compatibility_mode</a> is active!</strong> |
| 395 | + This option causes horrible bugs with MediaWiki; you cannot install or use |
| 396 | + MediaWiki unless this option is disabled.</li> |
| 397 | + <?php |
| 398 | +} |
| 399 | + |
| 400 | + |
| 401 | +if( $fatal ) { |
| 402 | + dieout( "Cannot install MediaWiki." ); |
| 403 | +} |
| 404 | + |
| 405 | +if( wfIniGetBool( "safe_mode" ) ) { |
| 406 | + $conf->safeMode = true; |
| 407 | + ?> |
| 408 | + <li><b class='error'>Warning:</b> <strong>PHP's |
| 409 | + <a href='http://www.php.net/features.safe-mode'>safe mode</a> is active.</strong> |
| 410 | + You may have problems caused by this, particularly if using image uploads. |
| 411 | + </li> |
| 412 | + <?php |
| 413 | +} else { |
| 414 | + $conf->safeMode = false; |
| 415 | +} |
| 416 | + |
| 417 | +$sapi = htmlspecialchars( php_sapi_name() ); |
| 418 | +print "<li>PHP server API is $sapi; "; |
| 419 | +$script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php'; |
| 420 | +if( $wgUsePathInfo ) { |
| 421 | + print "ok, using pretty URLs (<tt>$script/Page_Title</tt>)"; |
| 422 | +} else { |
| 423 | + print "using ugly URLs (<tt>$script?title=Page_Title</tt>)"; |
| 424 | +} |
| 425 | +print "</li>\n"; |
| 426 | + |
| 427 | +$conf->xml = function_exists( "utf8_encode" ); |
| 428 | +if( $conf->xml ) { |
| 429 | + print "<li>Have XML / Latin1-UTF-8 conversion support.</li>\n"; |
| 430 | +} else { |
| 431 | + dieout( "PHP's XML module is missing; the wiki requires functions in |
| 432 | + this module and won't work in this configuration. |
| 433 | + If you're running Mandrake, install the php-xml package." ); |
| 434 | +} |
| 435 | + |
| 436 | +# Check for session support |
| 437 | +if( !function_exists( 'session_name' ) ) |
| 438 | + dieout( "PHP's session module is missing. MediaWiki requires session support in order to function." ); |
| 439 | + |
| 440 | +# session.save_path doesn't *have* to be set, but if it is, and it's |
| 441 | +# not valid/writable/etc. then it can cause problems |
| 442 | +$sessionSavePath = mw_get_session_save_path(); |
| 443 | +$ssp = htmlspecialchars( $sessionSavePath ); |
| 444 | +# Warn the user if it's not set, but let them proceed |
| 445 | +if( !$sessionSavePath ) { |
| 446 | + print "<li><strong>Warning:</strong> A value for <tt>session.save_path</tt> |
| 447 | + has not been set in PHP.ini. If the default value causes problems with |
| 448 | + saving session data, set it to a valid path which is read/write/execute |
| 449 | + for the user your web server is running under.</li>"; |
| 450 | +} elseif ( is_dir( $sessionSavePath ) && is_writable( $sessionSavePath ) ) { |
| 451 | + # All good? Let the user know |
| 452 | + print "<li>Session save path (<tt>{$ssp}</tt>) appears to be valid.</li>"; |
| 453 | +} else { |
| 454 | + # Something not right? Warn the user, but let them proceed |
| 455 | + print "<li><strong>Warning:</strong> Your <tt>session.save_path</tt> value (<tt>{$ssp}</tt>) |
| 456 | + appears to be invalid or is not writable. PHP needs to be able to save data to |
| 457 | + this location for correct session operation.</li>"; |
| 458 | +} |
| 459 | + |
| 460 | +# Check for PCRE support |
| 461 | +if( !function_exists( 'preg_match' ) ) |
| 462 | + dieout( "The PCRE support module appears to be missing. MediaWiki requires the |
| 463 | + Perl-compatible regular expression functions." ); |
| 464 | + |
| 465 | +$memlimit = ini_get( "memory_limit" ); |
| 466 | +if( $memlimit == -1 ) { |
| 467 | + print "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n"; |
| 468 | +} else { |
| 469 | + print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars( $memlimit ). " bytes. "; |
| 470 | + $newlimit = wfMemoryLimit(); |
| 471 | + $memlimit = wfShorthandToInteger( $memlimit ); |
| 472 | + if( $newlimit < $memlimit ) { |
| 473 | + print "<b>Failed raising limit, installation may fail.</b>"; |
| 474 | + } elseif ( $newlimit > $memlimit ) { |
| 475 | + print "Raised <tt>memory_limit</tt> to " . htmlspecialchars( $newlimit ) . " bytes. "; |
| 476 | + } |
| 477 | + print "</li>\n"; |
| 478 | +} |
| 479 | + |
| 480 | +$conf->turck = function_exists( 'mmcache_get' ); |
| 481 | +if ( $conf->turck ) { |
| 482 | + print "<li><a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> installed</li>\n"; |
| 483 | +} |
| 484 | + |
| 485 | +$conf->xcache = function_exists( 'xcache_get' ); |
| 486 | +if( $conf->xcache ) |
| 487 | + print "<li><a href=\"http://trac.lighttpd.net/xcache/\">XCache</a> installed</li>\n"; |
| 488 | + |
| 489 | +$conf->apc = function_exists('apc_fetch'); |
| 490 | +if ($conf->apc ) { |
| 491 | + print "<li><a href=\"http://www.php.net/apc\">APC</a> installed</li>\n"; |
| 492 | +} |
| 493 | + |
| 494 | +$conf->eaccel = function_exists( 'eaccelerator_get' ); |
| 495 | +if ( $conf->eaccel ) { |
| 496 | + $conf->turck = 'eaccelerator'; |
| 497 | + print "<li><a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> installed</li>\n"; |
| 498 | +} |
| 499 | + |
| 500 | +$conf->dba = function_exists( 'dba_open' ); |
| 501 | + |
| 502 | +if( !( $conf->turck || $conf->eaccel || $conf->apc || $conf->xcache ) ) { |
| 503 | + echo( '<li>Couldn\'t find <a href="http://turck-mmcache.sourceforge.net">Turck MMCache</a>, |
| 504 | + <a href="http://eaccelerator.sourceforge.net">eAccelerator</a>, |
| 505 | + <a href="http://www.php.net/apc">APC</a> or <a href="http://trac.lighttpd.net/xcache/">XCache</a>; |
| 506 | + cannot use these for object caching.</li>' ); |
| 507 | +} |
| 508 | + |
| 509 | +$conf->phpCliPath = false; |
| 510 | +$phpClilocations = array_merge( |
| 511 | + array( |
| 512 | + "/usr/bin", |
| 513 | + "/usr/local/bin", |
| 514 | + "/opt/csw/bin", |
| 515 | + "/usr/gnu/bin", |
| 516 | + "/usr/sfw/bin" ), |
| 517 | + explode( PATH_SEPARATOR, getenv( "PATH" ) ) ); |
| 518 | +$phpClinames = array( "php", "php.exe" ); |
| 519 | +foreach ($phpClilocations as $loc) { |
| 520 | + $exe = locate_executable($loc, $phpClinames); |
| 521 | + if ($exe !== false) { |
| 522 | + $conf->phpCliPath= $exe; |
| 523 | + break; |
| 524 | + } |
| 525 | +} |
| 526 | + |
| 527 | +$conf->diff3 = false; |
| 528 | +$diff3locations = array_merge( |
| 529 | + array( |
| 530 | + "/usr/bin", |
| 531 | + "/usr/local/bin", |
| 532 | + "/opt/csw/bin", |
| 533 | + "/usr/gnu/bin", |
| 534 | + "/usr/sfw/bin" ), |
| 535 | + explode( PATH_SEPARATOR, getenv( "PATH" ) ) ); |
| 536 | +$diff3names = array( "gdiff3", "diff3", "diff3.exe" ); |
| 537 | + |
| 538 | +$diff3versioninfo = array( '$1 --version 2>&1', 'diff3 (GNU diffutils)' ); |
| 539 | +foreach ($diff3locations as $loc) { |
| 540 | + $exe = locate_executable($loc, $diff3names, $diff3versioninfo); |
| 541 | + if ($exe !== false) { |
| 542 | + $conf->diff3 = $exe; |
| 543 | + break; |
| 544 | + } |
| 545 | +} |
| 546 | + |
| 547 | +if ($conf->diff3) |
| 548 | + print "<li>Found GNU diff3: <tt>$conf->diff3</tt>.</li>"; |
| 549 | +else |
| 550 | + print "<li>GNU diff3 not found.</li>"; |
| 551 | + |
| 552 | +$conf->ImageMagick = false; |
| 553 | +$imcheck = array( "/usr/bin", "/opt/csw/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" ); |
| 554 | +foreach( $imcheck as $dir ) { |
| 555 | + $im = "$dir/convert"; |
| 556 | + if( @file_exists( $im ) ) { |
| 557 | + print "<li>Found ImageMagick: <tt>$im</tt>; image thumbnailing will be enabled if you enable uploads.</li>\n"; |
| 558 | + $conf->ImageMagick = $im; |
| 559 | + break; |
| 560 | + } |
| 561 | +} |
| 562 | + |
| 563 | +$conf->HaveGD = function_exists( "imagejpeg" ); |
| 564 | +if( $conf->HaveGD ) { |
| 565 | + print "<li>Found GD graphics library built-in"; |
| 566 | + if( !$conf->ImageMagick ) { |
| 567 | + print ", image thumbnailing will be enabled if you enable uploads"; |
| 568 | + } |
| 569 | + print ".</li>\n"; |
| 570 | +} else { |
| 571 | + if( !$conf->ImageMagick ) { |
| 572 | + print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n"; |
| 573 | + } |
| 574 | +} |
| 575 | + |
| 576 | +$conf->IP = dirname( dirname( __FILE__ ) ); |
| 577 | +print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP ) . "</tt></li>\n"; |
| 578 | + |
| 579 | + |
| 580 | +// PHP_SELF isn't available sometimes, such as when PHP is CGI but |
| 581 | +// cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME |
| 582 | +// to get the path to the current script... hopefully it's reliable. SIGH |
| 583 | +$path = ($_SERVER["PHP_SELF"] === '') |
| 584 | + ? $_SERVER["SCRIPT_NAME"] |
| 585 | + : $_SERVER["PHP_SELF"]; |
| 586 | + |
| 587 | +$conf->ScriptPath = preg_replace( '{^(.*)/config.*$}', '$1', $path ); |
| 588 | +print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath ) . "</tt></li>\n"; |
| 589 | + |
| 590 | + |
| 591 | + |
| 592 | +// We may be installing from *.php5 extension file, if so, print message |
| 593 | +$conf->ScriptExtension = '.php'; |
| 594 | +if (defined('MW_INSTALL_PHP5_EXT')) { |
| 595 | + $conf->ScriptExtension = '.php5'; |
| 596 | + print "<li>Installing MediaWiki with <tt>php5</tt> file extensions</li>\n"; |
| 597 | +} else { |
| 598 | + print "<li>Installing MediaWiki with <tt>php</tt> file extensions</li>\n"; |
| 599 | +} |
| 600 | + |
| 601 | + |
| 602 | +print "<li style='font-weight:bold;color:green;font-size:110%'>Environment checked. You can install MediaWiki.</li>\n"; |
| 603 | + $conf->posted = ($_SERVER["REQUEST_METHOD"] == "POST"); |
| 604 | + |
| 605 | + $conf->Sitename = ucfirst( importPost( "Sitename", "" ) ); |
| 606 | + $defaultEmail = empty( $_SERVER["SERVER_ADMIN"] ) |
| 607 | + ? 'root@localhost' |
| 608 | + : $_SERVER["SERVER_ADMIN"]; |
| 609 | + $conf->EmergencyContact = importPost( "EmergencyContact", $defaultEmail ); |
| 610 | + $conf->DBtype = importPost( "DBtype", $DefaultDBtype ); |
| 611 | + if ( !isset( $ourdb[$conf->DBtype] ) ) { |
| 612 | + $conf->DBtype = $DefaultDBtype; |
| 613 | + } |
| 614 | + |
| 615 | + $conf->DBserver = importPost( "DBserver", "localhost" ); |
| 616 | + $conf->DBname = importPost( "DBname", "wikidb" ); |
| 617 | + $conf->DBuser = importPost( "DBuser", "wikiuser" ); |
| 618 | + $conf->DBpassword = importPost( "DBpassword" ); |
| 619 | + $conf->DBpassword2 = importPost( "DBpassword2" ); |
| 620 | + $conf->SysopName = importPost( "SysopName", "WikiSysop" ); |
| 621 | + $conf->SysopPass = importPost( "SysopPass" ); |
| 622 | + $conf->SysopPass2 = importPost( "SysopPass2" ); |
| 623 | + $conf->RootUser = importPost( "RootUser", "root" ); |
| 624 | + $conf->RootPW = importPost( "RootPW", "" ); |
| 625 | + $useRoot = importCheck( 'useroot', false ); |
| 626 | + $conf->populateadmin = importCheck( 'populateadmin', false ); |
| 627 | + $conf->LanguageCode = importPost( "LanguageCode", "en" ); |
| 628 | + ## MySQL specific: |
| 629 | + $conf->DBprefix = importPost( "DBprefix" ); |
| 630 | + $conf->setSchema( |
| 631 | + importPost( "DBschema", "mysql5-binary" ), |
| 632 | + importPost( "DBengine", "InnoDB" ) ); |
| 633 | + |
| 634 | + ## Postgres specific: |
| 635 | + $conf->DBport = importPost( "DBport", "5432" ); |
| 636 | + $conf->DBmwschema = importPost( "DBmwschema", "mediawiki" ); |
| 637 | + $conf->DBts2schema = importPost( "DBts2schema", "public" ); |
| 638 | + |
| 639 | + ## SQLite specific |
| 640 | + $conf->SQLiteDataDir = importPost( "SQLiteDataDir", "" ); |
| 641 | + |
| 642 | + ## MSSQL specific |
| 643 | + // We need a second field so it doesn't overwrite the MySQL one |
| 644 | + $conf->DBprefix2 = importPost( "DBprefix2" ); |
| 645 | + |
| 646 | + ## DB2 specific: |
| 647 | + // New variable in order to have a different default port number |
| 648 | + $conf->DBport_db2 = importPost( "DBport_db2", "50000" ); |
| 649 | + $conf->DBmwschema = importPost( "DBmwschema", "mediawiki" ); |
| 650 | + $conf->DBcataloged = importPost( "DBcataloged", "cataloged" ); |
| 651 | + |
| 652 | + // Oracle specific |
| 653 | + $conf->DBprefix_ora = importPost( "DBprefix_ora" ); |
| 654 | + $conf->DBdefTS_ora = importPost( "DBdefTS_ora", "USERS" ); |
| 655 | + $conf->DBtempTS_ora = importPost( "DBtempTS_ora", "TEMP" ); |
| 656 | + |
| 657 | + $conf->ShellLocale = getShellLocale( $conf->LanguageCode ); |
| 658 | + |
| 659 | +/* Check for validity */ |
| 660 | +$errs = array(); |
| 661 | + |
| 662 | +if( preg_match( '/^$|^mediawiki$|#/i', $conf->Sitename ) ) { |
| 663 | + $errs["Sitename"] = "Must not be blank or \"MediaWiki\" and may not contain \"#\""; |
| 664 | +} |
| 665 | +if( $conf->DBuser == "" ) { |
| 666 | + $errs["DBuser"] = "Must not be blank"; |
| 667 | +} |
| 668 | +if( ($conf->DBtype == 'mysql') && (strlen($conf->DBuser) > 16) ) { |
| 669 | + $errs["DBuser"] = "Username too long"; |
| 670 | +} |
| 671 | +if( $conf->DBpassword == "" && $conf->DBtype != "postgres" ) { |
| 672 | + $errs["DBpassword"] = "Must not be blank"; |
| 673 | +} |
| 674 | +if( $conf->DBpassword != $conf->DBpassword2 ) { |
| 675 | + $errs["DBpassword2"] = "Passwords don't match!"; |
| 676 | +} |
| 677 | +if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix ) ) { |
| 678 | + $errs["DBprefix"] = "Invalid table prefix"; |
| 679 | +} else { |
| 680 | + untaint( $conf->DBprefix, TC_MYSQL ); |
| 681 | +} |
| 682 | +if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix_ora ) ) { |
| 683 | + $errs["DBprefix_ora"] = "Invalid table prefix"; |
| 684 | +} |
| 685 | + |
| 686 | +error_reporting( E_ALL | E_STRICT ); |
| 687 | + |
| 688 | +/** |
| 689 | + * Initialise $wgLang and $wgContLang to something so we can |
| 690 | + * call case-folding methods. Per Brion, this is English for |
| 691 | + * now, although we could be clever and initialise to the |
| 692 | + * user-selected language. |
| 693 | + */ |
| 694 | +$wgContLang = Language::factory( 'en' ); |
| 695 | +$wgLang = $wgContLang; |
| 696 | + |
| 697 | +/** |
| 698 | + * We're messing about with users, so we need a stub |
| 699 | + * authentication plugin... |
| 700 | + */ |
| 701 | +$wgAuth = new AuthPlugin(); |
| 702 | + |
| 703 | +/** |
| 704 | + * Validate the initial administrator account; username, |
| 705 | + * password checks, etc. |
| 706 | + */ |
| 707 | +if( $conf->SysopName ) { |
| 708 | + # Check that the user can be created |
| 709 | + $u = User::newFromName( $conf->SysopName ); |
| 710 | + if( is_a($u, 'User') ) { // please do not use instanceof, it breaks PHP4 |
| 711 | + # Various password checks |
| 712 | + if( $conf->SysopPass != '' ) { |
| 713 | + if( $conf->SysopPass == $conf->SysopPass2 ) { |
| 714 | + if( $u->isValidPassword( $conf->SysopPass ) !== true ) { |
| 715 | + $errs['SysopPass'] = "Bad password"; |
| 716 | + } |
| 717 | + } else { |
| 718 | + $errs['SysopPass2'] = "Passwords don't match"; |
| 719 | + } |
| 720 | + } else { |
| 721 | + $errs['SysopPass'] = "Cannot be blank"; |
| 722 | + } |
| 723 | + unset( $u ); |
| 724 | + } else { |
| 725 | + $errs['SysopName'] = "Bad username"; |
| 726 | + } |
| 727 | +} |
| 728 | + |
| 729 | +$conf->License = importRequest( "License", "none" ); |
| 730 | +if( $conf->License == "gfdl1_2" ) { |
| 731 | + $conf->RightsUrl = "http://www.gnu.org/licenses/old-licenses/fdl-1.2.txt"; |
| 732 | + $conf->RightsText = "GNU Free Documentation License 1.2"; |
| 733 | + $conf->RightsCode = "gfdl1_2"; |
| 734 | + $conf->RightsIcon = '${wgScriptPath}/skins/common/images/gnu-fdl.png'; |
| 735 | +} elseif( $conf->License == "gfdl1_3" ) { |
| 736 | + $conf->RightsUrl = "http://www.gnu.org/copyleft/fdl.html"; |
| 737 | + $conf->RightsText = "GNU Free Documentation License 1.3"; |
| 738 | + $conf->RightsCode = "gfdl1_3"; |
| 739 | + $conf->RightsIcon = '${wgScriptPath}/skins/common/images/gnu-fdl.png'; |
| 740 | +} elseif( $conf->License == "none" ) { |
| 741 | + $conf->RightsUrl = $conf->RightsText = $conf->RightsCode = $conf->RightsIcon = ""; |
| 742 | +} elseif( $conf->License == "pd" ) { |
| 743 | + $conf->RightsUrl = "http://creativecommons.org/licenses/publicdomain/"; |
| 744 | + $conf->RightsText = "Public Domain"; |
| 745 | + $conf->RightsCode = "pd"; |
| 746 | + $conf->RightsIcon = '${wgScriptPath}/skins/common/images/public-domain.png'; |
| 747 | +} else { |
| 748 | + $conf->RightsUrl = importRequest( "RightsUrl", "" ); |
| 749 | + $conf->RightsText = importRequest( "RightsText", "" ); |
| 750 | + $conf->RightsCode = importRequest( "RightsCode", "" ); |
| 751 | + $conf->RightsIcon = importRequest( "RightsIcon", "" ); |
| 752 | +} |
| 753 | + |
| 754 | +$conf->Shm = importRequest( "Shm", "none" ); |
| 755 | +$conf->MCServers = importRequest( "MCServers" ); |
| 756 | + |
| 757 | +/* Test memcached servers */ |
| 758 | + |
| 759 | +if ( $conf->Shm == 'memcached' && $conf->MCServers ) { |
| 760 | + $conf->MCServerArray = wfArrayMap( 'trim', explode( ',', $conf->MCServers ) ); |
| 761 | + foreach ( $conf->MCServerArray as $server ) { |
| 762 | + $error = testMemcachedServer( $server ); |
| 763 | + if ( $error ) { |
| 764 | + $errs["MCServers"] = $error; |
| 765 | + break; |
| 766 | + } |
| 767 | + } |
| 768 | +} else if ( $conf->Shm == 'memcached' ) { |
| 769 | + $errs["MCServers"] = "Please specify at least one server if you wish to use memcached"; |
| 770 | +} |
| 771 | + |
| 772 | +/* default values for installation */ |
| 773 | +$conf->Email = importRequest("Email", "email_enabled"); |
| 774 | +$conf->Emailuser = importRequest("Emailuser", "emailuser_enabled"); |
| 775 | +$conf->Enotif = importRequest("Enotif", "enotif_allpages"); |
| 776 | +$conf->Eauthent = importRequest("Eauthent", "eauthent_enabled"); |
| 777 | + |
| 778 | +if( $conf->posted && ( 0 == count( $errs ) ) ) { |
| 779 | + do { /* So we can 'continue' to end prematurely */ |
| 780 | + $conf->Root = ($conf->RootPW != ""); |
| 781 | + |
| 782 | + /* Load up the settings and get installin' */ |
| 783 | + $local = writeLocalSettings( $conf ); |
| 784 | + echo "<li style=\"list-style: none\">\n"; |
| 785 | + echo "<p><b>Generating configuration file...</b></p>\n"; |
| 786 | + echo "</li>\n"; |
| 787 | + |
| 788 | + $wgCommandLineMode = false; |
| 789 | + chdir( ".." ); |
| 790 | + $ok = eval( $local ); |
| 791 | + if( $ok === false ) { |
| 792 | + dieout( "<p>Errors in generated configuration; " . |
| 793 | + "most likely due to a bug in the installer... " . |
| 794 | + "Config file was: </p>" . |
| 795 | + "<pre>" . |
| 796 | + htmlspecialchars( $local ) . |
| 797 | + "</pre>" ); |
| 798 | + } |
| 799 | + $conf->DBtypename = ''; |
| 800 | + foreach (array_keys($ourdb) as $db) { |
| 801 | + if ($conf->DBtype === $db) |
| 802 | + $conf->DBtypename = $ourdb[$db]['fullname']; |
| 803 | + } |
| 804 | + if ( ! strlen($conf->DBtype)) { |
| 805 | + $errs["DBpicktype"] = "Please choose a database type"; |
| 806 | + continue; |
| 807 | + } |
| 808 | + |
| 809 | + if (! $conf->DBtypename) { |
| 810 | + $errs["DBtype"] = "Unknown database type '$conf->DBtype'"; |
| 811 | + continue; |
| 812 | + } |
| 813 | + print "<li>Database type: " . htmlspecialchars( $conf->DBtypename ) . "</li>\n"; |
| 814 | + $dbclass = 'Database'.ucfirst($conf->DBtype); |
| 815 | + $wgDBtype = $conf->DBtype; |
| 816 | + $wgDBadminuser = "root"; |
| 817 | + $wgDBadminpassword = $conf->RootPW; |
| 818 | + |
| 819 | + ## Mysql specific: |
| 820 | + $wgDBprefix = $conf->DBprefix; |
| 821 | + |
| 822 | + ## Postgres specific: |
| 823 | + $wgDBport = $conf->DBport; |
| 824 | + $wgDBmwschema = $conf->DBmwschema; |
| 825 | + $wgDBts2schema = $conf->DBts2schema; |
| 826 | + |
| 827 | + if( $conf->DBprefix2 != '' ) { |
| 828 | + // For MSSQL |
| 829 | + $wgDBprefix = $conf->DBprefix2; |
| 830 | + } elseif( $conf->DBprefix_ora != '' ) { |
| 831 | + // For Oracle |
| 832 | + $wgDBprefix = $conf->DBprefix_ora; |
| 833 | + } |
| 834 | + |
| 835 | + ## DB2 specific: |
| 836 | + $wgDBcataloged = $conf->DBcataloged; |
| 837 | + |
| 838 | + $wgCommandLineMode = true; |
| 839 | + if (! defined ( 'STDERR' ) ) |
| 840 | + define( 'STDERR', fopen("php://stderr", "wb")); |
| 841 | + $wgUseDatabaseMessages = false; /* FIXME: For database failure */ |
| 842 | + require_once( "$IP/includes/Setup.php" ); |
| 843 | + Language::getLocalisationCache()->disableBackend(); |
| 844 | + |
| 845 | + chdir( "config" ); |
| 846 | + |
| 847 | + $wgTitle = Title::newFromText( "Installation script" ); |
| 848 | + error_reporting( E_ALL | E_STRICT ); |
| 849 | + print "<li>Loading class: " . htmlspecialchars( $dbclass ) . "</li>\n"; |
| 850 | + if ( $conf->DBtype != 'sqlite' ) { |
| 851 | + $dbc = new $dbclass; |
| 852 | + } |
| 853 | + |
| 854 | + if( $conf->DBtype == 'mysql' ) { |
| 855 | + $mysqlOldClient = version_compare( mysql_get_client_info(), "4.1.0", "lt" ); |
| 856 | + if( $mysqlOldClient ) { |
| 857 | + print "<li><b>PHP is linked with old MySQL client libraries. If you are |
| 858 | + using a MySQL 4.1 server and have problems connecting to the database, |
| 859 | + see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html' |
| 860 | + >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b></li>\n"; |
| 861 | + } |
| 862 | + $ok = true; # Let's be optimistic |
| 863 | + |
| 864 | + # Decide if we're going to use the superuser or the regular database user |
| 865 | + $conf->Root = $useRoot; |
| 866 | + if( $conf->Root ) { |
| 867 | + $db_user = $conf->RootUser; |
| 868 | + $db_pass = $conf->RootPW; |
| 869 | + } else { |
| 870 | + $db_user = $wgDBuser; |
| 871 | + $db_pass = $wgDBpassword; |
| 872 | + } |
| 873 | + |
| 874 | + # Attempt to connect |
| 875 | + echo( "<li>Attempting to connect to database server as " . htmlspecialchars( $db_user ) . "..." ); |
| 876 | + $wgDatabase = Database::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 ); |
| 877 | + |
| 878 | + # Check the connection and respond to errors |
| 879 | + if( $wgDatabase->isOpen() ) { |
| 880 | + # Seems OK |
| 881 | + $ok = true; |
| 882 | + $wgDBadminuser = $db_user; |
| 883 | + $wgDBadminpassword = $db_pass; |
| 884 | + echo( "success.</li>\n" ); |
| 885 | + $wgDatabase->ignoreErrors( true ); |
| 886 | + $myver = $wgDatabase->getServerVersion(); |
| 887 | + } else { |
| 888 | + # There were errors, report them and back out |
| 889 | + $ok = false; |
| 890 | + $errno = mysql_errno(); |
| 891 | + $errtx = htmlspecialchars( mysql_error() ); |
| 892 | + switch( $errno ) { |
| 893 | + case 1045: |
| 894 | + case 2000: |
| 895 | + echo( "failed due to authentication errors. Check passwords.</li>" ); |
| 896 | + if( $conf->Root ) { |
| 897 | + # The superuser details are wrong |
| 898 | + $errs["RootUser"] = "Check username"; |
| 899 | + $errs["RootPW"] = "and password"; |
| 900 | + } else { |
| 901 | + # The regular user details are wrong |
| 902 | + $errs["DBuser"] = "Check username"; |
| 903 | + $errs["DBpassword"] = "and password"; |
| 904 | + } |
| 905 | + break; |
| 906 | + case 2002: |
| 907 | + case 2003: |
| 908 | + default: |
| 909 | + # General connection problem |
| 910 | + echo( htmlspecialchars( "failed with error [$errno] $errtx." ) . "</li>\n" ); |
| 911 | + $errs["DBserver"] = "Connection failed"; |
| 912 | + break; |
| 913 | + } # switch |
| 914 | + } #conn. att. |
| 915 | + |
| 916 | + if( !$ok ) { continue; } |
| 917 | + } |
| 918 | + else if( $conf->DBtype == 'ibm_db2' ) { |
| 919 | + if( $useRoot ) { |
| 920 | + $db_user = $conf->RootUser; |
| 921 | + $db_pass = $conf->RootPW; |
| 922 | + } else { |
| 923 | + $db_user = $wgDBuser; |
| 924 | + $db_pass = $wgDBpassword; |
| 925 | + } |
| 926 | + |
| 927 | + echo( "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) . |
| 928 | + "\" as \"" . htmlspecialchars( $db_user ) . "\"..." ); |
| 929 | + $wgDatabase = $dbc->newFromParams($wgDBserver, $db_user, $db_pass, $wgDBname, 1); |
| 930 | + // enable extra debug messages |
| 931 | + $dbc->setMode(DatabaseIbm_db2::INSTALL_MODE); |
| 932 | + $wgDatabase->setMode(DatabaseIbm_db2::INSTALL_MODE); |
| 933 | + |
| 934 | + if (!$wgDatabase->isOpen()) { |
| 935 | + print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n"; |
| 936 | + } else { |
| 937 | + $myver = $wgDatabase->getServerVersion(); |
| 938 | + } |
| 939 | + if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname); |
| 940 | + |
| 941 | + } elseif ( $conf->DBtype == 'sqlite' ) { |
| 942 | + if ("$wgSQLiteDataDir" == '') { |
| 943 | + $wgSQLiteDataDir = dirname($_SERVER['DOCUMENT_ROOT']).'/data'; |
| 944 | + } |
| 945 | + echo "<li>Attempting to connect to SQLite database at \"" . |
| 946 | + htmlspecialchars( $wgSQLiteDataDir ) . "\""; |
| 947 | + if ( !is_dir( $wgSQLiteDataDir ) ) { |
| 948 | + if ( is_writable( dirname( $wgSQLiteDataDir ) ) ) { |
| 949 | + $ok = wfMkdirParents( $wgSQLiteDataDir, $wgSQLiteDataDirMode ); |
| 950 | + } else { |
| 951 | + $ok = false; |
| 952 | + } |
| 953 | + if ( !$ok ) { |
| 954 | + echo ": cannot create data directory</li>"; |
| 955 | + $errs['SQLiteDataDir'] = 'Enter a valid data directory'; |
| 956 | + continue; |
| 957 | + } |
| 958 | + } |
| 959 | + if ( !is_writable( $wgSQLiteDataDir ) ) { |
| 960 | + echo ": data directory not writable</li>"; |
| 961 | + $errs['SQLiteDataDir'] = 'Enter a writable data directory'; |
| 962 | + continue; |
| 963 | + } |
| 964 | + $dataFile = "$wgSQLiteDataDir/$wgDBname.sqlite"; |
| 965 | + if ( file_exists( $dataFile ) && !is_writable( $dataFile ) ) { |
| 966 | + echo ": data file not writable</li>"; |
| 967 | + $errs['SQLiteDataDir'] = "$wgDBname.sqlite is not writable"; |
| 968 | + continue; |
| 969 | + } |
| 970 | + $wgDatabase = new DatabaseSqlite( false, false, false, $wgDBname, 1 ); |
| 971 | + if (!$wgDatabase->isOpen()) { |
| 972 | + print ": error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n"; |
| 973 | + $errs['SQLiteDataDir'] = 'Could not connect to database'; |
| 974 | + continue; |
| 975 | + } else { |
| 976 | + $myver = $wgDatabase->getServerVersion(); |
| 977 | + } |
| 978 | + if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname); |
| 979 | + echo "ok</li>\n"; |
| 980 | + } elseif ( $conf->DBtype == 'oracle' ) { |
| 981 | + echo "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) ."\"</li>"; |
| 982 | + $wgDatabase = $dbc->newFromParams('DUMMY', $wgDBuser, $wgDBpassword, $wgDBname, 1); |
| 983 | + if (!$wgDatabase->isOpen()) { |
| 984 | + $ok = true; |
| 985 | + echo "<li>Connect failed.</li>"; |
| 986 | + if ($useRoot) { |
| 987 | + if (ini_get('oci8.privileged_connect') === false) { |
| 988 | + echo "<li>Privileged connect disabled, please set oci8.privileged_connect or run maintenance/ora/user.sql script manually prior to continuing.</li>"; |
| 989 | + $ok = false; |
| 990 | + } else { |
| 991 | + $wgDBadminuser = $conf->RootUser; |
| 992 | + $wgDBadminpassword = $conf->RootPW; |
| 993 | + echo "<li>Attempting to create DB user.</li>"; |
| 994 | + $wgDatabase = $dbc->newFromParams('DUMMY', $wgDBadminuser, $wgDBadminpassword, $wgDBname, 1, 64); |
| 995 | + if ($wgDatabase->isOpen()) { |
| 996 | + $wgDBOracleDefTS = $conf->DBdefTS_ora; |
| 997 | + $wgDBOracleTempTS = $conf->DBtempTS_ora; |
| 998 | + $wgDatabase->sourceFile( "../maintenance/ora/user.sql" ); |
| 999 | + } else { |
| 1000 | + echo "<li>Invalid database superuser, please supply a valid superuser account.</li>"; |
| 1001 | + echo "<li>ERR: ".print_r(oci_error(), true)."</li>"; |
| 1002 | + $ok = false; |
| 1003 | + } |
| 1004 | + } |
| 1005 | + } else { |
| 1006 | + echo "<li>Database superuser missing, please supply a valid superuser account.</li>"; |
| 1007 | + $ok = false; |
| 1008 | + } |
| 1009 | + if (!$ok) { |
| 1010 | + $errs["RootUser"] = "Check username"; |
| 1011 | + $errs["RootPW"] = "and password"; |
| 1012 | + } else { |
| 1013 | + echo "<li>Attempting to connect to database with new user \"" . htmlspecialchars( $wgDBname ) ."\"</li>"; |
| 1014 | + $wgDatabase = $dbc->newFromParams('DUMMY', $wgDBuser, $wgDBpassword, $wgDBname, 1); |
| 1015 | + } |
| 1016 | + } |
| 1017 | + if ($ok) { |
| 1018 | + $myver = $wgDatabase->getServerVersion(); |
| 1019 | + } |
| 1020 | + } else { # not mysql |
| 1021 | + error_reporting( E_ALL | E_STRICT ); |
| 1022 | + $wgSuperUser = ''; |
| 1023 | + ## Possible connect as a superuser |
| 1024 | + // Changed !mysql to postgres check since it seems to only apply to postgres |
| 1025 | + if( $useRoot && $conf->DBtype == 'postgres' ) { |
| 1026 | + $wgDBsuperuser = $conf->RootUser; |
| 1027 | + echo( "<li>Attempting to connect to database \"postgres\" as superuser \"" . |
| 1028 | + htmlspecialchars( $wgDBsuperuser ) . "\"..." ); |
| 1029 | + $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBsuperuser, $conf->RootPW, "postgres", 1); |
| 1030 | + if (!$wgDatabase->isOpen()) { |
| 1031 | + print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n"; |
| 1032 | + $errs["DBserver"] = "Could not connect to database as superuser"; |
| 1033 | + $errs["RootUser"] = "Check username"; |
| 1034 | + $errs["RootPW"] = "and password"; |
| 1035 | + continue; |
| 1036 | + } |
| 1037 | + $wgDatabase->initial_setup($conf->RootPW, 'postgres'); |
| 1038 | + } |
| 1039 | + echo( "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) . |
| 1040 | + "\" as \"" . htmlspecialchars( $wgDBuser ) . "\"..." ); |
| 1041 | + $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1); |
| 1042 | + if (!$wgDatabase->isOpen()) { |
| 1043 | + print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n"; |
| 1044 | + $errs["DBserver"] = "Could not connect to database as user"; |
| 1045 | + $errs["DBuser"] = "Check username"; |
| 1046 | + $errs["DBpassword"] = "and password"; |
| 1047 | + continue; |
| 1048 | + } else { |
| 1049 | + $myver = $wgDatabase->getServerVersion(); |
| 1050 | + } |
| 1051 | + if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname); |
| 1052 | + } |
| 1053 | + |
| 1054 | + if ( !$wgDatabase->isOpen() ) { |
| 1055 | + $errs["DBserver"] = "Couldn't connect to database"; |
| 1056 | + continue; |
| 1057 | + } |
| 1058 | + |
| 1059 | + print "<li>Connected to " . htmlspecialchars( "{$conf->DBtype} $myver" ); |
| 1060 | + if ($conf->DBtype == 'mysql') { |
| 1061 | + if( version_compare( $myver, "4.0.14" ) < 0 ) { |
| 1062 | + print "</li>\n"; |
| 1063 | + dieout( "-- mysql 4.0.14 or later required. Aborting." ); |
| 1064 | + } |
| 1065 | + $mysqlNewAuth = version_compare( $myver, "4.1.0", "ge" ); |
| 1066 | + if( $mysqlNewAuth && $mysqlOldClient ) { |
| 1067 | + print "; <b class='error'>You are using MySQL 4.1 server, but PHP is linked |
| 1068 | + to old client libraries; if you have trouble with authentication, see |
| 1069 | + <a href='http://dev.mysql.com/doc/mysql/en/old-client.html' |
| 1070 | + >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>"; |
| 1071 | + } |
| 1072 | + if( $wgDBmysql5 ) { |
| 1073 | + if( $mysqlNewAuth ) { |
| 1074 | + print "; enabling MySQL 4.1/5.0 charset mode"; |
| 1075 | + } else { |
| 1076 | + print "; <b class='error'>MySQL 4.1/5.0 charset mode enabled, |
| 1077 | + but older version detected; will likely fail.</b>"; |
| 1078 | + } |
| 1079 | + } |
| 1080 | + print "</li>\n"; |
| 1081 | + |
| 1082 | + @$sel = $wgDatabase->selectDB( $wgDBname ); |
| 1083 | + if( $sel ) { |
| 1084 | + print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n"; |
| 1085 | + } else { |
| 1086 | + $err = mysql_errno(); |
| 1087 | + $databaseSafe = htmlspecialchars( $wgDBname ); |
| 1088 | + if( $err == 1102 /* Invalid database name */ ) { |
| 1089 | + print "<ul><li><strong>{$databaseSafe}</strong> is not a valid database name.</li></ul>"; |
| 1090 | + continue; |
| 1091 | + } elseif( $err != 1049 /* Database doesn't exist */ ) { |
| 1092 | + print "<ul><li>Error selecting database <strong>{$databaseSafe}</strong>: {$err} "; |
| 1093 | + print htmlspecialchars( mysql_error() ) . "</li></ul>"; |
| 1094 | + continue; |
| 1095 | + } |
| 1096 | + print "<li>Attempting to create database...</li>"; |
| 1097 | + $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" ); |
| 1098 | + if( !$res ) { |
| 1099 | + print "<li>Couldn't create database <tt>" . |
| 1100 | + htmlspecialchars( $wgDBname ) . |
| 1101 | + "</tt>; try with root access or check your username/pass.</li>\n"; |
| 1102 | + $errs["RootPW"] = "<- Enter"; |
| 1103 | + continue; |
| 1104 | + } |
| 1105 | + print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n"; |
| 1106 | + } |
| 1107 | + $wgDatabase->selectDB( $wgDBname ); |
| 1108 | + } |
| 1109 | + else if ($conf->DBtype == 'postgres') { |
| 1110 | + if( version_compare( $myver, "8.0" ) < 0 ) { |
| 1111 | + dieout( "<b>Postgres 8.0 or later is required</b>. Aborting." ); |
| 1112 | + } |
| 1113 | + } |
| 1114 | + |
| 1115 | + if( $wgDatabase->tableExists( "cur" ) || $wgDatabase->tableExists( "revision" ) ) { |
| 1116 | + print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n"; |
| 1117 | + |
| 1118 | + if ( $conf->DBtype == 'mysql') { |
| 1119 | + # Determine existing default character set |
| 1120 | + if ( $wgDatabase->tableExists( "revision" ) ) { |
| 1121 | + $revision = $wgDatabase->escapeLike( $conf->DBprefix . 'revision' ); |
| 1122 | + $res = $wgDatabase->query( "SHOW TABLE STATUS LIKE '$revision'" ); |
| 1123 | + $row = $wgDatabase->fetchObject( $res ); |
| 1124 | + if ( !$row ) { |
| 1125 | + echo "<li>SHOW TABLE STATUS query failed!</li>\n"; |
| 1126 | + $existingSchema = false; |
| 1127 | + $existingEngine = false; |
| 1128 | + } else { |
| 1129 | + if ( preg_match( '/^latin1/', $row->Collation ) ) { |
| 1130 | + $existingSchema = 'mysql4'; |
| 1131 | + } elseif ( preg_match( '/^utf8/', $row->Collation ) ) { |
| 1132 | + $existingSchema = 'mysql5'; |
| 1133 | + } elseif ( preg_match( '/^binary/', $row->Collation ) ) { |
| 1134 | + $existingSchema = 'mysql5-binary'; |
| 1135 | + } else { |
| 1136 | + $existingSchema = false; |
| 1137 | + echo "<li><strong>Warning:</strong> Unrecognised existing collation</li>\n"; |
| 1138 | + } |
| 1139 | + if ( isset( $row->Engine ) ) { |
| 1140 | + $existingEngine = $row->Engine; |
| 1141 | + } else { |
| 1142 | + $existingEngine = $row->Type; |
| 1143 | + } |
| 1144 | + } |
| 1145 | + if ( $existingSchema && $existingSchema != $conf->DBschema ) { |
| 1146 | + $encExisting = htmlspecialchars( $existingSchema ); |
| 1147 | + $encRequested = htmlspecialchars( $conf->DBschema ); |
| 1148 | + print "<li><strong>Warning:</strong> you requested the $encRequested schema, " . |
| 1149 | + "but the existing database has the $encExisting schema. This upgrade script ". |
| 1150 | + "can't convert it, so it will remain $encExisting.</li>\n"; |
| 1151 | + $conf->setSchema( $existingSchema, $conf->DBengine ); |
| 1152 | + } |
| 1153 | + if ( $existingEngine && $existingEngine != $conf->DBengine ) { |
| 1154 | + $encExisting = htmlspecialchars( $existingEngine ); |
| 1155 | + $encRequested = htmlspecialchars( $conf->DBengine ); |
| 1156 | + print "<li><strong>Warning:</strong> you requested the $encRequested storage " . |
| 1157 | + "engine, but the existing database uses the $encExisting engine. This upgrade " . |
| 1158 | + "script can't convert it, so it will remain $encExisting.</li>\n"; |
| 1159 | + $conf->setSchema( $conf->DBschema, $existingEngine ); |
| 1160 | + } |
| 1161 | + } |
| 1162 | + |
| 1163 | + # Create user if required |
| 1164 | + if ( $conf->Root ) { |
| 1165 | + $conn = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 ); |
| 1166 | + if ( $conn->isOpen() ) { |
| 1167 | + print "<li>DB user account ok</li>\n"; |
| 1168 | + $conn->close(); |
| 1169 | + } else { |
| 1170 | + print "<li>Granting user permissions..."; |
| 1171 | + if( $mysqlOldClient && $mysqlNewAuth ) { |
| 1172 | + 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>"; |
| 1173 | + } |
| 1174 | + print "</li>\n"; |
| 1175 | + $wgDatabase->sourceFile( "../maintenance/users.sql" ); |
| 1176 | + } |
| 1177 | + } |
| 1178 | + } |
| 1179 | + print "</ul><pre>\n"; |
| 1180 | + chdir( ".." ); |
| 1181 | + flush(); |
| 1182 | + do_all_updates(); |
| 1183 | + chdir( "config" ); |
| 1184 | + print "</pre>\n"; |
| 1185 | + print "<ul><li>Finished update checks.</li>\n"; |
| 1186 | + // if tables don't yet exist |
| 1187 | + } else { |
| 1188 | + # Determine available storage engines if possible |
| 1189 | + if ( $conf->DBtype == 'mysql' && version_compare( $myver, "4.1.2", "ge" ) ) { |
| 1190 | + $res = $wgDatabase->query( 'SHOW ENGINES' ); |
| 1191 | + $found = false; |
| 1192 | + while ( $row = $wgDatabase->fetchObject( $res ) ) { |
| 1193 | + if ( $row->Engine == $conf->DBengine && ( $row->Support == 'YES' || $row->Support == 'DEFAULT' ) ) { |
| 1194 | + $found = true; |
| 1195 | + break; |
| 1196 | + } |
| 1197 | + } |
| 1198 | + $wgDatabase->freeResult( $res ); |
| 1199 | + if ( !$found && $conf->DBengine != 'MyISAM' ) { |
| 1200 | + echo "<li><strong>Warning:</strong> " . htmlspecialchars( $conf->DBengine ) . |
| 1201 | + " storage engine not available, " . |
| 1202 | + "using MyISAM instead</li>\n"; |
| 1203 | + $conf->setSchema( $conf->DBschema, 'MyISAM' ); |
| 1204 | + } |
| 1205 | + } |
| 1206 | + |
| 1207 | + # FIXME: Check for errors |
| 1208 | + print "<li>Creating tables..."; |
| 1209 | + if ($conf->DBtype == 'mysql') { |
| 1210 | + $wgDatabase->sourceFile( "../maintenance/tables.sql" ); |
| 1211 | + $wgDatabase->sourceFile( "../maintenance/interwiki.sql" ); |
| 1212 | + } elseif (is_callable(array($wgDatabase, 'setup_database'))) { |
| 1213 | + $wgDatabase->setup_database(); |
| 1214 | + } |
| 1215 | + else { |
| 1216 | + $errs["DBtype"] = "Do not know how to handle database type '$conf->DBtype'"; |
| 1217 | + continue; |
| 1218 | + } |
| 1219 | + |
| 1220 | + print " done.</li>\n"; |
| 1221 | + |
| 1222 | + |
| 1223 | + if ($conf->DBtype == 'ibm_db2') { |
| 1224 | + // Now that table creation is done, make sure everything is committed |
| 1225 | + // Do this before doing inserts through API |
| 1226 | + if ($wgDatabase->lastError()) { |
| 1227 | + print "<li>Errors encountered during table creation -- rolled back</li>\n"; |
| 1228 | + $wgDatabase->rollback(); |
| 1229 | + } |
| 1230 | + else { |
| 1231 | + print "<li>MediaWiki tables successfully created</li>\n"; |
| 1232 | + $wgDatabase->commit(); |
| 1233 | + } |
| 1234 | + } |
| 1235 | + |
| 1236 | + print "<li>Initializing statistics...</li>\n"; |
| 1237 | + $wgDatabase->insert( 'site_stats', |
| 1238 | + array ( 'ss_row_id' => 1, |
| 1239 | + 'ss_total_views' => 0, |
| 1240 | + 'ss_total_edits' => 1, # Main page first edit |
| 1241 | + 'ss_good_articles' => 0, # Main page is not a good article - no internal link |
| 1242 | + 'ss_total_pages' => 1, # Main page |
| 1243 | + 'ss_users' => $conf->SysopName ? 1 : 0, # Sysop account, if created |
| 1244 | + 'ss_admins' => $conf->SysopName ? 1 : 0, # Sysop account, if created |
| 1245 | + 'ss_images' => 0 ) ); |
| 1246 | + |
| 1247 | + # Set up the "regular user" account *if we can, and if we need to* |
| 1248 | + if( $conf->Root and $conf->DBtype == 'mysql') { |
| 1249 | + # See if we need to |
| 1250 | + $wgDatabase2 = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 ); |
| 1251 | + if( $wgDatabase2->isOpen() ) { |
| 1252 | + # Nope, just close the test connection and continue |
| 1253 | + $wgDatabase2->close(); |
| 1254 | + echo( "<li>User " . htmlspecialchars( $wgDBuser ) . " exists. Skipping grants.</li>\n" ); |
| 1255 | + } else { |
| 1256 | + # Yes, so run the grants |
| 1257 | + echo( "<li>" . htmlspecialchars( "Granting user permissions to $wgDBuser on $wgDBname..." ) ); |
| 1258 | + $wgDatabase->sourceFile( "../maintenance/users.sql" ); |
| 1259 | + echo( "success.</li>\n" ); |
| 1260 | + } |
| 1261 | + } |
| 1262 | + |
| 1263 | + if( $conf->SysopName ) { |
| 1264 | + $u = User::newFromName( $conf->getSysopName() ); |
| 1265 | + if ( !$u ) { |
| 1266 | + print "<li><strong class=\"error\">Warning:</strong> Skipped sysop account creation - invalid username!</li>\n"; |
| 1267 | + } |
| 1268 | + else if ( 0 == $u->idForName() ) { |
| 1269 | + $u->addToDatabase(); |
| 1270 | + $u->setPassword( $conf->getSysopPass() ); |
| 1271 | + $u->saveSettings(); |
| 1272 | + |
| 1273 | + $u->addGroup( "sysop" ); |
| 1274 | + $u->addGroup( "bureaucrat" ); |
| 1275 | + |
| 1276 | + print "<li>Created sysop account <tt>" . |
| 1277 | + htmlspecialchars( $conf->SysopName ) . "</tt>.</li>\n"; |
| 1278 | + } else { |
| 1279 | + print "<li>Could not create user - already exists!</li>\n"; |
| 1280 | + } |
| 1281 | + } else { |
| 1282 | + print "<li>Skipped sysop account creation, no name given.</li>\n"; |
| 1283 | + } |
| 1284 | + |
| 1285 | + $titleobj = Title::newFromText( wfMsgNoDB( "mainpage" ) ); |
| 1286 | + $article = new Article( $titleobj ); |
| 1287 | + $newid = $article->insertOn( $wgDatabase ); |
| 1288 | + $revision = new Revision( array( |
| 1289 | + 'page' => $newid, |
| 1290 | + 'text' => wfMsg( 'mainpagetext' ) . "\n\n" . wfMsgNoTrans( 'mainpagedocfooter' ), |
| 1291 | + 'comment' => '', |
| 1292 | + 'user' => 0, |
| 1293 | + 'user_text' => 'MediaWiki default', |
| 1294 | + ) ); |
| 1295 | + $revid = $revision->insertOn( $wgDatabase ); |
| 1296 | + $article->updateRevisionOn( $wgDatabase, $revision ); |
| 1297 | + } |
| 1298 | + |
| 1299 | + /* Write out the config file now that all is well */ |
| 1300 | + print "<li style=\"list-style: none\">\n"; |
| 1301 | + print "<p>Creating LocalSettings.php...</p>\n\n"; |
| 1302 | + $localSettings = "<" . "?php$endl$local"; |
| 1303 | + // Fix up a common line-ending problem (due to CVS on Windows) |
| 1304 | + $localSettings = str_replace( "\r\n", "\n", $localSettings ); |
| 1305 | + $f = fopen( "LocalSettings.php", 'xt' ); |
| 1306 | + |
| 1307 | + if( $f == false ) { |
| 1308 | + print( "</li>\n" ); |
| 1309 | + 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" . |
| 1310 | + "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" . |
| 1311 | + "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" ); |
| 1312 | + } |
| 1313 | + if(fwrite( $f, $localSettings ) ) { |
| 1314 | + fclose( $f ); |
| 1315 | + print "<hr/>\n"; |
| 1316 | + writeSuccessMessage(); |
| 1317 | + print "</li>\n"; |
| 1318 | + } else { |
| 1319 | + fclose( $f ); |
| 1320 | + 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" ); |
| 1321 | + } |
| 1322 | + |
| 1323 | + } while( false ); |
| 1324 | +} |
| 1325 | + |
| 1326 | +print "</ul>\n"; |
| 1327 | +$mainListOpened = false; |
| 1328 | + |
| 1329 | +if( count( $errs ) ) { |
| 1330 | + /* Display options form */ |
| 1331 | + |
| 1332 | + if( $conf->posted ) { |
| 1333 | + echo "<p class='error-top'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n"; |
| 1334 | + } |
| 1335 | +?> |
| 1336 | + |
| 1337 | +<form action="<?php echo defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php'; ?>" name="config" method="post"> |
| 1338 | + |
| 1339 | +<h2>Site config</h2> |
| 1340 | + |
| 1341 | +<div class="config-section"> |
| 1342 | + <div class="config-input"> |
| 1343 | + <?php aField( $conf, "Sitename", "Wiki name:" ); ?> |
| 1344 | + </div> |
| 1345 | + <p class="config-desc"> |
| 1346 | + Preferably a short word without punctuation, i.e. "Wikipedia".<br /> |
| 1347 | + Will appear as the namespace name for "meta" pages, and throughout the interface. |
| 1348 | + </p> |
| 1349 | + <div class="config-input"><?php aField( $conf, "EmergencyContact", "Contact e-mail:" ); ?></div> |
| 1350 | + <p class="config-desc"> |
| 1351 | + 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. |
| 1352 | + </p> |
| 1353 | + |
| 1354 | + <div class="config-input"> |
| 1355 | + <label class='column' for="LanguageCode">Language:</label> |
| 1356 | + <select id="LanguageCode" name="LanguageCode"><?php |
| 1357 | + $list = getLanguageList(); |
| 1358 | + foreach( $list as $code => $name ) { |
| 1359 | + $sel = ($code == $conf->LanguageCode) ? 'selected="selected"' : ''; |
| 1360 | + $encCode = htmlspecialchars( $code ); |
| 1361 | + $encName = htmlspecialchars( $name ); |
| 1362 | + echo "\n\t\t<option value=\"$encCode\" $sel>$encName</option>"; |
| 1363 | + } |
| 1364 | + echo "\n"; |
| 1365 | + ?> |
| 1366 | + </select> |
| 1367 | + </div> |
| 1368 | + <p class="config-desc"> |
| 1369 | + Select the language for your wiki's interface. Some localizations aren't fully complete. Unicode (UTF-8) is used for all localizations. |
| 1370 | + </p> |
| 1371 | + |
| 1372 | + <div class="config-input"> |
| 1373 | + <label class='column'>Copyright/license:</label> |
| 1374 | + |
| 1375 | + <ul class="plain"> |
| 1376 | + <li><?php aField( $conf, "License", "No license metadata", "radio", "none" ); ?></li> |
| 1377 | + <li><?php aField( $conf, "License", "Public Domain", "radio", "pd" ); ?></li> |
| 1378 | + <li><?php aField( $conf, "License", "GNU Free Documentation License 1.2", "radio", "gfdl1_2" ); ?></li> |
| 1379 | + <li><?php aField( $conf, "License", "GNU Free Documentation License 1.3", "radio", "gfdl1_3" ); ?></li> |
| 1380 | + <li><?php |
| 1381 | + aField( $conf, "License", "A Creative Commons license - ", "radio", "cc" ); |
| 1382 | + $partner = "MediaWiki"; |
| 1383 | + $script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php'; |
| 1384 | + $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/$script?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" ); |
| 1385 | + $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" ); |
| 1386 | + $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" ); |
| 1387 | + print "<a href=\"$ccApp\" target='_blank'>choose</a>"; |
| 1388 | + if( $conf->License == "cc" ) { ?> |
| 1389 | + <ul> |
| 1390 | + <li><?php aField( $conf, "RightsIcon", "<img src=\"" . htmlspecialchars( $conf->RightsIcon ) . "\" alt='(Creative Commons icon)' />", "hidden" ); ?></li> |
| 1391 | + <li><?php aField( $conf, "RightsText", htmlspecialchars( $conf->RightsText ), "hidden" ); ?></li> |
| 1392 | + <li><?php aField( $conf, "RightsCode", "code: " . htmlspecialchars( $conf->RightsCode ), "hidden" ); ?></li> |
| 1393 | + <li><?php aField( $conf, "RightsUrl", "<a href=\"" . htmlspecialchars( $conf->RightsUrl ) . "\">" . htmlspecialchars( $conf->RightsUrl ) . "</a>", "hidden" ); ?></li> |
| 1394 | + </ul> |
| 1395 | + <?php } ?> |
| 1396 | + </li> |
| 1397 | + </ul> |
| 1398 | + </div> |
| 1399 | + <p class="config-desc"> |
| 1400 | + A notice, icon, and machine-readable copyright metadata will be displayed for the license you pick. |
| 1401 | + </p> |
| 1402 | + |
| 1403 | + |
| 1404 | + <div class="config-input"> |
| 1405 | + <?php aField( $conf, "SysopName", "Admin username:" ) ?> |
| 1406 | + </div> |
| 1407 | + <div class="config-input"> |
| 1408 | + <?php aField( $conf, "SysopPass", "Password:", "password" ) ?> |
| 1409 | + </div> |
| 1410 | + <div class="config-input"> |
| 1411 | + <?php aField( $conf, "SysopPass2", "Password confirm:", "password" ) ?> |
| 1412 | + </div> |
| 1413 | + <p class="config-desc"> |
| 1414 | + An admin can lock/delete pages, block users from editing, and do other maintenance tasks.<br /> |
| 1415 | + A new account will be added only when creating a new wiki database. |
| 1416 | + <br /><br /> |
| 1417 | + The password cannot be the same as the username. |
| 1418 | + </p> |
| 1419 | + |
| 1420 | + <div class="config-input"> |
| 1421 | + <label class='column'>Object caching:</label> |
| 1422 | + |
| 1423 | + <ul class="plain"> |
| 1424 | + <li><?php aField( $conf, "Shm", "No caching", "radio", "none" ); ?></li> |
| 1425 | + <?php |
| 1426 | + if ( $conf->turck ) { |
| 1427 | + echo "<li>"; |
| 1428 | + aField( $conf, "Shm", "Turck MMCache", "radio", "turck" ); |
| 1429 | + echo "</li>\n"; |
| 1430 | + } |
| 1431 | + if( $conf->xcache ) { |
| 1432 | + echo "<li>"; |
| 1433 | + aField( $conf, 'Shm', 'XCache', 'radio', 'xcache' ); |
| 1434 | + echo "</li>\n"; |
| 1435 | + } |
| 1436 | + if ( $conf->apc ) { |
| 1437 | + echo "<li>"; |
| 1438 | + aField( $conf, "Shm", "APC", "radio", "apc" ); |
| 1439 | + echo "</li>\n"; |
| 1440 | + } |
| 1441 | + if ( $conf->eaccel ) { |
| 1442 | + echo "<li>"; |
| 1443 | + aField( $conf, "Shm", "eAccelerator", "radio", "eaccel" ); |
| 1444 | + echo "</li>\n"; |
| 1445 | + } |
| 1446 | + if ( $conf->dba ) { |
| 1447 | + echo "<li>"; |
| 1448 | + aField( $conf, "Shm", "DBA (not recommended)", "radio", "dba" ); |
| 1449 | + echo "</li>"; |
| 1450 | + } |
| 1451 | + ?> |
| 1452 | + <li><?php aField( $conf, "Shm", "Memcached", "radio", "memcached" ); ?></li> |
| 1453 | + </ul> |
| 1454 | + <div style="clear:left"><?php aField( $conf, "MCServers", "Memcached servers:", "text" ) ?></div> |
| 1455 | + </div> |
| 1456 | + <p class="config-desc"> |
| 1457 | + An object caching system such as memcached will provide a significant performance boost, |
| 1458 | + but needs to be installed. Provide the server addresses and ports in a comma-separated list. |
| 1459 | + <br /><br /> |
| 1460 | + MediaWiki can also detect and support eAccelerator, Turck MMCache, APC, and XCache, but |
| 1461 | + these should not be used if the wiki will be running on multiple application servers. |
| 1462 | + <br/><br/> |
| 1463 | + DBA (Berkeley-style DB) is generally slower than using no cache at all, and is only |
| 1464 | + recommended for testing. |
| 1465 | + </p> |
| 1466 | +</div> |
| 1467 | + |
| 1468 | +<h2>E-mail, e-mail notification and authentication setup</h2> |
| 1469 | + |
| 1470 | +<div class="config-section"> |
| 1471 | + <div class="config-input"> |
| 1472 | + <label class='column'>E-mail features (global):</label> |
| 1473 | + <ul class="plain"> |
| 1474 | + <li><?php aField( $conf, "Email", "Enabled", "radio", "email_enabled" ); ?></li> |
| 1475 | + <li><?php aField( $conf, "Email", "Disabled", "radio", "email_disabled" ); ?></li> |
| 1476 | + </ul> |
| 1477 | + </div> |
| 1478 | + <p class="config-desc"> |
| 1479 | + Use this to disable all e-mail functions (password reminders, user-to-user e-mail, and e-mail notifications) |
| 1480 | + if sending mail doesn't work on your server. |
| 1481 | + </p> |
| 1482 | + |
| 1483 | + <div class="config-input"> |
| 1484 | + <label class='column'>User-to-user e-mail:</label> |
| 1485 | + <ul class="plain"> |
| 1486 | + <li><?php aField( $conf, "Emailuser", "Enabled", "radio", "emailuser_enabled" ); ?></li> |
| 1487 | + <li><?php aField( $conf, "Emailuser", "Disabled", "radio", "emailuser_disabled" ); ?></li> |
| 1488 | + </ul> |
| 1489 | + </div> |
| 1490 | + <p class="config-desc"> |
| 1491 | + 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. |
| 1492 | + </p> |
| 1493 | + <div class="config-input"> |
| 1494 | + <label class='column'>E-mail notification about changes:</label> |
| 1495 | + <ul class="plain"> |
| 1496 | + <li><?php aField( $conf, "Enotif", "Disabled", "radio", "enotif_disabled" ); ?></li> |
| 1497 | + <li><?php aField( $conf, "Enotif", "Enabled for changes to user discussion pages only", "radio", "enotif_usertalk" ); ?></li> |
| 1498 | + <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> |
| 1499 | + </ul> |
| 1500 | + </div> |
| 1501 | + <div class="config-desc"> |
| 1502 | + <p> |
| 1503 | + For this feature to work, an e-mail address must be present for the user account, and the notification |
| 1504 | + options in the user's preferences must be enabled. Also note the |
| 1505 | + authentication option below. When testing the feature, keep in mind that your own changes will never trigger notifications to be sent to yourself.</p> |
| 1506 | + |
| 1507 | + <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> |
| 1508 | + </div> |
| 1509 | + |
| 1510 | + <div class="config-input"> |
| 1511 | + <label class='column'>E-mail address authentication:</label> |
| 1512 | + <ul class="plain"> |
| 1513 | + <li><?php aField( $conf, "Eauthent", "Disabled", "radio", "eauthent_disabled" ); ?></li> |
| 1514 | + <li><?php aField( $conf, "Eauthent", "Enabled", "radio", "eauthent_enabled" ); ?></li> |
| 1515 | + </ul> |
| 1516 | + </div> |
| 1517 | + <div class="config-desc"> |
| 1518 | + <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 |
| 1519 | + change notification mails. Setting this option is <b>recommended</b> for public wikis because of potential abuse of the e-mail features above.</p> |
| 1520 | + </div> |
| 1521 | + |
| 1522 | +</div> |
| 1523 | + |
| 1524 | +<h2>Database config</h2> |
| 1525 | + |
| 1526 | +<div class="config-section"> |
| 1527 | +<div class="config-input"> |
| 1528 | + <label class='column'>Database type:</label> |
| 1529 | +<?php |
| 1530 | + if (isset($errs['DBpicktype'])) { |
| 1531 | + print "\t<span class='error'>" . htmlspecialchars( $errs['DBpicktype'] ) . "</span>\n"; |
| 1532 | + } |
| 1533 | +?> |
| 1534 | + <ul class='plain'><?php |
| 1535 | + database_picker($conf); |
| 1536 | + ?></ul> |
| 1537 | + </div> |
| 1538 | + |
| 1539 | + <div class="config-input" style="clear:left"> |
| 1540 | + <?php aField( $conf, "DBserver", "Database host:" ); ?> |
| 1541 | + </div> |
| 1542 | + <p class="config-desc"> |
| 1543 | + If your database server isn't on your web server, enter the name or IP address here. |
| 1544 | + </p> |
| 1545 | + |
| 1546 | + <div class="config-input"><?php aField( $conf, "DBname", "Database name:" ); ?></div> |
| 1547 | + <div class="config-input"><?php aField( $conf, "DBuser", "DB username:" ); ?></div> |
| 1548 | + <div class="config-input"><?php aField( $conf, "DBpassword", "DB password:", "password" ); ?></div> |
| 1549 | + <div class="config-input"><?php aField( $conf, "DBpassword2", "DB password confirm:", "password" ); ?></div> |
| 1550 | + <p class="config-desc"> |
| 1551 | + If you only have a single user account and database available, |
| 1552 | + enter those here. If you have database root access (see below) |
| 1553 | + you can specify new accounts/databases to be created. This account |
| 1554 | + will not be created if it pre-exists. If this is the case, ensure that it |
| 1555 | + has SELECT, INSERT, UPDATE, and DELETE permissions on the MediaWiki database. |
| 1556 | + </p> |
| 1557 | + |
| 1558 | + <div class="config-input"> |
| 1559 | + <label class="column">Superuser account:</label> |
| 1560 | + <input type="checkbox" name="useroot" id="useroot" <?php if( $useRoot ) { ?>checked="checked" <?php } ?> /> |
| 1561 | + <label for="useroot">Use superuser account</label> |
| 1562 | + <input type="checkbox" name="populateadmin" id="populateadmin" <?php if( $conf->populateadmin ) { ?>checked="checked" <?php } ?> /> |
| 1563 | + <label for="populateadmin">Set as admin user for maintenance</label> |
| 1564 | + </div> |
| 1565 | + <div class="config-input"><?php aField( $conf, "RootUser", "Superuser name:", "text" ); ?></div> |
| 1566 | + <div class="config-input"><?php aField( $conf, "RootPW", "Superuser password:", "password" ); ?></div> |
| 1567 | + |
| 1568 | + <p class="config-desc"> |
| 1569 | + If the database user specified above does not exist, or does not have access to create |
| 1570 | + the database (if needed) or tables within it, please check the box and provide details |
| 1571 | + of a superuser account, such as <strong>root</strong>, which does. |
| 1572 | + </p> |
| 1573 | + |
| 1574 | + <?php database_switcher('mysql'); ?> |
| 1575 | + <div class="config-input"><?php aField( $conf, "DBprefix", "Database table prefix:" ); ?></div> |
| 1576 | + <div class="config-desc"> |
| 1577 | + <p>If you need to share one database between multiple wikis, or |
| 1578 | + between MediaWiki and another web application, you may choose to |
| 1579 | + add a prefix to all the table names to avoid conflicts.</p> |
| 1580 | + |
| 1581 | + <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p> |
| 1582 | + </div> |
| 1583 | + |
| 1584 | + <div class="config-input"><label class="column">Storage Engine</label> |
| 1585 | + <div>Select one:</div> |
| 1586 | + <ul class="plain"> |
| 1587 | + <li><?php aField( $conf, "DBengine", "InnoDB", "radio", "InnoDB" ); ?></li> |
| 1588 | + <li><?php aField( $conf, "DBengine", "MyISAM", "radio", "MyISAM" ); ?></li> |
| 1589 | + </ul> |
| 1590 | + </div> |
| 1591 | + <p class="config-desc"> |
| 1592 | + InnoDB is best for public web installations, since it has good concurrency |
| 1593 | + support. MyISAM may be faster in single-user installations. MyISAM databases |
| 1594 | + tend to get corrupted more often than InnoDB databases. |
| 1595 | + </p> |
| 1596 | + <div class="config-input"><label class="column">Database character set</label> |
| 1597 | + <div>Select one:</div> |
| 1598 | + <ul class="plain"> |
| 1599 | + <li><?php aField( $conf, "DBschema", "MySQL 4.1/5.0 binary", "radio", "mysql5-binary" ); ?></li> |
| 1600 | + <li><?php aField( $conf, "DBschema", "MySQL 4.1/5.0 UTF-8", "radio", "mysql5" ); ?></li> |
| 1601 | + <li><?php aField( $conf, "DBschema", "MySQL 4.0 backwards-compatible UTF-8", "radio", "mysql4" ); ?></li> |
| 1602 | + </ul> |
| 1603 | + </div> |
| 1604 | + <p class="config-desc"> |
| 1605 | + This option is ignored on upgrade, the same character set will be kept. |
| 1606 | + <br/><br/> |
| 1607 | + <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!. |
| 1608 | + <br/><br/> |
| 1609 | + 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>. |
| 1610 | + </p> |
| 1611 | + </fieldset> |
| 1612 | + |
| 1613 | + <?php database_switcher('postgres'); ?> |
| 1614 | + <div class="config-input"><?php aField( $conf, "DBport", "Database port:" ); ?></div> |
| 1615 | + <div class="config-input"><?php aField( $conf, "DBmwschema", "Schema for mediawiki:" ); ?></div> |
| 1616 | + <div class="config-input"><?php aField( $conf, "DBts2schema", "Schema for tsearch2:" ); ?></div> |
| 1617 | + <div class="config-desc"> |
| 1618 | + <p>The username specified above (at "DB username") will have its search path set to the above schemas, |
| 1619 | + so it is recommended that you create a new user. The above schemas are generally correct: |
| 1620 | + only change them if you are sure you need to.</p> |
| 1621 | + </div> |
| 1622 | + </fieldset> |
| 1623 | + |
| 1624 | + <?php database_switcher('sqlite'); ?> |
| 1625 | + <div class="config-desc"> |
| 1626 | + <b>NOTE:</b> SQLite only uses the <i>Database name</i> setting above, the user, password and root settings are ignored. |
| 1627 | + </div> |
| 1628 | + <div class="config-input"><?php |
| 1629 | + aField( $conf, "SQLiteDataDir", "SQLite data directory:" ); |
| 1630 | + ?></div> |
| 1631 | + <div class="config-desc"> |
| 1632 | + <p>SQLite stores table data into files in the filesystem. |
| 1633 | + If you do not provide an explicit path, a "data" directory in |
| 1634 | + the parent of your document root will be used.</p> |
| 1635 | + |
| 1636 | + <p>This directory must exist and be writable by the web server.</p> |
| 1637 | + </div> |
| 1638 | + </fieldset> |
| 1639 | + |
| 1640 | + <?php database_switcher('mssql'); ?> |
| 1641 | + <div class="config-input"><?php |
| 1642 | + aField( $conf, "DBprefix2", "Database table prefix:" ); |
| 1643 | + ?></div> |
| 1644 | + <div class="config-desc"> |
| 1645 | + <p>If you need to share one database between multiple wikis, or |
| 1646 | + between MediaWiki and another web application, you may choose to |
| 1647 | + add a prefix to all the table names to avoid conflicts.</p> |
| 1648 | + |
| 1649 | + <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p> |
| 1650 | + </div> |
| 1651 | + </fieldset> |
| 1652 | + |
| 1653 | + <?php database_switcher('ibm_db2'); ?> |
| 1654 | + <div class="config-input"><?php |
| 1655 | + aField( $conf, "DBport_db2", "Database port:" ); |
| 1656 | + ?></div> |
| 1657 | + <div class="config-input"><?php |
| 1658 | + aField( $conf, "DBmwschema", "Schema for mediawiki:" ); |
| 1659 | + ?></div> |
| 1660 | + <div>Select one:</div> |
| 1661 | + <ul class="plain"> |
| 1662 | + <li><?php aField( $conf, "DBcataloged", "Cataloged (DB2 installed locally)", "radio", "cataloged" ); ?></li> |
| 1663 | + <li><?php aField( $conf, "DBcataloged", "Uncataloged (remote DB2 through ODBC)", "radio", "uncataloged" ); ?></li> |
| 1664 | + </ul> |
| 1665 | + <div class="config-desc"> |
| 1666 | + <p>If you need to share one database between multiple wikis, or |
| 1667 | + between MediaWiki and another web application, you may specify |
| 1668 | + a different schema to avoid conflicts.</p> |
| 1669 | + </div> |
| 1670 | + </fieldset> |
| 1671 | + |
| 1672 | + <?php database_switcher('oracle'); ?> |
| 1673 | + <div class="config-input"><?php aField( $conf, "DBprefix_ora", "Database table prefix:" ); ?></div> |
| 1674 | + <div class="config-desc"> |
| 1675 | + <p>If you need to share one database between multiple wikis, or |
| 1676 | + between MediaWiki and another web application, you may choose to |
| 1677 | + add a prefix to all the table names to avoid conflicts.</p> |
| 1678 | + |
| 1679 | + <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p> |
| 1680 | + </div> |
| 1681 | + <div class="config-input"><?php aField( $conf, "DBdefTS_ora", "Default tablespace:" ); ?></div> |
| 1682 | + <div class="config-input"><?php aField( $conf, "DBtempTS_ora", "Temporary tablespace:" ); ?></div> |
| 1683 | + </fieldset> |
| 1684 | + |
| 1685 | + <div class="config-input" style="padding:2em 0 3em"> |
| 1686 | + <label class='column'> </label> |
| 1687 | + <input type="submit" value="Install MediaWiki!" class="btn-install" /> |
| 1688 | + </div> |
| 1689 | +</div> |
| 1690 | +</form> |
| 1691 | +<script type="text/javascript"> |
| 1692 | +window.onload = toggleDBarea( <?php echo Xml::encodeJsVar( $conf->DBtype ); ?>, |
| 1693 | +<?php |
| 1694 | + ## If they passed in a root user name, don't populate it on page load |
| 1695 | + echo strlen(importPost('RootUser', '')) ? 0 : 1; |
| 1696 | +?>); |
| 1697 | +</script> |
| 1698 | +<?php |
| 1699 | +} |
| 1700 | + |
| 1701 | +/* -------------------------------------------------------------------------------------- */ |
| 1702 | +function writeSuccessMessage() { |
| 1703 | + $script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php'; |
| 1704 | + if ( wfIniGetBool( 'safe_mode' ) && !ini_get( 'open_basedir' ) ) { |
| 1705 | + echo <<<EOT |
| 1706 | +<div class="success-box"> |
| 1707 | +<p>Installation successful!</p> |
| 1708 | +<p>To complete the installation, please do the following: |
| 1709 | +<ol> |
| 1710 | + <li>Download config/LocalSettings.php with your FTP client or file manager</li> |
| 1711 | + <li>Upload it to the parent directory</li> |
| 1712 | + <li>Delete config/LocalSettings.php</li> |
| 1713 | + <li>Start using <a href='../$script'>your wiki</a>! |
| 1714 | +</ol> |
| 1715 | +<p>If you are in a shared hosting environment, do <strong>not</strong> just move LocalSettings.php |
| 1716 | +remotely. LocalSettings.php is currently owned by the user your webserver is running under, |
| 1717 | +which means that anyone on the same server can read your database password! Downloading |
| 1718 | +it and uploading it again will hopefully change the ownership to a user ID specific to you.</p> |
| 1719 | +</div> |
| 1720 | +EOT; |
| 1721 | + } else { |
| 1722 | + echo <<<EOT |
| 1723 | +<div class="success-box"> |
| 1724 | +<p> |
| 1725 | +<span class="success-message">Installation successful!</span> |
| 1726 | +Move the <tt>config/LocalSettings.php</tt> file to the parent directory, then follow |
| 1727 | +<a href="../$script"> this link</a> to your wiki.</p> |
| 1728 | +<p>You should change file permissions for <tt>LocalSettings.php</tt> as required to |
| 1729 | +prevent other users on the server reading passwords and altering configuration data.</p> |
| 1730 | +</div> |
| 1731 | +EOT; |
| 1732 | + } |
| 1733 | +} |
| 1734 | + |
| 1735 | + |
| 1736 | +function escapePhpString( $string ) { |
| 1737 | + if ( is_array( $string ) || is_object( $string ) ) { |
| 1738 | + return false; |
| 1739 | + } |
| 1740 | + return strtr( $string, |
| 1741 | + array( |
| 1742 | + "\n" => "\\n", |
| 1743 | + "\r" => "\\r", |
| 1744 | + "\t" => "\\t", |
| 1745 | + "\\" => "\\\\", |
| 1746 | + "\$" => "\\\$", |
| 1747 | + "\"" => "\\\"" |
| 1748 | + )); |
| 1749 | +} |
| 1750 | + |
| 1751 | +function writeLocalSettings( $conf ) { |
| 1752 | + $conf->PasswordSender = $conf->EmergencyContact; |
| 1753 | + $magic = ($conf->ImageMagick ? "" : "# "); |
| 1754 | + $convert = ($conf->ImageMagick ? $conf->ImageMagick : "/usr/bin/convert" ); |
| 1755 | + $rights = ($conf->RightsUrl) ? "" : "# "; |
| 1756 | + $hashedUploads = $conf->safeMode ? '' : '# '; |
| 1757 | + |
| 1758 | + if ( $conf->ShellLocale ) { |
| 1759 | + $locale = ''; |
| 1760 | + } else { |
| 1761 | + $locale = '# '; |
| 1762 | + $conf->ShellLocale = 'en_US.UTF-8'; |
| 1763 | + } |
| 1764 | + |
| 1765 | + switch ( $conf->Shm ) { |
| 1766 | + case 'memcached': |
| 1767 | + $cacheType = 'CACHE_MEMCACHED'; |
| 1768 | + $mcservers = var_export( $conf->MCServerArray, true ); |
| 1769 | + break; |
| 1770 | + case 'turck': |
| 1771 | + case 'xcache': |
| 1772 | + case 'apc': |
| 1773 | + case 'eaccel': |
| 1774 | + $cacheType = 'CACHE_ACCEL'; |
| 1775 | + $mcservers = 'array()'; |
| 1776 | + break; |
| 1777 | + case 'dba': |
| 1778 | + $cacheType = 'CACHE_DBA'; |
| 1779 | + $mcservers = 'array()'; |
| 1780 | + break; |
| 1781 | + default: |
| 1782 | + $cacheType = 'CACHE_NONE'; |
| 1783 | + $mcservers = 'array()'; |
| 1784 | + } |
| 1785 | + |
| 1786 | + if ( $conf->Email == 'email_enabled' ) { |
| 1787 | + $enableemail = 'true'; |
| 1788 | + $enableuseremail = ( $conf->Emailuser == 'emailuser_enabled' ) ? 'true' : 'false' ; |
| 1789 | + $eauthent = ( $conf->Eauthent == 'eauthent_enabled' ) ? 'true' : 'false' ; |
| 1790 | + switch ( $conf->Enotif ) { |
| 1791 | + case 'enotif_usertalk': |
| 1792 | + $enotifusertalk = 'true'; |
| 1793 | + $enotifwatchlist = 'false'; |
| 1794 | + break; |
| 1795 | + case 'enotif_allpages': |
| 1796 | + $enotifusertalk = 'true'; |
| 1797 | + $enotifwatchlist = 'true'; |
| 1798 | + break; |
| 1799 | + default: |
| 1800 | + $enotifusertalk = 'false'; |
| 1801 | + $enotifwatchlist = 'false'; |
| 1802 | + } |
| 1803 | + } else { |
| 1804 | + $enableuseremail = 'false'; |
| 1805 | + $enableemail = 'false'; |
| 1806 | + $eauthent = 'false'; |
| 1807 | + $enotifusertalk = 'false'; |
| 1808 | + $enotifwatchlist = 'false'; |
| 1809 | + } |
| 1810 | + |
| 1811 | + $file = @fopen( "/dev/urandom", "r" ); |
| 1812 | + if ( $file ) { |
| 1813 | + $secretKey = bin2hex( fread( $file, 32 ) ); |
| 1814 | + fclose( $file ); |
| 1815 | + } else { |
| 1816 | + $secretKey = ""; |
| 1817 | + for ( $i=0; $i<8; $i++ ) { |
| 1818 | + $secretKey .= dechex(mt_rand(0, 0x7fffffff)); |
| 1819 | + } |
| 1820 | + print "<li>Warning: \$wgSecretKey key is insecure, generated with mt_rand(). Consider changing it manually.</li>\n"; |
| 1821 | + } |
| 1822 | + |
| 1823 | + # Add slashes to strings for double quoting |
| 1824 | + $slconf = wfArrayMap( "escapePhpString", get_object_vars( $conf ) ); |
| 1825 | + if( $conf->License == 'gfdl1_2' || $conf->License == 'pd' || $conf->License == 'gfdl1_3' ) { |
| 1826 | + # Needs literal string interpolation for the current style path |
| 1827 | + $slconf['RightsIcon'] = $conf->RightsIcon; |
| 1828 | + } |
| 1829 | + |
| 1830 | + if( $conf->populateadmin ) { |
| 1831 | + $slconf['DBadminuser'] = $conf->RootUser; |
| 1832 | + $slconf['DBadminpassword'] = $conf->RootPW; |
| 1833 | + } |
| 1834 | + |
| 1835 | + if( $conf->DBtype == 'mysql' ) { |
| 1836 | + $dbsettings = |
| 1837 | +"# MySQL specific settings |
| 1838 | +\$wgDBprefix = \"{$slconf['DBprefix']}\"; |
| 1839 | + |
| 1840 | +# MySQL table options to use during installation or update |
| 1841 | +\$wgDBTableOptions = \"{$slconf['DBTableOptions']}\"; |
| 1842 | + |
| 1843 | +# Experimental charset support for MySQL 4.1/5.0. |
| 1844 | +\$wgDBmysql5 = {$conf->DBmysql5};"; |
| 1845 | + } elseif( $conf->DBtype == 'postgres' ) { |
| 1846 | + $dbsettings = |
| 1847 | +"# Postgres specific settings |
| 1848 | +\$wgDBport = \"{$slconf['DBport']}\"; |
| 1849 | +\$wgDBmwschema = \"{$slconf['DBmwschema']}\"; |
| 1850 | +\$wgDBts2schema = \"{$slconf['DBts2schema']}\";"; |
| 1851 | + } elseif( $conf->DBtype == 'sqlite' ) { |
| 1852 | + $dbsettings = |
| 1853 | +"# SQLite-specific settings |
| 1854 | +\$wgSQLiteDataDir = \"{$slconf['SQLiteDataDir']}\";"; |
| 1855 | + } elseif( $conf->DBtype == 'mssql' ) { |
| 1856 | + $dbsettings = |
| 1857 | +"# MSSQL specific settings |
| 1858 | +\$wgDBprefix = \"{$slconf['DBprefix2']}\";"; |
| 1859 | + } elseif( $conf->DBtype == 'ibm_db2' ) { |
| 1860 | + $dbsettings = |
| 1861 | +"# DB2 specific settings |
| 1862 | +\$wgDBport_db2 = \"{$slconf['DBport_db2']}\"; |
| 1863 | +\$wgDBmwschema = \"{$slconf['DBmwschema']}\"; |
| 1864 | +\$wgDBcataloged = \"{$slconf['DBcataloged']}\";"; |
| 1865 | + } elseif( $conf->DBtype == 'oracle' ) { |
| 1866 | + $dbsettings = |
| 1867 | +"# Oracle specific settings |
| 1868 | +\$wgDBprefix = \"{$slconf['DBprefix']}\";"; |
| 1869 | + } else { |
| 1870 | + // ummm... :D |
| 1871 | + $dbsettings = ''; |
| 1872 | + } |
| 1873 | + |
| 1874 | + |
| 1875 | + $localsettings = " |
| 1876 | +# This file was automatically generated by the MediaWiki installer. |
| 1877 | +# If you make manual changes, please keep track in case you need to |
| 1878 | +# recreate them later. |
| 1879 | +# |
| 1880 | +# See includes/DefaultSettings.php for all configurable settings |
| 1881 | +# and their default values, but don't forget to make changes in _this_ |
| 1882 | +# file, not there. |
| 1883 | +# |
| 1884 | +# Further documentation for configuration settings may be found at: |
| 1885 | +# http://www.mediawiki.org/wiki/Manual:Configuration_settings |
| 1886 | + |
| 1887 | +# If you customize your file layout, set \$IP to the directory that contains |
| 1888 | +# the other MediaWiki files. It will be used as a base to locate files. |
| 1889 | +if( defined( 'MW_INSTALL_PATH' ) ) { |
| 1890 | + \$IP = MW_INSTALL_PATH; |
| 1891 | +} else { |
| 1892 | + \$IP = dirname( __FILE__ ); |
| 1893 | +} |
| 1894 | + |
| 1895 | +\$path = array( \$IP, \"\$IP/includes\", \"\$IP/languages\" ); |
| 1896 | +set_include_path( implode( PATH_SEPARATOR, \$path ) . PATH_SEPARATOR . get_include_path() ); |
| 1897 | + |
| 1898 | +require_once( \"\$IP/includes/DefaultSettings.php\" ); |
| 1899 | + |
| 1900 | +if ( \$wgCommandLineMode ) { |
| 1901 | + if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) { |
| 1902 | + die( \"This script must be run from the command line\\n\" ); |
| 1903 | + } |
| 1904 | +} |
| 1905 | +## Uncomment this to disable output compression |
| 1906 | +# \$wgDisableOutputCompression = true; |
| 1907 | + |
| 1908 | +\$wgSitename = \"{$slconf['Sitename']}\"; |
| 1909 | + |
| 1910 | +## The URL base path to the directory containing the wiki; |
| 1911 | +## defaults for all runtime URL paths are based off of this. |
| 1912 | +## For more information on customizing the URLs please see: |
| 1913 | +## http://www.mediawiki.org/wiki/Manual:Short_URL |
| 1914 | +\$wgScriptPath = \"{$slconf['ScriptPath']}\"; |
| 1915 | +\$wgScriptExtension = \"{$slconf['ScriptExtension']}\"; |
| 1916 | + |
| 1917 | +## UPO means: this is also a user preference option |
| 1918 | + |
| 1919 | +\$wgEnableEmail = $enableemail; |
| 1920 | +\$wgEnableUserEmail = $enableuseremail; # UPO |
| 1921 | + |
| 1922 | +\$wgEmergencyContact = \"{$slconf['EmergencyContact']}\"; |
| 1923 | +\$wgPasswordSender = \"{$slconf['PasswordSender']}\"; |
| 1924 | + |
| 1925 | +\$wgEnotifUserTalk = $enotifusertalk; # UPO |
| 1926 | +\$wgEnotifWatchlist = $enotifwatchlist; # UPO |
| 1927 | +\$wgEmailAuthentication = $eauthent; |
| 1928 | + |
| 1929 | +## Database settings |
| 1930 | +\$wgDBtype = \"{$slconf['DBtype']}\"; |
| 1931 | +\$wgDBserver = \"{$slconf['DBserver']}\"; |
| 1932 | +\$wgDBname = \"{$slconf['DBname']}\"; |
| 1933 | +\$wgDBuser = \"{$slconf['DBuser']}\"; |
| 1934 | +\$wgDBpassword = \"{$slconf['DBpassword']}\"; |
| 1935 | + |
| 1936 | +{$dbsettings} |
| 1937 | + |
| 1938 | +## Database admin settings, used for maintenance scripts |
| 1939 | +\$wgDBadminuser = \"". ($conf->populateadmin ? $slconf['DBadminuser'] : '' )."\"; |
| 1940 | +\$wgDBadminpassword = \"". ($conf->populateadmin ? $slconf['DBadminpassword'] : '' )."\"; |
| 1941 | + |
| 1942 | +## Shared memory settings |
| 1943 | +\$wgMainCacheType = $cacheType; |
| 1944 | +\$wgMemCachedServers = $mcservers; |
| 1945 | + |
| 1946 | +## To enable image uploads, make sure the 'images' directory |
| 1947 | +## is writable, then set this to true: |
| 1948 | +\$wgEnableUploads = false; |
| 1949 | +{$magic}\$wgUseImageMagick = true; |
| 1950 | +{$magic}\$wgImageMagickConvertCommand = \"{$convert}\"; |
| 1951 | + |
| 1952 | +## If you use ImageMagick (or any other shell command) on a |
| 1953 | +## Linux server, this will need to be set to the name of an |
| 1954 | +## available UTF-8 locale |
| 1955 | +{$locale}\$wgShellLocale = \"{$slconf['ShellLocale']}\"; |
| 1956 | + |
| 1957 | +## If you want to use image uploads under safe mode, |
| 1958 | +## create the directories images/archive, images/thumb and |
| 1959 | +## images/temp, and make them all writable. Then uncomment |
| 1960 | +## this, if it's not already uncommented: |
| 1961 | +{$hashedUploads}\$wgHashedUploadDirectory = false; |
| 1962 | + |
| 1963 | +## If you have the appropriate support software installed |
| 1964 | +## you can enable inline LaTeX equations: |
| 1965 | +\$wgUseTeX = false; |
| 1966 | + |
| 1967 | +## Set \$wgCacheDirectory to a writable directory on the web server |
| 1968 | +## to make your wiki go slightly faster. The directory should not |
| 1969 | +## be publically accessible from the web. |
| 1970 | +#\$wgCacheDirectory = \"\$IP/cache\"; |
| 1971 | + |
| 1972 | +\$wgLocalInterwiki = strtolower( \$wgSitename ); |
| 1973 | + |
| 1974 | +\$wgLanguageCode = \"{$slconf['LanguageCode']}\"; |
| 1975 | + |
| 1976 | +\$wgSecretKey = \"$secretKey\"; |
| 1977 | + |
| 1978 | +## Default skin: you can change the default skin. Use the internal symbolic |
| 1979 | +## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook': |
| 1980 | +\$wgDefaultSkin = 'monobook'; |
| 1981 | + |
| 1982 | +## For attaching licensing metadata to pages, and displaying an |
| 1983 | +## appropriate copyright notice / icon. GNU Free Documentation |
| 1984 | +## License and Creative Commons licenses are supported so far. |
| 1985 | +{$rights}\$wgEnableCreativeCommonsRdf = true; |
| 1986 | +\$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright |
| 1987 | +\$wgRightsUrl = \"{$slconf['RightsUrl']}\"; |
| 1988 | +\$wgRightsText = \"{$slconf['RightsText']}\"; |
| 1989 | +\$wgRightsIcon = \"{$slconf['RightsIcon']}\"; |
| 1990 | +# \$wgRightsCode = \"{$slconf['RightsCode']}\"; # Not yet used |
| 1991 | + |
| 1992 | +\$wgDiff3 = \"{$slconf['diff3']}\"; |
| 1993 | + |
| 1994 | +\$wgPhpCliPath = \"{$slconf['phpCliPath']}\"; |
| 1995 | + |
| 1996 | +# When you make changes to this configuration file, this will make |
| 1997 | +# sure that cached pages are cleared. |
| 1998 | +\$wgCacheEpoch = max( \$wgCacheEpoch, gmdate( 'YmdHis', @filemtime( __FILE__ ) ) ); |
| 1999 | +"; ## End of setting the $localsettings string |
| 2000 | + |
| 2001 | + // Keep things in Unix line endings internally; |
| 2002 | + // the system will write out as local text type. |
| 2003 | + return str_replace( "\r\n", "\n", $localsettings ); |
| 2004 | +} |
| 2005 | + |
| 2006 | +function dieout( $text ) { |
| 2007 | + global $mainListOpened; |
| 2008 | + if( $mainListOpened ) echo( "</ul>" ); |
| 2009 | + if( $text != '' && substr( $text, 0, 2 ) != '<p' && substr( $text, 0, 2 ) != '<h' ){ |
| 2010 | + echo "<p>$text</p>\n"; |
| 2011 | + } else { |
| 2012 | + echo $text; |
| 2013 | + } |
| 2014 | + die( "\n\n</div>\n</div>\n</div>\n</div>\n</body>\n</html>" ); |
| 2015 | +} |
| 2016 | + |
| 2017 | +function importVar( &$var, $name, $default = "" ) { |
| 2018 | + if( isset( $var[$name] ) ) { |
| 2019 | + $retval = $var[$name]; |
| 2020 | + if ( get_magic_quotes_gpc() ) { |
| 2021 | + $retval = stripslashes( $retval ); |
| 2022 | + } |
| 2023 | + } else { |
| 2024 | + $retval = $default; |
| 2025 | + } |
| 2026 | + taint( $retval ); |
| 2027 | + return $retval; |
| 2028 | +} |
| 2029 | + |
| 2030 | +function importPost( $name, $default = "" ) { |
| 2031 | + return importVar( $_POST, $name, $default ); |
| 2032 | +} |
| 2033 | + |
| 2034 | +function importCheck( $name ) { |
| 2035 | + return isset( $_POST[$name] ); |
| 2036 | +} |
| 2037 | + |
| 2038 | +function importRequest( $name, $default = "" ) { |
| 2039 | + return importVar( $_REQUEST, $name, $default ); |
| 2040 | +} |
| 2041 | + |
| 2042 | +function aField( &$conf, $field, $text, $type = "text", $value = "", $onclick = '' ) { |
| 2043 | + static $radioCount = 0; |
| 2044 | + if( $type != "" ) { |
| 2045 | + $xtype = "type=\"$type\""; |
| 2046 | + } else { |
| 2047 | + $xtype = ""; |
| 2048 | + } |
| 2049 | + |
| 2050 | + $id = $field; |
| 2051 | + $nolabel = ($type == "radio") || ($type == "hidden"); |
| 2052 | + |
| 2053 | + if ($type == 'radio') |
| 2054 | + $id .= $radioCount++; |
| 2055 | + |
| 2056 | + if( !$nolabel ) { |
| 2057 | + echo "<label class='column' for=\"$id\">$text</label>"; |
| 2058 | + } |
| 2059 | + |
| 2060 | + if( $type == "radio" && $value == $conf->$field ) { |
| 2061 | + $checked = "checked='checked'"; |
| 2062 | + } else { |
| 2063 | + $checked = ""; |
| 2064 | + } |
| 2065 | + echo "<input $xtype name=\"$field\" id=\"$id\" class=\"iput-$type\" $checked "; |
| 2066 | + if ($onclick) { |
| 2067 | + echo " onclick='toggleDBarea(\"$value\",1)' " ; |
| 2068 | + } |
| 2069 | + echo "value=\""; |
| 2070 | + if( $type == "radio" ) { |
| 2071 | + echo htmlspecialchars( $value ); |
| 2072 | + } else { |
| 2073 | + echo htmlspecialchars( $conf->$field ); |
| 2074 | + } |
| 2075 | + |
| 2076 | + |
| 2077 | + echo "\" />"; |
| 2078 | + if( $nolabel ) { |
| 2079 | + echo "<label for=\"$id\">$text</label>"; |
| 2080 | + } |
| 2081 | + |
| 2082 | + global $errs; |
| 2083 | + if(isset($errs[$field])) { |
| 2084 | + echo "<span class='error'>" . htmlspecialchars( $errs[$field] ) . "</span>\n"; |
| 2085 | + } |
| 2086 | +} |
| 2087 | + |
| 2088 | +function getLanguageList() { |
| 2089 | + global $wgLanguageNames, $IP; |
| 2090 | + if( !isset( $wgLanguageNames ) ) { |
| 2091 | + require_once( "$IP/languages/Names.php" ); |
| 2092 | + } |
| 2093 | + |
| 2094 | + $codes = array(); |
| 2095 | + |
| 2096 | + $d = opendir( "../languages/messages" ); |
| 2097 | + /* In case we are called from the root directory */ |
| 2098 | + if (!$d) |
| 2099 | + $d = opendir( "languages/messages"); |
| 2100 | + while( false !== ($f = readdir( $d ) ) ) { |
| 2101 | + $m = array(); |
| 2102 | + if( preg_match( '/Messages([A-Z][a-z_]+)\.php$/', $f, $m ) ) { |
| 2103 | + $code = str_replace( '_', '-', strtolower( $m[1] ) ); |
| 2104 | + if( isset( $wgLanguageNames[$code] ) ) { |
| 2105 | + $name = wfBCP47( $code ) . ' - ' . $wgLanguageNames[$code]; |
| 2106 | + } else { |
| 2107 | + $name = $code; |
| 2108 | + } |
| 2109 | + $codes[$code] = $name; |
| 2110 | + } |
| 2111 | + } |
| 2112 | + closedir( $d ); |
| 2113 | + ksort( $codes ); |
| 2114 | + return $codes; |
| 2115 | +} |
| 2116 | + |
| 2117 | +#Check for location of an executable |
| 2118 | +# @param string $loc single location to check |
| 2119 | +# @param array $names filenames to check for. |
| 2120 | +# @param mixed $versioninfo array of details to use when checking version, use false for no version checking |
| 2121 | +function locate_executable($loc, $names, $versioninfo = false) { |
| 2122 | + if (!is_array($names)) |
| 2123 | + $names = array($names); |
| 2124 | + |
| 2125 | + foreach ($names as $name) { |
| 2126 | + $command = "$loc".DIRECTORY_SEPARATOR."$name"; |
| 2127 | + if (@file_exists($command)) { |
| 2128 | + if (!$versioninfo) |
| 2129 | + return $command; |
| 2130 | + |
| 2131 | + $file = str_replace('$1', $command, $versioninfo[0]); |
| 2132 | + if (strstr(`$file`, $versioninfo[1]) !== false) |
| 2133 | + return $command; |
| 2134 | + } |
| 2135 | + } |
| 2136 | + return false; |
| 2137 | +} |
| 2138 | + |
| 2139 | +# Test a memcached server |
| 2140 | +function testMemcachedServer( $server ) { |
| 2141 | + $hostport = explode(":", $server); |
| 2142 | + $errstr = false; |
| 2143 | + $fp = false; |
| 2144 | + if ( !function_exists( 'fsockopen' ) ) { |
| 2145 | + $errstr = "Can't connect to memcached, fsockopen() not present"; |
| 2146 | + } |
| 2147 | + if ( !$errstr && count( $hostport ) != 2 ) { |
| 2148 | + $errstr = 'Please specify host and port'; |
| 2149 | + } |
| 2150 | + if ( !$errstr ) { |
| 2151 | + list( $host, $port ) = $hostport; |
| 2152 | + $errno = 0; |
| 2153 | + $fsockerr = ''; |
| 2154 | + |
| 2155 | + $fp = @fsockopen( $host, $port, $errno, $fsockerr, 1.0 ); |
| 2156 | + if ( $fp === false ) { |
| 2157 | + $errstr = "Cannot connect to memcached on $host:$port : $fsockerr"; |
| 2158 | + } |
| 2159 | + } |
| 2160 | + if ( !$errstr ) { |
| 2161 | + $command = "version\r\n"; |
| 2162 | + $bytes = fwrite( $fp, $command ); |
| 2163 | + if ( $bytes != strlen( $command ) ) { |
| 2164 | + $errstr = "Cannot write to memcached socket on $host:$port"; |
| 2165 | + } |
| 2166 | + } |
| 2167 | + if ( !$errstr ) { |
| 2168 | + $expected = "VERSION "; |
| 2169 | + $response = fread( $fp, strlen( $expected ) ); |
| 2170 | + if ( $response != $expected ) { |
| 2171 | + $errstr = "Didn't get correct memcached response from $host:$port"; |
| 2172 | + } |
| 2173 | + } |
| 2174 | + if ( $fp ) { |
| 2175 | + fclose( $fp ); |
| 2176 | + } |
| 2177 | + if ( !$errstr ) { |
| 2178 | + echo "<li>Connected to memcached on " . htmlspecialchars( "$host:$port" ) ." successfully</li>"; |
| 2179 | + } |
| 2180 | + return $errstr; |
| 2181 | +} |
| 2182 | + |
| 2183 | +function database_picker($conf) { |
| 2184 | + global $ourdb; |
| 2185 | + print "\n"; |
| 2186 | + foreach(array_keys($ourdb) as $db) { |
| 2187 | + if ($ourdb[$db]['havedriver']) { |
| 2188 | + print "\t<li>"; |
| 2189 | + aField( $conf, "DBtype", $ourdb[$db]['fullname'], 'radio', $db, 'onclick'); |
| 2190 | + print "</li>\n"; |
| 2191 | + } |
| 2192 | + } |
| 2193 | + print "\n\t"; |
| 2194 | +} |
| 2195 | + |
| 2196 | +function database_switcher($db) { |
| 2197 | + global $ourdb; |
| 2198 | + $color = $ourdb[$db]['bgcolor']; |
| 2199 | + $full = $ourdb[$db]['fullname']; |
| 2200 | + print "<fieldset id='$db'><legend>$full specific options</legend>\n"; |
| 2201 | +} |
| 2202 | + |
| 2203 | +function printListItem( $item ) { |
| 2204 | + print "<li>$item</li>"; |
| 2205 | +} |
| 2206 | + |
| 2207 | +# Determine a suitable value for $wgShellLocale |
| 2208 | +function getShellLocale( $wikiLang ) { |
| 2209 | + # Give up now if we're in safe mode or open_basedir |
| 2210 | + # It's theoretically possible but tricky to work with |
| 2211 | + if ( wfIniGetBool( "safe_mode" ) || ini_get( 'open_basedir' ) ) { |
| 2212 | + return false; |
| 2213 | + } |
| 2214 | + |
| 2215 | + $os = php_uname( 's' ); |
| 2216 | + $supported = array( 'Linux', 'SunOS', 'HP-UX' ); # Tested these |
| 2217 | + if ( !in_array( $os, $supported ) ) { |
| 2218 | + return false; |
| 2219 | + } |
| 2220 | + |
| 2221 | + # Get a list of available locales |
| 2222 | + $lines = $ret = false; |
| 2223 | + exec( '/usr/bin/locale -a', $lines, $ret ); |
| 2224 | + if ( $ret ) { |
| 2225 | + return false; |
| 2226 | + } |
| 2227 | + |
| 2228 | + $lines = wfArrayMap( 'trim', $lines ); |
| 2229 | + $candidatesByLocale = array(); |
| 2230 | + $candidatesByLang = array(); |
| 2231 | + foreach ( $lines as $line ) { |
| 2232 | + if ( $line === '' ) { |
| 2233 | + continue; |
| 2234 | + } |
| 2235 | + if ( !preg_match( '/^([a-zA-Z]+)(_[a-zA-Z]+|)\.(utf8|UTF-8)(@[a-zA-Z_]*|)$/i', $line, $m ) ) { |
| 2236 | + continue; |
| 2237 | + } |
| 2238 | + list( $all, $lang, $territory, $charset, $modifier ) = $m; |
| 2239 | + $candidatesByLocale[$m[0]] = $m; |
| 2240 | + $candidatesByLang[$lang][] = $m; |
| 2241 | + } |
| 2242 | + |
| 2243 | + # Try the current value of LANG |
| 2244 | + if ( isset( $candidatesByLocale[ getenv( 'LANG' ) ] ) ) { |
| 2245 | + return getenv( 'LANG' ); |
| 2246 | + } |
| 2247 | + |
| 2248 | + # Try the most common ones |
| 2249 | + $commonLocales = array( 'en_US.UTF-8', 'en_US.utf8', 'de_DE.UTF-8', 'de_DE.utf8' ); |
| 2250 | + foreach ( $commonLocales as $commonLocale ) { |
| 2251 | + if ( isset( $candidatesByLocale[$commonLocale] ) ) { |
| 2252 | + return $commonLocale; |
| 2253 | + } |
| 2254 | + } |
| 2255 | + |
| 2256 | + # Is there an available locale in the Wiki's language? |
| 2257 | + if ( isset( $candidatesByLang[$wikiLang] ) ) { |
| 2258 | + $m = reset( $candidatesByLang[$wikiLang] ); |
| 2259 | + return $m[0]; |
| 2260 | + } |
| 2261 | + |
| 2262 | + # Are there any at all? |
| 2263 | + if ( count( $candidatesByLocale ) ) { |
| 2264 | + $m = reset( $candidatesByLocale ); |
| 2265 | + return $m[0]; |
| 2266 | + } |
| 2267 | + |
| 2268 | + # Give up |
| 2269 | + return false; |
| 2270 | +} |
| 2271 | + |
| 2272 | +function wfArrayMap( $function, $input ) { |
| 2273 | + $ret = array_map( $function, $input ); |
| 2274 | + foreach ( $ret as $key => $value ) { |
| 2275 | + $taint = istainted( $input[$key] ); |
| 2276 | + if ( $taint ) { |
| 2277 | + taint( $ret[$key], $taint ); |
| 2278 | + } |
| 2279 | + } |
| 2280 | + return $ret; |
| 2281 | +} |
| 2282 | + |
| 2283 | +?> |
| 2284 | + |
| 2285 | + <div class="license"> |
| 2286 | + <hr/> |
| 2287 | + <p>This program is free software; you can redistribute it and/or modify |
| 2288 | + it under the terms of the GNU General Public License as published by |
| 2289 | + the Free Software Foundation; either version 2 of the License, or |
| 2290 | + (at your option) any later version.</p> |
| 2291 | + |
| 2292 | + <p>This program is distributed in the hope that it will be useful, |
| 2293 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 2294 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 2295 | + GNU General Public License for more details.</p> |
| 2296 | + |
| 2297 | + <p>You should have received <a href="../COPYING">a copy of the GNU General Public License</a> |
| 2298 | + along with this program; if not, write to the Free Software |
| 2299 | + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 2300 | + or <a href="http://www.gnu.org/copyleft/gpl.html">read it online</a></p> |
| 2301 | + </div> |
| 2302 | + |
| 2303 | +</div></div></div> |
| 2304 | + |
| 2305 | + |
| 2306 | +<div id="column-one"> |
| 2307 | + <div class="portlet" id="p-logo"> |
| 2308 | + <a style="background-image: url(../skins/common/images/mediawiki.png);" |
| 2309 | + href="../" |
| 2310 | + title="Main Page"></a> |
| 2311 | + </div> |
| 2312 | + <script type="text/javascript"> if (window.isMSIE55) fixalpha(); </script> |
| 2313 | + <div class='portlet'><div class='pBody'> |
| 2314 | + <ul> |
| 2315 | + <li><a href="../README">Readme</a></li> |
| 2316 | + <li><a href="../RELEASE-NOTES">Release notes</a></li> |
| 2317 | + <li><a href="../docs/">Documentation</a></li> |
| 2318 | + <li><a href="http://www.mediawiki.org/wiki/Help:Contents">User's Guide</a></li> |
| 2319 | + <li><a href="http://www.mediawiki.org/wiki/Manual:Contents">Administrator's Guide</a></li> |
| 2320 | + <li><a href="http://www.mediawiki.org/wiki/Manual:FAQ">FAQ</a></li> |
| 2321 | + </ul> |
| 2322 | + <p style="font-size:90%;margin-top:1em">MediaWiki is Copyright © 2001-2009 by Magnus Manske, Brion Vibber, |
| 2323 | + Lee Daniel Crocker, Tim Starling, Erik Möller, Gabriel Wicke, Ævar Arnfjörð Bjarmason, Niklas Laxström, |
| 2324 | + Domas Mituzas, Rob Church, Yuri Astrakhan, Aryeh Gregor, Aaron Schulz and others.</p> |
| 2325 | + </div></div> |
| 2326 | +</div> |
| 2327 | + |
| 2328 | +</div> |
| 2329 | + |
| 2330 | +</body> |
| 2331 | +</html> |
Property changes on: trunk/phase3/config/Installer.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 2332 | + native |
Index: trunk/phase3/config/index.php |
— | — | @@ -19,13 +19,6 @@ |
20 | 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
21 | 21 | # http://www.gnu.org/copyleft/gpl.html |
22 | 22 | |
23 | | -error_reporting( E_ALL | E_STRICT ); |
24 | | -header( "Content-type: text/html; charset=utf-8" ); |
25 | | -@ini_set( "display_errors", true ); |
26 | | - |
27 | | -# In case of errors, let output be clean. |
28 | | -$wgRequestTime = microtime( true ); |
29 | | - |
30 | 23 | # Attempt to set up the include path, to fix problems with relative includes |
31 | 24 | $IP = dirname( dirname( __FILE__ ) ); |
32 | 25 | define( 'MW_INSTALL_PATH', $IP ); |
— | — | @@ -34,2301 +27,17 @@ |
35 | 28 | define( "MEDIAWIKI", true ); |
36 | 29 | define( "MEDIAWIKI_INSTALL", true ); |
37 | 30 | |
38 | | -// Run version checks before including other files |
39 | | -// so people don't see a scary parse error. |
40 | | -require_once( "$IP/install-utils.inc" ); |
41 | | -install_version_checks(); |
42 | | - |
43 | | -require_once( "$IP/includes/Defines.php" ); |
44 | | -require_once( "$IP/includes/DefaultSettings.php" ); |
45 | | -require_once( "$IP/includes/AutoLoader.php" ); |
46 | | -require_once( "$IP/includes/MagicWord.php" ); |
47 | | -require_once( "$IP/includes/Namespace.php" ); |
48 | | -require_once( "$IP/includes/ProfilerStub.php" ); |
49 | | -require_once( "$IP/includes/GlobalFunctions.php" ); |
50 | | -require_once( "$IP/includes/Hooks.php" ); |
51 | | -require_once( "$IP/includes/Exception.php" ); |
52 | | - |
53 | | -# If we get an exception, the user needs to know |
54 | | -# all the details |
55 | | -$wgShowExceptionDetails = true; |
56 | | -$wgShowSQLErrors = true; |
57 | | -wfInstallExceptionHandler(); |
58 | | -## Databases we support: |
59 | | - |
60 | | -$ourdb = array(); |
61 | | -$ourdb['mysql']['fullname'] = 'MySQL'; |
62 | | -$ourdb['mysql']['havedriver'] = 0; |
63 | | -$ourdb['mysql']['compile'] = 'mysql'; |
64 | | -$ourdb['mysql']['bgcolor'] = '#ffe5a7'; |
65 | | -$ourdb['mysql']['rootuser'] = 'root'; |
66 | | - |
67 | | -$ourdb['postgres']['fullname'] = 'PostgreSQL'; |
68 | | -$ourdb['postgres']['havedriver'] = 0; |
69 | | -$ourdb['postgres']['compile'] = 'pgsql'; |
70 | | -$ourdb['postgres']['bgcolor'] = '#aaccff'; |
71 | | -$ourdb['postgres']['rootuser'] = 'postgres'; |
72 | | - |
73 | | -$ourdb['sqlite']['fullname'] = 'SQLite'; |
74 | | -$ourdb['sqlite']['havedriver'] = 0; |
75 | | -$ourdb['sqlite']['compile'] = 'pdo_sqlite'; |
76 | | -$ourdb['sqlite']['bgcolor'] = '#b1ebb1'; |
77 | | -$ourdb['sqlite']['rootuser'] = ''; |
78 | | - |
79 | | -$ourdb['mssql']['fullname'] = 'MSSQL'; |
80 | | -$ourdb['mssql']['havedriver'] = 0; |
81 | | -$ourdb['mssql']['compile'] = 'mssql not ready'; # Change to 'mssql' after includes/DatabaseMssql.php added; |
82 | | -$ourdb['mssql']['bgcolor'] = '#ffc0cb'; |
83 | | -$ourdb['mssql']['rootuser'] = 'administrator'; |
84 | | - |
85 | | -$ourdb['ibm_db2']['fullname'] = 'DB2'; |
86 | | -$ourdb['ibm_db2']['havedriver'] = 0; |
87 | | -$ourdb['ibm_db2']['compile'] = 'ibm_db2'; |
88 | | -$ourdb['ibm_db2']['bgcolor'] = '#ffeba1'; |
89 | | -$ourdb['ibm_db2']['rootuser'] = 'db2admin'; |
90 | | - |
91 | | -$ourdb['oracle']['fullname'] = 'Oracle'; |
92 | | -$ourdb['oracle']['havedriver'] = 0; |
93 | | -$ourdb['oracle']['compile'] = 'oci8'; |
94 | | -$ourdb['oracle']['bgcolor'] = '#ffeba1'; |
95 | | -$ourdb['oracle']['rootuser'] = ''; |
96 | | - |
97 | | -?> |
98 | | -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
99 | | -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr"> |
100 | | -<head> |
101 | | - <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> |
102 | | - <meta name="robots" content="noindex,nofollow"/> |
103 | | - <title>MediaWiki <?php echo htmlspecialchars( $wgVersion ); ?> Installation</title> |
104 | | - <style type="text/css"> |
105 | | - |
106 | | - @import "../skins/monobook/main.css"; |
107 | | - |
108 | | - .env-check { |
109 | | - font-size: 90%; |
110 | | - margin: 1em 0 1em 2.5em; |
111 | | - } |
112 | | - |
113 | | - .config-section { |
114 | | - margin-top: 2em; |
115 | | - } |
116 | | - |
117 | | - .config-section label.column { |
118 | | - clear: left; |
119 | | - font-weight: bold; |
120 | | - width: 13em; |
121 | | - float: left; |
122 | | - text-align: right; |
123 | | - padding-right: 1em; |
124 | | - padding-top: .2em; |
125 | | - } |
126 | | - |
127 | | - .config-input { |
128 | | - clear: left; |
129 | | - zoom: 100%; /* IE hack */ |
130 | | - } |
131 | | - |
132 | | - .config-section .config-desc { |
133 | | - clear: left; |
134 | | - margin: 0 0 2em 18em; |
135 | | - padding-top: 1em; |
136 | | - font-size: 85%; |
137 | | - } |
138 | | - |
139 | | - .iput-text, .iput-password { |
140 | | - width: 14em; |
141 | | - margin-right: 1em; |
142 | | - } |
143 | | - |
144 | | - .error { |
145 | | - color: red; |
146 | | - background-color: #fff; |
147 | | - font-weight: bold; |
148 | | - left: 1em; |
149 | | - font-size: 100%; |
150 | | - } |
151 | | - |
152 | | - .error-top { |
153 | | - color: red; |
154 | | - background-color: #FFF0F0; |
155 | | - border: 2px solid red; |
156 | | - font-size: 130%; |
157 | | - font-weight: bold; |
158 | | - padding: 1em 1.5em; |
159 | | - margin: 2em 0 1em; |
160 | | - } |
161 | | - |
162 | | - ul.plain { |
163 | | - list-style-type: none; |
164 | | - list-style-image: none; |
165 | | - float: left; |
166 | | - margin: 0; |
167 | | - padding: 0; |
168 | | - } |
169 | | - |
170 | | - .btn-install { |
171 | | - font-weight: bold; |
172 | | - font-size: 110%; |
173 | | - padding: .2em .3em; |
174 | | - } |
175 | | - |
176 | | - .license { |
177 | | - font-size: 85%; |
178 | | - padding-top: 3em; |
179 | | - } |
180 | | - |
181 | | - span.success-message { |
182 | | - font-weight: bold; |
183 | | - font-size: 110%; |
184 | | - color: green; |
185 | | - } |
186 | | - .success-box { |
187 | | - font-size: 130%; |
188 | | - } |
189 | | - |
190 | | - </style> |
191 | | - <script type="text/javascript"> |
192 | | - <!-- |
193 | | - function hideall() { |
194 | | - <?php foreach (array_keys($ourdb) as $db) { |
195 | | - echo "\n var i = document.getElementById('$db'); if (i) i.style.display='none';"; |
196 | | - } |
197 | | - ?> |
198 | | - |
199 | | - } |
200 | | - function toggleDBarea(id,defaultroot) { |
201 | | - hideall(); |
202 | | - var dbarea = document.getElementById(id); |
203 | | - if (dbarea) dbarea.style.display = (dbarea.style.display == 'none') ? 'block' : 'none'; |
204 | | - var db = document.getElementById('RootUser'); |
205 | | - if (defaultroot) { |
206 | | -<?php foreach (array_keys($ourdb) as $db) { |
207 | | - echo " if (id == '$db') { db.value = '".$ourdb[$db]['rootuser']."';}\n"; |
208 | | -}?> |
209 | | - } |
210 | | - } |
211 | | - // --> |
212 | | - </script> |
213 | | -</head> |
214 | | - |
215 | | -<body> |
216 | | -<div id="globalWrapper"> |
217 | | -<div id="column-content"> |
218 | | -<div id="content"> |
219 | | -<div id="bodyContent"> |
220 | | - |
221 | | -<h1>MediaWiki <?php print htmlspecialchars( $wgVersion ) ?> Installation</h1> |
222 | | - |
223 | | -<?php |
224 | | -$mainListOpened = false; # Is the main list (environement checking) opend ? Used by dieout |
225 | | - |
226 | | -/* Check for existing configurations and bug out! */ |
227 | | - |
228 | | -if( file_exists( "../LocalSettings.php" ) ) { |
229 | | - $script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php'; |
230 | | - dieout( "<p><strong>Setup has completed, <a href='../$script'>your wiki</a> is configured.</strong></p> |
231 | | - <p>Please delete the /config directory for extra security.</p>" ); |
| 31 | +# Check for PHP 5 |
| 32 | +if ( !function_exists( 'version_compare' ) |
| 33 | + || version_compare( phpversion(), '5.0.0' ) < 0 |
| 34 | +) { |
| 35 | + define( 'MW_PHP4', '1' ); |
| 36 | + require( "$IP/includes/DefaultSettings.php" ); |
| 37 | + require( "$IP/includes/templates/PHP4.php" ); |
| 38 | + exit; |
232 | 39 | } |
233 | 40 | |
234 | | -if( file_exists( "./LocalSettings.php" ) ) { |
235 | | - writeSuccessMessage(); |
236 | | - dieout( '' ); |
237 | | -} |
238 | | - |
239 | | -if( !is_writable( "." ) ) { |
240 | | - dieout( "<h2>Can't write config file, aborting</h2> |
241 | | - |
242 | | - <p>In order to configure the wiki you have to make the <tt>config</tt> subdirectory |
243 | | - writable by the web server. Once configuration is done you'll move the created |
244 | | - <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can |
245 | | - then remove the <tt>config</tt> subdirectory entirely.</p> |
246 | | - |
247 | | - <p>To make the directory writable on a Unix/Linux system:</p> |
248 | | - |
249 | | - <pre> |
250 | | - cd <i>" . htmlspecialchars( dirname( dirname( __FILE__ ) ) ) . "</i> |
251 | | - chmod a+w config |
252 | | - </pre> |
253 | | - |
254 | | - <p>Afterwards retry to start the <a href=\"\">setup</a>.</p>" ); |
255 | | -} |
256 | | - |
257 | | - |
258 | | -require_once( "$IP/install-utils.inc" ); |
259 | | -require_once( "$IP/maintenance/updaters.inc" ); |
260 | | - |
261 | | -class ConfigData { |
262 | | - function getEncoded( $data ) { |
263 | | - # removing latin1 support, no need... |
264 | | - return $data; |
265 | | - } |
266 | | - function getSitename() { return $this->getEncoded( $this->Sitename ); } |
267 | | - function getSysopName() { return $this->getEncoded( $this->SysopName ); } |
268 | | - function getSysopPass() { return $this->getEncoded( $this->SysopPass ); } |
269 | | - |
270 | | - function setSchema( $schema, $engine ) { |
271 | | - $this->DBschema = $schema; |
272 | | - if ( !preg_match( '/^\w*$/', $engine ) ){ |
273 | | - $engine = 'InnoDB'; |
274 | | - } |
275 | | - switch ( $this->DBschema ) { |
276 | | - case 'mysql5': |
277 | | - $this->DBTableOptions = "ENGINE=$engine, DEFAULT CHARSET=utf8"; |
278 | | - $this->DBmysql5 = 'true'; |
279 | | - break; |
280 | | - case 'mysql5-binary': |
281 | | - $this->DBTableOptions = "ENGINE=$engine, DEFAULT CHARSET=binary"; |
282 | | - $this->DBmysql5 = 'true'; |
283 | | - break; |
284 | | - default: |
285 | | - $this->DBTableOptions = "TYPE=$engine"; |
286 | | - $this->DBmysql5 = 'false'; |
287 | | - } |
288 | | - $this->DBengine = $engine; |
289 | | - |
290 | | - # Set the global for use during install |
291 | | - global $wgDBTableOptions; |
292 | | - $wgDBTableOptions = $this->DBTableOptions; |
293 | | - } |
294 | | -} |
295 | | - |
296 | | -?> |
297 | | - |
298 | | -<ul> |
299 | | - <li> |
300 | | - <b>Don't forget security updates!</b> Keep an eye on the |
301 | | - <a href="http://lists.wikimedia.org/mailman/listinfo/mediawiki-announce">low-traffic |
302 | | - release announcements mailing list</a>. |
303 | | - </li> |
304 | | -</ul> |
305 | | - |
306 | | - |
307 | | -<h2>Checking environment...</h2> |
308 | | -<p><em>Please include all of the lines below when reporting installation problems.</em></p> |
309 | | -<ul class="env-check"> |
310 | | -<?php |
311 | | -$mainListOpened = true; |
312 | | - |
313 | | -$endl = " |
314 | | -"; |
315 | | -define( 'MW_NO_OUTPUT_BUFFER', 1 ); |
316 | | -$conf = new ConfigData; |
317 | | - |
318 | | -install_version_checks(); |
319 | | -$self = 'Installer'; # Maintenance script name, to please Setup.php |
320 | | - |
321 | | -print "<li>PHP " . htmlspecialchars( phpversion() ) . " installed</li>\n"; |
322 | | - |
323 | | -error_reporting( 0 ); |
324 | | -$phpdatabases = array(); |
325 | | -foreach (array_keys($ourdb) as $db) { |
326 | | - $compname = $ourdb[$db]['compile']; |
327 | | - if( extension_loaded( $compname ) || ( mw_have_dl() && dl( "{$compname}." . PHP_SHLIB_SUFFIX ) ) ) { |
328 | | - array_push($phpdatabases, $db); |
329 | | - $ourdb[$db]['havedriver'] = 1; |
330 | | - } |
331 | | -} |
332 | | -error_reporting( E_ALL | E_STRICT ); |
333 | | - |
334 | | -if (!$phpdatabases) { |
335 | | - print "Could not find a suitable database driver!<ul>"; |
336 | | - foreach (array_keys($ourdb) AS $db) { |
337 | | - $comp = $ourdb[$db]['compile']; |
338 | | - $full = $ourdb[$db]['fullname']; |
339 | | - print "<li>For <b>$full</b>, compile PHP using <b>--with-$comp</b>, " |
340 | | - ."or install the $comp.so module</li>\n"; |
341 | | - } |
342 | | - echo '</ul>'; |
343 | | - dieout( '' ); |
344 | | -} |
345 | | - |
346 | | -print "<li>Found database drivers for:"; |
347 | | -$DefaultDBtype = ''; |
348 | | -foreach (array_keys($ourdb) AS $db) { |
349 | | - if ($ourdb[$db]['havedriver']) { |
350 | | - if ( $DefaultDBtype == '' ) { |
351 | | - $DefaultDBtype = $db; |
352 | | - } |
353 | | - print " ".$ourdb[$db]['fullname']; |
354 | | - } |
355 | | -} |
356 | | -print "</li>\n"; |
357 | | - |
358 | | -if( wfIniGetBool( "register_globals" ) ) { |
359 | | - ?> |
360 | | - <li> |
361 | | - <div style="font-size:110%"> |
362 | | - <strong class="error">Warning:</strong> |
363 | | - <strong>PHP's <tt><a href="http://php.net/register_globals">register_globals</a></tt> option is enabled. Disable it if you can.</strong> |
364 | | - </div> |
365 | | - MediaWiki will work, but your server is more exposed to PHP-based security vulnerabilities. |
366 | | - </li> |
367 | | - <?php |
368 | | -} |
369 | | - |
370 | | -$fatal = false; |
371 | | - |
372 | | -if( wfIniGetBool( "magic_quotes_runtime" ) ) { |
373 | | - $fatal = true; |
374 | | - ?><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> |
375 | | - This option corrupts data input unpredictably; you cannot install or use |
376 | | - MediaWiki unless this option is disabled.</li> |
377 | | - <?php |
378 | | -} |
379 | | - |
380 | | -if( wfIniGetBool( "magic_quotes_sybase" ) ) { |
381 | | - $fatal = true; |
382 | | - ?><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> |
383 | | - This option corrupts data input unpredictably; you cannot install or use |
384 | | - MediaWiki unless this option is disabled.</li> |
385 | | - <?php |
386 | | -} |
387 | | - |
388 | | -if( wfIniGetBool( "mbstring.func_overload" ) ) { |
389 | | - $fatal = true; |
390 | | - ?><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> |
391 | | - This option causes errors and may corrupt data unpredictably; |
392 | | - you cannot install or use MediaWiki unless this option is disabled.</li> |
393 | | - <?php |
394 | | -} |
395 | | - |
396 | | -if( wfIniGetBool( "zend.ze1_compatibility_mode" ) ) { |
397 | | - $fatal = true; |
398 | | - ?><li class="error"><strong>Fatal: <a href="http://www.php.net/manual/en/ini.core.php">zend.ze1_compatibility_mode</a> is active!</strong> |
399 | | - This option causes horrible bugs with MediaWiki; you cannot install or use |
400 | | - MediaWiki unless this option is disabled.</li> |
401 | | - <?php |
402 | | -} |
403 | | - |
404 | | - |
405 | | -if( $fatal ) { |
406 | | - dieout( "Cannot install MediaWiki." ); |
407 | | -} |
408 | | - |
409 | | -if( wfIniGetBool( "safe_mode" ) ) { |
410 | | - $conf->safeMode = true; |
411 | | - ?> |
412 | | - <li><b class='error'>Warning:</b> <strong>PHP's |
413 | | - <a href='http://www.php.net/features.safe-mode'>safe mode</a> is active.</strong> |
414 | | - You may have problems caused by this, particularly if using image uploads. |
415 | | - </li> |
416 | | - <?php |
417 | | -} else { |
418 | | - $conf->safeMode = false; |
419 | | -} |
420 | | - |
421 | | -$sapi = htmlspecialchars( php_sapi_name() ); |
422 | | -print "<li>PHP server API is $sapi; "; |
423 | | -$script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php'; |
424 | | -if( $wgUsePathInfo ) { |
425 | | - print "ok, using pretty URLs (<tt>$script/Page_Title</tt>)"; |
426 | | -} else { |
427 | | - print "using ugly URLs (<tt>$script?title=Page_Title</tt>)"; |
428 | | -} |
429 | | -print "</li>\n"; |
430 | | - |
431 | | -$conf->xml = function_exists( "utf8_encode" ); |
432 | | -if( $conf->xml ) { |
433 | | - print "<li>Have XML / Latin1-UTF-8 conversion support.</li>\n"; |
434 | | -} else { |
435 | | - dieout( "PHP's XML module is missing; the wiki requires functions in |
436 | | - this module and won't work in this configuration. |
437 | | - If you're running Mandrake, install the php-xml package." ); |
438 | | -} |
439 | | - |
440 | | -# Check for session support |
441 | | -if( !function_exists( 'session_name' ) ) |
442 | | - dieout( "PHP's session module is missing. MediaWiki requires session support in order to function." ); |
443 | | - |
444 | | -# session.save_path doesn't *have* to be set, but if it is, and it's |
445 | | -# not valid/writable/etc. then it can cause problems |
446 | | -$sessionSavePath = mw_get_session_save_path(); |
447 | | -$ssp = htmlspecialchars( $sessionSavePath ); |
448 | | -# Warn the user if it's not set, but let them proceed |
449 | | -if( !$sessionSavePath ) { |
450 | | - print "<li><strong>Warning:</strong> A value for <tt>session.save_path</tt> |
451 | | - has not been set in PHP.ini. If the default value causes problems with |
452 | | - saving session data, set it to a valid path which is read/write/execute |
453 | | - for the user your web server is running under.</li>"; |
454 | | -} elseif ( is_dir( $sessionSavePath ) && is_writable( $sessionSavePath ) ) { |
455 | | - # All good? Let the user know |
456 | | - print "<li>Session save path (<tt>{$ssp}</tt>) appears to be valid.</li>"; |
457 | | -} else { |
458 | | - # Something not right? Warn the user, but let them proceed |
459 | | - print "<li><strong>Warning:</strong> Your <tt>session.save_path</tt> value (<tt>{$ssp}</tt>) |
460 | | - appears to be invalid or is not writable. PHP needs to be able to save data to |
461 | | - this location for correct session operation.</li>"; |
462 | | -} |
463 | | - |
464 | | -# Check for PCRE support |
465 | | -if( !function_exists( 'preg_match' ) ) |
466 | | - dieout( "The PCRE support module appears to be missing. MediaWiki requires the |
467 | | - Perl-compatible regular expression functions." ); |
468 | | - |
469 | | -$memlimit = ini_get( "memory_limit" ); |
470 | | -if( $memlimit == -1 ) { |
471 | | - print "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n"; |
472 | | -} else { |
473 | | - print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars( $memlimit ). " bytes. "; |
474 | | - $newlimit = wfMemoryLimit(); |
475 | | - $memlimit = wfShorthandToInteger( $memlimit ); |
476 | | - if( $newlimit < $memlimit ) { |
477 | | - print "<b>Failed raising limit, installation may fail.</b>"; |
478 | | - } elseif ( $newlimit > $memlimit ) { |
479 | | - print "Raised <tt>memory_limit</tt> to " . htmlspecialchars( $newlimit ) . " bytes. "; |
480 | | - } |
481 | | - print "</li>\n"; |
482 | | -} |
483 | | - |
484 | | -$conf->turck = function_exists( 'mmcache_get' ); |
485 | | -if ( $conf->turck ) { |
486 | | - print "<li><a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> installed</li>\n"; |
487 | | -} |
488 | | - |
489 | | -$conf->xcache = function_exists( 'xcache_get' ); |
490 | | -if( $conf->xcache ) |
491 | | - print "<li><a href=\"http://trac.lighttpd.net/xcache/\">XCache</a> installed</li>\n"; |
492 | | - |
493 | | -$conf->apc = function_exists('apc_fetch'); |
494 | | -if ($conf->apc ) { |
495 | | - print "<li><a href=\"http://www.php.net/apc\">APC</a> installed</li>\n"; |
496 | | -} |
497 | | - |
498 | | -$conf->eaccel = function_exists( 'eaccelerator_get' ); |
499 | | -if ( $conf->eaccel ) { |
500 | | - $conf->turck = 'eaccelerator'; |
501 | | - print "<li><a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> installed</li>\n"; |
502 | | -} |
503 | | - |
504 | | -$conf->dba = function_exists( 'dba_open' ); |
505 | | - |
506 | | -if( !( $conf->turck || $conf->eaccel || $conf->apc || $conf->xcache ) ) { |
507 | | - echo( '<li>Couldn\'t find <a href="http://turck-mmcache.sourceforge.net">Turck MMCache</a>, |
508 | | - <a href="http://eaccelerator.sourceforge.net">eAccelerator</a>, |
509 | | - <a href="http://www.php.net/apc">APC</a> or <a href="http://trac.lighttpd.net/xcache/">XCache</a>; |
510 | | - cannot use these for object caching.</li>' ); |
511 | | -} |
512 | | - |
513 | | -$conf->phpCliPath = false; |
514 | | -$phpClilocations = array_merge( |
515 | | - array( |
516 | | - "/usr/bin", |
517 | | - "/usr/local/bin", |
518 | | - "/opt/csw/bin", |
519 | | - "/usr/gnu/bin", |
520 | | - "/usr/sfw/bin" ), |
521 | | - explode( PATH_SEPARATOR, getenv( "PATH" ) ) ); |
522 | | -$phpClinames = array( "php", "php.exe" ); |
523 | | -foreach ($phpClilocations as $loc) { |
524 | | - $exe = locate_executable($loc, $phpClinames); |
525 | | - if ($exe !== false) { |
526 | | - $conf->phpCliPath= $exe; |
527 | | - break; |
528 | | - } |
529 | | -} |
530 | | - |
531 | | -$conf->diff3 = false; |
532 | | -$diff3locations = array_merge( |
533 | | - array( |
534 | | - "/usr/bin", |
535 | | - "/usr/local/bin", |
536 | | - "/opt/csw/bin", |
537 | | - "/usr/gnu/bin", |
538 | | - "/usr/sfw/bin" ), |
539 | | - explode( PATH_SEPARATOR, getenv( "PATH" ) ) ); |
540 | | -$diff3names = array( "gdiff3", "diff3", "diff3.exe" ); |
541 | | - |
542 | | -$diff3versioninfo = array( '$1 --version 2>&1', 'diff3 (GNU diffutils)' ); |
543 | | -foreach ($diff3locations as $loc) { |
544 | | - $exe = locate_executable($loc, $diff3names, $diff3versioninfo); |
545 | | - if ($exe !== false) { |
546 | | - $conf->diff3 = $exe; |
547 | | - break; |
548 | | - } |
549 | | -} |
550 | | - |
551 | | -if ($conf->diff3) |
552 | | - print "<li>Found GNU diff3: <tt>$conf->diff3</tt>.</li>"; |
553 | | -else |
554 | | - print "<li>GNU diff3 not found.</li>"; |
555 | | - |
556 | | -$conf->ImageMagick = false; |
557 | | -$imcheck = array( "/usr/bin", "/opt/csw/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" ); |
558 | | -foreach( $imcheck as $dir ) { |
559 | | - $im = "$dir/convert"; |
560 | | - if( @file_exists( $im ) ) { |
561 | | - print "<li>Found ImageMagick: <tt>$im</tt>; image thumbnailing will be enabled if you enable uploads.</li>\n"; |
562 | | - $conf->ImageMagick = $im; |
563 | | - break; |
564 | | - } |
565 | | -} |
566 | | - |
567 | | -$conf->HaveGD = function_exists( "imagejpeg" ); |
568 | | -if( $conf->HaveGD ) { |
569 | | - print "<li>Found GD graphics library built-in"; |
570 | | - if( !$conf->ImageMagick ) { |
571 | | - print ", image thumbnailing will be enabled if you enable uploads"; |
572 | | - } |
573 | | - print ".</li>\n"; |
574 | | -} else { |
575 | | - if( !$conf->ImageMagick ) { |
576 | | - print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n"; |
577 | | - } |
578 | | -} |
579 | | - |
580 | | -$conf->IP = dirname( dirname( __FILE__ ) ); |
581 | | -print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP ) . "</tt></li>\n"; |
582 | | - |
583 | | - |
584 | | -// PHP_SELF isn't available sometimes, such as when PHP is CGI but |
585 | | -// cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME |
586 | | -// to get the path to the current script... hopefully it's reliable. SIGH |
587 | | -$path = ($_SERVER["PHP_SELF"] === '') |
588 | | - ? $_SERVER["SCRIPT_NAME"] |
589 | | - : $_SERVER["PHP_SELF"]; |
590 | | - |
591 | | -$conf->ScriptPath = preg_replace( '{^(.*)/config.*$}', '$1', $path ); |
592 | | -print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath ) . "</tt></li>\n"; |
593 | | - |
594 | | - |
595 | | - |
596 | | -// We may be installing from *.php5 extension file, if so, print message |
597 | | -$conf->ScriptExtension = '.php'; |
598 | | -if (defined('MW_INSTALL_PHP5_EXT')) { |
599 | | - $conf->ScriptExtension = '.php5'; |
600 | | - print "<li>Installing MediaWiki with <tt>php5</tt> file extensions</li>\n"; |
601 | | -} else { |
602 | | - print "<li>Installing MediaWiki with <tt>php</tt> file extensions</li>\n"; |
603 | | -} |
604 | | - |
605 | | - |
606 | | -print "<li style='font-weight:bold;color:green;font-size:110%'>Environment checked. You can install MediaWiki.</li>\n"; |
607 | | - $conf->posted = ($_SERVER["REQUEST_METHOD"] == "POST"); |
608 | | - |
609 | | - $conf->Sitename = ucfirst( importPost( "Sitename", "" ) ); |
610 | | - $defaultEmail = empty( $_SERVER["SERVER_ADMIN"] ) |
611 | | - ? 'root@localhost' |
612 | | - : $_SERVER["SERVER_ADMIN"]; |
613 | | - $conf->EmergencyContact = importPost( "EmergencyContact", $defaultEmail ); |
614 | | - $conf->DBtype = importPost( "DBtype", $DefaultDBtype ); |
615 | | - if ( !isset( $ourdb[$conf->DBtype] ) ) { |
616 | | - $conf->DBtype = $DefaultDBtype; |
617 | | - } |
618 | | - |
619 | | - $conf->DBserver = importPost( "DBserver", "localhost" ); |
620 | | - $conf->DBname = importPost( "DBname", "wikidb" ); |
621 | | - $conf->DBuser = importPost( "DBuser", "wikiuser" ); |
622 | | - $conf->DBpassword = importPost( "DBpassword" ); |
623 | | - $conf->DBpassword2 = importPost( "DBpassword2" ); |
624 | | - $conf->SysopName = importPost( "SysopName", "WikiSysop" ); |
625 | | - $conf->SysopPass = importPost( "SysopPass" ); |
626 | | - $conf->SysopPass2 = importPost( "SysopPass2" ); |
627 | | - $conf->RootUser = importPost( "RootUser", "root" ); |
628 | | - $conf->RootPW = importPost( "RootPW", "" ); |
629 | | - $useRoot = importCheck( 'useroot', false ); |
630 | | - $conf->populateadmin = importCheck( 'populateadmin', false ); |
631 | | - $conf->LanguageCode = importPost( "LanguageCode", "en" ); |
632 | | - ## MySQL specific: |
633 | | - $conf->DBprefix = importPost( "DBprefix" ); |
634 | | - $conf->setSchema( |
635 | | - importPost( "DBschema", "mysql5-binary" ), |
636 | | - importPost( "DBengine", "InnoDB" ) ); |
637 | | - |
638 | | - ## Postgres specific: |
639 | | - $conf->DBport = importPost( "DBport", "5432" ); |
640 | | - $conf->DBmwschema = importPost( "DBmwschema", "mediawiki" ); |
641 | | - $conf->DBts2schema = importPost( "DBts2schema", "public" ); |
642 | | - |
643 | | - ## SQLite specific |
644 | | - $conf->SQLiteDataDir = importPost( "SQLiteDataDir", "" ); |
645 | | - |
646 | | - ## MSSQL specific |
647 | | - // We need a second field so it doesn't overwrite the MySQL one |
648 | | - $conf->DBprefix2 = importPost( "DBprefix2" ); |
649 | | - |
650 | | - ## DB2 specific: |
651 | | - // New variable in order to have a different default port number |
652 | | - $conf->DBport_db2 = importPost( "DBport_db2", "50000" ); |
653 | | - $conf->DBmwschema = importPost( "DBmwschema", "mediawiki" ); |
654 | | - $conf->DBcataloged = importPost( "DBcataloged", "cataloged" ); |
655 | | - |
656 | | - // Oracle specific |
657 | | - $conf->DBprefix_ora = importPost( "DBprefix_ora" ); |
658 | | - $conf->DBdefTS_ora = importPost( "DBdefTS_ora", "USERS" ); |
659 | | - $conf->DBtempTS_ora = importPost( "DBtempTS_ora", "TEMP" ); |
660 | | - |
661 | | - $conf->ShellLocale = getShellLocale( $conf->LanguageCode ); |
662 | | - |
663 | | -/* Check for validity */ |
664 | | -$errs = array(); |
665 | | - |
666 | | -if( preg_match( '/^$|^mediawiki$|#/i', $conf->Sitename ) ) { |
667 | | - $errs["Sitename"] = "Must not be blank or \"MediaWiki\" and may not contain \"#\""; |
668 | | -} |
669 | | -if( $conf->DBuser == "" ) { |
670 | | - $errs["DBuser"] = "Must not be blank"; |
671 | | -} |
672 | | -if( ($conf->DBtype == 'mysql') && (strlen($conf->DBuser) > 16) ) { |
673 | | - $errs["DBuser"] = "Username too long"; |
674 | | -} |
675 | | -if( $conf->DBpassword == "" && $conf->DBtype != "postgres" ) { |
676 | | - $errs["DBpassword"] = "Must not be blank"; |
677 | | -} |
678 | | -if( $conf->DBpassword != $conf->DBpassword2 ) { |
679 | | - $errs["DBpassword2"] = "Passwords don't match!"; |
680 | | -} |
681 | | -if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix ) ) { |
682 | | - $errs["DBprefix"] = "Invalid table prefix"; |
683 | | -} else { |
684 | | - untaint( $conf->DBprefix, TC_MYSQL ); |
685 | | -} |
686 | | -if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix_ora ) ) { |
687 | | - $errs["DBprefix_ora"] = "Invalid table prefix"; |
688 | | -} |
689 | | - |
690 | | -error_reporting( E_ALL | E_STRICT ); |
691 | | - |
692 | | -/** |
693 | | - * Initialise $wgLang and $wgContLang to something so we can |
694 | | - * call case-folding methods. Per Brion, this is English for |
695 | | - * now, although we could be clever and initialise to the |
696 | | - * user-selected language. |
697 | | - */ |
698 | | -$wgContLang = Language::factory( 'en' ); |
699 | | -$wgLang = $wgContLang; |
700 | | - |
701 | | -/** |
702 | | - * We're messing about with users, so we need a stub |
703 | | - * authentication plugin... |
704 | | - */ |
705 | | -$wgAuth = new AuthPlugin(); |
706 | | - |
707 | | -/** |
708 | | - * Validate the initial administrator account; username, |
709 | | - * password checks, etc. |
710 | | - */ |
711 | | -if( $conf->SysopName ) { |
712 | | - # Check that the user can be created |
713 | | - $u = User::newFromName( $conf->SysopName ); |
714 | | - if( is_a($u, 'User') ) { // please do not use instanceof, it breaks PHP4 |
715 | | - # Various password checks |
716 | | - if( $conf->SysopPass != '' ) { |
717 | | - if( $conf->SysopPass == $conf->SysopPass2 ) { |
718 | | - if( $u->isValidPassword( $conf->SysopPass ) !== true ) { |
719 | | - $errs['SysopPass'] = "Bad password"; |
720 | | - } |
721 | | - } else { |
722 | | - $errs['SysopPass2'] = "Passwords don't match"; |
723 | | - } |
724 | | - } else { |
725 | | - $errs['SysopPass'] = "Cannot be blank"; |
726 | | - } |
727 | | - unset( $u ); |
728 | | - } else { |
729 | | - $errs['SysopName'] = "Bad username"; |
730 | | - } |
731 | | -} |
732 | | - |
733 | | -$conf->License = importRequest( "License", "none" ); |
734 | | -if( $conf->License == "gfdl1_2" ) { |
735 | | - $conf->RightsUrl = "http://www.gnu.org/licenses/old-licenses/fdl-1.2.txt"; |
736 | | - $conf->RightsText = "GNU Free Documentation License 1.2"; |
737 | | - $conf->RightsCode = "gfdl1_2"; |
738 | | - $conf->RightsIcon = '${wgScriptPath}/skins/common/images/gnu-fdl.png'; |
739 | | -} elseif( $conf->License == "gfdl1_3" ) { |
740 | | - $conf->RightsUrl = "http://www.gnu.org/copyleft/fdl.html"; |
741 | | - $conf->RightsText = "GNU Free Documentation License 1.3"; |
742 | | - $conf->RightsCode = "gfdl1_3"; |
743 | | - $conf->RightsIcon = '${wgScriptPath}/skins/common/images/gnu-fdl.png'; |
744 | | -} elseif( $conf->License == "none" ) { |
745 | | - $conf->RightsUrl = $conf->RightsText = $conf->RightsCode = $conf->RightsIcon = ""; |
746 | | -} elseif( $conf->License == "pd" ) { |
747 | | - $conf->RightsUrl = "http://creativecommons.org/licenses/publicdomain/"; |
748 | | - $conf->RightsText = "Public Domain"; |
749 | | - $conf->RightsCode = "pd"; |
750 | | - $conf->RightsIcon = '${wgScriptPath}/skins/common/images/public-domain.png'; |
751 | | -} else { |
752 | | - $conf->RightsUrl = importRequest( "RightsUrl", "" ); |
753 | | - $conf->RightsText = importRequest( "RightsText", "" ); |
754 | | - $conf->RightsCode = importRequest( "RightsCode", "" ); |
755 | | - $conf->RightsIcon = importRequest( "RightsIcon", "" ); |
756 | | -} |
757 | | - |
758 | | -$conf->Shm = importRequest( "Shm", "none" ); |
759 | | -$conf->MCServers = importRequest( "MCServers" ); |
760 | | - |
761 | | -/* Test memcached servers */ |
762 | | - |
763 | | -if ( $conf->Shm == 'memcached' && $conf->MCServers ) { |
764 | | - $conf->MCServerArray = wfArrayMap( 'trim', explode( ',', $conf->MCServers ) ); |
765 | | - foreach ( $conf->MCServerArray as $server ) { |
766 | | - $error = testMemcachedServer( $server ); |
767 | | - if ( $error ) { |
768 | | - $errs["MCServers"] = $error; |
769 | | - break; |
770 | | - } |
771 | | - } |
772 | | -} else if ( $conf->Shm == 'memcached' ) { |
773 | | - $errs["MCServers"] = "Please specify at least one server if you wish to use memcached"; |
774 | | -} |
775 | | - |
776 | | -/* default values for installation */ |
777 | | -$conf->Email = importRequest("Email", "email_enabled"); |
778 | | -$conf->Emailuser = importRequest("Emailuser", "emailuser_enabled"); |
779 | | -$conf->Enotif = importRequest("Enotif", "enotif_allpages"); |
780 | | -$conf->Eauthent = importRequest("Eauthent", "eauthent_enabled"); |
781 | | - |
782 | | -if( $conf->posted && ( 0 == count( $errs ) ) ) { |
783 | | - do { /* So we can 'continue' to end prematurely */ |
784 | | - $conf->Root = ($conf->RootPW != ""); |
785 | | - |
786 | | - /* Load up the settings and get installin' */ |
787 | | - $local = writeLocalSettings( $conf ); |
788 | | - echo "<li style=\"list-style: none\">\n"; |
789 | | - echo "<p><b>Generating configuration file...</b></p>\n"; |
790 | | - echo "</li>\n"; |
791 | | - |
792 | | - $wgCommandLineMode = false; |
793 | | - chdir( ".." ); |
794 | | - $ok = eval( $local ); |
795 | | - if( $ok === false ) { |
796 | | - dieout( "<p>Errors in generated configuration; " . |
797 | | - "most likely due to a bug in the installer... " . |
798 | | - "Config file was: </p>" . |
799 | | - "<pre>" . |
800 | | - htmlspecialchars( $local ) . |
801 | | - "</pre>" ); |
802 | | - } |
803 | | - $conf->DBtypename = ''; |
804 | | - foreach (array_keys($ourdb) as $db) { |
805 | | - if ($conf->DBtype === $db) |
806 | | - $conf->DBtypename = $ourdb[$db]['fullname']; |
807 | | - } |
808 | | - if ( ! strlen($conf->DBtype)) { |
809 | | - $errs["DBpicktype"] = "Please choose a database type"; |
810 | | - continue; |
811 | | - } |
812 | | - |
813 | | - if (! $conf->DBtypename) { |
814 | | - $errs["DBtype"] = "Unknown database type '$conf->DBtype'"; |
815 | | - continue; |
816 | | - } |
817 | | - print "<li>Database type: " . htmlspecialchars( $conf->DBtypename ) . "</li>\n"; |
818 | | - $dbclass = 'Database'.ucfirst($conf->DBtype); |
819 | | - $wgDBtype = $conf->DBtype; |
820 | | - $wgDBadminuser = "root"; |
821 | | - $wgDBadminpassword = $conf->RootPW; |
822 | | - |
823 | | - ## Mysql specific: |
824 | | - $wgDBprefix = $conf->DBprefix; |
825 | | - |
826 | | - ## Postgres specific: |
827 | | - $wgDBport = $conf->DBport; |
828 | | - $wgDBmwschema = $conf->DBmwschema; |
829 | | - $wgDBts2schema = $conf->DBts2schema; |
830 | | - |
831 | | - if( $conf->DBprefix2 != '' ) { |
832 | | - // For MSSQL |
833 | | - $wgDBprefix = $conf->DBprefix2; |
834 | | - } elseif( $conf->DBprefix_ora != '' ) { |
835 | | - // For Oracle |
836 | | - $wgDBprefix = $conf->DBprefix_ora; |
837 | | - } |
838 | | - |
839 | | - ## DB2 specific: |
840 | | - $wgDBcataloged = $conf->DBcataloged; |
841 | | - |
842 | | - $wgCommandLineMode = true; |
843 | | - if (! defined ( 'STDERR' ) ) |
844 | | - define( 'STDERR', fopen("php://stderr", "wb")); |
845 | | - $wgUseDatabaseMessages = false; /* FIXME: For database failure */ |
846 | | - require_once( "$IP/includes/Setup.php" ); |
847 | | - Language::getLocalisationCache()->disableBackend(); |
848 | | - |
849 | | - chdir( "config" ); |
850 | | - |
851 | | - $wgTitle = Title::newFromText( "Installation script" ); |
852 | | - error_reporting( E_ALL | E_STRICT ); |
853 | | - print "<li>Loading class: " . htmlspecialchars( $dbclass ) . "</li>\n"; |
854 | | - if ( $conf->DBtype != 'sqlite' ) { |
855 | | - $dbc = new $dbclass; |
856 | | - } |
857 | | - |
858 | | - if( $conf->DBtype == 'mysql' ) { |
859 | | - $mysqlOldClient = version_compare( mysql_get_client_info(), "4.1.0", "lt" ); |
860 | | - if( $mysqlOldClient ) { |
861 | | - print "<li><b>PHP is linked with old MySQL client libraries. If you are |
862 | | - using a MySQL 4.1 server and have problems connecting to the database, |
863 | | - see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html' |
864 | | - >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b></li>\n"; |
865 | | - } |
866 | | - $ok = true; # Let's be optimistic |
867 | | - |
868 | | - # Decide if we're going to use the superuser or the regular database user |
869 | | - $conf->Root = $useRoot; |
870 | | - if( $conf->Root ) { |
871 | | - $db_user = $conf->RootUser; |
872 | | - $db_pass = $conf->RootPW; |
873 | | - } else { |
874 | | - $db_user = $wgDBuser; |
875 | | - $db_pass = $wgDBpassword; |
876 | | - } |
877 | | - |
878 | | - # Attempt to connect |
879 | | - echo( "<li>Attempting to connect to database server as " . htmlspecialchars( $db_user ) . "..." ); |
880 | | - $wgDatabase = Database::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 ); |
881 | | - |
882 | | - # Check the connection and respond to errors |
883 | | - if( $wgDatabase->isOpen() ) { |
884 | | - # Seems OK |
885 | | - $ok = true; |
886 | | - $wgDBadminuser = $db_user; |
887 | | - $wgDBadminpassword = $db_pass; |
888 | | - echo( "success.</li>\n" ); |
889 | | - $wgDatabase->ignoreErrors( true ); |
890 | | - $myver = $wgDatabase->getServerVersion(); |
891 | | - } else { |
892 | | - # There were errors, report them and back out |
893 | | - $ok = false; |
894 | | - $errno = mysql_errno(); |
895 | | - $errtx = htmlspecialchars( mysql_error() ); |
896 | | - switch( $errno ) { |
897 | | - case 1045: |
898 | | - case 2000: |
899 | | - echo( "failed due to authentication errors. Check passwords.</li>" ); |
900 | | - if( $conf->Root ) { |
901 | | - # The superuser details are wrong |
902 | | - $errs["RootUser"] = "Check username"; |
903 | | - $errs["RootPW"] = "and password"; |
904 | | - } else { |
905 | | - # The regular user details are wrong |
906 | | - $errs["DBuser"] = "Check username"; |
907 | | - $errs["DBpassword"] = "and password"; |
908 | | - } |
909 | | - break; |
910 | | - case 2002: |
911 | | - case 2003: |
912 | | - default: |
913 | | - # General connection problem |
914 | | - echo( htmlspecialchars( "failed with error [$errno] $errtx." ) . "</li>\n" ); |
915 | | - $errs["DBserver"] = "Connection failed"; |
916 | | - break; |
917 | | - } # switch |
918 | | - } #conn. att. |
919 | | - |
920 | | - if( !$ok ) { continue; } |
921 | | - } |
922 | | - else if( $conf->DBtype == 'ibm_db2' ) { |
923 | | - if( $useRoot ) { |
924 | | - $db_user = $conf->RootUser; |
925 | | - $db_pass = $conf->RootPW; |
926 | | - } else { |
927 | | - $db_user = $wgDBuser; |
928 | | - $db_pass = $wgDBpassword; |
929 | | - } |
930 | | - |
931 | | - echo( "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) . |
932 | | - "\" as \"" . htmlspecialchars( $db_user ) . "\"..." ); |
933 | | - $wgDatabase = $dbc->newFromParams($wgDBserver, $db_user, $db_pass, $wgDBname, 1); |
934 | | - // enable extra debug messages |
935 | | - $dbc->setMode(DatabaseIbm_db2::INSTALL_MODE); |
936 | | - $wgDatabase->setMode(DatabaseIbm_db2::INSTALL_MODE); |
937 | | - |
938 | | - if (!$wgDatabase->isOpen()) { |
939 | | - print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n"; |
940 | | - } else { |
941 | | - $myver = $wgDatabase->getServerVersion(); |
942 | | - } |
943 | | - if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname); |
944 | | - |
945 | | - } elseif ( $conf->DBtype == 'sqlite' ) { |
946 | | - if ("$wgSQLiteDataDir" == '') { |
947 | | - $wgSQLiteDataDir = dirname($_SERVER['DOCUMENT_ROOT']).'/data'; |
948 | | - } |
949 | | - echo "<li>Attempting to connect to SQLite database at \"" . |
950 | | - htmlspecialchars( $wgSQLiteDataDir ) . "\""; |
951 | | - if ( !is_dir( $wgSQLiteDataDir ) ) { |
952 | | - if ( is_writable( dirname( $wgSQLiteDataDir ) ) ) { |
953 | | - $ok = wfMkdirParents( $wgSQLiteDataDir, $wgSQLiteDataDirMode ); |
954 | | - } else { |
955 | | - $ok = false; |
956 | | - } |
957 | | - if ( !$ok ) { |
958 | | - echo ": cannot create data directory</li>"; |
959 | | - $errs['SQLiteDataDir'] = 'Enter a valid data directory'; |
960 | | - continue; |
961 | | - } |
962 | | - } |
963 | | - if ( !is_writable( $wgSQLiteDataDir ) ) { |
964 | | - echo ": data directory not writable</li>"; |
965 | | - $errs['SQLiteDataDir'] = 'Enter a writable data directory'; |
966 | | - continue; |
967 | | - } |
968 | | - $dataFile = "$wgSQLiteDataDir/$wgDBname.sqlite"; |
969 | | - if ( file_exists( $dataFile ) && !is_writable( $dataFile ) ) { |
970 | | - echo ": data file not writable</li>"; |
971 | | - $errs['SQLiteDataDir'] = "$wgDBname.sqlite is not writable"; |
972 | | - continue; |
973 | | - } |
974 | | - $wgDatabase = new DatabaseSqlite( false, false, false, $wgDBname, 1 ); |
975 | | - if (!$wgDatabase->isOpen()) { |
976 | | - print ": error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n"; |
977 | | - $errs['SQLiteDataDir'] = 'Could not connect to database'; |
978 | | - continue; |
979 | | - } else { |
980 | | - $myver = $wgDatabase->getServerVersion(); |
981 | | - } |
982 | | - if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname); |
983 | | - echo "ok</li>\n"; |
984 | | - } elseif ( $conf->DBtype == 'oracle' ) { |
985 | | - echo "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) ."\"</li>"; |
986 | | - $wgDatabase = $dbc->newFromParams('DUMMY', $wgDBuser, $wgDBpassword, $wgDBname, 1); |
987 | | - if (!$wgDatabase->isOpen()) { |
988 | | - $ok = true; |
989 | | - echo "<li>Connect failed.</li>"; |
990 | | - if ($useRoot) { |
991 | | - if (ini_get('oci8.privileged_connect') === false) { |
992 | | - echo "<li>Privileged connect disabled, please set oci8.privileged_connect or run maintenance/ora/user.sql script manually prior to continuing.</li>"; |
993 | | - $ok = false; |
994 | | - } else { |
995 | | - $wgDBadminuser = $conf->RootUser; |
996 | | - $wgDBadminpassword = $conf->RootPW; |
997 | | - echo "<li>Attempting to create DB user.</li>"; |
998 | | - $wgDatabase = $dbc->newFromParams('DUMMY', $wgDBadminuser, $wgDBadminpassword, $wgDBname, 1, 64); |
999 | | - if ($wgDatabase->isOpen()) { |
1000 | | - $wgDBOracleDefTS = $conf->DBdefTS_ora; |
1001 | | - $wgDBOracleTempTS = $conf->DBtempTS_ora; |
1002 | | - $wgDatabase->sourceFile( "../maintenance/ora/user.sql" ); |
1003 | | - } else { |
1004 | | - echo "<li>Invalid database superuser, please supply a valid superuser account.</li>"; |
1005 | | - echo "<li>ERR: ".print_r(oci_error(), true)."</li>"; |
1006 | | - $ok = false; |
1007 | | - } |
1008 | | - } |
1009 | | - } else { |
1010 | | - echo "<li>Database superuser missing, please supply a valid superuser account.</li>"; |
1011 | | - $ok = false; |
1012 | | - } |
1013 | | - if (!$ok) { |
1014 | | - $errs["RootUser"] = "Check username"; |
1015 | | - $errs["RootPW"] = "and password"; |
1016 | | - } else { |
1017 | | - echo "<li>Attempting to connect to database with new user \"" . htmlspecialchars( $wgDBname ) ."\"</li>"; |
1018 | | - $wgDatabase = $dbc->newFromParams('DUMMY', $wgDBuser, $wgDBpassword, $wgDBname, 1); |
1019 | | - } |
1020 | | - } |
1021 | | - if ($ok) { |
1022 | | - $myver = $wgDatabase->getServerVersion(); |
1023 | | - } |
1024 | | - } else { # not mysql |
1025 | | - error_reporting( E_ALL | E_STRICT ); |
1026 | | - $wgSuperUser = ''; |
1027 | | - ## Possible connect as a superuser |
1028 | | - // Changed !mysql to postgres check since it seems to only apply to postgres |
1029 | | - if( $useRoot && $conf->DBtype == 'postgres' ) { |
1030 | | - $wgDBsuperuser = $conf->RootUser; |
1031 | | - echo( "<li>Attempting to connect to database \"postgres\" as superuser \"" . |
1032 | | - htmlspecialchars( $wgDBsuperuser ) . "\"..." ); |
1033 | | - $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBsuperuser, $conf->RootPW, "postgres", 1); |
1034 | | - if (!$wgDatabase->isOpen()) { |
1035 | | - print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n"; |
1036 | | - $errs["DBserver"] = "Could not connect to database as superuser"; |
1037 | | - $errs["RootUser"] = "Check username"; |
1038 | | - $errs["RootPW"] = "and password"; |
1039 | | - continue; |
1040 | | - } |
1041 | | - $wgDatabase->initial_setup($conf->RootPW, 'postgres'); |
1042 | | - } |
1043 | | - echo( "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) . |
1044 | | - "\" as \"" . htmlspecialchars( $wgDBuser ) . "\"..." ); |
1045 | | - $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1); |
1046 | | - if (!$wgDatabase->isOpen()) { |
1047 | | - print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n"; |
1048 | | - $errs["DBserver"] = "Could not connect to database as user"; |
1049 | | - $errs["DBuser"] = "Check username"; |
1050 | | - $errs["DBpassword"] = "and password"; |
1051 | | - continue; |
1052 | | - } else { |
1053 | | - $myver = $wgDatabase->getServerVersion(); |
1054 | | - } |
1055 | | - if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname); |
1056 | | - } |
1057 | | - |
1058 | | - if ( !$wgDatabase->isOpen() ) { |
1059 | | - $errs["DBserver"] = "Couldn't connect to database"; |
1060 | | - continue; |
1061 | | - } |
1062 | | - |
1063 | | - print "<li>Connected to " . htmlspecialchars( "{$conf->DBtype} $myver" ); |
1064 | | - if ($conf->DBtype == 'mysql') { |
1065 | | - if( version_compare( $myver, "4.0.14" ) < 0 ) { |
1066 | | - print "</li>\n"; |
1067 | | - dieout( "-- mysql 4.0.14 or later required. Aborting." ); |
1068 | | - } |
1069 | | - $mysqlNewAuth = version_compare( $myver, "4.1.0", "ge" ); |
1070 | | - if( $mysqlNewAuth && $mysqlOldClient ) { |
1071 | | - print "; <b class='error'>You are using MySQL 4.1 server, but PHP is linked |
1072 | | - to old client libraries; if you have trouble with authentication, see |
1073 | | - <a href='http://dev.mysql.com/doc/mysql/en/old-client.html' |
1074 | | - >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>"; |
1075 | | - } |
1076 | | - if( $wgDBmysql5 ) { |
1077 | | - if( $mysqlNewAuth ) { |
1078 | | - print "; enabling MySQL 4.1/5.0 charset mode"; |
1079 | | - } else { |
1080 | | - print "; <b class='error'>MySQL 4.1/5.0 charset mode enabled, |
1081 | | - but older version detected; will likely fail.</b>"; |
1082 | | - } |
1083 | | - } |
1084 | | - print "</li>\n"; |
1085 | | - |
1086 | | - @$sel = $wgDatabase->selectDB( $wgDBname ); |
1087 | | - if( $sel ) { |
1088 | | - print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n"; |
1089 | | - } else { |
1090 | | - $err = mysql_errno(); |
1091 | | - $databaseSafe = htmlspecialchars( $wgDBname ); |
1092 | | - if( $err == 1102 /* Invalid database name */ ) { |
1093 | | - print "<ul><li><strong>{$databaseSafe}</strong> is not a valid database name.</li></ul>"; |
1094 | | - continue; |
1095 | | - } elseif( $err != 1049 /* Database doesn't exist */ ) { |
1096 | | - print "<ul><li>Error selecting database <strong>{$databaseSafe}</strong>: {$err} "; |
1097 | | - print htmlspecialchars( mysql_error() ) . "</li></ul>"; |
1098 | | - continue; |
1099 | | - } |
1100 | | - print "<li>Attempting to create database...</li>"; |
1101 | | - $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" ); |
1102 | | - if( !$res ) { |
1103 | | - print "<li>Couldn't create database <tt>" . |
1104 | | - htmlspecialchars( $wgDBname ) . |
1105 | | - "</tt>; try with root access or check your username/pass.</li>\n"; |
1106 | | - $errs["RootPW"] = "<- Enter"; |
1107 | | - continue; |
1108 | | - } |
1109 | | - print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n"; |
1110 | | - } |
1111 | | - $wgDatabase->selectDB( $wgDBname ); |
1112 | | - } |
1113 | | - else if ($conf->DBtype == 'postgres') { |
1114 | | - if( version_compare( $myver, "8.0" ) < 0 ) { |
1115 | | - dieout( "<b>Postgres 8.0 or later is required</b>. Aborting." ); |
1116 | | - } |
1117 | | - } |
1118 | | - |
1119 | | - if( $wgDatabase->tableExists( "cur" ) || $wgDatabase->tableExists( "revision" ) ) { |
1120 | | - print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n"; |
1121 | | - |
1122 | | - if ( $conf->DBtype == 'mysql') { |
1123 | | - # Determine existing default character set |
1124 | | - if ( $wgDatabase->tableExists( "revision" ) ) { |
1125 | | - $revision = $wgDatabase->escapeLike( $conf->DBprefix . 'revision' ); |
1126 | | - $res = $wgDatabase->query( "SHOW TABLE STATUS LIKE '$revision'" ); |
1127 | | - $row = $wgDatabase->fetchObject( $res ); |
1128 | | - if ( !$row ) { |
1129 | | - echo "<li>SHOW TABLE STATUS query failed!</li>\n"; |
1130 | | - $existingSchema = false; |
1131 | | - $existingEngine = false; |
1132 | | - } else { |
1133 | | - if ( preg_match( '/^latin1/', $row->Collation ) ) { |
1134 | | - $existingSchema = 'mysql4'; |
1135 | | - } elseif ( preg_match( '/^utf8/', $row->Collation ) ) { |
1136 | | - $existingSchema = 'mysql5'; |
1137 | | - } elseif ( preg_match( '/^binary/', $row->Collation ) ) { |
1138 | | - $existingSchema = 'mysql5-binary'; |
1139 | | - } else { |
1140 | | - $existingSchema = false; |
1141 | | - echo "<li><strong>Warning:</strong> Unrecognised existing collation</li>\n"; |
1142 | | - } |
1143 | | - if ( isset( $row->Engine ) ) { |
1144 | | - $existingEngine = $row->Engine; |
1145 | | - } else { |
1146 | | - $existingEngine = $row->Type; |
1147 | | - } |
1148 | | - } |
1149 | | - if ( $existingSchema && $existingSchema != $conf->DBschema ) { |
1150 | | - $encExisting = htmlspecialchars( $existingSchema ); |
1151 | | - $encRequested = htmlspecialchars( $conf->DBschema ); |
1152 | | - print "<li><strong>Warning:</strong> you requested the $encRequested schema, " . |
1153 | | - "but the existing database has the $encExisting schema. This upgrade script ". |
1154 | | - "can't convert it, so it will remain $encExisting.</li>\n"; |
1155 | | - $conf->setSchema( $existingSchema, $conf->DBengine ); |
1156 | | - } |
1157 | | - if ( $existingEngine && $existingEngine != $conf->DBengine ) { |
1158 | | - $encExisting = htmlspecialchars( $existingEngine ); |
1159 | | - $encRequested = htmlspecialchars( $conf->DBengine ); |
1160 | | - print "<li><strong>Warning:</strong> you requested the $encRequested storage " . |
1161 | | - "engine, but the existing database uses the $encExisting engine. This upgrade " . |
1162 | | - "script can't convert it, so it will remain $encExisting.</li>\n"; |
1163 | | - $conf->setSchema( $conf->DBschema, $existingEngine ); |
1164 | | - } |
1165 | | - } |
1166 | | - |
1167 | | - # Create user if required |
1168 | | - if ( $conf->Root ) { |
1169 | | - $conn = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 ); |
1170 | | - if ( $conn->isOpen() ) { |
1171 | | - print "<li>DB user account ok</li>\n"; |
1172 | | - $conn->close(); |
1173 | | - } else { |
1174 | | - print "<li>Granting user permissions..."; |
1175 | | - if( $mysqlOldClient && $mysqlNewAuth ) { |
1176 | | - 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>"; |
1177 | | - } |
1178 | | - print "</li>\n"; |
1179 | | - $wgDatabase->sourceFile( "../maintenance/users.sql" ); |
1180 | | - } |
1181 | | - } |
1182 | | - } |
1183 | | - print "</ul><pre>\n"; |
1184 | | - chdir( ".." ); |
1185 | | - flush(); |
1186 | | - do_all_updates(); |
1187 | | - chdir( "config" ); |
1188 | | - print "</pre>\n"; |
1189 | | - print "<ul><li>Finished update checks.</li>\n"; |
1190 | | - // if tables don't yet exist |
1191 | | - } else { |
1192 | | - # Determine available storage engines if possible |
1193 | | - if ( $conf->DBtype == 'mysql' && version_compare( $myver, "4.1.2", "ge" ) ) { |
1194 | | - $res = $wgDatabase->query( 'SHOW ENGINES' ); |
1195 | | - $found = false; |
1196 | | - while ( $row = $wgDatabase->fetchObject( $res ) ) { |
1197 | | - if ( $row->Engine == $conf->DBengine && ( $row->Support == 'YES' || $row->Support == 'DEFAULT' ) ) { |
1198 | | - $found = true; |
1199 | | - break; |
1200 | | - } |
1201 | | - } |
1202 | | - $wgDatabase->freeResult( $res ); |
1203 | | - if ( !$found && $conf->DBengine != 'MyISAM' ) { |
1204 | | - echo "<li><strong>Warning:</strong> " . htmlspecialchars( $conf->DBengine ) . |
1205 | | - " storage engine not available, " . |
1206 | | - "using MyISAM instead</li>\n"; |
1207 | | - $conf->setSchema( $conf->DBschema, 'MyISAM' ); |
1208 | | - } |
1209 | | - } |
1210 | | - |
1211 | | - # FIXME: Check for errors |
1212 | | - print "<li>Creating tables..."; |
1213 | | - if ($conf->DBtype == 'mysql') { |
1214 | | - $wgDatabase->sourceFile( "../maintenance/tables.sql" ); |
1215 | | - $wgDatabase->sourceFile( "../maintenance/interwiki.sql" ); |
1216 | | - } elseif (is_callable(array($wgDatabase, 'setup_database'))) { |
1217 | | - $wgDatabase->setup_database(); |
1218 | | - } |
1219 | | - else { |
1220 | | - $errs["DBtype"] = "Do not know how to handle database type '$conf->DBtype'"; |
1221 | | - continue; |
1222 | | - } |
1223 | | - |
1224 | | - print " done.</li>\n"; |
1225 | | - |
1226 | | - |
1227 | | - if ($conf->DBtype == 'ibm_db2') { |
1228 | | - // Now that table creation is done, make sure everything is committed |
1229 | | - // Do this before doing inserts through API |
1230 | | - if ($wgDatabase->lastError()) { |
1231 | | - print "<li>Errors encountered during table creation -- rolled back</li>\n"; |
1232 | | - $wgDatabase->rollback(); |
1233 | | - } |
1234 | | - else { |
1235 | | - print "<li>MediaWiki tables successfully created</li>\n"; |
1236 | | - $wgDatabase->commit(); |
1237 | | - } |
1238 | | - } |
1239 | | - |
1240 | | - print "<li>Initializing statistics...</li>\n"; |
1241 | | - $wgDatabase->insert( 'site_stats', |
1242 | | - array ( 'ss_row_id' => 1, |
1243 | | - 'ss_total_views' => 0, |
1244 | | - 'ss_total_edits' => 1, # Main page first edit |
1245 | | - 'ss_good_articles' => 0, # Main page is not a good article - no internal link |
1246 | | - 'ss_total_pages' => 1, # Main page |
1247 | | - 'ss_users' => $conf->SysopName ? 1 : 0, # Sysop account, if created |
1248 | | - 'ss_admins' => $conf->SysopName ? 1 : 0, # Sysop account, if created |
1249 | | - 'ss_images' => 0 ) ); |
1250 | | - |
1251 | | - # Set up the "regular user" account *if we can, and if we need to* |
1252 | | - if( $conf->Root and $conf->DBtype == 'mysql') { |
1253 | | - # See if we need to |
1254 | | - $wgDatabase2 = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 ); |
1255 | | - if( $wgDatabase2->isOpen() ) { |
1256 | | - # Nope, just close the test connection and continue |
1257 | | - $wgDatabase2->close(); |
1258 | | - echo( "<li>User " . htmlspecialchars( $wgDBuser ) . " exists. Skipping grants.</li>\n" ); |
1259 | | - } else { |
1260 | | - # Yes, so run the grants |
1261 | | - echo( "<li>" . htmlspecialchars( "Granting user permissions to $wgDBuser on $wgDBname..." ) ); |
1262 | | - $wgDatabase->sourceFile( "../maintenance/users.sql" ); |
1263 | | - echo( "success.</li>\n" ); |
1264 | | - } |
1265 | | - } |
1266 | | - |
1267 | | - if( $conf->SysopName ) { |
1268 | | - $u = User::newFromName( $conf->getSysopName() ); |
1269 | | - if ( !$u ) { |
1270 | | - print "<li><strong class=\"error\">Warning:</strong> Skipped sysop account creation - invalid username!</li>\n"; |
1271 | | - } |
1272 | | - else if ( 0 == $u->idForName() ) { |
1273 | | - $u->addToDatabase(); |
1274 | | - $u->setPassword( $conf->getSysopPass() ); |
1275 | | - $u->saveSettings(); |
1276 | | - |
1277 | | - $u->addGroup( "sysop" ); |
1278 | | - $u->addGroup( "bureaucrat" ); |
1279 | | - |
1280 | | - print "<li>Created sysop account <tt>" . |
1281 | | - htmlspecialchars( $conf->SysopName ) . "</tt>.</li>\n"; |
1282 | | - } else { |
1283 | | - print "<li>Could not create user - already exists!</li>\n"; |
1284 | | - } |
1285 | | - } else { |
1286 | | - print "<li>Skipped sysop account creation, no name given.</li>\n"; |
1287 | | - } |
1288 | | - |
1289 | | - $titleobj = Title::newFromText( wfMsgNoDB( "mainpage" ) ); |
1290 | | - $article = new Article( $titleobj ); |
1291 | | - $newid = $article->insertOn( $wgDatabase ); |
1292 | | - $revision = new Revision( array( |
1293 | | - 'page' => $newid, |
1294 | | - 'text' => wfMsg( 'mainpagetext' ) . "\n\n" . wfMsgNoTrans( 'mainpagedocfooter' ), |
1295 | | - 'comment' => '', |
1296 | | - 'user' => 0, |
1297 | | - 'user_text' => 'MediaWiki default', |
1298 | | - ) ); |
1299 | | - $revid = $revision->insertOn( $wgDatabase ); |
1300 | | - $article->updateRevisionOn( $wgDatabase, $revision ); |
1301 | | - } |
1302 | | - |
1303 | | - /* Write out the config file now that all is well */ |
1304 | | - print "<li style=\"list-style: none\">\n"; |
1305 | | - print "<p>Creating LocalSettings.php...</p>\n\n"; |
1306 | | - $localSettings = "<" . "?php$endl$local"; |
1307 | | - // Fix up a common line-ending problem (due to CVS on Windows) |
1308 | | - $localSettings = str_replace( "\r\n", "\n", $localSettings ); |
1309 | | - $f = fopen( "LocalSettings.php", 'xt' ); |
1310 | | - |
1311 | | - if( $f == false ) { |
1312 | | - print( "</li>\n" ); |
1313 | | - 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" . |
1314 | | - "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" . |
1315 | | - "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" ); |
1316 | | - } |
1317 | | - if(fwrite( $f, $localSettings ) ) { |
1318 | | - fclose( $f ); |
1319 | | - print "<hr/>\n"; |
1320 | | - writeSuccessMessage(); |
1321 | | - print "</li>\n"; |
1322 | | - } else { |
1323 | | - fclose( $f ); |
1324 | | - 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" ); |
1325 | | - } |
1326 | | - |
1327 | | - } while( false ); |
1328 | | -} |
1329 | | - |
1330 | | -print "</ul>\n"; |
1331 | | -$mainListOpened = false; |
1332 | | - |
1333 | | -if( count( $errs ) ) { |
1334 | | - /* Display options form */ |
1335 | | - |
1336 | | - if( $conf->posted ) { |
1337 | | - echo "<p class='error-top'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n"; |
1338 | | - } |
1339 | | -?> |
1340 | | - |
1341 | | -<form action="<?php echo defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php'; ?>" name="config" method="post"> |
1342 | | - |
1343 | | -<h2>Site config</h2> |
1344 | | - |
1345 | | -<div class="config-section"> |
1346 | | - <div class="config-input"> |
1347 | | - <?php aField( $conf, "Sitename", "Wiki name:" ); ?> |
1348 | | - </div> |
1349 | | - <p class="config-desc"> |
1350 | | - Preferably a short word without punctuation, i.e. "Wikipedia".<br /> |
1351 | | - Will appear as the namespace name for "meta" pages, and throughout the interface. |
1352 | | - </p> |
1353 | | - <div class="config-input"><?php aField( $conf, "EmergencyContact", "Contact e-mail:" ); ?></div> |
1354 | | - <p class="config-desc"> |
1355 | | - 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. |
1356 | | - </p> |
1357 | | - |
1358 | | - <div class="config-input"> |
1359 | | - <label class='column' for="LanguageCode">Language:</label> |
1360 | | - <select id="LanguageCode" name="LanguageCode"><?php |
1361 | | - $list = getLanguageList(); |
1362 | | - foreach( $list as $code => $name ) { |
1363 | | - $sel = ($code == $conf->LanguageCode) ? 'selected="selected"' : ''; |
1364 | | - $encCode = htmlspecialchars( $code ); |
1365 | | - $encName = htmlspecialchars( $name ); |
1366 | | - echo "\n\t\t<option value=\"$encCode\" $sel>$encName</option>"; |
1367 | | - } |
1368 | | - echo "\n"; |
1369 | | - ?> |
1370 | | - </select> |
1371 | | - </div> |
1372 | | - <p class="config-desc"> |
1373 | | - Select the language for your wiki's interface. Some localizations aren't fully complete. Unicode (UTF-8) is used for all localizations. |
1374 | | - </p> |
1375 | | - |
1376 | | - <div class="config-input"> |
1377 | | - <label class='column'>Copyright/license:</label> |
1378 | | - |
1379 | | - <ul class="plain"> |
1380 | | - <li><?php aField( $conf, "License", "No license metadata", "radio", "none" ); ?></li> |
1381 | | - <li><?php aField( $conf, "License", "Public Domain", "radio", "pd" ); ?></li> |
1382 | | - <li><?php aField( $conf, "License", "GNU Free Documentation License 1.2", "radio", "gfdl1_2" ); ?></li> |
1383 | | - <li><?php aField( $conf, "License", "GNU Free Documentation License 1.3", "radio", "gfdl1_3" ); ?></li> |
1384 | | - <li><?php |
1385 | | - aField( $conf, "License", "A Creative Commons license - ", "radio", "cc" ); |
1386 | | - $partner = "MediaWiki"; |
1387 | | - $script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php'; |
1388 | | - $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/$script?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" ); |
1389 | | - $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" ); |
1390 | | - $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" ); |
1391 | | - print "<a href=\"$ccApp\" target='_blank'>choose</a>"; |
1392 | | - if( $conf->License == "cc" ) { ?> |
1393 | | - <ul> |
1394 | | - <li><?php aField( $conf, "RightsIcon", "<img src=\"" . htmlspecialchars( $conf->RightsIcon ) . "\" alt='(Creative Commons icon)' />", "hidden" ); ?></li> |
1395 | | - <li><?php aField( $conf, "RightsText", htmlspecialchars( $conf->RightsText ), "hidden" ); ?></li> |
1396 | | - <li><?php aField( $conf, "RightsCode", "code: " . htmlspecialchars( $conf->RightsCode ), "hidden" ); ?></li> |
1397 | | - <li><?php aField( $conf, "RightsUrl", "<a href=\"" . htmlspecialchars( $conf->RightsUrl ) . "\">" . htmlspecialchars( $conf->RightsUrl ) . "</a>", "hidden" ); ?></li> |
1398 | | - </ul> |
1399 | | - <?php } ?> |
1400 | | - </li> |
1401 | | - </ul> |
1402 | | - </div> |
1403 | | - <p class="config-desc"> |
1404 | | - A notice, icon, and machine-readable copyright metadata will be displayed for the license you pick. |
1405 | | - </p> |
1406 | | - |
1407 | | - |
1408 | | - <div class="config-input"> |
1409 | | - <?php aField( $conf, "SysopName", "Admin username:" ) ?> |
1410 | | - </div> |
1411 | | - <div class="config-input"> |
1412 | | - <?php aField( $conf, "SysopPass", "Password:", "password" ) ?> |
1413 | | - </div> |
1414 | | - <div class="config-input"> |
1415 | | - <?php aField( $conf, "SysopPass2", "Password confirm:", "password" ) ?> |
1416 | | - </div> |
1417 | | - <p class="config-desc"> |
1418 | | - An admin can lock/delete pages, block users from editing, and do other maintenance tasks.<br /> |
1419 | | - A new account will be added only when creating a new wiki database. |
1420 | | - <br /><br /> |
1421 | | - The password cannot be the same as the username. |
1422 | | - </p> |
1423 | | - |
1424 | | - <div class="config-input"> |
1425 | | - <label class='column'>Object caching:</label> |
1426 | | - |
1427 | | - <ul class="plain"> |
1428 | | - <li><?php aField( $conf, "Shm", "No caching", "radio", "none" ); ?></li> |
1429 | | - <?php |
1430 | | - if ( $conf->turck ) { |
1431 | | - echo "<li>"; |
1432 | | - aField( $conf, "Shm", "Turck MMCache", "radio", "turck" ); |
1433 | | - echo "</li>\n"; |
1434 | | - } |
1435 | | - if( $conf->xcache ) { |
1436 | | - echo "<li>"; |
1437 | | - aField( $conf, 'Shm', 'XCache', 'radio', 'xcache' ); |
1438 | | - echo "</li>\n"; |
1439 | | - } |
1440 | | - if ( $conf->apc ) { |
1441 | | - echo "<li>"; |
1442 | | - aField( $conf, "Shm", "APC", "radio", "apc" ); |
1443 | | - echo "</li>\n"; |
1444 | | - } |
1445 | | - if ( $conf->eaccel ) { |
1446 | | - echo "<li>"; |
1447 | | - aField( $conf, "Shm", "eAccelerator", "radio", "eaccel" ); |
1448 | | - echo "</li>\n"; |
1449 | | - } |
1450 | | - if ( $conf->dba ) { |
1451 | | - echo "<li>"; |
1452 | | - aField( $conf, "Shm", "DBA (not recommended)", "radio", "dba" ); |
1453 | | - echo "</li>"; |
1454 | | - } |
1455 | | - ?> |
1456 | | - <li><?php aField( $conf, "Shm", "Memcached", "radio", "memcached" ); ?></li> |
1457 | | - </ul> |
1458 | | - <div style="clear:left"><?php aField( $conf, "MCServers", "Memcached servers:", "text" ) ?></div> |
1459 | | - </div> |
1460 | | - <p class="config-desc"> |
1461 | | - An object caching system such as memcached will provide a significant performance boost, |
1462 | | - but needs to be installed. Provide the server addresses and ports in a comma-separated list. |
1463 | | - <br /><br /> |
1464 | | - MediaWiki can also detect and support eAccelerator, Turck MMCache, APC, and XCache, but |
1465 | | - these should not be used if the wiki will be running on multiple application servers. |
1466 | | - <br/><br/> |
1467 | | - DBA (Berkeley-style DB) is generally slower than using no cache at all, and is only |
1468 | | - recommended for testing. |
1469 | | - </p> |
1470 | | -</div> |
1471 | | - |
1472 | | -<h2>E-mail, e-mail notification and authentication setup</h2> |
1473 | | - |
1474 | | -<div class="config-section"> |
1475 | | - <div class="config-input"> |
1476 | | - <label class='column'>E-mail features (global):</label> |
1477 | | - <ul class="plain"> |
1478 | | - <li><?php aField( $conf, "Email", "Enabled", "radio", "email_enabled" ); ?></li> |
1479 | | - <li><?php aField( $conf, "Email", "Disabled", "radio", "email_disabled" ); ?></li> |
1480 | | - </ul> |
1481 | | - </div> |
1482 | | - <p class="config-desc"> |
1483 | | - Use this to disable all e-mail functions (password reminders, user-to-user e-mail, and e-mail notifications) |
1484 | | - if sending mail doesn't work on your server. |
1485 | | - </p> |
1486 | | - |
1487 | | - <div class="config-input"> |
1488 | | - <label class='column'>User-to-user e-mail:</label> |
1489 | | - <ul class="plain"> |
1490 | | - <li><?php aField( $conf, "Emailuser", "Enabled", "radio", "emailuser_enabled" ); ?></li> |
1491 | | - <li><?php aField( $conf, "Emailuser", "Disabled", "radio", "emailuser_disabled" ); ?></li> |
1492 | | - </ul> |
1493 | | - </div> |
1494 | | - <p class="config-desc"> |
1495 | | - 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. |
1496 | | - </p> |
1497 | | - <div class="config-input"> |
1498 | | - <label class='column'>E-mail notification about changes:</label> |
1499 | | - <ul class="plain"> |
1500 | | - <li><?php aField( $conf, "Enotif", "Disabled", "radio", "enotif_disabled" ); ?></li> |
1501 | | - <li><?php aField( $conf, "Enotif", "Enabled for changes to user discussion pages only", "radio", "enotif_usertalk" ); ?></li> |
1502 | | - <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> |
1503 | | - </ul> |
1504 | | - </div> |
1505 | | - <div class="config-desc"> |
1506 | | - <p> |
1507 | | - For this feature to work, an e-mail address must be present for the user account, and the notification |
1508 | | - options in the user's preferences must be enabled. Also note the |
1509 | | - authentication option below. When testing the feature, keep in mind that your own changes will never trigger notifications to be sent to yourself.</p> |
1510 | | - |
1511 | | - <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> |
1512 | | - </div> |
1513 | | - |
1514 | | - <div class="config-input"> |
1515 | | - <label class='column'>E-mail address authentication:</label> |
1516 | | - <ul class="plain"> |
1517 | | - <li><?php aField( $conf, "Eauthent", "Disabled", "radio", "eauthent_disabled" ); ?></li> |
1518 | | - <li><?php aField( $conf, "Eauthent", "Enabled", "radio", "eauthent_enabled" ); ?></li> |
1519 | | - </ul> |
1520 | | - </div> |
1521 | | - <div class="config-desc"> |
1522 | | - <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 |
1523 | | - change notification mails. Setting this option is <b>recommended</b> for public wikis because of potential abuse of the e-mail features above.</p> |
1524 | | - </div> |
1525 | | - |
1526 | | -</div> |
1527 | | - |
1528 | | -<h2>Database config</h2> |
1529 | | - |
1530 | | -<div class="config-section"> |
1531 | | -<div class="config-input"> |
1532 | | - <label class='column'>Database type:</label> |
1533 | | -<?php |
1534 | | - if (isset($errs['DBpicktype'])) { |
1535 | | - print "\t<span class='error'>" . htmlspecialchars( $errs['DBpicktype'] ) . "</span>\n"; |
1536 | | - } |
1537 | | -?> |
1538 | | - <ul class='plain'><?php |
1539 | | - database_picker($conf); |
1540 | | - ?></ul> |
1541 | | - </div> |
1542 | | - |
1543 | | - <div class="config-input" style="clear:left"> |
1544 | | - <?php aField( $conf, "DBserver", "Database host:" ); ?> |
1545 | | - </div> |
1546 | | - <p class="config-desc"> |
1547 | | - If your database server isn't on your web server, enter the name or IP address here. |
1548 | | - </p> |
1549 | | - |
1550 | | - <div class="config-input"><?php aField( $conf, "DBname", "Database name:" ); ?></div> |
1551 | | - <div class="config-input"><?php aField( $conf, "DBuser", "DB username:" ); ?></div> |
1552 | | - <div class="config-input"><?php aField( $conf, "DBpassword", "DB password:", "password" ); ?></div> |
1553 | | - <div class="config-input"><?php aField( $conf, "DBpassword2", "DB password confirm:", "password" ); ?></div> |
1554 | | - <p class="config-desc"> |
1555 | | - If you only have a single user account and database available, |
1556 | | - enter those here. If you have database root access (see below) |
1557 | | - you can specify new accounts/databases to be created. This account |
1558 | | - will not be created if it pre-exists. If this is the case, ensure that it |
1559 | | - has SELECT, INSERT, UPDATE, and DELETE permissions on the MediaWiki database. |
1560 | | - </p> |
1561 | | - |
1562 | | - <div class="config-input"> |
1563 | | - <label class="column">Superuser account:</label> |
1564 | | - <input type="checkbox" name="useroot" id="useroot" <?php if( $useRoot ) { ?>checked="checked" <?php } ?> /> |
1565 | | - <label for="useroot">Use superuser account</label> |
1566 | | - <input type="checkbox" name="populateadmin" id="populateadmin" <?php if( $conf->populateadmin ) { ?>checked="checked" <?php } ?> /> |
1567 | | - <label for="populateadmin">Set as admin user for maintenance</label> |
1568 | | - </div> |
1569 | | - <div class="config-input"><?php aField( $conf, "RootUser", "Superuser name:", "text" ); ?></div> |
1570 | | - <div class="config-input"><?php aField( $conf, "RootPW", "Superuser password:", "password" ); ?></div> |
1571 | | - |
1572 | | - <p class="config-desc"> |
1573 | | - If the database user specified above does not exist, or does not have access to create |
1574 | | - the database (if needed) or tables within it, please check the box and provide details |
1575 | | - of a superuser account, such as <strong>root</strong>, which does. |
1576 | | - </p> |
1577 | | - |
1578 | | - <?php database_switcher('mysql'); ?> |
1579 | | - <div class="config-input"><?php aField( $conf, "DBprefix", "Database table prefix:" ); ?></div> |
1580 | | - <div class="config-desc"> |
1581 | | - <p>If you need to share one database between multiple wikis, or |
1582 | | - between MediaWiki and another web application, you may choose to |
1583 | | - add a prefix to all the table names to avoid conflicts.</p> |
1584 | | - |
1585 | | - <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p> |
1586 | | - </div> |
1587 | | - |
1588 | | - <div class="config-input"><label class="column">Storage Engine</label> |
1589 | | - <div>Select one:</div> |
1590 | | - <ul class="plain"> |
1591 | | - <li><?php aField( $conf, "DBengine", "InnoDB", "radio", "InnoDB" ); ?></li> |
1592 | | - <li><?php aField( $conf, "DBengine", "MyISAM", "radio", "MyISAM" ); ?></li> |
1593 | | - </ul> |
1594 | | - </div> |
1595 | | - <p class="config-desc"> |
1596 | | - InnoDB is best for public web installations, since it has good concurrency |
1597 | | - support. MyISAM may be faster in single-user installations. MyISAM databases |
1598 | | - tend to get corrupted more often than InnoDB databases. |
1599 | | - </p> |
1600 | | - <div class="config-input"><label class="column">Database character set</label> |
1601 | | - <div>Select one:</div> |
1602 | | - <ul class="plain"> |
1603 | | - <li><?php aField( $conf, "DBschema", "MySQL 4.1/5.0 binary", "radio", "mysql5-binary" ); ?></li> |
1604 | | - <li><?php aField( $conf, "DBschema", "MySQL 4.1/5.0 UTF-8", "radio", "mysql5" ); ?></li> |
1605 | | - <li><?php aField( $conf, "DBschema", "MySQL 4.0 backwards-compatible UTF-8", "radio", "mysql4" ); ?></li> |
1606 | | - </ul> |
1607 | | - </div> |
1608 | | - <p class="config-desc"> |
1609 | | - This option is ignored on upgrade, the same character set will be kept. |
1610 | | - <br/><br/> |
1611 | | - <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!. |
1612 | | - <br/><br/> |
1613 | | - 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>. |
1614 | | - </p> |
1615 | | - </fieldset> |
1616 | | - |
1617 | | - <?php database_switcher('postgres'); ?> |
1618 | | - <div class="config-input"><?php aField( $conf, "DBport", "Database port:" ); ?></div> |
1619 | | - <div class="config-input"><?php aField( $conf, "DBmwschema", "Schema for mediawiki:" ); ?></div> |
1620 | | - <div class="config-input"><?php aField( $conf, "DBts2schema", "Schema for tsearch2:" ); ?></div> |
1621 | | - <div class="config-desc"> |
1622 | | - <p>The username specified above (at "DB username") will have its search path set to the above schemas, |
1623 | | - so it is recommended that you create a new user. The above schemas are generally correct: |
1624 | | - only change them if you are sure you need to.</p> |
1625 | | - </div> |
1626 | | - </fieldset> |
1627 | | - |
1628 | | - <?php database_switcher('sqlite'); ?> |
1629 | | - <div class="config-desc"> |
1630 | | - <b>NOTE:</b> SQLite only uses the <i>Database name</i> setting above, the user, password and root settings are ignored. |
1631 | | - </div> |
1632 | | - <div class="config-input"><?php |
1633 | | - aField( $conf, "SQLiteDataDir", "SQLite data directory:" ); |
1634 | | - ?></div> |
1635 | | - <div class="config-desc"> |
1636 | | - <p>SQLite stores table data into files in the filesystem. |
1637 | | - If you do not provide an explicit path, a "data" directory in |
1638 | | - the parent of your document root will be used.</p> |
1639 | | - |
1640 | | - <p>This directory must exist and be writable by the web server.</p> |
1641 | | - </div> |
1642 | | - </fieldset> |
1643 | | - |
1644 | | - <?php database_switcher('mssql'); ?> |
1645 | | - <div class="config-input"><?php |
1646 | | - aField( $conf, "DBprefix2", "Database table prefix:" ); |
1647 | | - ?></div> |
1648 | | - <div class="config-desc"> |
1649 | | - <p>If you need to share one database between multiple wikis, or |
1650 | | - between MediaWiki and another web application, you may choose to |
1651 | | - add a prefix to all the table names to avoid conflicts.</p> |
1652 | | - |
1653 | | - <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p> |
1654 | | - </div> |
1655 | | - </fieldset> |
1656 | | - |
1657 | | - <?php database_switcher('ibm_db2'); ?> |
1658 | | - <div class="config-input"><?php |
1659 | | - aField( $conf, "DBport_db2", "Database port:" ); |
1660 | | - ?></div> |
1661 | | - <div class="config-input"><?php |
1662 | | - aField( $conf, "DBmwschema", "Schema for mediawiki:" ); |
1663 | | - ?></div> |
1664 | | - <div>Select one:</div> |
1665 | | - <ul class="plain"> |
1666 | | - <li><?php aField( $conf, "DBcataloged", "Cataloged (DB2 installed locally)", "radio", "cataloged" ); ?></li> |
1667 | | - <li><?php aField( $conf, "DBcataloged", "Uncataloged (remote DB2 through ODBC)", "radio", "uncataloged" ); ?></li> |
1668 | | - </ul> |
1669 | | - <div class="config-desc"> |
1670 | | - <p>If you need to share one database between multiple wikis, or |
1671 | | - between MediaWiki and another web application, you may specify |
1672 | | - a different schema to avoid conflicts.</p> |
1673 | | - </div> |
1674 | | - </fieldset> |
1675 | | - |
1676 | | - <?php database_switcher('oracle'); ?> |
1677 | | - <div class="config-input"><?php aField( $conf, "DBprefix_ora", "Database table prefix:" ); ?></div> |
1678 | | - <div class="config-desc"> |
1679 | | - <p>If you need to share one database between multiple wikis, or |
1680 | | - between MediaWiki and another web application, you may choose to |
1681 | | - add a prefix to all the table names to avoid conflicts.</p> |
1682 | | - |
1683 | | - <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p> |
1684 | | - </div> |
1685 | | - <div class="config-input"><?php aField( $conf, "DBdefTS_ora", "Default tablespace:" ); ?></div> |
1686 | | - <div class="config-input"><?php aField( $conf, "DBtempTS_ora", "Temporary tablespace:" ); ?></div> |
1687 | | - </fieldset> |
1688 | | - |
1689 | | - <div class="config-input" style="padding:2em 0 3em"> |
1690 | | - <label class='column'> </label> |
1691 | | - <input type="submit" value="Install MediaWiki!" class="btn-install" /> |
1692 | | - </div> |
1693 | | -</div> |
1694 | | -</form> |
1695 | | -<script type="text/javascript"> |
1696 | | -window.onload = toggleDBarea( <?php echo Xml::encodeJsVar( $conf->DBtype ); ?>, |
1697 | | -<?php |
1698 | | - ## If they passed in a root user name, don't populate it on page load |
1699 | | - echo strlen(importPost('RootUser', '')) ? 0 : 1; |
1700 | | -?>); |
1701 | | -</script> |
1702 | | -<?php |
1703 | | -} |
1704 | | - |
1705 | | -/* -------------------------------------------------------------------------------------- */ |
1706 | | -function writeSuccessMessage() { |
1707 | | - $script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php'; |
1708 | | - if ( wfIniGetBool( 'safe_mode' ) && !ini_get( 'open_basedir' ) ) { |
1709 | | - echo <<<EOT |
1710 | | -<div class="success-box"> |
1711 | | -<p>Installation successful!</p> |
1712 | | -<p>To complete the installation, please do the following: |
1713 | | -<ol> |
1714 | | - <li>Download config/LocalSettings.php with your FTP client or file manager</li> |
1715 | | - <li>Upload it to the parent directory</li> |
1716 | | - <li>Delete config/LocalSettings.php</li> |
1717 | | - <li>Start using <a href='../$script'>your wiki</a>! |
1718 | | -</ol> |
1719 | | -<p>If you are in a shared hosting environment, do <strong>not</strong> just move LocalSettings.php |
1720 | | -remotely. LocalSettings.php is currently owned by the user your webserver is running under, |
1721 | | -which means that anyone on the same server can read your database password! Downloading |
1722 | | -it and uploading it again will hopefully change the ownership to a user ID specific to you.</p> |
1723 | | -</div> |
1724 | | -EOT; |
1725 | | - } else { |
1726 | | - echo <<<EOT |
1727 | | -<div class="success-box"> |
1728 | | -<p> |
1729 | | -<span class="success-message">Installation successful!</span> |
1730 | | -Move the <tt>config/LocalSettings.php</tt> file to the parent directory, then follow |
1731 | | -<a href="../$script"> this link</a> to your wiki.</p> |
1732 | | -<p>You should change file permissions for <tt>LocalSettings.php</tt> as required to |
1733 | | -prevent other users on the server reading passwords and altering configuration data.</p> |
1734 | | -</div> |
1735 | | -EOT; |
1736 | | - } |
1737 | | -} |
1738 | | - |
1739 | | - |
1740 | | -function escapePhpString( $string ) { |
1741 | | - if ( is_array( $string ) || is_object( $string ) ) { |
1742 | | - return false; |
1743 | | - } |
1744 | | - return strtr( $string, |
1745 | | - array( |
1746 | | - "\n" => "\\n", |
1747 | | - "\r" => "\\r", |
1748 | | - "\t" => "\\t", |
1749 | | - "\\" => "\\\\", |
1750 | | - "\$" => "\\\$", |
1751 | | - "\"" => "\\\"" |
1752 | | - )); |
1753 | | -} |
1754 | | - |
1755 | | -function writeLocalSettings( $conf ) { |
1756 | | - $conf->PasswordSender = $conf->EmergencyContact; |
1757 | | - $magic = ($conf->ImageMagick ? "" : "# "); |
1758 | | - $convert = ($conf->ImageMagick ? $conf->ImageMagick : "/usr/bin/convert" ); |
1759 | | - $rights = ($conf->RightsUrl) ? "" : "# "; |
1760 | | - $hashedUploads = $conf->safeMode ? '' : '# '; |
1761 | | - |
1762 | | - if ( $conf->ShellLocale ) { |
1763 | | - $locale = ''; |
1764 | | - } else { |
1765 | | - $locale = '# '; |
1766 | | - $conf->ShellLocale = 'en_US.UTF-8'; |
1767 | | - } |
1768 | | - |
1769 | | - switch ( $conf->Shm ) { |
1770 | | - case 'memcached': |
1771 | | - $cacheType = 'CACHE_MEMCACHED'; |
1772 | | - $mcservers = var_export( $conf->MCServerArray, true ); |
1773 | | - break; |
1774 | | - case 'turck': |
1775 | | - case 'xcache': |
1776 | | - case 'apc': |
1777 | | - case 'eaccel': |
1778 | | - $cacheType = 'CACHE_ACCEL'; |
1779 | | - $mcservers = 'array()'; |
1780 | | - break; |
1781 | | - case 'dba': |
1782 | | - $cacheType = 'CACHE_DBA'; |
1783 | | - $mcservers = 'array()'; |
1784 | | - break; |
1785 | | - default: |
1786 | | - $cacheType = 'CACHE_NONE'; |
1787 | | - $mcservers = 'array()'; |
1788 | | - } |
1789 | | - |
1790 | | - if ( $conf->Email == 'email_enabled' ) { |
1791 | | - $enableemail = 'true'; |
1792 | | - $enableuseremail = ( $conf->Emailuser == 'emailuser_enabled' ) ? 'true' : 'false' ; |
1793 | | - $eauthent = ( $conf->Eauthent == 'eauthent_enabled' ) ? 'true' : 'false' ; |
1794 | | - switch ( $conf->Enotif ) { |
1795 | | - case 'enotif_usertalk': |
1796 | | - $enotifusertalk = 'true'; |
1797 | | - $enotifwatchlist = 'false'; |
1798 | | - break; |
1799 | | - case 'enotif_allpages': |
1800 | | - $enotifusertalk = 'true'; |
1801 | | - $enotifwatchlist = 'true'; |
1802 | | - break; |
1803 | | - default: |
1804 | | - $enotifusertalk = 'false'; |
1805 | | - $enotifwatchlist = 'false'; |
1806 | | - } |
1807 | | - } else { |
1808 | | - $enableuseremail = 'false'; |
1809 | | - $enableemail = 'false'; |
1810 | | - $eauthent = 'false'; |
1811 | | - $enotifusertalk = 'false'; |
1812 | | - $enotifwatchlist = 'false'; |
1813 | | - } |
1814 | | - |
1815 | | - $file = @fopen( "/dev/urandom", "r" ); |
1816 | | - if ( $file ) { |
1817 | | - $secretKey = bin2hex( fread( $file, 32 ) ); |
1818 | | - fclose( $file ); |
1819 | | - } else { |
1820 | | - $secretKey = ""; |
1821 | | - for ( $i=0; $i<8; $i++ ) { |
1822 | | - $secretKey .= dechex(mt_rand(0, 0x7fffffff)); |
1823 | | - } |
1824 | | - print "<li>Warning: \$wgSecretKey key is insecure, generated with mt_rand(). Consider changing it manually.</li>\n"; |
1825 | | - } |
1826 | | - |
1827 | | - # Add slashes to strings for double quoting |
1828 | | - $slconf = wfArrayMap( "escapePhpString", get_object_vars( $conf ) ); |
1829 | | - if( $conf->License == 'gfdl1_2' || $conf->License == 'pd' || $conf->License == 'gfdl1_3' ) { |
1830 | | - # Needs literal string interpolation for the current style path |
1831 | | - $slconf['RightsIcon'] = $conf->RightsIcon; |
1832 | | - } |
1833 | | - |
1834 | | - if( $conf->populateadmin ) { |
1835 | | - $slconf['DBadminuser'] = $conf->RootUser; |
1836 | | - $slconf['DBadminpassword'] = $conf->RootPW; |
1837 | | - } |
1838 | | - |
1839 | | - if( $conf->DBtype == 'mysql' ) { |
1840 | | - $dbsettings = |
1841 | | -"# MySQL specific settings |
1842 | | -\$wgDBprefix = \"{$slconf['DBprefix']}\"; |
1843 | | - |
1844 | | -# MySQL table options to use during installation or update |
1845 | | -\$wgDBTableOptions = \"{$slconf['DBTableOptions']}\"; |
1846 | | - |
1847 | | -# Experimental charset support for MySQL 4.1/5.0. |
1848 | | -\$wgDBmysql5 = {$conf->DBmysql5};"; |
1849 | | - } elseif( $conf->DBtype == 'postgres' ) { |
1850 | | - $dbsettings = |
1851 | | -"# Postgres specific settings |
1852 | | -\$wgDBport = \"{$slconf['DBport']}\"; |
1853 | | -\$wgDBmwschema = \"{$slconf['DBmwschema']}\"; |
1854 | | -\$wgDBts2schema = \"{$slconf['DBts2schema']}\";"; |
1855 | | - } elseif( $conf->DBtype == 'sqlite' ) { |
1856 | | - $dbsettings = |
1857 | | -"# SQLite-specific settings |
1858 | | -\$wgSQLiteDataDir = \"{$slconf['SQLiteDataDir']}\";"; |
1859 | | - } elseif( $conf->DBtype == 'mssql' ) { |
1860 | | - $dbsettings = |
1861 | | -"# MSSQL specific settings |
1862 | | -\$wgDBprefix = \"{$slconf['DBprefix2']}\";"; |
1863 | | - } elseif( $conf->DBtype == 'ibm_db2' ) { |
1864 | | - $dbsettings = |
1865 | | -"# DB2 specific settings |
1866 | | -\$wgDBport_db2 = \"{$slconf['DBport_db2']}\"; |
1867 | | -\$wgDBmwschema = \"{$slconf['DBmwschema']}\"; |
1868 | | -\$wgDBcataloged = \"{$slconf['DBcataloged']}\";"; |
1869 | | - } elseif( $conf->DBtype == 'oracle' ) { |
1870 | | - $dbsettings = |
1871 | | -"# Oracle specific settings |
1872 | | -\$wgDBprefix = \"{$slconf['DBprefix']}\";"; |
1873 | | - } else { |
1874 | | - // ummm... :D |
1875 | | - $dbsettings = ''; |
1876 | | - } |
1877 | | - |
1878 | | - |
1879 | | - $localsettings = " |
1880 | | -# This file was automatically generated by the MediaWiki installer. |
1881 | | -# If you make manual changes, please keep track in case you need to |
1882 | | -# recreate them later. |
1883 | | -# |
1884 | | -# See includes/DefaultSettings.php for all configurable settings |
1885 | | -# and their default values, but don't forget to make changes in _this_ |
1886 | | -# file, not there. |
1887 | | -# |
1888 | | -# Further documentation for configuration settings may be found at: |
1889 | | -# http://www.mediawiki.org/wiki/Manual:Configuration_settings |
1890 | | - |
1891 | | -# If you customize your file layout, set \$IP to the directory that contains |
1892 | | -# the other MediaWiki files. It will be used as a base to locate files. |
1893 | | -if( defined( 'MW_INSTALL_PATH' ) ) { |
1894 | | - \$IP = MW_INSTALL_PATH; |
1895 | | -} else { |
1896 | | - \$IP = dirname( __FILE__ ); |
1897 | | -} |
1898 | | - |
1899 | | -\$path = array( \$IP, \"\$IP/includes\", \"\$IP/languages\" ); |
1900 | | -set_include_path( implode( PATH_SEPARATOR, \$path ) . PATH_SEPARATOR . get_include_path() ); |
1901 | | - |
1902 | | -require_once( \"\$IP/includes/DefaultSettings.php\" ); |
1903 | | - |
1904 | | -if ( \$wgCommandLineMode ) { |
1905 | | - if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) { |
1906 | | - die( \"This script must be run from the command line\\n\" ); |
1907 | | - } |
1908 | | -} |
1909 | | -## Uncomment this to disable output compression |
1910 | | -# \$wgDisableOutputCompression = true; |
1911 | | - |
1912 | | -\$wgSitename = \"{$slconf['Sitename']}\"; |
1913 | | - |
1914 | | -## The URL base path to the directory containing the wiki; |
1915 | | -## defaults for all runtime URL paths are based off of this. |
1916 | | -## For more information on customizing the URLs please see: |
1917 | | -## http://www.mediawiki.org/wiki/Manual:Short_URL |
1918 | | -\$wgScriptPath = \"{$slconf['ScriptPath']}\"; |
1919 | | -\$wgScriptExtension = \"{$slconf['ScriptExtension']}\"; |
1920 | | - |
1921 | | -## UPO means: this is also a user preference option |
1922 | | - |
1923 | | -\$wgEnableEmail = $enableemail; |
1924 | | -\$wgEnableUserEmail = $enableuseremail; # UPO |
1925 | | - |
1926 | | -\$wgEmergencyContact = \"{$slconf['EmergencyContact']}\"; |
1927 | | -\$wgPasswordSender = \"{$slconf['PasswordSender']}\"; |
1928 | | - |
1929 | | -\$wgEnotifUserTalk = $enotifusertalk; # UPO |
1930 | | -\$wgEnotifWatchlist = $enotifwatchlist; # UPO |
1931 | | -\$wgEmailAuthentication = $eauthent; |
1932 | | - |
1933 | | -## Database settings |
1934 | | -\$wgDBtype = \"{$slconf['DBtype']}\"; |
1935 | | -\$wgDBserver = \"{$slconf['DBserver']}\"; |
1936 | | -\$wgDBname = \"{$slconf['DBname']}\"; |
1937 | | -\$wgDBuser = \"{$slconf['DBuser']}\"; |
1938 | | -\$wgDBpassword = \"{$slconf['DBpassword']}\"; |
1939 | | - |
1940 | | -{$dbsettings} |
1941 | | - |
1942 | | -## Database admin settings, used for maintenance scripts |
1943 | | -\$wgDBadminuser = \"". ($conf->populateadmin ? $slconf['DBadminuser'] : '' )."\"; |
1944 | | -\$wgDBadminpassword = \"". ($conf->populateadmin ? $slconf['DBadminpassword'] : '' )."\"; |
1945 | | - |
1946 | | -## Shared memory settings |
1947 | | -\$wgMainCacheType = $cacheType; |
1948 | | -\$wgMemCachedServers = $mcservers; |
1949 | | - |
1950 | | -## To enable image uploads, make sure the 'images' directory |
1951 | | -## is writable, then set this to true: |
1952 | | -\$wgEnableUploads = false; |
1953 | | -{$magic}\$wgUseImageMagick = true; |
1954 | | -{$magic}\$wgImageMagickConvertCommand = \"{$convert}\"; |
1955 | | - |
1956 | | -## If you use ImageMagick (or any other shell command) on a |
1957 | | -## Linux server, this will need to be set to the name of an |
1958 | | -## available UTF-8 locale |
1959 | | -{$locale}\$wgShellLocale = \"{$slconf['ShellLocale']}\"; |
1960 | | - |
1961 | | -## If you want to use image uploads under safe mode, |
1962 | | -## create the directories images/archive, images/thumb and |
1963 | | -## images/temp, and make them all writable. Then uncomment |
1964 | | -## this, if it's not already uncommented: |
1965 | | -{$hashedUploads}\$wgHashedUploadDirectory = false; |
1966 | | - |
1967 | | -## If you have the appropriate support software installed |
1968 | | -## you can enable inline LaTeX equations: |
1969 | | -\$wgUseTeX = false; |
1970 | | - |
1971 | | -## Set \$wgCacheDirectory to a writable directory on the web server |
1972 | | -## to make your wiki go slightly faster. The directory should not |
1973 | | -## be publically accessible from the web. |
1974 | | -#\$wgCacheDirectory = \"\$IP/cache\"; |
1975 | | - |
1976 | | -\$wgLocalInterwiki = strtolower( \$wgSitename ); |
1977 | | - |
1978 | | -\$wgLanguageCode = \"{$slconf['LanguageCode']}\"; |
1979 | | - |
1980 | | -\$wgSecretKey = \"$secretKey\"; |
1981 | | - |
1982 | | -## Default skin: you can change the default skin. Use the internal symbolic |
1983 | | -## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook': |
1984 | | -\$wgDefaultSkin = 'monobook'; |
1985 | | - |
1986 | | -## For attaching licensing metadata to pages, and displaying an |
1987 | | -## appropriate copyright notice / icon. GNU Free Documentation |
1988 | | -## License and Creative Commons licenses are supported so far. |
1989 | | -{$rights}\$wgEnableCreativeCommonsRdf = true; |
1990 | | -\$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright |
1991 | | -\$wgRightsUrl = \"{$slconf['RightsUrl']}\"; |
1992 | | -\$wgRightsText = \"{$slconf['RightsText']}\"; |
1993 | | -\$wgRightsIcon = \"{$slconf['RightsIcon']}\"; |
1994 | | -# \$wgRightsCode = \"{$slconf['RightsCode']}\"; # Not yet used |
1995 | | - |
1996 | | -\$wgDiff3 = \"{$slconf['diff3']}\"; |
1997 | | - |
1998 | | -\$wgPhpCliPath = \"{$slconf['phpCliPath']}\"; |
1999 | | - |
2000 | | -# When you make changes to this configuration file, this will make |
2001 | | -# sure that cached pages are cleared. |
2002 | | -\$wgCacheEpoch = max( \$wgCacheEpoch, gmdate( 'YmdHis', @filemtime( __FILE__ ) ) ); |
2003 | | -"; ## End of setting the $localsettings string |
2004 | | - |
2005 | | - // Keep things in Unix line endings internally; |
2006 | | - // the system will write out as local text type. |
2007 | | - return str_replace( "\r\n", "\n", $localsettings ); |
2008 | | -} |
2009 | | - |
2010 | | -function dieout( $text ) { |
2011 | | - global $mainListOpened; |
2012 | | - if( $mainListOpened ) echo( "</ul>" ); |
2013 | | - if( $text != '' && substr( $text, 0, 2 ) != '<p' && substr( $text, 0, 2 ) != '<h' ){ |
2014 | | - echo "<p>$text</p>\n"; |
2015 | | - } else { |
2016 | | - echo $text; |
2017 | | - } |
2018 | | - die( "\n\n</div>\n</div>\n</div>\n</div>\n</body>\n</html>" ); |
2019 | | -} |
2020 | | - |
2021 | | -function importVar( &$var, $name, $default = "" ) { |
2022 | | - if( isset( $var[$name] ) ) { |
2023 | | - $retval = $var[$name]; |
2024 | | - if ( get_magic_quotes_gpc() ) { |
2025 | | - $retval = stripslashes( $retval ); |
2026 | | - } |
2027 | | - } else { |
2028 | | - $retval = $default; |
2029 | | - } |
2030 | | - taint( $retval ); |
2031 | | - return $retval; |
2032 | | -} |
2033 | | - |
2034 | | -function importPost( $name, $default = "" ) { |
2035 | | - return importVar( $_POST, $name, $default ); |
2036 | | -} |
2037 | | - |
2038 | | -function importCheck( $name ) { |
2039 | | - return isset( $_POST[$name] ); |
2040 | | -} |
2041 | | - |
2042 | | -function importRequest( $name, $default = "" ) { |
2043 | | - return importVar( $_REQUEST, $name, $default ); |
2044 | | -} |
2045 | | - |
2046 | | -function aField( &$conf, $field, $text, $type = "text", $value = "", $onclick = '' ) { |
2047 | | - static $radioCount = 0; |
2048 | | - if( $type != "" ) { |
2049 | | - $xtype = "type=\"$type\""; |
2050 | | - } else { |
2051 | | - $xtype = ""; |
2052 | | - } |
2053 | | - |
2054 | | - $id = $field; |
2055 | | - $nolabel = ($type == "radio") || ($type == "hidden"); |
2056 | | - |
2057 | | - if ($type == 'radio') |
2058 | | - $id .= $radioCount++; |
2059 | | - |
2060 | | - if( !$nolabel ) { |
2061 | | - echo "<label class='column' for=\"$id\">$text</label>"; |
2062 | | - } |
2063 | | - |
2064 | | - if( $type == "radio" && $value == $conf->$field ) { |
2065 | | - $checked = "checked='checked'"; |
2066 | | - } else { |
2067 | | - $checked = ""; |
2068 | | - } |
2069 | | - echo "<input $xtype name=\"$field\" id=\"$id\" class=\"iput-$type\" $checked "; |
2070 | | - if ($onclick) { |
2071 | | - echo " onclick='toggleDBarea(\"$value\",1)' " ; |
2072 | | - } |
2073 | | - echo "value=\""; |
2074 | | - if( $type == "radio" ) { |
2075 | | - echo htmlspecialchars( $value ); |
2076 | | - } else { |
2077 | | - echo htmlspecialchars( $conf->$field ); |
2078 | | - } |
2079 | | - |
2080 | | - |
2081 | | - echo "\" />"; |
2082 | | - if( $nolabel ) { |
2083 | | - echo "<label for=\"$id\">$text</label>"; |
2084 | | - } |
2085 | | - |
2086 | | - global $errs; |
2087 | | - if(isset($errs[$field])) { |
2088 | | - echo "<span class='error'>" . htmlspecialchars( $errs[$field] ) . "</span>\n"; |
2089 | | - } |
2090 | | -} |
2091 | | - |
2092 | | -function getLanguageList() { |
2093 | | - global $wgLanguageNames, $IP; |
2094 | | - if( !isset( $wgLanguageNames ) ) { |
2095 | | - require_once( "$IP/languages/Names.php" ); |
2096 | | - } |
2097 | | - |
2098 | | - $codes = array(); |
2099 | | - |
2100 | | - $d = opendir( "../languages/messages" ); |
2101 | | - /* In case we are called from the root directory */ |
2102 | | - if (!$d) |
2103 | | - $d = opendir( "languages/messages"); |
2104 | | - while( false !== ($f = readdir( $d ) ) ) { |
2105 | | - $m = array(); |
2106 | | - if( preg_match( '/Messages([A-Z][a-z_]+)\.php$/', $f, $m ) ) { |
2107 | | - $code = str_replace( '_', '-', strtolower( $m[1] ) ); |
2108 | | - if( isset( $wgLanguageNames[$code] ) ) { |
2109 | | - $name = wfBCP47( $code ) . ' - ' . $wgLanguageNames[$code]; |
2110 | | - } else { |
2111 | | - $name = $code; |
2112 | | - } |
2113 | | - $codes[$code] = $name; |
2114 | | - } |
2115 | | - } |
2116 | | - closedir( $d ); |
2117 | | - ksort( $codes ); |
2118 | | - return $codes; |
2119 | | -} |
2120 | | - |
2121 | | -#Check for location of an executable |
2122 | | -# @param string $loc single location to check |
2123 | | -# @param array $names filenames to check for. |
2124 | | -# @param mixed $versioninfo array of details to use when checking version, use false for no version checking |
2125 | | -function locate_executable($loc, $names, $versioninfo = false) { |
2126 | | - if (!is_array($names)) |
2127 | | - $names = array($names); |
2128 | | - |
2129 | | - foreach ($names as $name) { |
2130 | | - $command = "$loc".DIRECTORY_SEPARATOR."$name"; |
2131 | | - if (@file_exists($command)) { |
2132 | | - if (!$versioninfo) |
2133 | | - return $command; |
2134 | | - |
2135 | | - $file = str_replace('$1', $command, $versioninfo[0]); |
2136 | | - if (strstr(`$file`, $versioninfo[1]) !== false) |
2137 | | - return $command; |
2138 | | - } |
2139 | | - } |
2140 | | - return false; |
2141 | | -} |
2142 | | - |
2143 | | -# Test a memcached server |
2144 | | -function testMemcachedServer( $server ) { |
2145 | | - $hostport = explode(":", $server); |
2146 | | - $errstr = false; |
2147 | | - $fp = false; |
2148 | | - if ( !function_exists( 'fsockopen' ) ) { |
2149 | | - $errstr = "Can't connect to memcached, fsockopen() not present"; |
2150 | | - } |
2151 | | - if ( !$errstr && count( $hostport ) != 2 ) { |
2152 | | - $errstr = 'Please specify host and port'; |
2153 | | - } |
2154 | | - if ( !$errstr ) { |
2155 | | - list( $host, $port ) = $hostport; |
2156 | | - $errno = 0; |
2157 | | - $fsockerr = ''; |
2158 | | - |
2159 | | - $fp = @fsockopen( $host, $port, $errno, $fsockerr, 1.0 ); |
2160 | | - if ( $fp === false ) { |
2161 | | - $errstr = "Cannot connect to memcached on $host:$port : $fsockerr"; |
2162 | | - } |
2163 | | - } |
2164 | | - if ( !$errstr ) { |
2165 | | - $command = "version\r\n"; |
2166 | | - $bytes = fwrite( $fp, $command ); |
2167 | | - if ( $bytes != strlen( $command ) ) { |
2168 | | - $errstr = "Cannot write to memcached socket on $host:$port"; |
2169 | | - } |
2170 | | - } |
2171 | | - if ( !$errstr ) { |
2172 | | - $expected = "VERSION "; |
2173 | | - $response = fread( $fp, strlen( $expected ) ); |
2174 | | - if ( $response != $expected ) { |
2175 | | - $errstr = "Didn't get correct memcached response from $host:$port"; |
2176 | | - } |
2177 | | - } |
2178 | | - if ( $fp ) { |
2179 | | - fclose( $fp ); |
2180 | | - } |
2181 | | - if ( !$errstr ) { |
2182 | | - echo "<li>Connected to memcached on " . htmlspecialchars( "$host:$port" ) ." successfully</li>"; |
2183 | | - } |
2184 | | - return $errstr; |
2185 | | -} |
2186 | | - |
2187 | | -function database_picker($conf) { |
2188 | | - global $ourdb; |
2189 | | - print "\n"; |
2190 | | - foreach(array_keys($ourdb) as $db) { |
2191 | | - if ($ourdb[$db]['havedriver']) { |
2192 | | - print "\t<li>"; |
2193 | | - aField( $conf, "DBtype", $ourdb[$db]['fullname'], 'radio', $db, 'onclick'); |
2194 | | - print "</li>\n"; |
2195 | | - } |
2196 | | - } |
2197 | | - print "\n\t"; |
2198 | | -} |
2199 | | - |
2200 | | -function database_switcher($db) { |
2201 | | - global $ourdb; |
2202 | | - $color = $ourdb[$db]['bgcolor']; |
2203 | | - $full = $ourdb[$db]['fullname']; |
2204 | | - print "<fieldset id='$db'><legend>$full specific options</legend>\n"; |
2205 | | -} |
2206 | | - |
2207 | | -function printListItem( $item ) { |
2208 | | - print "<li>$item</li>"; |
2209 | | -} |
2210 | | - |
2211 | | -# Determine a suitable value for $wgShellLocale |
2212 | | -function getShellLocale( $wikiLang ) { |
2213 | | - # Give up now if we're in safe mode or open_basedir |
2214 | | - # It's theoretically possible but tricky to work with |
2215 | | - if ( wfIniGetBool( "safe_mode" ) || ini_get( 'open_basedir' ) ) { |
2216 | | - return false; |
2217 | | - } |
2218 | | - |
2219 | | - $os = php_uname( 's' ); |
2220 | | - $supported = array( 'Linux', 'SunOS', 'HP-UX' ); # Tested these |
2221 | | - if ( !in_array( $os, $supported ) ) { |
2222 | | - return false; |
2223 | | - } |
2224 | | - |
2225 | | - # Get a list of available locales |
2226 | | - $lines = $ret = false; |
2227 | | - exec( '/usr/bin/locale -a', $lines, $ret ); |
2228 | | - if ( $ret ) { |
2229 | | - return false; |
2230 | | - } |
2231 | | - |
2232 | | - $lines = wfArrayMap( 'trim', $lines ); |
2233 | | - $candidatesByLocale = array(); |
2234 | | - $candidatesByLang = array(); |
2235 | | - foreach ( $lines as $line ) { |
2236 | | - if ( $line === '' ) { |
2237 | | - continue; |
2238 | | - } |
2239 | | - if ( !preg_match( '/^([a-zA-Z]+)(_[a-zA-Z]+|)\.(utf8|UTF-8)(@[a-zA-Z_]*|)$/i', $line, $m ) ) { |
2240 | | - continue; |
2241 | | - } |
2242 | | - list( $all, $lang, $territory, $charset, $modifier ) = $m; |
2243 | | - $candidatesByLocale[$m[0]] = $m; |
2244 | | - $candidatesByLang[$lang][] = $m; |
2245 | | - } |
2246 | | - |
2247 | | - # Try the current value of LANG |
2248 | | - if ( isset( $candidatesByLocale[ getenv( 'LANG' ) ] ) ) { |
2249 | | - return getenv( 'LANG' ); |
2250 | | - } |
2251 | | - |
2252 | | - # Try the most common ones |
2253 | | - $commonLocales = array( 'en_US.UTF-8', 'en_US.utf8', 'de_DE.UTF-8', 'de_DE.utf8' ); |
2254 | | - foreach ( $commonLocales as $commonLocale ) { |
2255 | | - if ( isset( $candidatesByLocale[$commonLocale] ) ) { |
2256 | | - return $commonLocale; |
2257 | | - } |
2258 | | - } |
2259 | | - |
2260 | | - # Is there an available locale in the Wiki's language? |
2261 | | - if ( isset( $candidatesByLang[$wikiLang] ) ) { |
2262 | | - $m = reset( $candidatesByLang[$wikiLang] ); |
2263 | | - return $m[0]; |
2264 | | - } |
2265 | | - |
2266 | | - # Are there any at all? |
2267 | | - if ( count( $candidatesByLocale ) ) { |
2268 | | - $m = reset( $candidatesByLocale ); |
2269 | | - return $m[0]; |
2270 | | - } |
2271 | | - |
2272 | | - # Give up |
2273 | | - return false; |
2274 | | -} |
2275 | | - |
2276 | | -function wfArrayMap( $function, $input ) { |
2277 | | - $ret = array_map( $function, $input ); |
2278 | | - foreach ( $ret as $key => $value ) { |
2279 | | - $taint = istainted( $input[$key] ); |
2280 | | - if ( $taint ) { |
2281 | | - taint( $ret[$key], $taint ); |
2282 | | - } |
2283 | | - } |
2284 | | - return $ret; |
2285 | | -} |
2286 | | - |
2287 | | -?> |
2288 | | - |
2289 | | - <div class="license"> |
2290 | | - <hr/> |
2291 | | - <p>This program is free software; you can redistribute it and/or modify |
2292 | | - it under the terms of the GNU General Public License as published by |
2293 | | - the Free Software Foundation; either version 2 of the License, or |
2294 | | - (at your option) any later version.</p> |
2295 | | - |
2296 | | - <p>This program is distributed in the hope that it will be useful, |
2297 | | - but WITHOUT ANY WARRANTY; without even the implied warranty of |
2298 | | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2299 | | - GNU General Public License for more details.</p> |
2300 | | - |
2301 | | - <p>You should have received <a href="../COPYING">a copy of the GNU General Public License</a> |
2302 | | - along with this program; if not, write to the Free Software |
2303 | | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
2304 | | - or <a href="http://www.gnu.org/copyleft/gpl.html">read it online</a></p> |
2305 | | - </div> |
2306 | | - |
2307 | | -</div></div></div> |
2308 | | - |
2309 | | - |
2310 | | -<div id="column-one"> |
2311 | | - <div class="portlet" id="p-logo"> |
2312 | | - <a style="background-image: url(../skins/common/images/mediawiki.png);" |
2313 | | - href="../" |
2314 | | - title="Main Page"></a> |
2315 | | - </div> |
2316 | | - <script type="text/javascript"> if (window.isMSIE55) fixalpha(); </script> |
2317 | | - <div class='portlet'><div class='pBody'> |
2318 | | - <ul> |
2319 | | - <li><a href="../README">Readme</a></li> |
2320 | | - <li><a href="../RELEASE-NOTES">Release notes</a></li> |
2321 | | - <li><a href="../docs/">Documentation</a></li> |
2322 | | - <li><a href="http://www.mediawiki.org/wiki/Help:Contents">User's Guide</a></li> |
2323 | | - <li><a href="http://www.mediawiki.org/wiki/Manual:Contents">Administrator's Guide</a></li> |
2324 | | - <li><a href="http://www.mediawiki.org/wiki/Manual:FAQ">FAQ</a></li> |
2325 | | - </ul> |
2326 | | - <p style="font-size:90%;margin-top:1em">MediaWiki is Copyright © 2001-2009 by Magnus Manske, Brion Vibber, |
2327 | | - Lee Daniel Crocker, Tim Starling, Erik Möller, Gabriel Wicke, Ævar Arnfjörð Bjarmason, Niklas Laxström, |
2328 | | - Domas Mituzas, Rob Church, Yuri Astrakhan, Aryeh Gregor, Aaron Schulz and others.</p> |
2329 | | - </div></div> |
2330 | | -</div> |
2331 | | - |
2332 | | -</div> |
2333 | | - |
2334 | | -</body> |
2335 | | -</html> |
| 41 | +// Isolate the rest of the code so this file can die out cleanly |
| 42 | +// if we find we're running under PHP 4.x... We use PHP 5 syntax |
| 43 | +// which doesn't parse under 4. |
| 44 | +require( dirname( __FILE__ ) . "/Installer.php" ); |