require_once( "includes/DefaultSettings.php" );
require_once( "includes/MagicWord.php" );
require_once( "includes/Namespace.php" );
+require_once( "includes/ProfilerStub.php" );
+
+## 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';
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
}
</style>
+ <script type="text/javascript">
+ <!--
+ function hideall() {
+ <?php foreach (array_keys($ourdb) as $db) {
+ echo "\n document.getElementById('$db').style.display='none';";
+ }
+ ?>
+
+ }
+ function toggleDBarea(id) {
+ hideall();
+ var dbarea = document.getElementById(id).style;
+ dbarea.display = (dbarea.display == 'none') ? 'block' : 'none';
+ var db = document.getElementById('RootUser');
+ <?php foreach (array_keys($ourdb) as $db) {
+ echo "\n if (id == '$db') { db.value = '".$ourdb[$db]['rootuser']."';}";
+ }
+ ?>
+
+ }
+ // -->
+ </script>
</head>
<body>
print "<li>PHP " . phpversion() . " installed</li>\n";
+## Temporarily turn off all errors as we try to discover installed databases
+$olderrnum = error_reporting(0);
+
+$phpdatabases = array();
+foreach (array_keys($ourdb) as $db) {
+ $compname = $ourdb[$db]['compile'];
+ if (extension_loaded($compname) or dl($compname . '.' . PHP_SHLIB_SUFFIX)) {
+ array_push($phpdatabases, $db);
+ $ourdb[$db]['havedriver'] = 1;
+ }
+}
+
+error_reporting($olderrornum);
+
+if (!$phpdatabases) {
+ print "Could not find a suitable database driver!<ul>";
+ foreach (array_keys($ourdb) AS $db) {
+ $comp = $ourdb[$db]['compile'];
+ $full = $ourdb[$db]['fullname'];
+ print "<li>For <b>$full</b>, compile PHP using <b>--with-$comp</b>, "
+ ."or install the $comp.so module</li>\n";
+ }
+ dieout( "</ul></ul>" );
+}
+
+print "<li>Found database drivers for:";
+foreach (array_keys($ourdb) AS $db) {
+ if ($ourdb[$db]['havedriver']) {
+ $DefaultDBtype = $db;
+ print " ".$ourdb[$db]['fullname'];
+ }
+}
+print "</li>\n";
+if (count($phpdatabases) != 1)
+ $DefaultDBtype = '';
+
if( ini_get( "register_globals" ) ) {
?>
<li>
$conf->turck = 'eaccelerator';
print "<li><a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> installed</li>\n";
}
-if (!$conf->turck && !$conf->eaccel && !$conf->apc) {
- print "<li>Neither <a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> nor ".
- "<a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> nor ".
- "<a href=\"http://www.php.net/apc\">APC</a> are installed, " .
- "can't use object caching functions</li>\n";
+
+if( !$conf->turck && !$conf->eaccel && !$conf->apc ) {
+ echo( '<li>Couldn\'t find <a href="http://turck-mmcache.sourceforge.net">Turck MMCache</a>,
+ <a href="http://eaccelerator.sourceforge.net">eAccelerator</a> or
+ <a href="http://www.php.net/apc">APC</a>. Object caching functions cannot be used.</li>' );
}
$conf->diff3 = false;
-$diff3locations = array("/usr/bin", "/usr/local/bin", "/opt/csw/bin", "/usr/gnu/bin", "/usr/sfw/bin") + explode($sep, getenv("PATH"));
-$diff3names = array("gdiff3", "diff3", "diff3.exe");
+$diff3locations = array( "/usr/bin", "/usr/local/bin", "/opt/csw/bin", "/usr/gnu/bin", "/usr/sfw/bin" ) + explode( $sep, getenv( "PATH" ) );
+$diff3names = array( "gdiff3", "diff3", "diff3.exe" );
-$diff3versioninfo = array('$1 --version 2>&1', 'diff3 (GNU diffutils)');
+$diff3versioninfo = array( '$1 --version 2>&1', 'diff3 (GNU diffutils)' );
foreach ($diff3locations as $loc) {
$exe = locate_executable($loc, $diff3names, $diff3versioninfo);
if ($exe !== false) {
? 'root@localhost'
: $_SERVER["SERVER_ADMIN"];
$conf->EmergencyContact = importPost( "EmergencyContact", $defaultEmail );
- $conf->DBtype = importPost( "DBtype", "mysql" );
+ $conf->DBtype = importPost( "DBtype", $DefaultDBtype );
+?>
+
+<?php
$conf->DBserver = importPost( "DBserver", "localhost" );
$conf->DBname = importPost( "DBname", "wikidb" );
$conf->DBuser = importPost( "DBuser", "wikiuser" );
$conf->DBpassword = importPost( "DBpassword" );
$conf->DBpassword2 = importPost( "DBpassword2" );
- $conf->DBprefix = importPost( "DBprefix" );
- $conf->DBmysql5 = (importPost( "DBmysql5" ) == "true") ? "true" : "false";
- $conf->RootUser = importPost( "RootUser", "root" );
- $conf->RootPW = importPost( "RootPW", "-" );
- $conf->LanguageCode = importPost( "LanguageCode", "en" );
$conf->SysopName = importPost( "SysopName", "WikiSysop" );
$conf->SysopPass = importPost( "SysopPass" );
$conf->SysopPass2 = importPost( "SysopPass2" );
+ $conf->RootUser = importPost( "RootUser", "root" );
+ $conf->RootPW = importPost( "RootPW", "-" );
+
+ ## MySQL specific:
+ $conf->DBprefix = importPost( "DBprefix" );
+ $conf->DBmysql5 = (importPost( "DBmysql5" ) == "true") ? "true" : "false";
+ $conf->LanguageCode = importPost( "LanguageCode", "en" );
+
+ ## Postgres specific:
+ $conf->DBport = importPost( "DBport", "5432" );
+ $conf->DBmwschema = importPost( "DBmwschema", "mediawiki" );
+ $conf->DBts2schema = importPost( "DBts2schema", "public" );
/* Check for validity */
$errs = array();
$wgCommandLineMode = false;
chdir( ".." );
eval($local);
- if (!in_array($conf->DBtype, array("mysql", "oracle", "postgres"))) {
- $errs["DBtype"] = "Unknown database type.";
+ $conf->DBtypename = '';
+ foreach (array_keys($ourdb) as $db) {
+ if ($conf->DBtype === $db)
+ $conf->DBtypename = $ourdb[$db]['fullname'];
+ }
+ if ( ! strlen($conf->DBtype)) {
+ $errs["DBpicktype"] = "Please choose a database type";
continue;
}
- print "<li>Database type: {$conf->DBtype}</li>\n";
+
+ if (! $conf->DBtypename) {
+ $errs["DBtype"] = "Unknown database type '$conf->DBtype'";
+ continue;
+ }
+ print "<li>Database type: {$conf->DBtypename}</li>\n";
$dbclass = 'Database'.ucfirst($conf->DBtype);
$wgDBtype = $conf->DBtype;
$wgDBadminuser = "root";
$wgDBadminpassword = $conf->RootPW;
+
+ ## Mysql specific:
$wgDBprefix = $conf->DBprefix;
+
+ ## Postgres specific:
+ $wgDBport = $conf->DBport;
+ $wgDBmwschema = $conf->DBmwschema;
+ $wgDBts2schema = $conf->DBts2schema;
+
$wgCommandLineMode = true;
$wgUseDatabaseMessages = false; /* FIXME: For database failure */
require_once( "includes/Setup.php" );
require_once( "maintenance/InitialiseMessages.inc" );
$wgTitle = Title::newFromText( "Installation script" );
+error_reporting( E_ALL );
+ print "<li>Loading class: $dbclass";
$dbc = new $dbclass;
if( $conf->DBtype == 'mysql' ) {
# Attempt to connect
echo( "<li>Attempting to connect to database server as $db_user..." );
$wgDatabase = Database::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 );
-
+
# Check the connection and respond to errors
if( $wgDatabase->isOpen() ) {
# Seems OK
if( !$ok ) { continue; }
} else /* not mysql */ {
- echo( "<li>Attempting to connect to database server as $wgDBuser..." );
+ error_reporting( E_ALL );
+ $wgSuperUser = '';
+ ## Possible connect as a superuser
+ if( $conf->RootPW != '-' and strlen($conf->RootPW)) {
+ $wgDBsuperuser = $conf->RootUser;
+ echo( "<li>Attempting to connect to database \"postgres\" as superuser \"$wgDBsuperuser\"..." );
+ $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBsuperuser, $conf->RootPW, "postgres", 1);
+ if (!$wgDatabase->isOpen()) {
+ print " error: " . $wgDatabase->lastError() . "</li>\n";
+ $errs["DBserver"] = "Couldn't connect to database as superuser";
+ $errs["RootUser"] = "Check username";
+ $errs["RootPW"] = "and password";
+ continue;
+ }
+ }
+ echo( "<li>Attempting to connect to database \"$wgDBname\" as \"$wgDBuser\"..." );
$wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1);
if (!$wgDatabase->isOpen()) {
print " error: " . $wgDatabase->lastError() . "</li>\n";
} else {
- $wgDatabase->ignoreErrors(true);
$myver = $wgDatabase->getServerVersion();
}
}
print "<li>Connected to $myver";
if ($conf->DBtype == 'mysql') {
if( version_compare( $myver, "4.0.14" ) < 0 ) {
- die( " -- mysql 4.0.14 or later required. Aborting." );
+ dieout( " -- mysql 4.0.14 or later required. Aborting." );
}
$mysqlNewAuth = version_compare( $myver, "4.1.0", "ge" );
if( $mysqlNewAuth && $mysqlOldClient ) {
}
$wgDatabase->selectDB( $wgDBname );
}
+ else if ($conf->DBtype == 'postgres') {
+ if( version_compare( $myver, "PostgreSQL 8.0" ) < 0 ) {
+ dieout( " <b>Postgres 8.0 or later is required</b>. Aborting.</li></ul>" );
+ }
+ }
if( $wgDatabase->tableExists( "cur" ) || $wgDatabase->tableExists( "revision" ) ) {
print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n";
- # Create user if required
- if ( $conf->Root ) {
+ # Create user if required (todo: other databases)
+ if ( $conf->Root && $conf->DBtype == 'mysql') {
$conn = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
if ( $conn->isOpen() ) {
print "<li>DB user account ok</li>\n";
dbsource( "../maintenance/users.sql", $wgDatabase );
}
}
- print "<pre>\n";
- chdir( ".." );
- flush();
- do_all_updates();
- chdir( "config" );
-
- print "</pre>\n";
+ if ( $conf->DBtype == 'mysql') {
+ print "<pre>\n";
+ chdir( ".." );
+ flush();
+ do_all_updates();
+ chdir( "config" );
+ print "</pre>\n";
+ }
print "<li>Finished update checks.</li>\n";
} else {
# FIXME: Check for errors
}
dbsource( "../maintenance/interwiki.sql", $wgDatabase );
} else if ($conf->DBtype == 'postgres') {
- dbsource( "../maintenance/postgres/tables.sql", $wgDatabase );
- $wgDatabase->update_interwiki();
- } else {
- dbsource( "../maintenance/oracle/tables.sql", $wgDatabase );
- dbsource( "../maintenance/oracle/interwiki.sql", $wgDatabase );
+ $wgDatabase->setup_database();
+ }
+ else {
+ $errs["DBtype"] = "Do not know how to handle database type '$conf->DBtype'";
+ continue;
}
print " done.</li>\n";
'ss_good_articles' => 0 ) );
# Set up the "regular user" account *if we can, and if we need to*
- if( $conf->Root ) {
+ if( $conf->Root and $conf->DBtype == 'mysql') {
# See if we need to
$wgDatabase2 = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
if( $wgDatabase2->isOpen() ) {
$revid = $revision->insertOn( $wgDatabase );
$article->updateRevisionOn( $wgDatabase, $revision );
- print "<li><pre>";
- initialiseMessages();
- print "</pre></li>\n";
+ initialiseMessages( false, false, 'printListItem' );
}
/* Write out the config file now that all is well */
?>
</div>
<p class="config-desc">
- Preferably a short word without punctuation, e.g. "Wikipedia".<br>
+ Preferably a short word without punctuation, i.e. "Wikipedia".<br />
Will appear as the namespace name for "meta" pages, and throughout the interface.
</p>
<?php aField( $conf, "SysopPass2", "Password confirm:", "password" ) ?>
</div>
<p class="config-desc">
- An admin can lock/delete pages, block users from editing, and other maintenance tasks.<br>
+ An admin can lock/delete pages, block users from editing, and other maintenance tasks.<br />
A new account will be added only when creating a new wiki database.
</p>
<div class="config-section">
<div class="config-input">
<label class='column'>Database type:</label>
- <ul class='plain'>
- <li><?php aField( $conf, "DBtype", "MySQL", "radio", "mysql"); ?></li>
- <li><?php aField( $conf, "DBtype", "Oracle (experimental)", "radio", "oracle" ); ?></li>
- <li><?php aField( $conf, "DBtype", "PostgreSQL", "radio", "postgres" ); ?></li>
- </ul>
+<?php if (isset($errs['DBpicktype'])) print "<span class='error'>$errs[DBpicktype]</span>\n"; ?>
+ <ul class='plain'><?php database_picker($conf) ?></ul>
</div>
<div class="config-input" style="clear:left"><?php
- aField( $conf, "DBserver", "SQL server host:" );
+ aField( $conf, "DBserver", "Database host:" );
?></div>
<p class="config-desc">
- If your database server isn't on your web server, enter the name
- or IP address here. MySQL and PostgreSQL only. If using a port for PostgreSQL, enter the number here.
+ If your database server isn't on your web server, enter the name or IP address here.
</p>
<div class="config-input"><?php
aField( $conf, "DBname", "Database name:" );
?></div>
- <div class="config-desc">
- If using Oracle, set this to your connection identifier.
- </div>
<div class="config-input"><?php
aField( $conf, "DBuser", "DB username:" );
?></div>
has SELECT, INSERT, UPDATE and DELETE permissions on the MediaWiki database.
</p>
+ <?php database_switcher('mysql'); ?>
<div class="config-input"><?php
aField( $conf, "DBprefix", "Database table prefix:" );
?></div>
cause things to break. <b>If upgrading an older installation, leave
in backwards-compatible mode.</b>
</p>
+ </div>
+
+ <?php database_switcher('postgres'); ?>
+ <div class="config-input"><?php
+ aField( $conf, "DBport", "Database port:" );
+ ?></div>
+ <div class="config-input"><?php
+ aField( $conf, "DBmwschema", "Schema for mediawiki:" );
+ ?></div>
+ <div class="config-input"><?php
+ aField( $conf, "DBts2schema", "Schema for tsearch2:" );
+ ?></div>
+ <div class="config-desc">
+ <p>The username specified above will have it's search path set to the above schemas,
+ so it is recommended that you create a new user.</p>
+ </div>
+ </div>
<div class="config-input">
<?php
</div>
+<script type="text/javascript">
+window.onload = toggleDBarea('<?php echo $conf->DBtype; ?>');
+</script>
+
</form>
<?php
\$wgDBpassword = \"{$slconf['DBpassword']}\";
\$wgDBprefix = \"{$slconf['DBprefix']}\";
\$wgDBtype = \"{$slconf['DBtype']}\";
+\$wgDBport = \"{$slconf['DBport']}\";
# Experimental charset support for MySQL 4.1/5.0.
\$wgDBmysql5 = {$conf->DBmysql5};
$radioCount = 0;
-function aField( &$conf, $field, $text, $type = "text", $value = "" ) {
+function aField( &$conf, $field, $text, $type = "text", $value = "", $onclick = '' ) {
global $radioCount;
if( $type != "" ) {
$xtype = "type=\"$type\"";
} else {
$checked = "";
}
- echo "\t\t<input $xtype name=\"$field\" id=\"$id\" class=\"iput-$type\" $checked value=\"";
+ echo "\t\t<input $xtype name=\"$field\" id=\"$id\" class=\"iput-$type\" $checked ";
+ if ($onclick) {
+ echo " onclick='toggleDBarea(\"$value\")' " ;
+ }
+ echo "value=\"";
if( $type == "radio" ) {
echo htmlspecialchars( $value );
} else {
echo htmlspecialchars( $conf->$field );
}
+
+
echo "\" />\n";
if( $nolabel ) {
echo " $text</label>\n";
$d = opendir( "languages");
while( false !== ($f = readdir( $d ) ) ) {
$m = array();
- if( preg_match( '/Language([A-Z][a-z_]+)\.php$/', $f, $m ) ) {
+ if( preg_match( '/Messages([A-Z][a-z_]+)\.php$/', $f, $m ) ) {
$code = str_replace( '_', '-', strtolower( $m[1] ) );
if( isset( $wgLanguageNames[$code] ) ) {
$name = $code . ' - ' . $wgLanguageNames[$code];
}
return $errstr;
}
+
+function database_picker($conf) {
+ global $ourdb;
+ print "\n";
+ foreach(array_keys($ourdb) as $db) {
+ if ($ourdb[$db]['havedriver']) {
+ print "<li>";
+ aField( $conf, "DBtype", $ourdb[$db]['fullname'], 'radio', $db, 'onclick');
+ print "</li>\n";
+ }
+ }
+ print "\n";
+}
+
+function database_switcher($db) {
+ global $ourdb;
+ $color = $ourdb[$db]['bgcolor'];
+ $full = $ourdb[$db]['fullname'];
+ print "<div id='$db' style='display:none; background: $color'>\n";
+ print "<h3>$full specific options:</h3>\n";
+}
+
+function printListItem( $item ) {
+ print "<li>$item</li>";
+}
+
?>
<div class="license">