function loadlang($language)
{
    $l = new lang();
    $l->updatelang($language);
    return $l;
}
 function __construct()
 {
     error_reporting(E_ALL);
     // as it crashes between this and load of the config
     // we need to have all debug info
     // FIXME
     if (!file_exists('.install.php')) {
         include 'kernel/config.class.php';
         $config = new config();
         $lang = new lang();
         $config->addConfigByFileName('site.config.php', TYPE_STRING, 'database/tblprefix', 0);
         define('TBL_PREFIX', $config->getConfigByNameType('database/tblprefix', TYPE_STRING));
         define('TBL_PAGES', TBL_PREFIX . 'pages');
         include 'kernel/help.class.php';
         include 'kernel/error.class.php';
         // This should not be in the release
         include 'kernel/users.class.php';
         include 'kernel/news.class.php';
         include 'kernel/polls.class.php';
         $config->addConfigByFileName('site.config.php', TYPE_INT, 'general/errorreporting', 0);
         $config->addConfigByFileName('site.config.php', TYPE_STRING, 'general/webmastermail', 0);
         error_reporting($config->getConfigByNameType('general/errorreporting', TYPE_INT));
         $config->addConfigByFileName('site.config.php', TYPE_STRING, 'general/databasetype', 0);
         loaddbclass($config->getConfigByNameType('general/databasetype', TYPE_STRING));
         $database = new database($config, 'site.config.php');
         $database->connect();
         // TODO
         $tables = array();
         if (checkDatabase($database, $tables)) {
             // Database seems to be OK
             $config->addConfigByFileName('site.config.php', TYPE_BOOL, 'user/activatemail', 0);
             $user = new user($database, $config->getConfigByNameType('user/activatemail', TYPE_BOOL), $lang);
             $news = new news($database, $user, $config, $lang);
             $poll = new polls($database, $config, $lang);
             $this->help = new help($database, $config, $lang);
             $config->addConfigByFileName('site.config.php', TYPE_FLOAT, 'general/servertimezone');
             $config->addConfigByFileName('site.config.php', TYPE_STRING, 'general/httplink');
             $config->addConfigByFileName('site.config.php', TYPE_STRING, 'general/sitename');
             $config->addConfigByFileName('site.config.php', TYPE_STRING, 'general/description');
             $config->addConfigByList('GET;YAPCAS_USER;COOKIE;FILE', array('timezone', $user, 'timezone', 'site.config.php'), 'general/timezone', TYPE_FLOAT, 1);
             $config->addConfigByList('GET;YAPCAS_USER;COOKIE;FILE', array('timeformat', $user, 'timeformat', 'site.config.php'), 'general/timeformat', TYPE_STRING, '');
             $config->addConfigByList('GET;YAPCAS_USER;COOKIE;FILE', array('language', $user, 'language', 'site.config.php'), 'general/language', TYPE_STRING, STANDARD_LANGUAGE);
             $lang->updatelang($config->getConfigByNameType('general/language', TYPE_STRING));
             $config->addConfigByList('GET;YAPCAS_USER;COOKIE;FILE', array('theme', $user, 'theme', 'site.config.php'), 'general/theme', TYPE_STRING, 'moderngray');
             $config->addConfigByList('GET;YAPCAS_USER;COOKIE;FILE', array('threaded', $user, 'threaded', 'site.config.php'), 'news/threaded', TYPE_BOOL, YES);
             $config->addConfigByList('GET;YAPCAS_USER;COOKIE;FILE', array('langcode', $user, 'langcode', 'site.config.php'), 'general/langcode', TYPE_STRING);
             $config->addConfigByList('YAPCAS_USER', array($user), 'user/email', TYPE_STRING);
             $config->addConfigByList('YAPCAS_USER', array($user), 'user/name', TYPE_STRING, 'anonymous');
             $this->loadtheme($config->getConfigByNameType('general/theme', TYPE_STRING));
             $this->config = $config;
             $this->news = $news;
             $this->config = $config;
             $this->poll = $poll;
             $this->lang = $lang;
             $this->user = $user;
             $this->database = $database;
             global $theme, $config, $news, $poll, $user, $lang, $database;
             $config = $this->config;
             $news = $this->news;
             $config = $this->config;
             $poll = $this->poll;
             $lang = $this->lang;
             $user = $this->user;
             $database = $this->database;
             $theme = $this;
         }
     } else {
         if (file_exists('site.config.php')) {
             include 'kernel/config.class.php';
             $config = new config();
             $config->addConfigByFileName('site.config.php', TYPE_STRING, 'database/tblprefix', 0);
             define('TBL_PREFIX', $config->getConfigByNameType('database/tblprefix', TYPE_STRING));
             define('TBL_PAGES', TBL_PREFIX . 'pages');
             $config->addConfigByFileName('site.config.php', TYPE_INT, 'general/errorreporting', 0);
             //error_reporting ($config->getConfigByNameType('general/errorreporting',TYPE_INT));
             $config->addConfigByFileName('site.config.php', TYPE_STRING, 'general/databasetype', 0);
             loaddbclass($config->getConfigByNameType('general/databasetype', TYPE_STRING));
             $database = new database($config, 'site.config.php');
             $database->connect();
             // FIXME
             $tables = array();
             if (checkDatabase($database, $tables)) {
                 // site is configured but the installscript exists???
                 echo 'DELETE install.php and than reload this page';
                 exit;
             } else {
                 header('Location: install.php');
             }
         } else {
             header('Location: install.php');
         }
     }
 }