<?php
/*
Fruity - A Nagios Configuration Tool
Copyright (C) 2005 Groundwork Open Source Solutions

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

/*
Fruity Index Page, Displays Menu, and Statistics
*/
include_once('includes/config.inc');


if(isset($_GET['request'])) {
	if($_GET['request'] == "delete" && $_GET['section'] == "broker") {
		// We want to delete an event broker module
		$fruity->delete_broker_module($_GET['module_id']);
		$status_msg = "Deleted event broker module.";
	}
}

if(isset($_POST['request'])) {
	if(count($_POST['main_config'])) {
		foreach($_POST['main_config'] as $key=>$value)
			$_SESSION['tempData']['main_config'][$key] = $value;
	}
	if($_POST['request'] == 'update') {
		if(!$_POST['main_global_config_checkboxes']['global_host_event_handler']){
			$_SESSION['tempData']['main_config']['global_host_event_handler'] = NULL;
		}

		if(!$_POST['main_global_config_checkboxes']['global_service_event_handler']){
			$_SESSION['tempData']['main_config']['global_service_event_handler'] = NULL;
		}
		if($fruity->update_main_conf($_SESSION['tempData']['main_config'])) {
			unset($_SESSION['tempData']);
			$status_msg = "Updated Main Configuration.";
		}
		else {
			unset($_SESSION['tempData']);
			$status_msg = "Failed To Update Main Configuration.";
		}
	}
	else if($_POST['request'] == "module_add") {
		if(!strlen(trim($_GET['module_line']))) {
			$status_msg = "Broker module line cannot be blank.";
		}
		else {
			// We want to add an event broker module
			$fruity->add_broker_module($_POST['module_line']);
			$status_msg = "Added Broker Module";
		}
	}
}

// Get Existing CGI Configuration
$fruity->get_main_conf($_SESSION['tempData']['main_config']);
	

// To create a "default" command
$fruity->return_command_list($command_list);
$command_list[] = array("command_id" => 0, "command_name" => "None");

// Let's create the date format select list
$date_format_list[] = array("values" => "us", "text" => "us - MM/DD/YYYY HH:MM:SS");
$date_format_list[] = array("values" => "euro", "text" => "euro - DD/MM/YYYY HH:MM:SS");
$date_format_list[] = array("values" => "iso8601", "text" => "iso8601 - YYYY-MM-DD HH:MM:SS");
$date_format_list[] = array("values" => "strict-iso8601", "text" => "strict-iso8601 - YYYY-MM-DDTHH:MM:SS");

// Let's make the log rotation select list
$log_rotate_list[] = array("values" => "n", "text" => "None");
$log_rotate_list[] = array("values" => "h", "text" => "Hourly");
$log_rotate_list[] = array("values" => "d", "text" => "Daily");
$log_rotate_list[] = array("values" => "w", "text" => "Weekly");
$log_rotate_list[] = array("values" => "m", "text" => "Monthly");


if(!isset($_GET['section']))
	$_GET['section'] = 'paths';



