/** * Loads the current configuration off the database table * * @param int $profile_id The profile where to read the configuration from, defaults to current profile * * @return bool True if everything was read properly */ public function load_configuration($profile_id = null) { // Load the database class $db = Factory::getDatabase($this->get_platform_database_options()); // Initialize the registry $registry = Factory::getConfiguration(); $registry->reset(); // 1) Load the INI format local configuration dump: $filename = realpath(dirname(__FILE__) . '/Config/config.ini'); $ini_data_local = file_get_contents($filename); // Configuration found. Convert to array format. $ini_data_local = \Akeeba\Engine\Util\ParseIni::parse_ini_file_php($ini_data_local, true, true); $ini_data = array(); foreach ($ini_data_local as $section => $row) { if (!empty($row)) { foreach ($row as $key => $value) { $ini_data["{$section}.{$key}"] = $value; } } } unset($ini_data_local); // Import the configuration array $protected_keys = $registry->getProtectedKeys(); $registry->resetProtectedKeys(); $registry->mergeArray($ini_data, false, false); $registry->setProtectedKeys($protected_keys); // 2) Load the INI format local configuration dump off the database: $db = \Akeeba\Engine\Factory::getDatabase($this->get_platform_database_options()); $sql = $db->getQuery(true)->select($db->qn('configuration'))->from($db->qn($this->tableNameProfiles))->where($db->qn('id') . ' = ' . $db->q(1)); $db->setQuery($sql); $ini_data_local = $db->loadResult(); if (empty($ini_data_local) || is_null($ini_data_local)) { // No configuration was saved yet - store the defaults $this->save_configuration($profile_id); } else { // Configuration found. Convert to array format. if (function_exists('get_magic_quotes_runtime')) { if (@get_magic_quotes_runtime()) { $ini_data_local = stripslashes($ini_data_local); } } // Decrypt the data if required $ini_data_local = \Akeeba\Engine\Factory::getSecureSettings()->decryptSettings($ini_data_local); $ini_data_local = \Akeeba\Engine\Util\ParseIni::parse_ini_file_php($ini_data_local, true, true); $ini_data = array(); foreach ($ini_data_local as $section => $row) { if (is_array($row) && !empty($row)) { foreach ($row as $key => $value) { $ini_data["{$section}.{$key}"] = $value; } } } unset($ini_data_local); $allowedOverrides = array('akeeba.basic.clientsidewait', 'akeeba.basic.file_extensions', 'akeeba.basic.exclude_folders', 'akeeba.basic.exclude_files', 'akeeba.tuning.min_exec_time', 'akeeba.tuning.max_exec_time', 'akeeba.tuning.run_time_bias'); foreach ($allowedOverrides as $key) { if (isset($ini_data[$key])) { $registry->setKeyProtection($key, false); $registry->set($key, $ini_data[$key]); $registry->setKeyProtection($key, true); } } } $registry->activeProfile = 1; // Apply config overrides if (is_array($this->configOverrides) && !empty($this->configOverrides)) { $protected_keys = $registry->getProtectedKeys(); $registry->resetProtectedKeys(); $registry->mergeArray($this->configOverrides, false, false); $registry->setProtectedKeys($protected_keys); } $registry->activeProfile = $profile_id; }