X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=config%2FInstaller.php;h=e2a29d1361b188e6e76e503789de13e036db7ec1;hb=e143f6ca5cd5a342965421e10ff3fbce59c3561e;hp=76e7ae7dbce51c252d77a9fa587985a819b8e2ee;hpb=eec1e42eea8657172f5f226ef13412e12703cfa5;p=lhc%2Fweb%2Fwiklou.git diff --git a/config/Installer.php b/config/Installer.php index 76e7ae7dbc..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.' ); @@ -32,7 +36,7 @@ $wgRequestTime = microtime( true ); // Run version checks before including other files // so people don't see a scary parse error. -require_once( "$IP/install-utils.inc" ); +require_once( "$IP/maintenance/install-utils.inc" ); install_version_checks(); require_once( "$IP/includes/Defines.php" ); @@ -44,6 +48,8 @@ require_once( "$IP/includes/ProfilerStub.php" ); require_once( "$IP/includes/GlobalFunctions.php" ); require_once( "$IP/includes/Hooks.php" ); require_once( "$IP/includes/Exception.php" ); +require_once( "$IP/includes/json/Services_JSON.php" ); +require_once( "$IP/includes/json/FormatJson.php" ); # If we get an exception, the user needs to know # all the details @@ -53,45 +59,64 @@ wfInstallExceptionHandler(); ## Databases we support: $ourdb = array(); -$ourdb['mysql']['fullname'] = 'MySQL'; -$ourdb['mysql']['havedriver'] = 0; -$ourdb['mysql']['compile'] = 'mysql'; -$ourdb['mysql']['bgcolor'] = '#ffe5a7'; -$ourdb['mysql']['rootuser'] = 'root'; - -$ourdb['postgres']['fullname'] = 'PostgreSQL'; -$ourdb['postgres']['havedriver'] = 0; -$ourdb['postgres']['compile'] = 'pgsql'; -$ourdb['postgres']['bgcolor'] = '#aaccff'; -$ourdb['postgres']['rootuser'] = 'postgres'; - -$ourdb['sqlite']['fullname'] = 'SQLite'; -$ourdb['sqlite']['havedriver'] = 0; -$ourdb['sqlite']['compile'] = 'pdo_sqlite'; -$ourdb['sqlite']['bgcolor'] = '#b1ebb1'; -$ourdb['sqlite']['rootuser'] = ''; - -$ourdb['mssql']['fullname'] = 'MSSQL'; -$ourdb['mssql']['havedriver'] = 0; -$ourdb['mssql']['compile'] = 'mssql not ready'; # Change to 'mssql' after includes/DatabaseMssql.php added; -$ourdb['mssql']['bgcolor'] = '#ffc0cb'; -$ourdb['mssql']['rootuser'] = 'administrator'; - -$ourdb['ibm_db2']['fullname'] = 'DB2'; -$ourdb['ibm_db2']['havedriver'] = 0; -$ourdb['ibm_db2']['compile'] = 'ibm_db2'; -$ourdb['ibm_db2']['bgcolor'] = '#ffeba1'; -$ourdb['ibm_db2']['rootuser'] = 'db2admin'; - -$ourdb['oracle']['fullname'] = 'Oracle'; -$ourdb['oracle']['havedriver'] = 0; -$ourdb['oracle']['compile'] = 'oci8'; -$ourdb['oracle']['bgcolor'] = '#ffeba1'; -$ourdb['oracle']['rootuser'] = ''; + +$ourdb['mysql'] = array( + 'fullname' => 'MySQL', + 'havedriver' => 0, + 'compile' => 'mysql', + 'bgcolor' => '#ffe5a7', + 'rootuser' => 'root', + 'serverless' => false +); + +$ourdb['postgres'] = array( + 'fullname' => 'PostgreSQL', + 'havedriver' => 0, + 'compile' => 'pgsql', + 'bgcolor' => '#aaccff', + 'rootuser' => 'postgres', + 'serverless' => false +); + +$ourdb['sqlite'] = array( + 'fullname' => 'SQLite', + 'havedriver' => 0, + 'compile' => 'pdo_sqlite', + 'bgcolor' => '#b1ebb1', + 'rootuser' => '', + 'serverless' => true +); + +$ourdb['mssql'] = array( + 'fullname' => 'Microsoft SQL Server', + 'havedriver' => 0, + 'compile' => 'sqlsrv', + 'bgcolor' => '#cccccc', + 'rootuser' => 'root', + 'serverless' => false +); + +$ourdb['ibm_db2'] = array( + 'fullname' => 'DB2', + 'havedriver' => 0, + 'compile' => 'ibm_db2', + 'bgcolor' => '#ffeba1', + 'rootuser' => 'db2admin', + 'serverless' => false +); + +$ourdb['oracle'] = array( + 'fullname' => 'Oracle', + 'havedriver' => 0, + 'compile' => 'oci8', + 'bgcolor' => '#ffeba1', + 'rootuser' => 'sys', + 'serverless' => false +); ?> - + @@ -172,12 +197,13 @@ $ourdb['oracle']['rootuser'] = ''; font-size: 85%; padding-top: 3em; } - + span.success-message { font-weight: bold; font-size: 110%; color: green; } + .success-box { font-size: 130%; } @@ -185,23 +211,25 @@ $ourdb['oracle']['rootuser'] = ''; @@ -245,12 +273,11 @@ if( !is_writable( "." ) ) { cd " . htmlspecialchars( dirname( dirname( __FILE__ ) ) ) . " chmod a+w config - +

