(bug 6827) some i18n specific maintenance scripts fails after merge of localisation...
[lhc/web/wiklou.git] / config / index.php
index 44bb403..1b8d5b8 100644 (file)
@@ -24,7 +24,7 @@ header( "Content-type: text/html; charset=utf-8" );
 @ini_set( "display_errors", true );
 
 # In case of errors, let output be clean.
-$wgRequestTime = microtime();
+$wgRequestTime = microtime( true );
 
 # Attempt to set up the include path, to fix problems with relative includes
 $IP = dirname( dirname( __FILE__ ) );
@@ -41,6 +41,22 @@ require_once( "includes/Defines.php" );
 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">
@@ -126,6 +142,28 @@ require_once( "includes/Namespace.php" );
                }
 
        </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>
@@ -206,6 +244,42 @@ install_version_checks();
 
 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>
@@ -293,6 +367,10 @@ if( $conf->xml ) {
 if( !function_exists( 'session_name' ) )
        dieout( "PHP's session module is missing. MediaWiki requires session support in order to function." );
 
+# Likewise for PCRE
+if( !function_exists( 'preg_match' ) )
+       dieout( "The PCRE regular expression functions are missing. MediaWiki requires these in order to function." );
+
 $memlimit = ini_get( "memory_limit" );
 $conf->raiseMemory = false;
 if( empty( $memlimit ) || $memlimit == -1 ) {
@@ -326,21 +404,29 @@ $conf->turck = function_exists( 'mmcache_get' );
 if ( $conf->turck ) {
        print "<li><a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> installed</li>\n";
 }
+
+$conf->apc = function_exists('apc_fetch');
+if ($conf->apc ) {
+       print "<li><a href=\"http://www.php.net/apc\">APC</a> installed</li>";
+}
+
 $conf->eaccel = function_exists( 'eaccelerator_get' );
 if ( $conf->eaccel ) {
     $conf->turck = 'eaccelerator';
     print "<li><a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> installed</li>\n";
 }
-if (!$conf->turck && !$conf->eaccel) {
-       print "<li>Neither <a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> nor <a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</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", "/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) {
@@ -394,20 +480,30 @@ print "<li style='font-weight:bold;color:green;font-size:110%'>Environment check
                ? '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();
@@ -486,17 +582,34 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
                $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;
+               }
+
+               if (! $conf->DBtypename) {
+                       $errs["DBtype"] = "Unknown database type '$conf->DBtype'";
                        continue;
                }
-               print "<li>Database type: {$conf->DBtype}</li>\n";
+               print "<li>Database type: {$conf->DBtypename}</li>\n";
                $dbclass = 'Database'.ucfirst($conf->DBtype);
-               require_once("$dbclass.php");
                $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" );
@@ -505,6 +618,8 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
                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' ) {
@@ -533,7 +648,7 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
                        # 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
@@ -542,7 +657,7 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
                                $wgDBadminpassword = $db_pass;
                                echo( "success.</li>\n" );
                                $wgDatabase->ignoreErrors( true );
-                               $myver = mysql_get_server_info( $wgDatabase->mConn );
+                               $myver = $wgDatabase->getServerVersion();
                        } else {
                                # There were errors, report them and back out
                                $ok = false;
@@ -575,12 +690,26 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
                        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();
                        }
                }
