/** * Perform the installation associated with the step. * Variables required by the installation are stored within the session. * * @author KnowledgeTree Team * @access public */ public function installStep() { // get data from the server $conf = $this->getDataFromSession("configuration"); $server = $conf['server']; $paths = $conf['paths']; // initialise writing to config.ini $configPath = realpath('../../config/config.ini'); $ini = false; if (file_exists($configPath)) { $ini = new Ini($configPath); } // initialise the db connection // retrieve database information from session $dbconf = $this->getDataFromSession("database"); // make db connection $this->_dbhandler->load($dbconf['dhost'], $dbconf['duname'], $dbconf['dpassword'], $dbconf['dname']); // add db config to server variables $server = $this->registerDBConfig($server, $dbconf); $table = 'config_settings'; // write server settings to config_settings table and config.ini foreach ($server as $item) { switch ($item['where']) { case 'file': $value = $item['value']; if ($value == 'yes') { $value = 'true'; } if ($value == 'no') { $value = 'false'; } if (!$ini === false) { $ini->updateItem($item['section'], $item['setting'], $value); } break; case 'db': $value = mysql_real_escape_string($item['value']); $setting = mysql_real_escape_string($item['setting']); $sql = "UPDATE {$table} SET value = '{$value}' WHERE item = '{$setting}'"; $this->_dbhandler->query($sql); break; } } // write the paths to the config_settings table if (is_array($paths)) { foreach ($paths as $item) { if (empty($item['setting'])) { continue; } $value = mysql_real_escape_string($item['path']); $setting = mysql_real_escape_string($item['setting']); $sql = "UPDATE {$table} SET value = '{$value}' WHERE item = '{$setting}'"; $this->_dbhandler->query($sql); } } // write out the config.ini file if (!$ini === false) { $ini->write(); } // close the database connection $this->_dbhandler->close(); }