function load_sqlconfig(&$config) { $config_defined = get_defined_settings(); // defined in config.php // Override some whitelisted definitions from config.php foreach ($config_defined as $key => $definition) { if (in_array($key, $config['definitions_whitelist']) && version_compare(PHP_VERSION, '5.3.0') >= 0 && is_array($definition) && is_array($config[$key])) { $config[$key] = array_replace_recursive($config[$key], $definition); } } foreach (dbFetchRows("SELECT * FROM `config`") as $item) { // Convert boo|bee|baa config value into $config['boo']['bee']['baa'] $tree = explode('|', $item['config_key']); //if (array_key_exists($tree[0], $config_defined)) { continue; } // This complete skip option if first level key defined in $config // Unfortunately, I don't know of a better way to do this... // Perhaps using array_map() ? Unclear... hacky. :[ // FIXME use a loop with references! (cf. nested location menu) switch (count($tree)) { case 1: //if (isset($config_defined[$tree[0]])) { continue; } // Note, false for null values if (array_key_exists($tree[0], $config_defined)) { continue; } $config[$tree[0]] = unserialize($item['config_value']); break; case 2: if (isset($config_defined[$tree[0]][$tree[1]])) { continue; } // Note, false for null values $config[$tree[0]][$tree[1]] = unserialize($item['config_value']); break; case 3: if (isset($config_defined[$tree[0]][$tree[1]][$tree[2]])) { continue; } // Note, false for null values $config[$tree[0]][$tree[1]][$tree[2]] = unserialize($item['config_value']); break; case 4: if (isset($config_defined[$tree[0]][$tree[1]][$tree[2]][$tree[3]])) { continue; } // Note, false for null values $config[$tree[0]][$tree[1]][$tree[2]][$tree[3]] = unserialize($item['config_value']); break; case 5: if (isset($config_defined[$tree[0]][$tree[1]][$tree[2]][$tree[3]][$tree[4]])) { continue; } // Note, false for null values $config[$tree[0]][$tree[1]][$tree[2]][$tree[3]][$tree[4]] = unserialize($item['config_value']); break; default: print_error("Too many array levels for SQL configuration parser!"); } } }
* * @package observium * @subpackage web * @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited * */ if ($_SESSION['userlevel'] < 10) { print_error_permission(); return; } register_html_resource('js', 'clipboard.min.js'); register_html_resource('script', 'new Clipboard("#clipboard");'); // Load SQL config into $database_config load_sqlconfig($database_config); // cache default and config.php-defined values $defined_config = get_defined_settings(); $default_config = get_default_settings(); echo '<form id="settings" name="settings" method="post" action="" class="form form-inline">' . PHP_EOL; // Pretty inefficient looping everything if section != all, but meh // This is only done on this page, so there is no performance issue for the rest of Observium foreach ($config_subsections as $section => $subdata) { if (isset($config_sections[$section]['edition']) && $config_sections[$section]['edition'] != OBSERVIUM_EDITION) { // Skip sections not allowed for current Observium edition continue; } echo ' <div class="row"> <div class="col-md-12"> <!-- BEGIN SECTION ' . $section . ' -->' . PHP_EOL; if ($vars['section'] == 'all' || $vars['section'] == $section) { if ($vars['section'] == 'all') { // When printing all, also print the section name echo generate_box_open(array('title' => $config_sections[$section]['text'], 'header-border' => TRUE)); echo generate_box_close();
<?php /** * Observium Network Management and Monitoring System * Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org * * @package observium * @subpackage webui * @author Adam Armstrong <*****@*****.**> * @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited * */ if ($_SESSION['userlevel'] == '10') { print_warning("This is a dump of your Observium configuration. To adjust it, please modify your <strong>config.php</strong> file."); print_vars(get_defined_settings()); } // EOF