@@ -592,8 +721,8 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
 
                print "<li>Connected to $myver";
                if ($conf->DBtype == 'mysql') {
-                       if( version_compare( $myver, "4.0.0" ) < 0 ) {
-                               die( " -- mysql 4.0 or later required. Aborting." );
+                       if( version_compare( $myver, "4.0.14" ) < 0 ) {
+                               dieout( " -- mysql 4.0.14 or later required. Aborting." );
                        }
                        $mysqlNewAuth   = version_compare( $myver, "4.1.0", "ge" );
                        if( $mysqlNewAuth && $mysqlOldClient ) {
@@ -612,7 +741,7 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
                        }
                        print "</li>\n";
 
-                       @$sel = mysql_select_db( $wgDBname, $wgDatabase->mConn );
+                       @$sel = $wgDatabase->selectDB( $wgDBname );
                        if( $sel ) {
                                print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
                        } else {
@@ -634,12 +763,17 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
                        }
                        $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";
@@ -653,13 +787,14 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
                                        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
@@ -674,11 +809,11 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
                                }
                                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";
@@ -691,7 +826,7 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
                                       '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() ) {
@@ -738,9 +873,7 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
                        $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 */
@@ -798,7 +931,7 @@ if( count( $errs ) ) {
                ?>
        </div>
        <p class="config-desc">
-               Preferably a short word without punctuation, i.e. "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>
 
@@ -868,7 +1001,7 @@ if( count( $errs ) ) {
                <?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>
 
@@ -883,8 +1016,11 @@ if( count( $errs ) ) {
                                aField( $conf, "Shm", "Turck MMCache", "radio", "turck" );
                                echo "</li>";
                        }
-               ?>
-               <?php
+                       if ( $conf->apc ) {
+                               echo "<li>";
+                               aField( $conf, "Shm", "APC", "radio", "apc" );
+                               echo "</li>";
+                       }
                        if ( $conf->eaccel ) {
                                echo "<li>";
                                aField( $conf, "Shm", "eAccelerator", "radio", "eaccel" );
@@ -896,8 +1032,8 @@ if( count( $errs ) ) {
                <div style="clear:left"><?php aField( $conf, "MCServers", "Memcached servers:", "text" ) ?></div>
        </div>
        <p class="config-desc">
-               Using a shared memory system such as Turck MMCache, eAccelerator, or Memcached will speed
-               up MediaWiki significantly. Memcached is the best solution but needs to be
+               Using a shared memory system such as Turck MMCache, APC, eAccelerator, or Memcached 
+               will speed up MediaWiki significantly. Memcached is the best solution but needs to be
                installed. Specify the server addresses and ports in a comma-separted list. Only
                use Turck shared memory if the wiki will be running on a single Apache server.
        </p>
@@ -964,27 +1100,20 @@ if( count( $errs ) ) {
 <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>
@@ -1004,6 +1133,7 @@ if( count( $errs ) ) {
                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>
@@ -1028,6 +1158,23 @@ if( count( $errs ) ) {
                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
@@ -1053,6 +1200,10 @@ if( count( $errs ) ) {
 
 </div>
 
+<script type="text/javascript">
+window.onload = toggleDBarea('<?php echo $conf->DBtype; ?>');
+</script>
+
 </form>
 
 <?php
@@ -1111,6 +1262,7 @@ function writeLocalSettings( $conf ) {
                        $mcservers = var_export( $conf->MCServerArray, true );
                        break;
                case 'turck':
+               case 'apc':
                case 'eaccel':
                        $cacheType = 'CACHE_ACCEL';
                        $mcservers = 'array()';
@@ -1164,7 +1316,6 @@ function writeLocalSettings( $conf ) {
                $slconf['RightsIcon'] = $conf->RightsIcon;
        }
 
-       $sep = PATH_SEPARATOR;
        $localsettings = "
 # This file was automatically generated by the MediaWiki installer.
 # If you make manual changes, please keep track in case you need to
@@ -1183,7 +1334,7 @@ if( defined( 'MW_INSTALL_PATH' ) ) {
 }
 
 \$path = array( \$IP, \"\$IP/includes\", \"\$IP/languages\" );
-set_include_path( implode( PATH_SEPARATOR, \$path ) );
+set_include_path( implode( PATH_SEPARATOR, \$path ) . PATH_SEPARATOR . get_include_path() );
 
 require_once( \"includes/DefaultSettings.php\" );
 
@@ -1239,6 +1390,7 @@ if ( \$wgCommandLineMode ) {
 \$wgDBpassword       = \"{$slconf['DBpassword']}\";
 \$wgDBprefix         = \"{$slconf['DBprefix']}\";
 \$wgDBtype           = \"{$slconf['DBtype']}\";
+\$wgDBport           = \"{$slconf['DBport']}\";
 
 # Experimental charset support for MySQL 4.1/5.0.
 \$wgDBmysql5 = {$conf->DBmysql5};
@@ -1325,7 +1477,7 @@ function importRequest( $name, $default = "" ) {
 
 $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\"";
@@ -1333,7 +1485,7 @@ function aField( &$conf, $field, $text, $type = "text", $value = "" ) {
                $xtype = "";
        }
 
-       if(!(isset($id)) or ($id == "") ) $id = $field;
+       $id = $field;
        $nolabel = ($type == "radio") || ($type == "hidden");
 
        if ($type == 'radio')
@@ -1350,12 +1502,18 @@ function aField( &$conf, $field, $text, $type = "text", $value = "" ) {
        } 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";
@@ -1374,9 +1532,12 @@ function getLanguageList() {
        $codes = array();
 
        $d = opendir( "../languages" );
+       /* In case we are called from the root directory */
+       if (!$d)
+               $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];
@@ -1413,14 +1574,6 @@ function locate_executable($loc, $names, $versioninfo = false) {
        return false;
 }
 
-function get_db_version() {
-       global $wgDatabase, $conf;
-       if ($conf->DBtype == 'mysql')
-               return mysql_get_server_info( $wgDatabase->mConn );
-       else if ($conf->DBtype == 'oracle')
-               return oci_server_version($wgDatabase->mConn);
-}
-
 # Test a memcached server
 function testMemcachedServer( $server ) {
        $hostport = explode(":", $server);
@@ -1465,6 +1618,32 @@ function testMemcachedServer( $server ) {
        }
        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">