function commit_changes() { global $root_dir; $vars = $_POST; create_mysql_tables(); list($f1, $f2) = get_config_files(); /// $fp = @fopen($fn = "{$root_dir}/config.inc.php", 'wb'); if (!$fp) { display_send_files_form($fn); return; } fwrite($fp, $f1); fclose($fp); $HTTP_HOST = $_SERVER['HTTP_HOST']; $REQUEST_URI = $_SERVER['REQUEST_URI']; header(sprintf("Location: http://%s%s?step=5", $HTTP_HOST, $REQUEST_URI)); exit; }
<?php include "functions.php"; // pre-define variables so the E_NOTICES do not show in webserver logs $javascript = ""; $sidebar['ok'] = array(); $sidebar['critical'] = array(); $sidebar['warning'] = array(); $sidebar['unknown'] = array(); $stats['ok'] = 0; $stats['critical'] = 0; $stats['warning'] = 0; $stats['unknown'] = 0; // Get list of all Nagios configuration files into an array $files = get_config_files(); // Read content of all Nagios configuration files into one huge array foreach ($files as $file) { $raw_data[$file] = file($file); } $data = filter_raw_data($raw_data); // hosts definition - we are only interested in hostname, parents and notes with position information foreach ($data as $host) { if ((!empty($host["host_name"]) && !preg_match("/^\\!/", $host['host_name'])) | $host['register'] == 0) { $hostname = 'x' . safe_name($host["host_name"]) . 'x'; $hosts[$hostname]['host_name'] = $hostname; $hosts[$hostname]['nagios_host_name'] = $host["host_name"]; $hosts[$hostname]['alias'] = "<i>(" . $host["alias"] . ")</i>"; // iterate for every option for the host foreach ($host as $option => $value) { // get parents information if ($option == "parents") {