Index: /trunk/admin/include/functions_install.inc.php
===================================================================
--- /trunk/admin/include/functions_install.inc.php	(revision 5386)
+++ /trunk/admin/include/functions_install.inc.php	(revision 5387)
@@ -140,5 +140,5 @@
 }
 
-function try_db_connection(&$infos, &$errors)
+function install_db_connect(&$infos, &$errors)
 {
   try
Index: /trunk/admin/include/functions_upgrade.php
===================================================================
--- /trunk/admin/include/functions_upgrade.php	(revision 5386)
+++ /trunk/admin/include/functions_upgrade.php	(revision 5387)
@@ -67,4 +67,6 @@
   define('PLUGINS_TABLE', $prefixeTable.'plugins');
   define('OLD_PERMALINKS_TABLE', $prefixeTable.'old_permalinks');
+  define('THEMES_TABLE', $prefixeTable.'themes');
+  define('LANGUAGES_TABLE', $prefixeTable.'languages');
 }
 
@@ -214,3 +216,18 @@
 }
 
+function upgrade_db_connect()
+{
+  global $conf;
+
+  try
+  {
+    $pwg_db_link = pwg_db_connect($conf['db_host'], $conf['db_user'],
+                                  $conf['db_password'], $conf['db_base']);
+  }
+  catch (Exception $e)
+  {
+    my_error(l10n($e->getMessage()), true); 
+  }
+}
+
 ?>
Index: /trunk/install.php
===================================================================
--- /trunk/install.php	(revision 5386)
+++ /trunk/install.php	(revision 5387)
@@ -184,5 +184,4 @@
 include(PHPWG_ROOT_PATH . 'include/functions.inc.php');
 include(PHPWG_ROOT_PATH . 'admin/include/functions.php');
-include(PHPWG_ROOT_PATH . 'admin/include/functions_upgrade.php');
 
 include(PHPWG_ROOT_PATH . 'admin/include/languages.class.php');
@@ -260,8 +259,9 @@
 include(PHPWG_ROOT_PATH .'include/dblayer/functions_'.$dblayer.'.inc.php');
 include(PHPWG_ROOT_PATH . 'admin/include/functions_install.inc.php');
+include(PHPWG_ROOT_PATH . 'admin/include/functions_upgrade.php');
 
 if ( isset( $_POST['install'] ))
 {
-  if (try_db_connection($infos, $errors))
+  if (install_db_connect($infos, $errors))
   {
     $required_version = constant('REQUIRED_'.strtoupper($dblayer).'_VERSION');
Index: /trunk/upgrade.php
===================================================================
--- /trunk/upgrade.php	(revision 5386)
+++ /trunk/upgrade.php	(revision 5387)
@@ -39,28 +39,13 @@
 include_once(PHPWG_ROOT_PATH.'include/functions.inc.php');
 include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
-include_once(PHPWG_ROOT_PATH.'admin/include/functions_upgrade.php');
 
 include(PHPWG_ROOT_PATH.'local/config/database.inc.php');
 include(PHPWG_ROOT_PATH . 'include/config_default.inc.php');
 @include(PHPWG_ROOT_PATH. 'local/config/config.inc.php');
-include(PHPWG_ROOT_PATH .'include/dblayer/functions_'.$conf['dblayer'].'.inc.php');
-
-prepare_conf_upgrade();
-
+
+// $conf is not used for users tables - define cannot be re-defined
+define('USERS_TABLE', $prefixeTable.'users');
 include_once(PHPWG_ROOT_PATH.'include/constants.php');
 define('PREFIX_TABLE', $prefixeTable);
-
-// Database connection
-try
-{
-  $pwg_db_link = pwg_db_connect($conf['db_host'], $conf['db_user'],
-                                $conf['db_password'], $conf['db_base']);
-}
-catch (Exception $e)
-{
-  my_error(l10n($e->getMessage(), true)); 
-}
-
-pwg_db_check_charset();
 
 // +-----------------------------------------------------------------------+
@@ -149,4 +134,7 @@
 // |                             language                                  |
 // +-----------------------------------------------------------------------+
+include(PHPWG_ROOT_PATH . 'admin/include/languages.class.php');
+$languages = new languages('utf-8');
+
 if (isset($_GET['language']))
 {
@@ -157,5 +145,5 @@
   $language = 'en_UK';
   // Try to get browser language
-  foreach (get_languages('utf-8') as $language_code => $language_name)
+  foreach ($languages->fs_languages as $language_code => $language_name)
   {
     if (substr($language_code,0,2) == @substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2))
@@ -206,4 +194,14 @@
   include(PHPWG_ROOT_PATH.'install/php5_apache_configuration.php');
 }
+
+// +-----------------------------------------------------------------------+
+// |                          database connection                          |
+// +-----------------------------------------------------------------------+
+include_once(PHPWG_ROOT_PATH.'admin/include/functions_upgrade.php');
+include(PHPWG_ROOT_PATH .'include/dblayer/functions_'.$conf['dblayer'].'.inc.php');
+
+upgrade_db_connect();
+
+pwg_db_check_charset();
 
 // +-----------------------------------------------------------------------+