Afterwards retry to start the setup.

" ); } -require_once( "$IP/install-utils.inc" ); require_once( "$IP/maintenance/updaters.inc" ); class ConfigData { @@ -319,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; } @@ -396,7 +423,6 @@ if( wfIniGetBool( "zend.ze1_compatibility_mode" ) ) { PHP is configured with no memory_limit.\n"; @@ -476,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"; @@ -492,37 +518,17 @@ 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.
  • ' ); } -$conf->phpCliPath = false; -$phpClilocations = array_merge( - array( - "/usr/bin", - "/usr/local/bin", - "/opt/csw/bin", - "/usr/gnu/bin", - "/usr/sfw/bin" ), - explode( PATH_SEPARATOR, getenv( "PATH" ) ) ); -$phpClinames = array( "php", "php.exe" ); -foreach ($phpClilocations as $loc) { - $exe = locate_executable($loc, $phpClinames); - if ($exe !== false) { - $conf->phpCliPath= $exe; - break; - } -} - $conf->diff3 = false; $diff3locations = array_merge( array( @@ -611,42 +617,37 @@ 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->populateadmin = importCheck( 'populateadmin', false ); $conf->LanguageCode = importPost( "LanguageCode", "en" ); ## MySQL specific: $conf->DBprefix = importPost( "DBprefix" ); - $conf->setSchema( - importPost( "DBschema", "mysql5-binary" ), + $conf->setSchema( + importPost( "DBschema", "mysql5-binary" ), importPost( "DBengine", "InnoDB" ) ); ## Postgres specific: - $conf->DBport = importPost( "DBport", "5432" ); - $conf->DBmwschema = importPost( "DBmwschema", "mediawiki" ); + $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 $conf->DBport_db2 = importPost( "DBport_db2", "50000" ); - $conf->DBmwschema = importPost( "DBmwschema", "mediawiki" ); $conf->DBcataloged = importPost( "DBcataloged", "cataloged" ); + $conf->DBdb2schema = importPost( "DBdb2schema", "mediawiki" ); // Oracle specific $conf->DBprefix_ora = importPost( "DBprefix_ora" ); @@ -661,17 +662,19 @@ $errs = array(); if( preg_match( '/^$|^mediawiki$|#/i', $conf->Sitename ) ) { $errs["Sitename"] = "Must not be blank or \"MediaWiki\" and may not contain \"#\""; } -if( $conf->DBuser == "" ) { - $errs["DBuser"] = "Must not be blank"; -} -if( ($conf->DBtype == 'mysql') && (strlen($conf->DBuser) > 16) ) { - $errs["DBuser"] = "Username too long"; -} -if( $conf->DBpassword == "" && $conf->DBtype != "postgres" ) { - $errs["DBpassword"] = "Must not be blank"; -} -if( $conf->DBpassword != $conf->DBpassword2 ) { - $errs["DBpassword2"] = "Passwords don't match!"; +if( !$ourdb[$conf->DBtype]['serverless'] ) { + if( $conf->DBuser == "" ) { + $errs["DBuser"] = "Must not be blank"; + } + if( ($conf->DBtype == 'mysql') && (strlen($conf->DBuser) > 16) ) { + $errs["DBuser"] = "Username too long"; + } + if( $conf->DBpassword == "" && $conf->DBtype != "postgres" ) { + $errs["DBpassword"] = "Must not be blank"; + } + if( $conf->DBpassword != $conf->DBpassword2 ) { + $errs["DBpassword2"] = "Passwords don't match!"; + } } if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix ) ) { $errs["DBprefix"] = "Invalid table prefix"; @@ -706,11 +709,11 @@ $wgAuth = new AuthPlugin(); if( $conf->SysopName ) { # Check that the user can be created $u = User::newFromName( $conf->SysopName ); - if( is_a($u, 'User') ) { // please do not use instanceof, it breaks PHP4 + if( $u instanceof User ) { # Various password checks if( $conf->SysopPass != '' ) { if( $conf->SysopPass == $conf->SysopPass2 ) { - if( $u->isValidPassword( $conf->SysopPass ) !== true ) { + if( !$u->isValidPassword( $conf->SysopPass ) ) { $errs['SysopPass'] = "Bad password"; } } else { @@ -782,7 +785,7 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { $local = writeLocalSettings( $conf ); echo "
  • \n"; echo "

    Generating configuration file...

    \n"; - echo "
  • \n"; + echo "\n"; $wgCommandLineMode = false; chdir( ".." ); @@ -820,27 +823,29 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { ## Postgres specific: $wgDBport = $conf->DBport; - $wgDBmwschema = $conf->DBmwschema; $wgDBts2schema = $conf->DBts2schema; - if( $conf->DBprefix2 != '' ) { - // For MSSQL - $wgDBprefix = $conf->DBprefix2; - } elseif( $conf->DBprefix_ora != '' ) { + if( $wgDBtype == 'postgres' ) { + $wgDBmwschema = $conf->DBpgschema; + } elseif ( $wgDBtype == 'ibm_db2' ) { + $wgDBmwschema = $conf->DBdb2schema; + } + + if( $conf->DBprefix_ora != '' ) { // For Oracle $wgDBprefix = $conf->DBprefix_ora; } ## DB2 specific: $wgDBcataloged = $conf->DBcataloged; - + $wgCommandLineMode = true; if (! defined ( 'STDERR' ) ) define( 'STDERR', fopen("php://stderr", "wb")); $wgUseDatabaseMessages = false; /* FIXME: For database failure */ require_once( "$IP/includes/Setup.php" ); Language::getLocalisationCache()->disableBackend(); - + chdir( "config" ); $wgTitle = Title::newFromText( "Installation script" ); @@ -914,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; @@ -922,14 +963,14 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { $db_user = $wgDBuser; $db_pass = $wgDBpassword; } - - echo( "
  • Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) . + + echo( "
  • Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) . "\" as \"" . htmlspecialchars( $db_user ) . "\"..." ); $wgDatabase = $dbc->newFromParams($wgDBserver, $db_user, $db_pass, $wgDBname, 1); // enable extra debug messages $dbc->setMode(DatabaseIbm_db2::INSTALL_MODE); $wgDatabase->setMode(DatabaseIbm_db2::INSTALL_MODE); - + if (!$wgDatabase->isOpen()) { print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "
  • \n"; } else { @@ -938,11 +979,9 @@ 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'; - } - echo "
  • Attempting to connect to SQLite database at \"" . - htmlspecialchars( $wgSQLiteDataDir ) . "\""; + $wgSQLiteDataDir = $conf->SQLiteDataDir; + echo '
  • Attempting to connect to SQLite database at "' . + htmlspecialchars( $wgSQLiteDataDir ) . '": '; if ( !is_dir( $wgSQLiteDataDir ) ) { if ( is_writable( dirname( $wgSQLiteDataDir ) ) ) { $ok = wfMkdirParents( $wgSQLiteDataDir, $wgSQLiteDataDirMode ); @@ -950,35 +989,55 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { $ok = false; } if ( !$ok ) { - echo ": cannot create data directory
  • "; + echo "cannot create data directory"; $errs['SQLiteDataDir'] = 'Enter a valid data directory'; continue; } } if ( !is_writable( $wgSQLiteDataDir ) ) { - echo ": data directory not writable"; + echo "data directory not writable"; $errs['SQLiteDataDir'] = 'Enter a writable data directory'; continue; } - $dataFile = "$wgSQLiteDataDir/$wgDBname.sqlite"; - if ( file_exists( $dataFile ) && !is_writable( $dataFile ) ) { - echo ": data file not writable"; - $errs['SQLiteDataDir'] = "$wgDBname.sqlite is not writable"; + $dataFile = DatabaseSqlite::generateFileName( $wgSQLiteDataDir, $wgDBname ); + if ( file_exists( $dataFile ) ) { + if ( !is_writable( $dataFile ) ) { + echo "data file not writable"; + $errs['SQLiteDataDir'] = basename( $dataFile ) . " is not writable"; + continue; + } + } else { + if ( file_put_contents( $dataFile, '' ) === false ) { + echo 'could not create database file "' . htmlspecialchars( basename( $dataFile ) ) . "\"\n"; + $errs['SQLiteDataDir'] = "couldn't create " . basename( $dataFile ); + continue; + } + } + try { + $wgDatabase = new DatabaseSqlite( false, false, false, $wgDBname, 1 ); + } + catch( MWException $ex ) { + echo 'error: ' . htmlspecialchars( $ex->getMessage() ) . "\n"; continue; } - $wgDatabase = new DatabaseSqlite( false, false, false, $wgDBname, 1 ); + if (!$wgDatabase->isOpen()) { - print ": error: " . htmlspecialchars( $wgDatabase->lastError() ) . "\n"; + print "error: " . htmlspecialchars( $wgDatabase->lastError() ) . "\n"; $errs['SQLiteDataDir'] = 'Could not connect to database'; continue; } 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 ) ."\"
  • "; + $old_error_level = error_reporting(); + wfSuppressWarnings(); $wgDatabase = $dbc->newFromParams('DUMMY', $wgDBuser, $wgDBpassword, $wgDBname, 1); + wfRestoreWarnings(); if (!$wgDatabase->isOpen()) { $ok = true; echo "
  • Connect failed.
  • "; @@ -994,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)."
  • "; @@ -1018,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); + echo( "
  • Attempting to connect to database \"postgres\" as superuser \"" . + 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"; @@ -1033,9 +1091,9 @@ 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 ) . + echo( "
  • Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) . "\" as \"" . htmlspecialchars( $wgDBuser ) . "\"..." ); $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1); if (!$wgDatabase->isOpen()) { @@ -1048,7 +1106,7 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { $myver = $wgDatabase->getServerVersion(); } if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname); - } + } if ( !$wgDatabase->isOpen() ) { $errs["DBserver"] = "Couldn't connect to database"; @@ -1145,7 +1203,7 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { $encExisting = htmlspecialchars( $existingSchema ); $encRequested = htmlspecialchars( $conf->DBschema ); print "
  • Warning: you requested the $encRequested schema, " . - "but the existing database has the $encExisting schema. This upgrade script ". + "but the existing database has the $encExisting schema. This upgrade script ". "can't convert it, so it will remain $encExisting.
  • \n"; $conf->setSchema( $existingSchema, $conf->DBengine ); } @@ -1171,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); } } } @@ -1194,20 +1253,27 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { break; } } - $wgDatabase->freeResult( $res ); if ( !$found && $conf->DBengine != 'MyISAM' ) { - echo "
  • Warning: " . htmlspecialchars( $conf->DBengine ) . + echo "
  • Warning: " . htmlspecialchars( $conf->DBengine ) . " storage engine not available, " . "using MyISAM instead
  • \n"; $conf->setSchema( $conf->DBschema, 'MyISAM' ); } } - # 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(); } @@ -1216,10 +1282,8 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { continue; } - print " done.\n"; - - - if ($conf->DBtype == 'ibm_db2') { + + if ( $conf->DBtype == 'ibm_db2' ) { // Now that table creation is done, make sure everything is committed // Do this before doing inserts through API if ($wgDatabase->lastError()) { @@ -1230,6 +1294,10 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { print "
  • MediaWiki tables successfully created
  • \n"; $wgDatabase->commit(); } + } elseif ( $conf->DBtype == 'sqlite' ) { + // Ensure proper searchindex format. We have to do that separately because + // if SQLite is compiled without the FTS3 module, table creation syntax will be invalid. + sqlite_setup_searchindex(); } print "
  • Initializing statistics...
  • \n"; @@ -1254,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 ); + } } } @@ -1303,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" . @@ -1422,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' ); @@ -1456,10 +1524,10 @@ 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 +

      + DBA (Berkeley-style DB) is generally slower than using no cache at all, and is only recommended for testing.

      @@ -1493,14 +1561,14 @@ if( count( $errs ) ) {
      • -
      • -
      • +
      • +

      For this feature to work, an e-mail address must be present for the user account, and the notification - options in the user's preferences must be enabled. Also note the + options in the user's preferences must be enabled. Also note the authentication option below. When testing the feature, keep in mind that your own changes will never trigger notifications to be sent to yourself.

      There are additional options for fine tuning in /includes/DefaultSettings.php; copy these to your LocalSettings.php and edit them there to change them.

      @@ -1525,50 +1593,52 @@ if( count( $errs ) ) {
      -" . htmlspecialchars( $errs['DBpicktype'] ) . "\n"; } ?> -
      -
      - +
      +
      + +
      +

      + If your database server isn't on your web server, enter the name or IP address here. +

      -

      - If your database server isn't on your web server, enter the name or IP address here. -

      - -
      -
      -
      -
      -

      - If you only have a single user account and database available, - enter those here. If you have database root access (see below) - you can specify new accounts/databases to be created. This account - will not be created if it pre-exists. If this is the case, ensure that it - has SELECT, INSERT, UPDATE, and DELETE permissions on the MediaWiki database. -

      -
      - - checked="checked" /> -   - populateadmin ) { ?>checked="checked" /> -   +
      +
      +
      +
      +
      +

      + If you only have a single user account and database available, + enter those here. If you have database root access (see below) + you can specify new accounts/databases to be created. This account + will not be created if it pre-exists. If this is the case, ensure that it + has SELECT, INSERT, UPDATE, and DELETE permissions on the MediaWiki database. +

      + +
      + + checked="checked" /> +   +
      +
      +
      + +

      + If the database user specified above does not exist, or does not have access to create + the database (if needed) or tables within it, please check the box and provide details + of a superuser account, such as root, which does. +

      -
      -
      - -

      - If the database user specified above does not exist, or does not have access to create - the database (if needed) or tables within it, please check the box and provide details - of a superuser account, such as root, which does. -

      @@ -1588,8 +1658,8 @@ if( count( $errs ) ) {

    - InnoDB is best for public web installations, since it has good concurrency - support. MyISAM may be faster in single-user installations. MyISAM databases + InnoDB is best for public web installations, since it has good concurrency + support. MyISAM may be faster in single-user installations. MyISAM databases tend to get corrupted more often than InnoDB databases.

    @@ -1601,60 +1671,50 @@ if( count( $errs ) ) {

    - This option is ignored on upgrade, the same character set will be kept. -

    + This option is ignored on upgrade, the same character set will be kept. +

    WARNING: If you use backwards-compatible UTF-8 on MySQL 4.1+, and subsequently back up the database with mysqldump, it may destroy all non-ASCII characters, irreversibly corrupting your backups!. -

    +

    In binary mode, 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 UTF-8 mode, 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 Basic Multilingual Plane.

    -
    +
    -

    The username specified above (at "DB username") will have its search path set to the above schemas, - so it is recommended that you create a new user. The above schemas are generally correct: +

    The username specified above (at "DB username") will have its search path set to the above schemas, + so it is recommended that you create a new user. The above schemas are generally correct: only change them if you are sure you need to.

    -
    - NOTE: SQLite only uses the Database name setting above, the user, password and root settings are ignored. -
    -

    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.

    - +
    Select one:
      @@ -1682,7 +1742,7 @@ if( count( $errs ) ) {
      - +
      @@ -1701,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: @@ -1716,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! @@ -1727,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; } } @@ -1753,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 = ''; @@ -1766,7 +1831,6 @@ function writeLocalSettings( $conf ) { $cacheType = 'CACHE_MEMCACHED'; $mcservers = var_export( $conf->MCServerArray, true ); break; - case 'turck': case 'xcache': case 'apc': case 'eaccel': @@ -1825,11 +1889,6 @@ function writeLocalSettings( $conf ) { # Needs literal string interpolation for the current style path $slconf['RightsIcon'] = $conf->RightsIcon; } - - if( $conf->populateadmin ) { - $slconf['DBadminuser'] = $conf->RootUser; - $slconf['DBadminpassword'] = $conf->RootPW; - } if( $conf->DBtype == 'mysql' ) { $dbsettings = @@ -1845,26 +1904,22 @@ function writeLocalSettings( $conf ) { $dbsettings = "# Postgres specific settings \$wgDBport = \"{$slconf['DBport']}\"; -\$wgDBmwschema = \"{$slconf['DBmwschema']}\"; +\$wgDBmwschema = \"{$slconf['DBpgschema']}\"; \$wgDBts2schema = \"{$slconf['DBts2schema']}\";"; } 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']}\"; -\$wgDBmwschema = \"{$slconf['DBmwschema']}\"; +\$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 = ''; @@ -1913,6 +1968,13 @@ if ( \$wgCommandLineMode ) { \$wgScriptPath = \"{$slconf['ScriptPath']}\"; \$wgScriptExtension = \"{$slconf['ScriptExtension']}\"; +## The relative URL path to the skins directory +\$wgStylePath = \"\$wgScriptPath/skins\"; + +## The relative URL path to the logo. Make sure you change this from the default, +## or else you'll overwrite your logo when you upgrade! +\$wgLogo = \"\$wgStylePath/common/images/wiki.png\"; + ## UPO means: this is also a user preference option \$wgEnableEmail = $enableemail; @@ -1934,10 +1996,6 @@ if ( \$wgCommandLineMode ) { {$dbsettings} -## Database admin settings, used for maintenance scripts -\$wgDBadminuser = \"". ($conf->populateadmin ? $slconf['DBadminuser'] : '' )."\"; -\$wgDBadminpassword = \"". ($conf->populateadmin ? $slconf['DBadminpassword'] : '' )."\"; - ## Shared memory settings \$wgMainCacheType = $cacheType; \$wgMemCachedServers = $mcservers; @@ -1975,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 @@ -1990,8 +2048,6 @@ if ( \$wgCommandLineMode ) { \$wgDiff3 = \"{$slconf['diff3']}\"; -\$wgPhpCliPath = \"{$slconf['phpCliPath']}\"; - # When you make changes to this configuration file, this will make # sure that cached pages are cleared. \$wgCacheEpoch = max( \$wgCacheEpoch, gmdate( 'YmdHis', @filemtime( __FILE__ ) ) ); @@ -2085,30 +2141,13 @@ function aField( &$conf, $field, $text, $type = "text", $value = "", $onclick = } function getLanguageList() { - global $wgLanguageNames, $IP; - if( !isset( $wgLanguageNames ) ) { - require_once( "$IP/languages/Names.php" ); - } + global $wgDummyLanguageCodes; $codes = array(); - - $d = opendir( "../languages/messages" ); - /* In case we are called from the root directory */ - if (!$d) - $d = opendir( "languages/messages"); - while( false !== ($f = readdir( $d ) ) ) { - $m = array(); - if( preg_match( '/Messages([A-Z][a-z_]+)\.php$/', $f, $m ) ) { - $code = str_replace( '_', '-', strtolower( $m[1] ) ); - if( isset( $wgLanguageNames[$code] ) ) { - $name = wfBCP47( $code ) . ' - ' . $wgLanguageNames[$code]; - } else { - $name = $code; - } - $codes[$code] = $name; - } + foreach ( Language::getLanguageNames() as $code => $name ) { + if( in_array( $code, $wgDummyLanguageCodes ) ) continue; + $codes[$code] = $code . ' - ' . $name; } - closedir( $d ); ksort( $codes ); return $codes; } @@ -2196,7 +2235,7 @@ function database_switcher($db) { global $ourdb; $color = $ourdb[$db]['bgcolor']; $full = $ourdb[$db]['fullname']; - print "
      $full specific options\n"; + print "
      $full-specific options\n"; } function printListItem( $item ) { @@ -2207,7 +2246,7 @@ function printListItem( $item ) { function getShellLocale( $wikiLang ) { # Give up now if we're in safe mode or open_basedir # It's theoretically possible but tricky to work with - if ( wfIniGetBool( "safe_mode" ) || ini_get( 'open_basedir' ) ) { + if ( wfIniGetBool( "safe_mode" ) || ini_get( 'open_basedir' ) || !function_exists('exec') ) { return false; } @@ -2268,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; -} - ?>
      @@ -2318,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.