$activatemail = 'true'; } elseif ($activatemail == NO) { $activatemail = 'false'; } else { // Can never happen $activatemail = 'true'; } $config .= "\$config['user']['activatemail'] = {$activatemail};" . NL; $config .= '?>'; $handle = fopen('site.config.php', 'w'); fwrite($handle, $config); fclose($handle); // do dbstuff try { $config = new CConfig(); $d = $database->load($_POST['databasetype']); $d->connect($_POST['databasehost'], $_POST['databaseuser'], $_POST['databasepassword'], $_POST['databasename']); define('TBL_PREFIX', $_POST['databaseprefix']); $queries = file_get_contents('kernel/sql/users.sql'); $queries .= file_get_contents('kernel/sql/news.sql'); $queries .= file_get_contents('kernel/sql/polls.sql'); $queries .= file_get_contents('kernel/sql/basic.sql'); $queries .= file_get_contents('kernel/sql/help.sql'); // TODO include_once 'kernel/language.class.php'; $languages = new CLang(); foreach ($languages->installed() as $language) { echo $language; $languages->update($language); $tmpquery = file_get_contents('kernel/sql/basicpages.sql'); $tmpquery = ereg_replace('%language%', $languages->getPrefLangCode(), $tmpquery);
function __construct() { error_reporting(E_ALL); session_start(); // check for PHP version $req = '5.0.0'; if (version_compare($req, phpversion(), '>=')) { die('PHP Version ' . $req . ' or higher is required'); } // as it crashes between this and load of the config // we need to have all debug info // FIXME if (!file_exists('.install.php')) { include_once 'kernel/constants.php'; include_once 'kernel/config.class.php'; include_once 'kernel/language.class.php'; $config = new CConfig(); $config->addConfigByFileName('site.config.php', TYPE_STRING, 'database/tblprefix', 0); define('TBL_PREFIX', $config->getConfigByNameType('database/tblprefix', TYPE_STRING)); include_once 'kernel/help.class.php'; include_once 'kernel/users.class.php'; include_once 'kernel/news.class.php'; include_once 'kernel/polls.class.php'; include_once 'kernel/exception.class.php'; include_once 'kernel/database.class.php'; define('TBL_PAGES', TBL_PREFIX . 'pages'); $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); $dbType = $config->getConfigByNameType('general/databasetype', TYPE_STRING); $dbclass = new CDatabase(); $database = $dbclass->load($dbType, $config, 'site.config.php'); $config->addConfigByFileName('site.config.php', TYPE_STRING, 'database/host', 'localhost'); $config->addConfigByFileName('site.config.php', TYPE_STRING, 'database/user', 0); $config->addConfigByFileName('site.config.php', TYPE_STRING, 'database/password', 0); $config->addConfigByFileName('site.config.php', TYPE_STRING, 'database/name', 0); $host = $config->getConfigByNameType('database/host', TYPE_STRING); $user = $config->getConfigByNameType('database/user', TYPE_STRING); $password = $config->getConfigByNameType('database/password', TYPE_STRING); $dbname = $config->getConfigByNameType('database/name', TYPE_STRING); $database->connect($host, $user, $password, $dbname); // TODO $tables = array(); if (checkDatabase($database, $tables)) { // Database seems to be OK $config->addConfigByFileName('site.config.php', TYPE_BOOL, 'user/activatemail', 0); $lang = new CLang(); $user = new CUser($database, $config->getConfigByNameType('user/activatemail', TYPE_BOOL), $lang); $config->addConfigByList('GET;YAPCAS_USER;COOKIE;FILE', array('contentlanguage', $user, 'contentlanguage', 'site.config.php'), 'general/contentlanguage', TYPE_STRING, DEFAULT_CONTENT_LANG); $contentLang = $config->getConfigByNameType('general/contentlanguage', TYPE_STRING); $news = new CNews($database, $lang, $contentLang); $poll = new CPoll($database, $config, $lang); $this->help = new CHelp($database, $config, $lang); $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, 0); $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('uilanguage', $user, 'uilanguage', 'site.config.php'), 'general/uilanguage', TYPE_STRING, STANDARD_LANGUAGE); $lang->update($config->getConfigByNameType('general/uilanguage', 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('headlines', $user, 'headlines', 'site.config.php'), 'news/headlines', TYPE_INT, 5); $config->addConfigByList('GET;YAPCAS_USER;COOKIE;FILE', array('postsonpage', $user, 'postsonpage', 'site.config.php'), 'news/postsonpage', TYPE_INT, 10); $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; $this->BBCTags = array('b', 'u', 'i', 'quote'); 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_once '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'); } } }