function installConfigAndDatabase($siteName, $siteDefaultLanguage, $dbDriverName, $databaseHost, $databaseUser, $databasePassword, $databaseName, $databasePrefix, $adminLogin, $adminPassword, $adminMail) { DatabaseDriverManager::findAllDriversInDirectory('core/dbdrivers'); $dbDriver = DatabaseDriverManager::loadDriver($dbDriverName); if (!isError($dbDriver)) { $dbDriver->connect($databaseHost, $databaseUser, $databasePassword, $databaseName); $dbDriver->setPrefix($databasePrefix); $pluginManager = new pluginManager($this->_pluginAPI); $pluginManager->findAllPlugins('interface/core-plugins/'); // an hack for viewPage to be first $foundPlugins = array_reverse($pluginManager->getAllFoundPlugins()); foreach ($foundPlugins as $plugin) { if (is_a($plugin, 'InstallablePlugin')) { $a = $plugin->install($this->_pluginAPI, $dbDriver, $siteDefaultLanguage); if (isError($a)) { var_dump($a); die('Something went wrong'); } } } $userM = new userManager($dbDriver); $admin = $userM->newUser(); $a = $admin->initFromArray(array('login' => $adminLogin, 'password' => md5($adminPassword), 'email' => $adminMail)); $userM->addUserToDatabase($admin); $group = $userM->newGroup(); $group->initFromArray(array('generic_name' => 'administrator', 'generic_description' => 'The admin users')); $userM->addGroupToDatabase($group); $group->assignPermission('edit_admin', true); $admin->addToGroup($group); $group = $userM->newGroup(); $group->initFromArray(array('generic_name' => 'normaluser', 'generic_description' => 'All users')); $userM->addGroupToDatabase($group); $group->assignPermission('edit_admin', false); $admin->addToGroup($group); $group = $userM->newGroup(); $group->initFromArray(array('generic_name' => 'anonymous', 'generic_description' => 'Not logged in')); $userM->addGroupToDatabase($group); $group->assignPermission('edit_admin', false); $configContents = '<?php' . PHP_NL . PHP_NL; $configContents .= '$configItems[\'/databases/driver\']=\'' . $dbDriverName . '\';' . PHP_NL; $configContents .= '$configItems[\'/databases/host\']=\'' . $databaseHost . '\';' . PHP_NL; $configContents .= '$configItems[\'/databases/password\']=\'' . $databasePassword . '\';' . PHP_NL; $configContents .= '$configItems[\'/databases/user\']=\'' . $databaseUser . '\';' . PHP_NL; $configContents .= '$configItems[\'/databases/database\']=\'' . $databaseName . '\';' . PHP_NL; $configContents .= '$configItems[\'/databases/table_prefix\']=\'' . $databasePrefix . '\';' . PHP_NL . PHP_NL; $configContents .= '$configItems[\'/site/title\']=\'' . $siteName . '\';' . PHP_NL; $configContents .= '$configItems[\'/site/default_language\']=\'' . $siteDefaultLanguage . '\';' . PHP_NL; $configContents .= '$configItems[\'/site/enableUsers\']=true;' . PHP_NL; $configContents .= '$configItems[\'/languages/' . $siteDefaultLanguage . '\']=\'' . $siteDefaultLanguage . '\';' . PHP_NL; $configContents .= '?>'; $c = @fopen('config.php', 'w'); if ($c !== false) { fwrite($c, $configContents); fclose($c); header('Location: index.php'); } else { $sm =& $this->_pluginAPI->getSmarty(); $sm->assign('CONFIG_CONTENT', htmlspecialchars($configContents)); $sm->display('installer/save_config_manual.tpl'); } } else { var_dump($dbModule); } }