print_header("Main Configuration File Editor");
?>
&nbsp;<a class="sublink" href="<?=$path_config['doc_root'];?>main.php?section=paths">Paths</a> | <a class="sublink" href="<?=$path_config['doc_root'];?>main.php?section=status">Status</a> | <a class="sublink" href="<?=$path_config['doc_root'];?>main.php?section=security">Security</a> | <a class="sublink" href="<?=$path_config['doc_root'];?>main.php?section=restart">Restart Actions</a> | <a class="sublink" href="<?=$path_config['doc_root'];?>main.php?section=logging">Logging</a> | <a class="sublink" href="<?=$path_config['doc_root'];?>main.php?section=external">External Commands</a> | <a class="sublink" href="<?=$path_config['doc_root'];?>main.php?section=retention">Retention</a> | <a class="sublink" href="<?=$path_config['doc_root'];?>main.php?section=global">Global Handlers</a> | <a class="sublink" href="<?=$path_config['doc_root'];?>main.php?section=intervals">Intervals</a> | <a class="sublink" href="<?=$path_config['doc_root'];?>main.php?section=flap">Flap</a> | <a class="sublink" href="<?=$path_config['doc_root'];?>main.php?section=timeouts">Timeouts</a> | <a class="sublink" href="<?=$path_config['doc_root'];?>main.php?section=obsess">Obsess</a> | <a class="sublink" href="<?=$path_config['doc_root'];?>main.php?section=freshness">Freshness</a> | <a class="sublink" href="<?=$path_config['doc_root'];?>main.php?section=broker">Event Broker</a> | <a class="sublink" href="<?=$path_config['doc_root'];?>main.php?section=other">Other</a><br />
<br />
<?php
	if(isset($status_msg)) {
		?>
		<div align="center" class="statusmsg"><?=$status_msg;?></div><br />
		<?php
	}
	?>
	<br />
	<?php
	if($_GET['section'] == 'paths') {
		print_window_header("Paths", "100%", "center");
		?>
		<form name="main_path_config" method="post" action="<?=$path_config['doc_root'];?>main.php?section=paths">
		<input type="hidden" name="request" value="update" />
			<b>Configuration Directory</b><br />
			<input type="text" size="80" maxlength="255" name="main_config[config_dir]" value="<?=$_SESSION['tempData']['main_config']['config_dir'];?>"><br />
			<?=$fruity->element_desc("config_dir", "nagios_main_desc"); ?></div><br />
			<br />
			<b>Log File</b><br />
			<input type="text" size="80" maxlength="255" name="main_config[log_file]"  value="<?=$_SESSION['tempData']['main_config']['log_file'];?>"><br />
			<?=$fruity->element_desc("log_file", "nagios_main_desc"); ?><br />
			<br />
			<b>Object Cache File</b><br />
			<input type="text" size="80" maxlength="255" name="main_config[object_cache_file]"  value="<?=$_SESSION['tempData']['main_config']['object_cache_file'];?>"><br />
			<?=$fruity->element_desc("object_cache_file", "nagios_main_desc"); ?><br />
			<br />
			<b>Temporary File</b><br />
			<input type="text" size="80" maxlength="255" name="main_config[temp_file]"  value="<?=$_SESSION['tempData']['main_config']['temp_file'];?>"><br />
			<?=$fruity->element_desc("temp_file", "nagios_main_desc"); ?><br />
			<br />
			<b>Status File</b><br />
			<input type="text" size="80" maxlength="255" name="main_config[status_file]"  value="<?=$_SESSION['tempData']['main_config']['status_file'];?>"><br />
			<?=$fruity->element_desc("status_file", "nagios_main_desc"); ?><br />
			<br />
			<b>Log Archive Path</b><br />
			<input type="text" size="80" maxlength="255" name="main_config[log_archive_path]"  value="<?=$_SESSION['tempData']['main_config']['log_archive_path'];?>"><br />
			<?=$fruity->element_desc("log_archive_path", "nagios_main_desc"); ?><br />
			<br />
			<b>Command File</b><br />
			<input type="text" size="80" maxlength="255" name="main_config[command_file]"  value="<?=$_SESSION['tempData']['main_config']['command_file'];?>"><br />
			<?=$fruity->element_desc("command_file", "nagios_main_desc"); ?><br />
			<br />
			<b>Downtime File</b><br />
			<input type="text" size="80" maxlength="255" name="main_config[downtime_file]"  value="<?=$_SESSION['tempData']['main_config']['downtime_file'];?>"><br />
			<?=$fruity->element_desc("downtime_file", "nagios_main_desc"); ?><br />
			<br />
			<b>Comment File</b><br />
			<input type="text" size="80" maxlength="255" name="main_config[comment_file]"  value="<?=$_SESSION['tempData']['main_config']['comment_file'];?>"><br />
			<?=$fruity->element_desc("comment_file", "nagios_main_desc"); ?><br />
			<br />
			<b>Lock File</b><br />
			<input type="text" size="80" maxlength="255" name="main_config[lock_file]"  value="<?=$_SESSION['tempData']['main_config']['lock_file'];?>"><br />
			<?=$fruity->element_desc("lock_file", "nagios_main_desc"); ?><br />
			<br />
			<b>State Retention File</b><br />
			<input type="text" size="80" maxlength="255" name="main_config[state_retention_file]"  value="<?=$_SESSION['tempData']['main_config']['state_retention_file'];?>"><br />
			<?=$fruity->element_desc("state_retention_file", "nagios_main_desc"); ?><br />
			<br />
			<b>p1.pl File</b><br />
			<input type="text" size="80" maxlength="255" name="main_config[p1_file]"  value="<?=$_SESSION['tempData']['main_config']['p1_file'];?>"><br />
			<?=$fruity->element_desc("p1_file", "nagios_main_desc"); ?><br />
			<br />				
			<input type="submit" value="Update Path Configuration" />
			</form>
			<?php
	}
	else if($_GET['section'] == 'status') {
		print_window_header("Status", "100%", "center");
		?>
		<form name="main_status_config" method="post" action="<?=$path_config['doc_root'];?>main.php?section=status">
		<input type="hidden" name="request" value="update" />
			<b>Aggregate Status Updates </b><?php print_select("main_config[aggregate_status_updates]", $enable_list, "values", "text", $_SESSION['tempData']['main_config']['aggregate_status_updates']);?><br /> 
			<?=$fruity->element_desc("aggregate_status_updates", "nagios_main_desc"); ?><br />
			<br />
			<b>Aggregated Status Update Interval: </b><input type="text" size="2" maxlength="2" name="main_config[status_update_interval]"  value="<?=$_SESSION['tempData']['main_config']['status_update_interval'];?>"><b> Seconds</b><br />
			<?=$fruity->element_desc("status_update_interval", "nagios_main_desc"); ?><br />
			<br />
		<input type="submit" value="Update Status Configuration" />
		</form>
		<?php
		
	}
	else if($_GET['section'] == 'security') {
		print_window_header("Security", "100%", "center");
		?>
		<form name="main_security_config" method="post" action="<?=$path_config['doc_root'];?>main.php?section=security">
		<input type="hidden" name="request" value="update" />
			<b>Nagios User:</b> <input type="text" name="main_config[nagios_user]" value="<?=$_SESSION['tempData']['main_config']['nagios_user'];?>"><br />
			<?=$fruity->element_desc("nagios_user", "nagios_main_desc"); ?><br />
			<br />
			<b>Nagios Group:</b> <input type="text" name="main_config[nagios_group]"  value="<?=$_SESSION['tempData']['main_config']['nagios_group'];?>"><br />
			<?=$fruity->element_desc("nagios_group", "nagios_main_desc"); ?><br />
			<br />
		<input type="submit" value="Update Security Configuration" />
		</form>
		<?php
	}
	else if($_GET['section'] == 'restart') {
		print_window_header("Restart", "100%", "center");
		?>
		<form name="main_restart_config" method="post" action="<?=$path_config['doc_root'];?>main.php?section=restart">
		<input type="hidden" name="request" value="update" />
			<b>Notifications:</b> <?php print_select("main_config[enable_notifications]", $enable_list, "values", "text", $_SESSION['tempData']['main_config']['enable_notifications']);?><br /> 
			<?=$fruity->element_desc("enable_notifications", "nagios_main_desc"); ?><br />
			<br />
			<b>Execute Service Checks:</b> <?php print_select("main_config[execute_service_checks]", $enable_list, "values", "text", $_SESSION['tempData']['main_config']['execute_service_checks']);?><br />
			<?=$fruity->element_desc("execute_service_checks", "nagios_main_desc"); ?><br />
			<br />
			<b>Accept Passive Service Checks:</b> <?php print_select("main_config[accept_passive_service_checks]", $enable_list, "values", "text", $_SESSION['tempData']['main_config']['accept_passive_service_checks']);?><br />
			<?=$fruity->element_desc("accept_passive_service_checks", "nagios_main_desc"); ?><br />
			<br />
			<b>Execute Host Checks:</b> <?php print_select("main_config[execute_host_checks]", $enable_list, "values", "text", $_SESSION['tempData']['main_config']['execute_host_checks']);?><br />
			<?=$fruity->element_desc("execute_host_checks", "nagios_main_desc"); ?><br />
			<br />
			<b>Accept Passive Host Checks:</b> <?php print_select("main_config[accept_passive_host_checks]", $enable_list, "values", "text", $_SESSION['tempData']['main_config']['accept_passive_host_checks']);?><br />
			<?=$fruity->element_desc("accept_passive_host_checks", "nagios_main_desc"); ?><br />
			<br />
			<b>Event Handlers:</b> <?php print_select("main_config[enable_event_handlers]", $enable_list, "values", "text", $_SESSION['tempData']['main_config']['enable_event_handlers']);?><br />
			<?=$fruity->element_desc("enable_event_handlers", "nagios_main_desc"); ?><br />
			<br />
		<input type="submit" value="Update Restart Configuration" />
		</form>
		<?php
	}
	else if($_GET['section'] == 'logging') {
		print_window_header("Logging", "100%", "center");
		?>
		<form name="main_logging_config" method="post" action="<?=$path_config['doc_root'];?>main.php?section=logging">
		<input type="hidden" name="request" value="update" />
			<b>Log Rotation Method:</b> <?php print_select("main_config[log_rotation_method]", $log_rotate_list, "values", "text", $_SESSION['tempData']['main_config']['log_rotation_method']);?><br />
			<?=$fruity->element_desc("log_rotation_method", "nagios_main_desc"); ?><br />
			<br />
			<b>Use Syslog:</b> <?php print_select("main_config[use_syslog]", $enable_list, "values", "text", $_SESSION['tempData']['main_config']['use_syslog']);?><br />
			<?=$fruity->element_desc("use_syslog", "nagios_main_desc"); ?><br />
			<br />
			<b>Log Notifications:</b> <?php print_select("main_config[log_notifications]", $enable_list, "values", "text", $_SESSION['tempData']['main_config']['log_notifications']);?><br />
			<?=$fruity->element_desc("log_notifications", "nagios_main_desc"); ?><br />
			<br />		
			<b>Log Service Retries:</b> <?php print_select("main_config[log_service_retries]", $enable_list, "values", "text", $_SESSION['tempData']['main_config']['log_service_retries']);?><br />
			<?=$fruity->element_desc("log_service_retries", "nagios_main_desc"); ?><br />
			<br />
			<b>Log Host Retries:</b> <?php print_select("main_config[log_host_retries]", $enable_list, "values", "text", $_SESSION['tempData']['main_config']['log_host_retries']);?><br />
			<?=$fruity->element_desc("log_host_retries", "nagios_main_desc"); ?><br />
			<br />	
			<b>Log Event Handlers:</b> <?php print_select("main_config[log_event_handlers]", $enable_list, "values", "text", $_SESSION['tempData']['main_config']['log_event_handlers']);?><br />
			<?=$fruity->element_desc("log_event_handlers", "nagios_main_desc"); ?><br />
			<br />	
			<b>Log Initial States:</b> <?php print_select("main_config[log_initial_states]", $enable_list, "values", "text", $_SESSION['tempData']['main_config']['log_initial_states']);?><br />
			<?=$fruity->element_desc("log_initial_states", "nagios_main_desc"); ?><br />
			<br />	
			<b>Log External Commands:</b> <?php print_select("main_config[log_external_commands]", $enable_list, "values", "text", $_SESSION['tempData']['main_config']['log_external_commands']);?><br />
			<?=$fruity->element_desc("log_external_commands", "nagios_main_desc"); ?><br />
			<br />
			<b>Log Passive Checks:</b> <?php print_select("main_config[log_passive_checks]", $enable_list, "values", "text", $_SESSION['tempData']['main_config']['log_passive_checks']);?><br />
			<?=$fruity->element_desc("log_passive_checks", "nagios_main_desc"); ?><br />
			<br />				
		<input type="submit" value="Update Logging Configuration" />
		</form>
		<?php
	}
	else if($_GET['section'] == 'external') {
		print_window_header("External", "100%", "center");
		?>
		<form name="main_external_config" method="post" action="<?=$path_config['doc_root'];?>main.php?section=external">
		<input type="hidden" name="request" value="update" />
			<b>Check External Commands:</b> <?php print_select("main_config[check_external_commands]", $enable_list, "values", "text", $_SESSION['tempData']['main_config']['check_external_commands']);?><br />
			<?=$fruity->element_desc("check_external_commands", "nagios_main_desc"); ?><br />
			<br />		
			<b>Command Check Interval:</b> <input type="text" size="2" maxlength="2" name="main_config[command_check_interval]"  value="<?=$_SESSION['tempData']['main_config']['command_check_interval'];?>"><br />
			<?=$fruity->element_desc("command_check_interval", "nagios_main_desc"); ?><br />
			<br />
		<input type="submit" value="Update External Command Configuration" />
		</form>
		<?php
	}
	else if($_GET['section'] == 'retention') {
		print_window_header("Retention", "100%", "center");
		?>
		<form name="main_retention_config" method="post" action="<?=$path_config['doc_root'];?>main.php?section=retention">
		<input type="hidden" name="request" value="update" />
			<b>Retain State Information:</b> <?php print_select("main_config[retain_state_information]", $enable_list, "values", "text", $_SESSION['tempData']['main_config']['retain_state_information']);?><br />
			<?=$fruity->element_desc("retain_state_information", "nagios_main_desc"); ?><br />
			<br />
			<b>Retention Update Interval:</b> <input type="text" size="2" maxlength="2" name="main_config[retention_update_interval]"  value="<?=$_SESSION['tempData']['main_config']['retention_update_interval'];?>"> Minutes<br />
			<?=$fruity->element_desc("retention_update_interval", "nagios_main_desc"); ?><br />
			<br />
			<b>Use Retained Program State:</b> <?php print_select("main_config[use_retained_program_state]", $enable_list, "values", "text", $_SESSION['tempData']['main_config']['use_retained_program_state']);?><br />
			<?=$fruity->element_desc("use_retained_program_state", "nagios_main_desc"); ?><br />
			<br />
			<b>Use Retained Scheduling Info:</b> <?php print_select("main_config[use_retained_scheduling_info]", $enable_list, "values", "text", $_SESSION['tempData']['main_config']['use_retained_scheduling_info']);?><br />
			<?=$fruity->element_desc("use_retained_scheduling_info", "nagios_main_desc"); ?><br />
			<br />
		<input type="submit" value="Update Retention Configuration" />
		</form>
		<?php
	}
	else if($_GET['section'] == 'global') {
		print_window_header("Global Handlers", "100%", "center");
		?>
		<form name="main_global_config" method="post" action="<?=$path_config['doc_root'];?>main.php?section=global">
		<input type="hidden" name="request" value="update" />
		<br />
		<?php
		double_pane_form_window_start();
		double_pane_select_form_element_with_enabler("#f0f0f0", "main_global_config", "main_config[global_host_event_handler]", "Global Host Event Handler", $fruity->element_desc("global_host_event_handler", "nagios_main_desc"), $command_list, "command_id", "command_name", $_SESSION['tempData']['main_config']['global_host_event_handler'], "global_host_event_handler", "Enabled");
		double_pane_select_form_element_with_enabler("#f0f0f0", "main_global_config", "main_config[global_service_event_handler]", "Global Service Event Handler", $fruity->element_desc("global_service_event_handler", "nagios_main_desc"), $command_list, "command_id", "command_name", $_SESSION['tempData']['main_config']['global_service_event_handler'], "global_service_event_handler", "Enabled");
		double_pane_form_window_finish();
		?>
		<br />
		<input type="submit" value="Update Global Handlers Configuration" />
		<br />
		</form>
		<?php
	}
	else if($_GET['section'] == 'intervals') {
		print_window_header("Intervals", "100%", "center");
		?>
		<form name="main_interval_config" method="post" action="<?=$path_config['doc_root'];?>main.php?section=intervals">
		<input type="hidden" name="request" value="update" />
			<b>Sleep Time:</b> <input type="text" size="6" maxlength="6" name="main_config[sleep_time]"  value="<?=$_SESSION['tempData']['main_config']['sleep_time'];?>"> <b>Seconds</b><br />
			<?=$fruity->element_desc("sleep_time", "nagios_main_desc"); ?><br />
			<br />
			<b>Service Inter Check Delay Method:</b> <input type="text" name="main_config[service_inter_check_delay_method]"  value="<?=$_SESSION['tempData']['main_config']['service_inter_check_delay_method'];?>"> <b>Seconds</b><br />
			<?=$fruity->element_desc("service_inter_check_delay_method", "nagios_main_desc"); ?><br />
			<br />
			<b>Max Service Check Spread:</b> <input type="text" name="main_config[max_service_check_spread]"  value="<?=$_SESSION['tempData']['main_config']['max_service_check_spread'];?>"> <b>Minutes</b><br />
			<?=$fruity->element_desc("max_service_check_spread", "nagios_main_desc"); ?><br />
			<br />
			<b>Host Inter Check Delay Method:</b> <input type="text" name="main_config[host_inter_check_delay_method]"  value="<?=$_SESSION['tempData']['main_config']['host_inter_check_delay_method'];?>"> <b>Seconds</b><br />
			<?=$fruity->element_desc("host_inter_check_delay_method", "nagios_main_desc"); ?><br />
			<br />
			<b>Max Host Check Spread:</b> <input type="text" name="main_config[max_host_check_spread]"  value="<?=$_SESSION['tempData']['main_config']['max_host_check_spread'];?>"> <b>Minutes</b><br />
			<?=$fruity->element_desc("max_host_check_spread", "nagios_main_desc"); ?><br />
			<br />
			<b>Service Interleave Factor:</b> <input type="text" name="main_config[service_interleave_factor]"  value="<?=$_SESSION['tempData']['main_config']['service_interleave_factor'];?>"><br />
			<?=$fruity->element_desc("service_interleave_factor", "nagios_main_desc"); ?><br />
			<br />
			<b>Maximum Concurrent Checks:</b> <input type="text" size="2" maxlength="2" name="main_config[max_concurrent_checks]"  value="<?=$_SESSION['tempData']['main_config']['max_concurrent_checks'];?>"><br />
			<?=$fruity->element_desc("max_concurrent_checks", "nagios_main_desc"); ?><br />
			<br />
			<b>Service Reaper Frequency:</b> <input type="text" size="2" maxlength="2" name="main_config[service_reaper_frequency]"  value="<?=$_SESSION['tempData']['main_config']['service_reaper_frequency'];?>"><br />
			<?=$fruity->element_desc("service_reaper_frequency", "nagios_main_desc"); ?><br />
			<br />
			<b>Interval Length:</b> <input type="text" size="2" maxlength="2" name="main_config[interval_length]"  value="<?=$_SESSION['tempData']['main_config']['interval_length'];?>"> <b>Seconds</b><br />
			<?=$fruity->element_desc("interval_length", "nagios_main_desc"); ?><br />
			<br />
			Auto Reschedule Checks: <?php print_select("main_config[auto_reschedule_checks]", $enable_list, "values", "text", $_SESSION['tempData']['main_config']['auto_reschedule_checks']);?><br />
			<?=$fruity->element_desc("auto_reschedule_checks", "nagios_main_desc"); ?><br />
			<br />
			<b>Auto Rescheduling Interval:</b> <input type="text" size="8" maxlength="8" name="main_config[auto_rescheduling_interval]"  value="<?=$_SESSION['tempData']['main_config']['auto_rescheduling_interval'];?>"> <b>Seconds</b><br />
			<?=$fruity->element_desc("auto_rescheduling_interval", "nagios_main_desc"); ?><br />
			<br />
			<b>Auto Rescheduling Window:</b> <input type="text" size="8" maxlength="8" name="main_config[auto_rescheduling_window]"  value="<?=$_SESSION['tempData']['main_config']['auto_rescheduling_window'];?>"> <b>Seconds</b><br />
			<?=$fruity->element_desc("auto_rescheduling_window", "nagios_main_desc"); ?><br />
			<br />		
			Use Agressive Host Checking: <?php print_select("main_config[use_aggressive_host_checking]", $enable_list, "values", "text", $_SESSION['tempData']['main_config']['use_aggressive_host_checking']);?><br />
			<?=$fruity->element_desc("use_aggressive_host_checking", "nagios_main_desc"); ?><br />
			<br />
		<input type="submit" value="Update Interval Configuration" />
		</form>
		<?php
	}
	else if($_GET['section'] == 'flap') {
		print_window_header("Flapping", "100%", "center");
		?>
		<form name="main_flap_config" method="post" action="<?=$path_config['doc_root'];?>main.php?section=flap">
		<input type="hidden" name="request" value="update" />
			<b>Enable Flap Detection:</b> <?php print_select("main_config[enable_flap_detection]", $enable_list, "values", "text", $_SESSION['tempData']['main_config']['enable_flap_detection']);?><br />
			<?=$fruity->element_desc("enable_flap_detection", "nagios_main_desc"); ?><br />
			<br />
			<b>Low Service Flap Threshold:</b> <input type="text" size="2" maxlength="2" name="main_config[low_service_flap_threshold]"  value="<?=$_SESSION['tempData']['main_config']['low_service_flap_threshold'];?>"> <b>Percent</b><br />
			<?=$fruity->element_desc("low_service_flap_threshold", "nagios_main_desc"); ?><br />
			<br />
			<b>High Service Flap Threshold:</b> <input type="text" size="2" maxlength="2" name="main_config[high_service_flap_threshold]"  value="<?=$_SESSION['tempData']['main_config']['high_service_flap_threshold'];?>"> <b>Percent</b><br />
			<?=$fruity->element_desc("high_service_flap_threshold", "nagios_main_desc"); ?><br />
			<br />
			<b>Low Host Flap Threshold:</b> <input type="text" size="2" maxlength="2" name="main_config[low_host_flap_threshold]"  value="<?=$_SESSION['tempData']['main_config']['low_host_flap_threshold'];?>"> <b>Percent</b><br />
			<?=$fruity->element_desc("low_host_flap_threshold", "nagios_main_desc"); ?><br />
			<br />
			<b>High Host Flap Threshold:</b> <input type="text" size="2" maxlength="2" name="main_config[high_host_flap_threshold]"  value="<?=$_SESSION['tempData']['main_config']['high_host_flap_threshold'];?>"> <b>Percent</b><br />
			<?=$fruity->element_desc("high_host_flap_threshold", "nagios_main_desc"); ?><br />
			<br />
		<input type="submit" value="Update Interval Configuration" />
		</form>
		<?php
	}
	else if($_GET['section'] == 'timeouts') {
		print_window_header("Timeouts", "100%", "center");
		?>
		<form name="main_timeouts_config" method="post" action="<?=$path_config['doc_root'];?>main.php?section=timeouts">
		<input type="hidden" name="request" value="update" />
			<b>Service Check Timeout:</b> <input type="text" size="8" maxlength="8" name="main_config[service_check_timeout]"  value="<?=$_SESSION['tempData']['main_config']['service_check_timeout'];?>"> <b>Seconds</b><br />
			<?=$fruity->element_desc("service_check_timeout", "nagios_main_desc"); ?><br />
			<br />
			<b>Host Check Timeout:</b> <input type="text" size="8" maxlength="8" name="main_config[host_check_timeout]"  value="<?=$_SESSION['tempData']['main_config']['host_check_timeout'];?>"> <b>Seconds</b><br />
			<?=$fruity->element_desc("host_check_timeout", "nagios_main_desc"); ?><br />
			<br />
			<b>Event Handler Timeout:</b> <input type="text" size="8" maxlength="8" name="main_config[event_handler_timeout]"  value="<?=$_SESSION['tempData']['main_config']['event_handler_timeout'];?>"> <b>Seconds</b><br />
			<?=$fruity->element_desc("event_handler_timeout", "nagios_main_desc"); ?><br />
			<br />
			<b>Notification Timeout:</b> <input type="text" size="8" maxlength="8" name="main_config[notification_timeout]"  value="<?=$_SESSION['tempData']['main_config']['notification_timeout'];?>"> <b>Seconds</b><br />
			<?=$fruity->element_desc("notification_timeout", "nagios_main_desc"); ?><br />
			<br />
			<b>Obsessive Compulsive Service Processor Timeout:</b> <input type="text" size="8" maxlength="8" name="main_config[ocsp_timeout]"  value="<?=$_SESSION['tempData']['main_config']['ocsp_timeout'];?>"> <b>Seconds</b><br />
			<?=$fruity->element_desc("ocsp_timeout", "nagios_main_desc"); ?><br />
			<br />
			<b>Obsessive Compulsive Host Processor Timeout:</b> <input type="text" size="8" maxlength="8" name="main_config[ochp_timeout]"  value="<?=$_SESSION['tempData']['main_config']['ochp_timeout'];?>"> <b>Seconds</b><br />
			<?=$fruity->element_desc("ochp_timeout", "nagios_main_desc"); ?><br />
			<br />				
			<b>Performance Data Processor Command Timeout:</b> <input type="text" size="8" maxlength="8" name="main_config[perfdata_timeout]"  value="<?=$_SESSION['tempData']['main_config']['perfdata_timeout'];?>"> <b>Seconds</b><br />
			<?=$fruity->element_desc("perfdata_timeout", "nagios_main_desc"); ?><br />
			<br />

		<input type="submit" value="Update Timeout Configuration" />
		</form>
		<?php
	}
	else if($_GET['section'] == 'obsess') {
		print_window_header("Obsession", "100%", "center");
		?>
		<form name="main_obsess_config" method="post" action="<?=$path_config['doc_root'];?>main.php?section=obsess">
		<input type="hidden" name="request" value="update" />
			<b>Obsess Over Services:</b> <?php print_select("main_config[obsess_over_services]", $enable_list, "values", "text", $_SESSION['tempData']['main_config']['obsess_over_services']);?><br />
			<?=$fruity->element_desc("obsess_over_services", "nagios_main_desc"); ?><br />
			<br />
			<b>Obsessive Compulsive Service Processor Command:</b> <?php print_select("main_config[ocsp_command]", $command_list, "command_id", "command_name", $_SESSION['tempData']['main_config']['ocsp_command']);?><br />
			<?=$fruity->element_desc("ocsp_command", "nagios_main_desc"); ?><br />
			<br />
			<b>Obsess Over Hosts:</b> <?php print_select("main_config[obsess_over_hosts]", $enable_list, "values", "text", $_SESSION['tempData']['main_config']['obsess_over_hosts']);?><br />
			<?=$fruity->element_desc("obsess_over_hosts", "nagios_main_desc"); ?><br />
			<br />
			<b>Obsessive Compulsive Host Processor Command:</b> <?php print_select("main_config[ochp_command]", $command_list, "command_id", "command_name", $_SESSION['tempData']['main_config']['ochp_command']);?><br />
			<?=$fruity->element_desc("ochp_command", "nagios_main_desc"); ?><br />
			<br />				
		<input type="submit" value="Update Obsession Configuration" />
		</form>
		<?php
	}
	else if($_GET['section'] == 'freshness') {
		print_window_header("Freshness", "100%", "center");
		?>
		<form name="main_freshness_config" method="post" action="<?=$path_config['doc_root'];?>main.php?section=freshness">
		<input type="hidden" name="request" value="update" />
			<b>Check Service Freshness:</b> <?php print_select("main_config[check_service_freshness]", $enable_list, "values", "text", $_SESSION['tempData']['main_config']['check_service_freshness']);?><br />
			<?=$fruity->element_desc("check_service_freshness", "nagios_main_desc"); ?><br />
			<br />
			<b>Service Freshness Check Interval:</b> <input type="text" size="2" maxlength="2" name="main_config[service_freshness_check_interval]"  value="<?=$_SESSION['tempData']['main_config']['service_freshness_check_interval'];?>"> <b>Seconds</b><br />
			<?=$fruity->element_desc("service_freshness_check_interval", "nagios_main_desc"); ?><br />
			<br />
			<b>Check Host Freshness:</b> <?php print_select("main_config[check_host_freshness]", $enable_list, "values", "text", $_SESSION['tempData']['main_config']['check_host_freshness']);?><br />
			<?=$fruity->element_desc("check_host_freshness", "nagios_main_desc"); ?><br />
			<br />
			<b>Host Freshness Check Interval:</b> <input type="text" size="2" maxlength="2" name="main_config[host_freshness_check_interval]"  value="<?=$_SESSION['tempData']['main_config']['host_freshness_check_interval'];?>"> <b>Seconds</b><br />
			<?=$fruity->element_desc("host_freshness_check_interval", "nagios_main_desc"); ?><br />
			<br />				
		<input type="submit" value="Update Obsession Configuration" />
		</form>
		<?php
	}
	else if($_GET['section'] == 'other') {
		print_window_header("Other", "100%", "center");
		?>
		<form name="main_other_config" method="post" action="<?=$path_config['doc_root'];?>main.php?section=other">
		<input type="hidden" name="request" value="update" />
			<b>Soft State Dependencies:</b> <?php print_select("main_config[soft_state_dependencies]", $enable_list, "values", "text", $_SESSION['tempData']['main_config']['soft_state_dependencies']);?><br />
			<?=$fruity->element_desc("soft_state_dependencies", "nagios_main_desc"); ?><br />
			<br />
			<b>Process Performance Data:</b> <?php print_select("main_config[process_performance_data]", $enable_list, "values", "text", $_SESSION['tempData']['main_config']['process_performance_data']);?><br />
			<?=$fruity->element_desc("process_performance_data", "nagios_main_desc"); ?><br />
			<br />
			<b>Host Performance Data Command:</b> <?php print_select("main_config[host_perfdata_command]", $command_list, "command_id", "command_name", $_SESSION['tempData']['main_config']['host_perfdata_command']);?><br />
			<?=$fruity->element_desc("host_perfdata_command", "nagios_main_desc"); ?><br />
			<br />
			<b>Host Performance Data File:</b> <input type="text" size="60" name="main_config[host_perfdata_file]"  value="<?=$_SESSION['tempData']['main_config']['host_perfdata_file'];?>"><br />
			<?=$fruity->element_desc("host_perfdata_file", "nagios_main_desc"); ?><br />
			<br />
			<b>Host Performance Data File Mode:</b> <?php print_select("main_config[host_perfdata_file_mode]", array(array('mode' => 'a', 'label' => 'Append'), array('mode' => 'w', 'label' => 'Write')), "mode", "label", $_SESSION['tempData']['main_config']['host_perfdata_file_mode']);?><br />
			<?=$fruity->element_desc("host_perfdata_file_mode", "nagios_main_desc"); ?><br />
			<br />			
			<b>Host Performance Template:</b> <input type="text" size="60" name="main_config[host_perfdata_template]"  value="<?=$_SESSION['tempData']['main_config']['host_perfdata_template'];?>"><br />
			<?=$fruity->element_desc("host_perfdata_template", "nagios_main_desc"); ?><br />
			<br />
			<b>Host Performance Data File Processing Interval:</b> <input type="text" size="5" maxlength="5" name="main_config[host_perfdata_file_processing_interval]"  value="<?=$_SESSION['tempData']['main_config']['host_perfdata_file_processing_interval'];?>"><br />
			<?=$fruity->element_desc("host_perfdata_file_processing_interval", "nagios_main_desc"); ?><br />
			<br />
			<b>Host Performance Data File Processing Command:</b> <?php print_select("main_config[host_perfdata_file_processing_command]", $command_list, "command_id", "command_name", $_SESSION['tempData']['main_config']['host_perfdata_file_processing_command']);?><br />
			<?=$fruity->element_desc("host_perfdata_file_processing_command", "nagios_main_desc"); ?><br />
			<br />
			<b>Service Performance Data Command:</b> <?php print_select("main_config[service_perfdata_command]", $command_list, "command_id", "command_name", $_SESSION['tempData']['main_config']['service_perfdata_command']);?><br />
			<?=$fruity->element_desc("service_perfdata_command", "nagios_main_desc"); ?><br />
			<br />
			<b>Service Performance Data File:</b> <input type="text" size="60" name="main_config[service_perfdata_file]"  value="<?=$_SESSION['tempData']['main_config']['service_perfdata_file'];?>"><br />
			<?=$fruity->element_desc("service_perfdata_file", "nagios_main_desc"); ?><br />
			<br />
			<b>Service Performance Data File Mode:</b> <?php print_select("main_config[service_perfdata_file_mode]", array(array('mode' => 'a', 'label' => 'Append'), array('mode' => 'w', 'label' => 'Write')), "mode", "label", $_SESSION['tempData']['main_config']['service_perfdata_file_mode']);?><br />
			<?=$fruity->element_desc("service_perfdata_file_mode", "nagios_main_desc"); ?><br />
			<br />			
			<b>Service Performance Template:</b> <input type="text" size="60" name="main_config[service_perfdata_template]"  value="<?=$_SESSION['tempData']['main_config']['service_perfdata_template'];?>"><br />
			<?=$fruity->element_desc("service_perfdata_template", "nagios_main_desc"); ?><br />
			<br />
			<b>Service Performance Data File Processing Interval:</b> <input type="text" size="5" maxlength="5" name="main_config[service_perfdata_file_processing_interval]"  value="<?=$_SESSION['tempData']['main_config']['service_perfdata_file_processing_interval'];?>"><br />
			<?=$fruity->element_desc("service_perfdata_file_processing_interval", "nagios_main_desc"); ?><br />
			<br />
			<b>Service Performance Data File Processing Command:</b> <?php print_select("main_config[service_perfdata_file_processing_command]", $command_list, "command_id", "command_name", $_SESSION['tempData']['main_config']['service_perfdata_file_processing_command']);?><br />
			<?=$fruity->element_desc("service_perfdata_file_processing_command", "nagios_main_desc"); ?><br />
			<br />
			
			
			<b>Check For Orphaned Services:</b> <?php print_select("main_config[check_for_orphaned_services]", $enable_list, "values", "text", $_SESSION['tempData']['main_config']['check_for_orphaned_services']);?><br />
			<?=$fruity->element_desc("check_for_orphaned_services", "nagios_main_desc"); ?><br />
			<br />
			<b>Date Format:</b> <?php print_select("main_config[date_format]", $date_format_list, "values", "text", $_SESSION['tempData']['main_config']['date_format']);?><br />
			<?=$fruity->element_desc("date_format", "nagios_main_desc"); ?><br />
			<br />
			<b>Illegal Object Name Characters:</b> <input type="text" name="main_config[illegal_object_name_chars]"  value="<?=$_SESSION['tempData']['main_config']['illegal_object_name_chars'];?>"><br />
			<?=$fruity->element_desc("illegal_object_name_chars", "nagios_main_desc"); ?><br />
			<br />
			<b>Illegal Macro Output Characters:</b> <input type="text" name="main_config[illegal_macro_output_chars]"  value="<?=$_SESSION['tempData']['main_config']['illegal_macro_output_chars'];?>"><br />
			<?=$fruity->element_desc("illegal_macro_output_chars", "nagios_main_desc"); ?><br />
			<br />
			<b>Use Regular Expression Matching:</b> <?php print_select("main_config[use_regexp_matching]", $enable_list, "values", "text", $_SESSION['tempData']['main_config']['use_regexp_matching']);?><br />
			<?=$fruity->element_desc("use_regexp_matching", "nagios_main_desc"); ?><br />
			<br />
			<b>Use True Regular Expression Matching:</b> <?php print_select("main_config[use_true_regexp_matching]", $enable_list, "values", "text", $_SESSION['tempData']['main_config']['use_true_regexp_matching']);?><br />
			<?=$fruity->element_desc("use_true_regexp_matching", "nagios_main_desc"); ?><br />
			<br />

			<b>Daemon Dumps Core:</b> <?php print_select("main_config[daemon_dumps_core]", $enable_list, "values", "text", $_SESSION['tempData']['main_config']['daemon_dumps_core']);?><br />
			<?=$fruity->element_desc("daemon_dumps_core", "nagios_main_desc"); ?><br />
			<br />
			<b>Admin Email:</b> <input type="text" name="main_config[admin_email]"  value="<?=$_SESSION['tempData']['main_config']['admin_email'];?>"><br />
			<?=$fruity->element_desc("admin_email", "nagios_main_desc"); ?><br />
			<br />
			<b>Admin Pager:</b> <input type="text" name="main_config[admin_pager]"  value="<?=$_SESSION['tempData']['main_config']['admin_pager'];?>"><br />
			<?=$fruity->element_desc("admin_pager", "nagios_main_desc"); ?><br />
			<br />
		<input type="submit" value="Update Other Configuration" />
		</form>
		<?php
	}
	else if($_GET['section'] == 'broker') {
		$fruity->return_broker_modules($module_list);
		$numOfModules = count($module_list);
		
		print_window_header("Event Broker", "100%", "center");
		
		$broker_list = array();
		$broker_list[] = array("value" => "0", "label" => "Broker nothing");
		$broker_list[] = array("value" => "-1", "label" => "Broker everything");
		
		?>
		<form name="main_broker_config" method="post" action="<?=$path_config['doc_root'];?>main.php?section=broker">
		<input type="hidden" name="request" value="update" />
			<b>Event Broker Options:</b> <?php print_select("main_config[event_broker_options]", $broker_list, "value", "label", $_SESSION['tempData']['main_config']['event_broker_options']);?><br />
			<?=$fruity->element_desc("event_broker_options", "nagios_main_desc"); ?><br />
			<br />
		<input type="submit" value="Update Event Broker Configuration" />
		</form>
		
		<table width="100%" align="center" cellspacing="0" cellpadding="2" border="0">
			<tr class="altTop">
			<td colspan="2">Event Broker Modules:</td>
			</tr>
			<?php
			$counter = 0;
			if($numOfModules) {
				foreach($module_list as $module) {
					if($counter % 2) {
						?>
						<tr class="altRow1">
						<?php
					}
					else {
						?>
						<tr class="altRow2">
						<?php
					}
					?>
					<td height="20" width="60" class="altLeft">&nbsp;[ <a href="<?=$path_config['doc_root'];?>main.php?section=broker&request=delete&module_id=<?=$module['module_id'];?>" onClick="javascript:return confirmDelete();">Delete</a> ]</td>
					<td height="20" class="altRight"><b><?=$module['module_line']?></b></td>
					</tr>
					<?php
					$counter++;
				}
			}
			?>
		</table>
		<br />
		<br />
		<b>Add Event Broker Module:</b>
		<form action="<?=$_SERVER['PHP_SELF'];?>?&section=broker" method="post">
		<input type="hidden" name="request" value="module_add" />
		Module Path And Any Arguments:<input type="text" size="50" maxsize="255" name="module_line" /> <input type="submit" value="Add Module" /><br />
		<i>Example:</i> /usr/lib/module.so arg1 arg2 arg3
		</form>
		<?php
	}
	
	print_window_footer();
	?>
	<br />
	<?php
print_footer();
?>
