/** * Process the entered database configuration */ public function dbprocessAction() { $installSession = new Zend_Session_Namespace('Loomp_Install'); $this->view->loggedIn = $installSession->loggedIn; if (!$this->view->loggedIn) { return $this->_helper->redirector('index'); } $request = $this->getRequest(); // Check if we have a POST request if (!$request->isPost()) { return $this->_helper->redirector('database'); } // Get our form and validate it $form = $this->getDatabaseConfigForm(); if (!$form->isValid($request->getPost())) { // Invalid entries $this->view->form = $form; return $this->render('database'); // re-render the login form } $dbConfig = $form->getValues(); $this->view->dbConfig = $form->getValues(); try { // set system db configuration to form data in order to test connection $curConf = Zend_Registry::getInstance()->configuration->loomp->db; $curConf->type = $dbConfig['type']; $curConf->host = $dbConfig['host']; $curConf->name = $dbConfig['database']; $curConf->user = $dbConfig['username']; $curConf->pass = $dbConfig['password']; $this->getDbConnection(); // write connection parameter to local config $this->resetLocalConfigFile(); $localConfig = new Zend_Config_Ini(LOCAL_CONFIG_FILE, APPLICATION_ENVIRONMENT, true); $localConfig->__set("loomp.db.type", $dbConfig['type']); $localConfig->__set("loomp.db.host", $dbConfig['host']); $localConfig->__set("loomp.db.name", $dbConfig['database']); $localConfig->__set("loomp.db.user", $dbConfig['username']); $localConfig->__set("loomp.db.pass", $dbConfig['password']); $request = new Zend_Controller_Request_Http(); $localConfig->__set("server.path", $request->getBaseUrl()); $localConfig->__set("server.host", $_SERVER['HTTP_HOST']); $localConfig->__set("rap.path", $request->getBaseUrl() . "/data"); $localConfig->__set("loomp.base", (isset($_SERVER['HTTPS']) ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $request->getBaseUrl()); $localConfig->__set("install.password", $installSession->installPassword); $writer = new Zend_Config_Writer_Ini(); $writer->write(LOCAL_CONFIG_FILE, $localConfig, true); $this->getLog()->debug("Local config has been written to disk"); $config = Zend_Registry::getInstance()->configuration; $config->merge($localConfig); } catch (Exception $e) { $this->addFlashMessage("Local configuration file could not be written."); $this->getLog()->err("Error while writing local configuration: " . $e->getMessage()); return $this->_helper->redirector('database'); } return $this->_helper->redirector('update'); }