X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=config%2FInstaller.php;h=e2a29d1361b188e6e76e503789de13e036db7ec1;hb=e143f6ca5cd5a342965421e10ff3fbce59c3561e;hp=b3eb386d2f17201703740b9b47f39773c5fc7736;hpb=4dfd052775dfd3b4cdceaab6ce501ddc89a2829e;p=lhc%2Fweb%2Fwiklou.git diff --git a/config/Installer.php b/config/Installer.php index b3eb386d2f..e2a29d1361 100644 --- a/config/Installer.php +++ b/config/Installer.php @@ -1,23 +1,27 @@ , 2006 Rob Church -# http://www.mediawiki.org/ -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# http://www.gnu.org/copyleft/gpl.html +/** + * MediaWiki web-based config/installation + * + * Copyright © 2004 Brion Vibber , 2006 Rob Church + * http://www.mediawiki.org/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @file + */ if( !defined( 'MEDIAWIKI_INSTALL' ) ) { die( 'Not an entry point.' ); @@ -84,11 +88,11 @@ $ourdb['sqlite'] = array( ); $ourdb['mssql'] = array( - 'fullname' => 'MSSQL', + 'fullname' => 'Microsoft SQL Server', 'havedriver' => 0, - 'compile' => 'mssql_not_ready', # Change to 'mssql' after includes/DatabaseMssql.php added; - 'bgcolor' => '#ffc0cb', - 'rootuser' => 'administrator', + 'compile' => 'sqlsrv', + 'bgcolor' => '#cccccc', + 'rootuser' => 'root', 'serverless' => false ); @@ -112,7 +116,7 @@ $ourdb['oracle'] = array( ?> - + @@ -342,7 +346,7 @@ error_reporting( 0 ); $phpdatabases = array(); foreach (array_keys($ourdb) as $db) { $compname = $ourdb[$db]['compile']; - if( extension_loaded( $compname ) || ( mw_have_dl() && dl( "{$compname}." . PHP_SHLIB_SUFFIX ) ) ) { + if( wfDl( $compname ) ) { array_push($phpdatabases, $db); $ourdb[$db]['havedriver'] = 1; } @@ -503,11 +507,6 @@ if( $memlimit == -1 ) { print "\n"; } -$conf->turck = function_exists( 'mmcache_get' ); -if ( $conf->turck ) { - print "
  • Turck MMCache installed
  • \n"; -} - $conf->xcache = function_exists( 'xcache_get' ); if( $conf->xcache ) print "
  • XCache installed
  • \n"; @@ -519,15 +518,13 @@ if ($conf->apc ) { $conf->eaccel = function_exists( 'eaccelerator_get' ); if ( $conf->eaccel ) { - $conf->turck = 'eaccelerator'; print "
  • eAccelerator installed
  • \n"; } $conf->dba = function_exists( 'dba_open' ); -if( !( $conf->turck || $conf->eaccel || $conf->apc || $conf->xcache ) ) { - echo( '
  • Couldn\'t find Turck MMCache, - eAccelerator, +if( !( $conf->eaccel || $conf->apc || $conf->xcache ) ) { + echo( '
  • Couldn\'t find eAccelerator, APC or XCache; cannot use these for object caching.
  • ' ); } @@ -620,15 +617,15 @@ print "
  • Environment check $conf->DBtype = $DefaultDBtype; } - $conf->DBserver = importPost( "DBserver", "localhost" ); - $conf->DBname = importPost( "DBname", "wikidb" ); - $conf->DBuser = importPost( "DBuser", "wikiuser" ); + $conf->DBserver = importPost( "DBserver", $wgDBserver ); + $conf->DBname = importPost( "DBname", $wgDBname ); + $conf->DBuser = importPost( "DBuser", $wgDBuser ); $conf->DBpassword = importPost( "DBpassword" ); $conf->DBpassword2 = importPost( "DBpassword2" ); $conf->SysopName = importPost( "SysopName", "WikiSysop" ); $conf->SysopPass = importPost( "SysopPass" ); $conf->SysopPass2 = importPost( "SysopPass2" ); - $conf->RootUser = importPost( "RootUser", "root" ); + $conf->RootUser = importPost( "RootUser" ); $conf->RootPW = importPost( "RootPW", "" ); $useRoot = importCheck( 'useroot', false ); $conf->LanguageCode = importPost( "LanguageCode", "en" ); @@ -639,16 +636,12 @@ print "
  • Environment check importPost( "DBengine", "InnoDB" ) ); ## Postgres specific: - $conf->DBport = importPost( "DBport", "5432" ); + $conf->DBport = importPost( "DBport", $wgDBport ); $conf->DBts2schema = importPost( "DBts2schema", "public" ); $conf->DBpgschema = importPost( "DBpgschema", "mediawiki" ); ## SQLite specific - $conf->SQLiteDataDir = importPost( "SQLiteDataDir", "" ); - - ## MSSQL specific - // We need a second field so it doesn't overwrite the MySQL one - $conf->DBprefix2 = importPost( "DBprefix2" ); + $conf->SQLiteDataDir = importPost( "SQLiteDataDir", "$IP/../data" ); ## DB2 specific: // New variable in order to have a different default port number @@ -838,10 +831,7 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { $wgDBmwschema = $conf->DBdb2schema; } - if( $conf->DBprefix2 != '' ) { - // For MSSQL - $wgDBprefix = $conf->DBprefix2; - } elseif( $conf->DBprefix_ora != '' ) { + if( $conf->DBprefix_ora != '' ) { // For Oracle $wgDBprefix = $conf->DBprefix_ora; } @@ -929,6 +919,42 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { if( !$ok ) { continue; } } + else if ( $conf->DBtype == 'mssql' ) { + error_reporting( E_ALL ); + # Possible connect as a superuser + if ( $useRoot ) { + echo( "
  • Attempting to connect to database \"{$conf->DBtype}\" as superuser \"{$conf->RootUser}\"" ); + $wgDatabase = $dbc->newFromParams( + $conf->DBserver, + $conf->RootUser, + $conf->RootPW, + false, + false, + 1 + ); + if ( !$wgDatabase->isOpen() ) { + echo( " error: {$wgDatabase->lastError()}
  • \n" ); + $errs['DBserver'] = 'Could not connect to database as superuser'; + $errs['RootUser'] = 'Check username'; + $errs['RootPW'] = 'and password'; + continue; + } + $wgDatabase->initial_setup( $conf->RootPW, $conf->DBtype ); + } + echo( "
  • Attempting to connect to database \"{$wgDBname}\" as \"{$wgDBuser}\"..." ); + $wgDatabase = $dbc->newFromParams( + $conf->DBserver, + $conf->DBuser, + $conf->DBpassword, + $conf->DBname, + 1 + ); + if ( !$wgDatabase->isOpen() ) { + echo( " error: {$wgDatabase->lastError()}
  • \n" ); + } else { + $myver = $wgDatabase->getServerVersion(); + } + } else if( $conf->DBtype == 'ibm_db2' ) { if( $useRoot ) { $db_user = $conf->RootUser; @@ -953,9 +979,7 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname); } elseif ( $conf->DBtype == 'sqlite' ) { - if ("$wgSQLiteDataDir" == '') { - $wgSQLiteDataDir = dirname($_SERVER['DOCUMENT_ROOT']).'/data'; - } + $wgSQLiteDataDir = $conf->SQLiteDataDir; echo '
  • Attempting to connect to SQLite database at "' . htmlspecialchars( $wgSQLiteDataDir ) . '": '; if ( !is_dir( $wgSQLiteDataDir ) ) { @@ -1004,7 +1028,9 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { } else { $myver = $wgDatabase->getServerVersion(); } - if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname); + if ( is_callable( array( $wgDatabase, 'initial_setup' ) ) ) { + $wgDatabase->initial_setup('', $wgDBname); + } echo "ok
  • \n"; } elseif ( $conf->DBtype == 'oracle' ) { echo "
  • Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) ."\"
  • "; @@ -1027,7 +1053,8 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { if ($wgDatabase->isOpen()) { $wgDBOracleDefTS = $conf->DBdefTS_ora; $wgDBOracleTempTS = $conf->DBtempTS_ora; - $wgDatabase->sourceFile( "../maintenance/ora/user.sql" ); + $res = $wgDatabase->sourceFile( "../maintenance/ora/user.sql" ); + if ($res !== true) dieout($res); } else { echo "
  • Invalid database superuser, please supply a valid superuser account.
  • "; echo "
  • ERR: ".print_r(oci_error(), true)."
  • "; @@ -1051,14 +1078,12 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { } } else { # not mysql error_reporting( E_ALL | E_STRICT ); - $wgSuperUser = ''; ## Possible connect as a superuser // Changed !mysql to postgres check since it seems to only apply to postgres if( $useRoot && $conf->DBtype == 'postgres' ) { - $wgDBsuperuser = $conf->RootUser; echo( "
  • Attempting to connect to database \"postgres\" as superuser \"" . - htmlspecialchars( $wgDBsuperuser ) . "\"..." ); - $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBsuperuser, $conf->RootPW, "postgres", 1); + htmlspecialchars( $conf->RootUser ) . "\"..." ); + $wgDatabase = $dbc->newFromParams($wgDBserver, $conf->RootUser, $conf->RootPW, "postgres", 1); if (!$wgDatabase->isOpen()) { print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "
  • \n"; $errs["DBserver"] = "Could not connect to database as superuser"; @@ -1066,7 +1091,7 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { $errs["RootPW"] = "and password"; continue; } - $wgDatabase->initial_setup($conf->RootPW, 'postgres'); + $wgDatabase->initial_setup($conf->RootUser, $conf->RootPW, 'postgres'); } echo( "
  • Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) . "\" as \"" . htmlspecialchars( $wgDBuser ) . "\"..." ); @@ -1204,7 +1229,8 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { print " If the next step fails, see http://dev.mysql.com/doc/mysql/en/old-client.html for help."; } print "
  • \n"; - $wgDatabase->sourceFile( "../maintenance/users.sql" ); + $res = $wgDatabase->sourceFile( "../maintenance/users.sql" ); + if ($res !== true) dieout($res); } } } @@ -1227,7 +1253,6 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { break; } } - $wgDatabase->freeResult( $res ); if ( !$found && $conf->DBengine != 'MyISAM' ) { echo "
  • Warning: " . htmlspecialchars( $conf->DBengine ) . " storage engine not available, " . @@ -1236,11 +1261,19 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { } } - # FIXME: Check for errors print "
  • Creating tables..."; if ($conf->DBtype == 'mysql') { - $wgDatabase->sourceFile( "../maintenance/tables.sql" ); - $wgDatabase->sourceFile( "../maintenance/interwiki.sql" ); + $res = $wgDatabase->sourceFile( "../maintenance/tables.sql" ); + if ($res === true) { + print " done.
  • \n
  • Populating interwiki table... \n"; + $res = $wgDatabase->sourceFile( "../maintenance/interwiki.sql" ); + } + if ($res === true) { + print " done.
  • \n"; + } else { + print " FAILED\n"; + dieout( htmlspecialchars( $res ) ); + } } elseif (is_callable(array($wgDatabase, 'setup_database'))) { $wgDatabase->setup_database(); } @@ -1249,8 +1282,6 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { continue; } - print " done.\n"; - if ( $conf->DBtype == 'ibm_db2' ) { // Now that table creation is done, make sure everything is committed @@ -1291,8 +1322,13 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { } else { # Yes, so run the grants echo( "
  • " . htmlspecialchars( "Granting user permissions to $wgDBuser on $wgDBname..." ) ); - $wgDatabase->sourceFile( "../maintenance/users.sql" ); - echo( "success.
  • \n" ); + $res = $wgDatabase->sourceFile( "../maintenance/users.sql" ); + if ( $res === true ) { + echo( " success.\n" ); + } else { + echo( " FAILED.\n" ); + dieout( $res ); + } } } @@ -1340,7 +1376,7 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { $localSettings = str_replace( "\r\n", "\n", $localSettings ); $f = fopen( "LocalSettings.php", 'xt' ); - if( $f == false ) { + if( !$f ) { print( "\n" ); dieout( "

    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...

    \n" . "

    Here's the file that would have been written, try to paste it into place manually:

    \n" . @@ -1459,11 +1495,6 @@ if( count( $errs ) ) {
    • turck ) { - echo "
    • "; - aField( $conf, "Shm", "Turck MMCache", "radio", "turck" ); - echo "
    • \n"; - } if( $conf->xcache ) { echo "
    • "; aField( $conf, 'Shm', 'XCache', 'radio', 'xcache' ); @@ -1493,7 +1524,7 @@ if( count( $errs ) ) { An object caching system such as memcached will provide a significant performance boost, but needs to be installed. Provide the server addresses and ports in a comma-separated list.

      - MediaWiki can also detect and support eAccelerator, Turck MMCache, APC, and XCache, but + MediaWiki can also detect and support eAccelerator, APC, and XCache, but these should not be used if the wiki will be running on multiple application servers.

      DBA (Berkeley-style DB) is generally slower than using no cache at all, and is only @@ -1530,8 +1561,8 @@ if( count( $errs ) ) {
      • -
      • -
      • +
      • +
      @@ -1597,7 +1628,7 @@ if( count( $errs ) ) {
      checked="checked" /> -   +  
      @@ -1664,27 +1695,20 @@ if( count( $errs ) ) { aField( $conf, "SQLiteDataDir", "SQLite data directory:" ); ?>
      -

      SQLite stores table data into files in the filesystem. - If you do not provide an explicit path, a "data" directory in - the parent of your document root will be used.

      +

      SQLite stores table data into files in the + filesystem.

      This directory must exist and be writable by the web server.

      - -
      + +
      -

      If you need to share one database between multiple wikis, or - between MediaWiki and another web application, you may choose to - add a prefix to all the table names to avoid conflicts.

      - -

      Avoid exotic characters; something like mw_ is good.

      +

      No MS SQL Server specific options at this time.

      - - + +
      - +
      @@ -1737,7 +1761,7 @@ window.onload = toggleDBarea( DBtype ); ?>, function writeSuccessMessage() { $script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php'; if ( wfIniGetBool( 'safe_mode' ) && !ini_get( 'open_basedir' ) ) { - echo <<

      Installation successful!

      To complete the installation, please do the following: @@ -1752,9 +1776,9 @@ remotely. LocalSettings.php is currently owned by the user your webserver is run which means that anyone on the same server can read your database password! Downloading it and uploading it again will hopefully change the ownership to a user ID specific to you.

      -EOT; +HTML; } else { - echo <<

      Installation successful! @@ -1763,7 +1787,7 @@ Move the config/LocalSettings.php file to the parent directory, then fo

      You should change file permissions for LocalSettings.php as required to prevent other users on the server reading passwords and altering configuration data.

      -EOT; +HTML; } } @@ -1789,6 +1813,11 @@ function writeLocalSettings( $conf ) { $convert = ($conf->ImageMagick ? $conf->ImageMagick : "/usr/bin/convert" ); $rights = ($conf->RightsUrl) ? "" : "# "; $hashedUploads = $conf->safeMode ? '' : '# '; + $dir = realpath( $conf->SQLiteDataDir ); + if ( !$dir ) { + $dir = $conf->SQLiteDataDir; // dumb realpath sometimes fails + } + $sqliteDataDir = escapePhpString( $dir ); if ( $conf->ShellLocale ) { $locale = ''; @@ -1802,7 +1831,6 @@ function writeLocalSettings( $conf ) { $cacheType = 'CACHE_MEMCACHED'; $mcservers = var_export( $conf->MCServerArray, true ); break; - case 'turck': case 'xcache': case 'apc': case 'eaccel': @@ -1881,21 +1909,17 @@ function writeLocalSettings( $conf ) { } elseif( $conf->DBtype == 'sqlite' ) { $dbsettings = "# SQLite-specific settings -\$wgSQLiteDataDir = \"{$slconf['SQLiteDataDir']}\";"; - } elseif( $conf->DBtype == 'mssql' ) { - $dbsettings = -"# MSSQL specific settings -\$wgDBprefix = \"{$slconf['DBprefix2']}\";"; +\$wgSQLiteDataDir = \"{$sqliteDataDir}\";"; } elseif( $conf->DBtype == 'ibm_db2' ) { $dbsettings = "# DB2 specific settings -\$wgDBport_db2 = \"{$slconf['DBport_db2']}\"; +\$wgDBport = \"{$slconf['DBport_db2']}\"; \$wgDBmwschema = \"{$slconf['DBdb2schema']}\"; \$wgDBcataloged = \"{$slconf['DBcataloged']}\";"; } elseif( $conf->DBtype == 'oracle' ) { $dbsettings = "# Oracle specific settings -\$wgDBprefix = \"{$slconf['DBprefix']}\";"; +\$wgDBprefix = \"{$slconf['DBprefix_ora']}\";"; } else { // ummm... :D $dbsettings = ''; @@ -2009,7 +2033,7 @@ if ( \$wgCommandLineMode ) { \$wgSecretKey = \"$secretKey\"; ## Default skin: you can change the default skin. Use the internal symbolic -## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook': +## names, ie 'vector', 'monobook': \$wgDefaultSkin = 'monobook'; ## For attaching licensing metadata to pages, and displaying an @@ -2283,17 +2307,6 @@ function getShellLocale( $wikiLang ) { return false; } -function wfArrayMap( $function, $input ) { - $ret = array_map( $function, $input ); - foreach ( $ret as $key => $value ) { - $taint = istainted( $input[$key] ); - if ( $taint ) { - taint( $ret[$key], $taint ); - } - } - return $ret; -} - ?>
      @@ -2333,7 +2346,7 @@ function wfArrayMap( $function, $input ) {
    • Administrator's Guide
    • FAQ
    -

    MediaWiki is Copyright © 2001-2009 by Magnus Manske, Brion Vibber, +

    MediaWiki is Copyright © 2001-2010 by Magnus Manske, Brion Vibber, Lee Daniel Crocker, Tim Starling, Erik Möller, Gabriel Wicke, Ævar Arnfjörð Bjarmason, Niklas Laxström, Domas Mituzas, Rob Church, Yuri Astrakhan, Aryeh Gregor, Aaron Schulz and others.