Example #1
0
function draw_edit_form($array) {
	global $colors;

	//print "<pre>";print_r($array);print "</pre>";

	if (sizeof($array) > 0) {
		while (list($top_branch, $top_children) = each($array)) {
			if ($top_branch == "config") {
				$config_array = $top_children;
			}elseif ($top_branch == "fields") {
				$fields_array = $top_children;
			}
		}
	}

	$i = 0;
	if (sizeof($fields_array) > 0) {
		while (list($field_name, $field_array) = each($fields_array)) {
			if ($i == 0) {
				if (!isset($config_array["no_form_tag"])) {
					print "<form method='post' action='" . ((isset($config_array["post_to"])) ? $config_array["post_to"] : basename($_SERVER["PHP_SELF"])) . "'" . ((isset($config_array["form_name"])) ? " name='" . $config_array["form_name"] . "'" : "") . ">\n";
				}
			}

			if ($field_array["method"] == "hidden") {
				form_hidden_box($field_name, $field_array["value"], ((isset($field_array["default"])) ? $field_array["default"] : ""));
			}elseif ($field_array["method"] == "hidden_zero") {
				form_hidden_box($field_name, $field_array["value"], "0");
			}elseif ($field_array["method"] == "spacer") {
				print "<tr bgcolor='" . $colors["header_panel"] . "'><td colspan='2' class='textSubHeaderDark'>" . $field_array["friendly_name"] . "</td></tr>\n";
			}else{
				if (isset($config_array["force_row_color"])) {
					print "<tr bgcolor='#" . $config_array["force_row_color"] . "'>";
				}else{
					form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],$i);
				}

				print "<td width='" . ((isset($config_array["left_column_width"])) ? $config_array["left_column_width"] : "50%") . "'>\n<font class='textEditTitle'>" . $field_array["friendly_name"] . "</font><br>\n";

				if (isset($field_array["sub_checkbox"])) {
					form_checkbox($field_array["sub_checkbox"]["name"], $field_array["sub_checkbox"]["value"], $field_array["sub_checkbox"]["friendly_name"], "", ((isset($field_array["form_id"])) ? $field_array["form_id"] : ""));
				}

				print ((isset($field_array["description"])) ? $field_array["description"] : "") . "</td>\n";

				print "<td>";

				draw_edit_control($field_name, $field_array);

				print "</td>\n</tr>\n";

				$i++;
			}

			if ($i == sizeof($fields_array)) {
				//print "</form>";
			}
		}
	}
}
Example #2
0
function draw_edit_form($array)
{
    if (sizeof($array) > 0) {
        while (list($top_branch, $top_children) = each($array)) {
            if ($top_branch == "config") {
                $config_array = $top_children;
            } elseif ($top_branch == "fields") {
                $fields_array = $top_children;
            }
        }
    }
    $i = 0;
    if (sizeof($fields_array) > 0) {
        while (list($field_name, $field_array) = each($fields_array)) {
            if ($i == 0) {
                if (!isset($config_array["no_form_tag"])) {
                    print "<tr style='display:none;'><td><form method='post' autocomplete='off' action='" . (isset($config_array["post_to"]) ? $config_array["post_to"] : basename($_SERVER["PHP_SELF"])) . "'" . (isset($config_array["form_name"]) ? " name='" . $config_array["form_name"] . "'" : "") . (isset($config_array["enctype"]) ? " enctype='" . $config_array["enctype"] . "'" : "") . "></td></tr>\n";
                }
            }
            if ($field_array["method"] == "hidden") {
                form_hidden_box($field_name, $field_array["value"], isset($field_array["default"]) ? $field_array["default"] : "");
            } elseif ($field_array["method"] == "hidden_zero") {
                form_hidden_box($field_name, $field_array["value"], "0");
            } elseif ($field_array["method"] == "spacer") {
                if (isset($field_array['collapsible']) && $field_array['collapsible'] == 'true') {
                    $collapsible = true;
                } else {
                    $collapsible = false;
                }
                print "<tr class='spacer tableHeader" . ($collapsible ? ' collapsible' : '') . "' id='row_{$field_name}'><td colspan='2' style='cursor:pointer;' class='tableSubHeaderColumn'>" . $field_array["friendly_name"] . ($collapsible ? "<div style='float:right;padding-right:4px;'><i class='fa fa-angle-double-up'></i></div>" : "") . "</td></tr>\n";
            } else {
                if (isset($config_array["force_row_color"])) {
                    print "<tr class='even-alternate'>";
                } else {
                    form_alternate_row('row_' . $field_name);
                }
                print "<td width='" . (isset($config_array["left_column_width"]) ? $config_array["left_column_width"] : "50%") . "'>\n<font class='textEditTitle'>" . $field_array["friendly_name"] . "</font><br>\n";
                if (isset($field_array["sub_checkbox"])) {
                    form_checkbox($field_array["sub_checkbox"]["name"], $field_array["sub_checkbox"]["value"], $field_array["sub_checkbox"]["friendly_name"], isset($field_array["sub_checkbox"]["default"]) ? $field_array["sub_checkbox"]["default"] : "", isset($field_array["sub_checkbox"]["form_id"]) ? $field_array["sub_checkbox"]["form_id"] : "", isset($field_array["sub_checkbox"]["class"]) ? $field_array["sub_checkbox"]["class"] : "", isset($field_array["sub_checkbox"]["on_change"]) ? $field_array["sub_checkbox"]["on_change"] : "");
                }
                print (isset($field_array["description"]) ? $field_array["description"] : "") . "</td>\n";
                print "<td>";
                draw_edit_control($field_name, $field_array);
                print "</td>\n</tr>\n";
            }
            $i++;
        }
    }
}
Example #3
0
function draw_edit_form($array)
{
    global $colors;
    if (sizeof($array) > 0) {
        while (list($top_branch, $top_children) = each($array)) {
            if ($top_branch == "config") {
                $config_array = $top_children;
            } elseif ($top_branch == "fields") {
                $fields_array = $top_children;
            }
        }
    }
    $i = 0;
    if (sizeof($fields_array) > 0) {
        while (list($field_name, $field_array) = each($fields_array)) {
            if ($i == 0) {
                if (!isset($config_array["no_form_tag"])) {
                    print "<tr style='display:none;'><td><form method='post' autocomplete='off' action='" . (isset($config_array["post_to"]) ? $config_array["post_to"] : basename($_SERVER["PHP_SELF"])) . "'" . (isset($config_array["form_name"]) ? " name='" . $config_array["form_name"] . "'" : "") . (isset($config_array["enctype"]) ? " enctype='" . $config_array["enctype"] . "'" : "") . "></td></tr>\n";
                }
            }
            if ($field_array["method"] == "hidden") {
                form_hidden_box($field_name, $field_array["value"], isset($field_array["default"]) ? $field_array["default"] : "");
            } elseif ($field_array["method"] == "hidden_zero") {
                form_hidden_box($field_name, $field_array["value"], "0");
            } elseif ($field_array["method"] == "spacer") {
                print "<tr id='row_{$field_name}' bgcolor='#" . $colors["header_panel"] . "'><td colspan='2' class='tableSubHeaderColumn'>" . $field_array["friendly_name"] . "</td></tr>\n";
            } else {
                if (isset($config_array["force_row_color"])) {
                    print "<tr id='row_{$field_name}' bgcolor='#" . $config_array["force_row_color"] . "'>";
                } else {
                    form_alternate_row_color($colors["form_alternate1"], $colors["form_alternate2"], $i, 'row_' . $field_name);
                }
                print "<td width='" . (isset($config_array["left_column_width"]) ? $config_array["left_column_width"] : "50%") . "'>\n<font class='textEditTitle'>" . $field_array["friendly_name"] . "</font><br>\n";
                if (isset($field_array["sub_checkbox"])) {
                    form_checkbox($field_array["sub_checkbox"]["name"], $field_array["sub_checkbox"]["value"], $field_array["sub_checkbox"]["friendly_name"], "", isset($check_array["on_change"]) ? $check_array["on_change"] : "", isset($field_array["form_id"]) ? $field_array["form_id"] : "");
                }
                print (isset($field_array["description"]) ? $field_array["description"] : "") . "</td>\n";
                print "<td>";
                draw_edit_control($field_name, $field_array);
                print "</td>\n</tr>\n";
            }
            $i++;
        }
    }
}
Example #4
0
function flowview_display_form()
{
    global $config, $graph_timespans;
    include $config['base_path'] . '/plugins/flowview/variables.php';
    include $config['base_path'] . '/plugins/flowview/arrays.php';
    display_tabs();
    form_start('flowview.php', 'flowview');
    html_start_box('Flow Filter Constraints  <span id="text"></span>', '100%', '', '3', 'center', '');
    ?>
	<tr class='even center'>
		<td style='text-align:center'>
			<table class='filterTable' width='100%'>
				<tr>
					<td>
						Filter
					</td>
					<td>
						<?php 
    draw_edit_control('query', $query_name_field);
    ?>
					</td>
					<td>
						Listener
					</td>
					<td>
						<?php 
    draw_edit_control('device_name', $device_name_field);
    ?>
					</td>
				</tr>
				<tr>
					<td>
                        Presets
					</td>
					<td>
						<select id='predefined_timespan' name='predefined_timespan' onChange='applyTimespan()'>
							<?php 
    if ($timespan == 0) {
        $graph_timespans[GT_CUSTOM] = 'Custom';
        $start_val = 0;
        $end_val = sizeof($graph_timespans);
    } else {
        if (isset($graph_timespans[GT_CUSTOM])) {
            asort($graph_timespans);
            array_shift($graph_timespans);
        }
        $start_val = 1;
        $end_val = sizeof($graph_timespans) + 1;
    }
    if (sizeof($graph_timespans) > 0) {
        for ($value = $start_val; $value < $end_val; $value++) {
            print "<option value='{$value}'";
            if ($timespan == $value) {
                print ' selected';
            }
            print '>' . title_trim($graph_timespans[$value], 40) . "</option>\n";
        }
    }
    ?>
						</select>
					</td>

					<td>
						Start Date
					</td>
					<td class='nowrap'>
						<input type='text' size='15' id='date1' value='<?php 
    echo $date1;
    ?>
'>
						<i id='startDate' class='calendar fa fa-calendar' title='Start Date Selector'></i>
					</td>
					<td>
						End Date
					</td>
					<td>
						<input type='text' size='15' id='date2' value='<?php 
    echo $date2;
    ?>
'>
						<i id='endDate' class='calendar fa fa-calendar' title='End Date Selector'></i>
					</td>
				</tr>
				<tr>
					<td colspan='9'><hr size='2'></td>
				</tr>
				<tr>
					<td>
						Protocols
					</td>
					<td>
						<?php 
    draw_edit_control('protocols', $ip_protocol_field);
    ?>
					</td>
					<td>
						TCP Flags
					</td>
					<td>
						<input type='text' size='10' name='tcp_flags' value='<?php 
    echo $tcp_flags;
    ?>
'>
					</td>
					<td>
						TOS Fields
					</td>
					<td>
						<input type='text' size='10' name='tos_fields' value='<?php 
    echo $tos_fields;
    ?>
'>
					</td>
					<td colspan=2>
						(e.g., -0x0b/0x0F)
					</td>
				</tr>
				<tr>
					<td>
						Source IP
					</td>
					<td>
						<input type='text' size='19' name='source_address' value='<?php 
    echo $source_address;
    ?>
'>
					</td>
					<td>
						Source Port(s)
					</td>
					<td>
						<input type='text' size='20' name='source_port' value='<?php 
    echo $source_port;
    ?>
'>
					</td>
					<td>
						Source Interface
					</td>
					<td>
						<input type='text' size='2' name='source_if' value='<?php 
    echo $source_if;
    ?>
'>
					</td>
					<td>
						Source AS
					</td>
					<td>
						<input type='text' size='6' name='source_as' value='<?php 
    echo $source_as;
    ?>
'>
					</td>
				</tr>
				<tr>
					<td>
						Dest IP
					</td>
					<td>
						<input type='text' size='19' name='dest_address' value='<?php 
    echo $dest_address;
    ?>
'></td>
					<td>
						Dest Port(s)
					</td>
					<td>
						<input type='text' size='20' name='dest_port' value='<?php 
    echo $dest_port;
    ?>
'>
					</td>
					<td>
						Dest Interface
					</td>
					<td>
						<input type='text' size='2' name='dest_if' value='<?php 
    echo $dest_if;
    ?>
'>
					</td>
					<td>
						Dest AS
					</td>
					<td>
						<input type='text' size='6' name='dest_as' value='<?php 
    echo $dest_as;
    ?>
'>
						<input type='hidden' name='header' value='false'>
					</td>
				</tr>
				<tr>
					<td colspan='9'>
						<hr size='2'>
						<center><strong>Note:</strong> Multiple field entries, separated by commas, are permitted in the fields above. A minus sign (-) will negate an entry (e.g. -80 for Port, would mean any Port but 80)</center>
						<hr size='2'>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<?php 
    html_end_box(false);
    ?>

	<?php 
    html_start_box('Report Parameters', '100%', '', '3', 'center', '');
    ?>
	<tr class='even'>
		<td>
			<table class='filterTable'>
				<tr id='rsettings'>
					<td>Statistics:</td>
					<td><?php 
    draw_edit_control('stat_report', $stat_report_field);
    ?>
</td>
					<td>Printed:</td>
					<td><?php 
    draw_edit_control('print_report', $print_report_field);
    ?>
</td>
					<td>Include if:</td>
					<td><?php 
    draw_edit_control('flow_select', $flow_select_field);
    ?>
</td>
					<td>Resolve Addresses:</td>
					<td><?php 
    draw_edit_control('resolve_addresses', $resolve_addresses_field);
    ?>
</td>
				</tr>
				<tr id='rlimits'>
					<td class='sortfield'>Sort Field:</td>
					<td class='sortfield'><select id='sort_field' name='sort_field'></select></td>
					<td>Max Flows:</td>
					<td><?php 
    draw_edit_control('cutoff_lines', $cutoff_lines_field);
    ?>
</td>
					<td>Minimum Bytes:</td>
					<td><?php 
    draw_edit_control('cutoff_octets', $cutoff_octets_field);
    ?>
</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td colspan='9'><hr size='2'></td>
	</tr>
	<tr>
		<td colspan='9'>
			<input type='hidden' id='action' name='action' value='view'>
			<input type='hidden' id='new_query' name='new_query' value=''>
			<input type='hidden' id='changed' name='changed' value='0'>
			<center>
				<input id='view' type='button' name='view' value='View'>
				<input id='defaults' type='button' value='Defaults'>
				<input id='save' type='button' name='save' value='Save'>
				<input id='saveas' type='button' name='saveas' value='Save As'>
				<input id='delete' type='button' name='delete' value='Delete'>
			</center>
		</td>
	</tr>
	<?php 
    html_end_box();
    form_end();
    ?>
	<script type='text/javascript'>

	var date1Open = false;
	var date2Open = false;

	function applyTimespan() {
		$.getJSON('flowview.php?action=gettimespan&timespan='+$('#predefined_timespan').val(), function(data) {
			$('#date1').val(data['current_value_date1']);
			$('#date2').val(data['current_value_date2']);
		});
	}

	function applyFilter() {
		loadPageNoHeader('flowview.php?action=loadquery&tab=filters&header=false&query='+$('#query').val());
	}

	function statSelect() {
		statval = $('#stat_report').val();
		setStatOption(statval);

		if (statval > 0) {
			$('#print_report').attr('value', 0);
			$('#print_report').prop('disabled', true);
			$('#rlimits').children('.sortfield').show();
		}else{
			$('#print_report').prop('disabled', false);
		}

		if (statval == 99 || statval < 1) {
			$('#rlimits').hide();
		} else {
			$('#rlimits').show();
		}

		if (statval == 0 && $('#print_report').val() == 0) {
			$('#view').prop('disabled', true);
			$('#save').prop('disabled', true);
			$('#saveas').prop('disabled', true);
		}else{
			$('#view').prop('disabled', false);
			$('#save').prop('disabled', false);
			$('#saveas').prop('disabled', false);
		}
	}

	function printSelect() {
		statval = $('#print_report').val();

		if (statval > 0) {
			$('#stat_report').attr('value',0);
			$('#stat_report').prop('disabled', false);
			$('#sort_field').prop('disabled', false);
			$('#rlimits').hide();
			$('#rlimits').children('.sortfield').hide();
		} else {
			$('#rlimits').show();
			$('#cutoff_lines').prop('disabled', false);
			$('#cutoff_octets').prop('disabled', false);

			if ($('#stat_report').val() == 0) {
				$('#stat_report').attr('value', 10);
			}

			$('#stat_report').prop('disabled', false);
			statSelect();
			return;
		}
		if (statval == 4 || statval == 5) {
			$('#cutoff_lines').prop('disabled', false);
			$('#cutoff_octets').prop('disabled', false);
			$('#rlimits').show();
		} else {
			$('#cutoff_lines').prop('disabled', true);
			$('#cutoff_octets').prop('disabled', true);
			$('#rlimits').hide();
		}

		if (statval == 0 && $('#stat_report').val() == 0) {
			$('#view').prop('disabled', true);
			$('#save').prop('disabled', true);
			$('#saveas').prop('disabled', true);
		}else{
			$('#view').prop('disabled', false);
			$('#save').prop('disabled', false);
			$('#saveas').prop('disabled', false);
		}
	}

	$('#device_name').change(function () {
		<?php 
    if (api_user_realm_auth('flowview_devices.php')) {
        ?>
		if ($(this).val() == 0) {
			$('#view').prop('disabled', true);
			$('#save').prop('disabled', true);
		}else{
			$('#view').prop('disabled', false);
			$('#save').prop('disabled', false);
		}
		<?php 
    } else {
        ?>
		if ($(this).val() == 0) {
			$('#view').prop('disabled', true);
		}else{
			$('#view').prop('disabled', false);
		}
		<?php 
    }
    ?>
	});

	$('#date1, #date2').change(function() {
		if ($('#predefined_timespan option').length == 28) {
			$('#predefined_timespan').prepend("<option value='0' selected='selected'>Custom</option>");
			$('#predefined_timespan').val('0');
			<?php 
    if (get_selected_theme() != 'classic') {
        ?>
			$('#predefined_timespan').selectmenu('refresh');
			<?php 
    }
    ?>
		}
	});

	$(function() {
		$('#startDate').click(function() {
			if (date1Open) {
				date1Open = false;
				$('#date1').datetimepicker('hide');
			}else{
				date1Open = true;
				$('#date1').datetimepicker('show');
			}
		});

		$('#endDate').click(function() {
			if (date2Open) {
				date2Open = false;
				$('#date2').datetimepicker('hide');
			}else{
				date2Open = true;
				$('#date2').datetimepicker('show');
			}
		});

		$('#date1').datetimepicker({
			minuteGrid: 10,
			stepMinute: 1,
			showAnim: 'slideDown',
			numberOfMonths: 1,
			timeFormat: 'HH:mm',
			dateFormat: 'yy-mm-dd',
			showButtonPanel: false
		});

		$('#date2').datetimepicker({
			minuteGrid: 10,
			stepMinute: 1,
			showAnim: 'slideDown',
			numberOfMonths: 1,
			timeFormat: 'HH:mm',
			dateFormat: 'yy-mm-dd',
			showButtonPanel: false
		});

		$('#saveas').hide();

		<?php 
    if (api_user_realm_auth('flowview_devices.php')) {
        ?>
		if ($('#query').val() == 0) {
			$('#delete').hide();
		}else{
			$('#save').attr('value', 'Update');
			$('#saveas').show();
		}
		<?php 
    } else {
        ?>
		$('#delete').hide();
		$('#save').hide();
		<?php 
    }
    ?>

		$('#flowview').change(function() {
			$('#changed').attr('value', '1');
		});

		<?php 
    if (api_user_realm_auth('flowview_devices.php')) {
        ?>
		if ($('#device_name').val() == 0) {
			$('#view').prop('disabled', true);
			$('#save').prop('disabled', true);
		}else{
			$('#view').prop('disabled', false);
			$('#save').prop('disabled', false);
		}
		<?php 
    } else {
        ?>
		if ($('#device_name').val() == 0) {
			$('#view').prop('disabled', true);
		}else{
			$('#view').prop('disabled', false);
		}
		<?php 
    }
    ?>

		$('#stat_report').change(function() {
			statSelect();
		});

		$('#print_report').change(function() {
			printSelect();
		});

		statSelect();
		printSelect();

		$('#fdialog').dialog({
			autoOpen: false,
			width: 380,
			height: 120,
			resizable: false,
			modal: true
		});
	});

	$('#view').click(function() {
		$('#action').attr('value', 'view');
		$.post('flowview.php', $('input, select, textarea').serialize(), function(data) {
			$('#main').html(data);
			applySkin();
		});
	});

	$('#saveas').click(function() {
		console.log('This is saveas');
		$('#squery').attr('value', $('#query>option:selected').text()+' (New)');
		$('#fdialog').dialog('open');
		$('#qcancel').click(function() {
			$('#fdialog').dialog('close');
		});
		$('#qsave').click(function() {
			$('#new_query').attr('value', $('#squery').val());
			$('#action').attr('value', 'save');
			$.post('flowview.php', $('#flowview').serialize(), function(data) {
				if (data!='error') {
					$('#text').show().text('Filter Saved').fadeOut(2000);
					$('#query').append("<option value='"+data+"'>"+$('#new_query').val()+"</option>");
					$('#query').attr('value', data);
				}
			});
			$('#fdialog').dialog('close');
		});
	});

	$('#save').click(function() {
		if ($('#query').val() == 0) {
			$('#fdialog').dialog('open');
			$('#qcancel').click(function() {
				$('#fdialog').dialog('close');
			});
			$('#qsave').click(function() {
				$('#new_query').attr('value', $('#squery').val());
				$('#action').attr('value', 'save');
				$.post('flowview.php', $('#flowview').serialize(), function(data) {
					if (data!='error') {
						loadPageNoHeader('flowview.php?tab=filters&header=false&action=loadquery&query='+data);
						$('#text').show().text('Filter Settings Saved').fadeOut(2000);
					}
				});
				$('#fdialog').dialog('close');
			});
		}else{
			$('#action').attr('value', 'save');
			$.post('flowview.php', $('#flowview').serialize(), function(data) {
				$('#text').show().text('Filter Updated').fadeOut(2000);
			});
		}
	});

	$('#delete').click(function() {
		loadPageNoHeader('flowview.php?header=false&action=delete&query='+$('#query').val());
	});

	$('#defaults').click(function() {
		setDefaults();
	});

	function setDefaults() {
		// Flow Filter Settings
		$('#device').attr('value',0);
		$('#date1').attr('value', '');
		$('#start_time').attr('value','-8 HOURS');
		$('#date2').attr('value','');
		$('#end_time').attr('value','NOW');
		$('#source_address').attr('value','');
		$('#source_port').attr('value','');
		$('#source_if').attr('value','');
		$('#source_as').attr('value','');
		$('#dest_address').attr('value','');
		$('#dest_port').attr('value','');
		$('#dest_if').attr('value','');
		$('#dest_as').attr('value','');
		$('#protocols').attr('value',0);
		$('#tos_fields').attr('value','');
		$('#tcp_flags').attr('value','');
		// Report Settings
		$('#stat_report').attr('value',10);
		$('#print_report').attr('value',0);
		$('#flow_select').attr('value',1);
		$('#sort_field').attr('value',4);
		$('#cutoff_lines').attr('value','100');
		$('#cutoff_octets').attr('value', '');
		$('#resolve_addresses').attr('value',0);
		statSelect();
	}

	function setStatOption(choose) {
		stat = document.flowview.sort_field;
		stat.options.length = 0;
		defsort = 1;
		if (choose == 10) {
			stat.options[stat.options.length] = new Option('Source IP', '1');
			stat.options[stat.options.length] = new Option('Destination IP', '2');
			stat.options[stat.options.length] = new Option('Flows', '3');
			stat.options[stat.options.length] = new Option('Bytes', '4');
			stat.options[stat.options.length] = new Option('Packets', '5');
			defsort = 4;
		} else if (choose == 5 || choose == 6 || choose == 7) {
			stat.options[stat.options.length] = new Option('Port', '1');
			stat.options[stat.options.length] = new Option('Flows', '2');
			stat.options[stat.options.length] = new Option('Bytes', '3');
			stat.options[stat.options.length] = new Option('Packets', '4');
			defsort = 3;
		} else if (choose == 8 || choose == 9 || choose == 11) {
			stat.options[stat.options.length] = new Option('IP', '1');
			stat.options[stat.options.length] = new Option('Flows', '2');
			stat.options[stat.options.length] = new Option('Bytes', '3');
			stat.options[stat.options.length] = new Option('Packets', '4');
			defsort = 3;
		} else if (choose == 12) {
			stat.options[stat.options.length] = new Option('Protocol', '1');
			stat.options[stat.options.length] = new Option('Flows', '2');
			stat.options[stat.options.length] = new Option('Bytes', '3');
			stat.options[stat.options.length] = new Option('Packets', '4');
			defsort = 3;
		} else if (choose == 17 || choose == 18) {
			stat.options[stat.options.length] = new Option('Interface', '1');
			stat.options[stat.options.length] = new Option('Flows', '2');
			stat.options[stat.options.length] = new Option('Bytes', '3');
			stat.options[stat.options.length] = new Option('Packets', '4');
			defsort = 3;
		} else if (choose == 23) {
			stat.options[stat.options.length] = new Option('Input Interface', '1');
			stat.options[stat.options.length] = new Option('Output Interface', '2');
			stat.options[stat.options.length] = new Option('Flows', '3');
			stat.options[stat.options.length] = new Option('Bytes', '4');
			stat.options[stat.options.length] = new Option('Packets', '5');
			defsort = 4;
		} else if (choose == 19 || choose == 20) {
			stat.options[stat.options.length] = new Option('AS', '1');
			stat.options[stat.options.length] = new Option('Flows', '2');
			stat.options[stat.options.length] = new Option('Bytes', '3');
			stat.options[stat.options.length] = new Option('Packets', '4');
			defsort = 3;
		} else if (choose == 21) {
			stat.options[stat.options.length] = new Option('Source AS', '1');
			stat.options[stat.options.length] = new Option('Destination AS', '2');
			stat.options[stat.options.length] = new Option('Flows', '3');
			stat.options[stat.options.length] = new Option('Bytes', '4');
			stat.options[stat.options.length] = new Option('Packets', '5');
			defsort = 4;
		} else if (choose == 22) {
			stat.options[stat.options.length] = new Option('TOS', '1');
			stat.options[stat.options.length] = new Option('Flows', '2');
			stat.options[stat.options.length] = new Option('Bytes', '3');
			stat.options[stat.options.length] = new Option('Packets', '4');
			defsort = 3;
		} else if (choose == 24 || choose == 25) {
			stat.options[stat.options.length] = new Option('Prefix', '1');
			stat.options[stat.options.length] = new Option('Flows', '2');
			stat.options[stat.options.length] = new Option('Bytes', '3');
			stat.options[stat.options.length] = new Option('Packets', '4');
			defsort = 3;
		} else if (choose == 26) {
			stat.options[stat.options.length] = new Option('Source Prefix', '1');
			stat.options[stat.options.length] = new Option('Destination Prefix', '2');
			stat.options[stat.options.length] = new Option('Flows', '3');
			stat.options[stat.options.length] = new Option('Bytes', '4');
			stat.options[stat.options.length] = new Option('Packets', '5');
			defsort = 4;
		} else {

		}

		if (statreport == choose) {
			stat.value = sortfield;
		} else {
			stat.value = defsort;
		}
	}

	var sortfield='<?php 
    echo $sort_field;
    ?>
';
	var statreport='<?php 
    echo $stat_report > 0 ? $stat_report : 0;
    ?>
';

	</script>

	<?php 
}
Example #5
0
function draw_edit_form($array) {
	global $colors;

	//print "<pre>";print_r($array);print "</pre>";

	if (sizeof($array) > 0) {
		while (list($top_branch, $top_children) = each($array)) {
			if ($top_branch == "config") {
				$config_array = $top_children;
			}elseif ($top_branch == "fields") {
				$fields_array = $top_children;
			}
		}
	}

	$i = 0;
	if (sizeof($fields_array) > 0) {
		while (list($field_name, $field_array) = each($fields_array)) {
			if ($i == 0) {
				if (!isset($config_array["no_form_tag"])) {
					echo "<form method='post' action='" . ((isset($config_array["post_to"])) ? $config_array["post_to"] : basename($_SERVER["PHP_SELF"])) . "'" . ((isset($config_array["form_name"])) ? " name='" . $config_array["form_name"] . "'" : "") . ">\n";
				}
			}

			if ($field_array["method"] == "hidden") {
				form_hidden_box($field_name, $field_array["value"], ((isset($field_array["default"])) ? $field_array["default"] : ""));
			}elseif ($field_array["method"] == "hidden_zero") {
				form_hidden_box($field_name, $field_array["value"], "0");
			}elseif ($field_array["method"] == "spacer") {
				echo "<tr bgcolor='" . $colors["header_panel_background"] . "'><td colspan='2' class='textSubHeaderDark'>" . $field_array["friendly_name"] . "</td></tr>\n";
			}else{
				/* row color */
				if (isset($config_array["force_row_color"])) {
					echo "<tr bgcolor='#" . $config_array["force_row_color"] . "'>";
				}else{
					form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],$i);
				}

				/* column width */
				echo "<td width='" . ((isset($config_array["left_column_width"])) ? $config_array["left_column_width"] : "50%") . "'>\n<font class='textEditTitle'>" . $field_array["friendly_name"] . "</font><br>\n";

				/* sub-field name components */
				if (isset($field_array["sub_template_checkbox"])) {
					form_checkbox($field_array["sub_template_checkbox"]["name"], $field_array["sub_template_checkbox"]["value"], $field_array["sub_template_checkbox"]["friendly_name"], "", ((isset($field_array["form_id"])) ? $field_array["form_id"] : ""), "template_checkbox_status(\"$field_name\",\"" . $field_array["sub_template_checkbox"]["name"] . "\",\"" . $field_array["method"] . "\")");
				}

				/* field description */
				echo ((isset($field_array["description"])) ? $field_array["description"] : "") . "</td>\n";

				echo "<td>";

				if (isset($field_array["preset"])) {
					$field_array["preset"]["js_onchange"] = "document.forms[0].$field_name.value=document.forms[0].preset_$field_name.value";
					echo "<table width='100%' cellspacing='0' cellpadding='0'><tr>";

					/* main form item */
					echo "<td>";
					draw_edit_control($field_name, $field_array);
					echo "</td>";

					/* special handling for drop_array's so we can add a 'none' option that clears the
					 * preset value */
					if (($field_array["preset"]["method"] == "drop_array") || ($field_array["preset"]["method"] == "drop_color")) {
						$_arr = array();

						/* convert sql-keyed array into array("id" => "value") style */
						if (isset($field_array["preset"]["sql"])) {
							$_arr = array_rekey(db_fetch_assoc($field_array["preset"]["sql"]), "id", "name");
						}

						/* add a "None" option that clears the preset */
						$field_array["preset"]["array"][""] = "(None)";
						$field_array["preset"]["array"] += $_arr;
					}

					/* preset form item */
					echo "<td align='right'>";
					draw_edit_control("preset_$field_name", $field_array["preset"]);
					echo "<span style='font-weight: bold; color: #c34138; font-size: 14px;' title='Preset Selection'>*</span\n";
					echo "</td>";

					echo "</tr></table>\n";
				}else{
					draw_edit_control($field_name, $field_array);
				}

				echo "</td>\n</tr>\n";

				$i++;
			}

			if ($i == sizeof($fields_array)) {
				//print "</form>";
			}
		}
	}
}
Example #6
0
/** draw_edit_form - draws an html edit form
   @param array $array - an array that contains all of the information needed to draw
     the html form. see the arrays contained in include/global_settings.php
     for the extact syntax of this array */
function draw_edit_form($array) {
	global $colors;

	if (sizeof($array) > 0) {
		while (list($top_branch, $top_children) = each($array)) {
			if ($top_branch == "config") {
				$config_array = $top_children;
			}elseif ($top_branch == "fields") {
				$fields_array = $top_children;
			}
		}
	}

	$i = 0;
	if (sizeof($fields_array) > 0) {
		while (list($field_name, $field_array) = each($fields_array)) {
			if ($i == 0) {
				if (!isset($config_array["no_form_tag"])) {
					print "<form method='post' action='" . ((isset($config_array["post_to"])) ? $config_array["post_to"] : basename($_SERVER["PHP_SELF"])) . "'" . ((isset($config_array["form_name"])) ? " name='" . $config_array["form_name"] . "'" : "") . ">\n";
				}
			}

			if ($field_array["method"] == "hidden") { /* TODO: input type=hidden is not allowed inside a <table> but outside e.g. a <td> */
				form_hidden_box($field_name, $field_array["value"], ((isset($field_array["default"])) ? $field_array["default"] : ""));
			}elseif ($field_array["method"] == "hidden_zero") {
				form_hidden_box($field_name, $field_array["value"], "0");
			}elseif ($field_array["method"] == "spacer") {
				print "<tr id='row_$field_name'><td colspan='2' class='textRowSubHeaderDark'>" . $field_array["friendly_name"] . "</td></tr>\n";
			}else{
				if (isset($config_array["force_row_color"])) {
					print "<tr id='row_$field_name' bgcolor='#" . $config_array["force_row_color"] . "'>";
				}else{
					form_alternate_row_color('row_' . $field_name);
				}

				if (isset($field_array["sub_checkbox"])) {
					/* print description as a hover */
					$width = ((isset($config_array["left_column_width"])) ? (" width='" . $config_array["left_column_width"] . "'") : "");
					print "<td" . $width . " class='template_checkbox'>\n";
					print "<font class='textEditTitle'>" . $field_array["friendly_name"] . "</font><br>\n";

					if (isset($field_array["description"])) {
						if (strlen($field_array["description"])) {
							print "<div>" . $field_array["description"] . "</div>";
						}
					}

					form_checkbox($field_array["sub_checkbox"]["name"],
						$field_array["sub_checkbox"]["value"],
						$field_array["sub_checkbox"]["friendly_name"],
						((isset($field_array["default"])) ? $field_array["default"] : ""),
						((isset($field_array["form_id"])) ? $field_array["form_id"] : ""),
						((isset($field_array["class"])) ? $field_array["class"] : ""),
						((isset($field_array["on_change"])) ? $field_array["on_change"] : ""));
					print "</td>\n";
				} else {
					$width = ((isset($config_array["left_column_width"])) ? (" width='" . $config_array["left_column_width"] . "'") : "");
					print "<td" . $width . ">\n";
					print "<font class='textEditTitle'>" . $field_array["friendly_name"] . "</font><br>\n";
					print ((isset($field_array["description"])) ? $field_array["description"] : "");
					print "</td>\n";
				}

				print "<td>";

				draw_edit_control($field_name, $field_array);

				print "</td>\n</tr>\n";
			}

			$i++;
		}
	}
}
Example #7
0
function flowview_display_form()
{
    global $config, $colors;
    include $config['base_path'] . '/plugins/flowview/variables.php';
    include $config['base_path'] . '/plugins/flowview/arrays.php';
    print '<form id="flowview" action="' . $config['url_path'] . 'plugins/flowview/flowview.php" method="post" name="flowview">';
    display_tabs();
    html_start_box("<strong>Flow Filter Constraints</strong>", "100%", $colors["header"], "3", "center", "");
    ?>
	<tr>
		<td>
			<table border='0' cellspacing='0' cellpadding='1' width='100%' style='white-space:nowrap;'>
				<tr>
					<td>Saved Query:</td>
					<td><?php 
    draw_edit_control("query", $query_name_field);
    ?>
</td>
					<td>Listener:</td>
					<td><?php 
    draw_edit_control("device_name", $device_name_field);
    ?>
</td>
				</tr>
				<tr>
					<td>Start Date:</td>
					<td><input type='text' size='10' name='start_date' value='<?php 
    echo $start_date;
    ?>
'></td>
					<td>Start Time:</td><td><input type='text' size='8' name='start_time' value='<?php 
    echo $start_time;
    ?>
'></td>
					<td>TOS Fields:</td>
					<td><input type='text' size='10' name='tos_fields' value='<?php 
    echo $tos_fields;
    ?>
'></td>
					<td colspan=2>(e.g., -0x0b/0x0F)</td>
				</tr>
				<tr>
					<td>End Date:</td>
					<td><input type='text' size='10' name='end_date' value='<?php 
    echo $end_date;
    ?>
'></td>
					<td>End Time:</td>
					<td><input type='text' size='8' name='end_time' value='<?php 
    echo $end_time;
    ?>
'></td>
					<td>TCP Flags:</td>
					<td><input type='text' size='10' name='tcp_flags' value='<?php 
    echo $tcp_flags;
    ?>
'></td>
					<td>Protocols:</td>
					<td><?php 
    draw_edit_control("protocols", $ip_protocol_field);
    ?>
</td>
				</tr>
				<tr>
					<td>Source IP:</td>
					<td><input type='text' size='19' name='source_address' value='<?php 
    echo $source_address;
    ?>
'></td>
					<td>Source Port(s):</td>
					<td><input type='text' size='20' name='source_port' value='<?php 
    echo $source_port;
    ?>
'></td>
					<td>Source Interface:</td>
					<td><input type='text' size='2' name='source_if' value='<?php 
    echo $source_if;
    ?>
'></td>
					<td>Source AS:</td>
					<td><input type='text' size='6' name='source_as' value='<?php 
    echo $source_as;
    ?>
'></td>
				</tr>
				<tr>
					<td>Dest IP:</td>
					<td><input type='text' size='19' name='dest_address' value='<?php 
    echo $dest_address;
    ?>
'></td>
					<td>Dest Port(s):</td>
					<td><input type='text' size='20' name='dest_port' value='<?php 
    echo $dest_port;
    ?>
'></td>
					<td>Dest Interface:</td>
					<td><input type='text' size='2' name='dest_if' value='<?php 
    echo $dest_if;
    ?>
'></td>
					<td>Dest AS:</td>
					<td><input type='text' size='6' name='dest_as' value='<?php 
    echo $dest_as;
    ?>
'></td>
				</tr>
				<tr>
					<td colspan='9'>
						<hr size='2'>
						<center><strong>Note:</strong> Multiple field entries, separated by commas, are permitted in the fields above. A minus sign (-) will negate an entry (e.g. -80 for Port, would mean any Port but 80)</center>
						<hr size='2'>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<?php 
    html_end_box(false);
    ?>
	<?php 
    html_start_box("<strong>Report Parameters</strong>", "100%", $colors["header"], "3", "center", "");
    ?>
	<tr>
		<td>
			<table cellpadding='1' cellspacing='0' border='0' width='100%' style='white-space:nowrap;'>
				<tr id='rsettings'>
					<td>Statistics:</td>
					<td><?php 
    draw_edit_control("stat_report", $stat_report_field);
    ?>
</td>
					<td>Printed:</td>
					<td><?php 
    draw_edit_control("print_report", $print_report_field);
    ?>
</td>
					<td>Include if:</td>
					<td><?php 
    draw_edit_control("flow_select", $flow_select_field);
    ?>
</td>
					<td>Resolve Addresses:</td>
					<td><?php 
    draw_edit_control("resolve_addresses", $resolve_addresses_field);
    ?>
</td>
				</tr>
				<tr id='rlimits'>
					<td class='sortfield'>Sort Field:</td>
					<td class='sortfield'><select id='sort_field' name='sort_field'></select></td>
					<td>Max Flows:</td>
					<td><?php 
    draw_edit_control("cutoff_lines", $cutoff_lines_field);
    ?>
</td>
					<td>Minimum Bytes:</td>
					<td><?php 
    draw_edit_control("cutoff_octets", $cutoff_octets_field);
    ?>
</td>
				</tr>
				<tr>
			</table>
		</td>
	</tr>
		<td colspan='9'><hr size='2'></td>
	</tr>
	<tr>
		<td colspan='9'>
			<input type='hidden' id='action' name='action' value='view'>
			<input type='hidden' id='new_query' name='new_query' value=''>
			<input type='hidden' id='changed' name='changed' value='0'>
			<center>
				<input id='view' type='button' name='view' value='View'>
				<input id='defaults' type='button' value='Defaults'>
				<input id='save' type='button' name='save' value='Save'>
				<input id='saveas' type='button' name='saveas' value='Save As'>
				<input id='delete' type='button' name='delete' value='Delete'>
			</center>
		</td>
	</tr>
	<?php 
    html_end_box();
    ?>
	</table></td></tr>
	<?php 
    print '</form>';
    ?>
	<script type="text/javascript">
	<!--
	function statSelect() {
		statval = $('#stat_report').val();
		setStatOption(statval);
		if (statval > 0) {
			$('#print_report').attr('value', 0);
			$('#print_report').attr('disabled', 'disabled');
			$('#rlimits').children('.sortfield').show();
		}else{
			$('#print_report').attr('disabled', '');
		}
		if (statval == 99 || statval < 1) {
			$('#rlimits').hide();
		} else {
			$('#rlimits').show();
		}

		if (statval == 0 && $('#print_report').val() == 0) {
			$('#view').attr('disabled','disabled');
			$('#save').attr('disabled','disabled');
			$('#saveas').attr('disabled','disabled');
		}else{
			$('#view').attr('disabled','');
			$('#save').attr('disabled','');
			$('#saveas').attr('disabled','');
		}
	}

	function printSelect() {
		statval = $('#print_report').val();
		if (statval > 0) {
			$('#stat_report').attr('value',0);
			$('#stat_report').attr('disabled', 'disabled');
			$('#sort_field').removeAttr('disabled');
			$('#rlimits').hide();
			$('#rlimits').children('.sortfield').hide();
		} else {
			$('#rlimits').show();
			$('#cutoff_lines').removeAttr('disabled');
			$('#cutoff_octets').removeAttr('disabled');
			if ($('#stat_report').val() == 0) {
				$('#stat_report').attr('value', 10);
			}
			$('#stat_report').removeAttr('disabled');
			statSelect();
			return;
		}
		if (statval == 4 || statval == 5) {
			$('#cutoff_lines').removeAttr('disabled');
			$('#cutoff_octets').removeAttr('disabled');
			$('#rlimits').show();
		} else {
			$('#cutoff_lines').attr('disabled','disabled');
			$('#cutoff_octets').attr('disabled','disabled');
			$('#rlimits').hide();
		}

		if (statval == 0 && $('#stat_report').val() == 0) {
			$('#view').attr('disabled','disabled');
			$('#save').attr('disabled','disabled');
			$('#saveas').attr('disabled','disabled');
		}else{
			$('#view').attr('disabled','');
			$('#save').attr('disabled','');
			$('#saveas').attr('disabled','');
		}
	}

	$('#device_name').change(function () {
		<?php 
    if (api_user_realm_auth('flowview_devices.php')) {
        ?>
		if ($(this).val() == 0) {
			$('#view').attr('disabled', 'disabled');
			$('#save').attr('disabled', 'disabled');
		}else{
			$('#view').removeAttr('disabled');
			$('#save').removeAttr('disabled');
		}
		<?php 
    } else {
        ?>
		if ($(this).val() == 0) {
			$('#view').attr('disabled', 'disabled');
		}else{
			$('#view').removeAttr('disabled');
		}
		<?php 
    }
    ?>
	});

	$().ready(function () {
		$('#saveas').hide();
		<?php 
    if (api_user_realm_auth('flowview_devices.php')) {
        ?>
		if ($('#query').val() == 0) {
			$('#delete').hide();
		}else{
			$('#save').attr('value', 'Update');
			$('#saveas').show();
		}
		<?php 
    } else {
        ?>
		$('#delete').hide();
		$('#save').hide();
		<?php 
    }
    ?>

		$('#query').change(function() {
			window.location="flowview.php?action=loadquery&query="+$('#query').val();
		});

		$('#flowview').change(function() {
			$('#changed').attr('value', '1');
		});

		<?php 
    if (api_user_realm_auth('flowview_devices.php')) {
        ?>
		if ($('#device_name').val() == 0) {
			$('#view').attr('disabled', 'disabled');
			$('#save').attr('disabled', 'disabled');
		}else{
			$('#view').removeAttr('disabled');
			$('#save').removeAttr('disabled');
		}
		<?php 
    } else {
        ?>
		if ($('#device_name').val() == 0) {
			$('#view').attr('disabled', 'disabled');
		}else{
			$('#view').removeAttr('disabled');
		}
		<?php 
    }
    ?>

		$('#stat_report').change(function() {
			statSelect();
		});

		$('#print_report').change(function() {
			printSelect();
		});

		statSelect();
		printSelect();

		$("#fdialog").dialog({
			autoOpen: false,
			width: 320,
			height: 90,
			resizable: false,
			modal: true
		});
	});

	$('#view').click(function() {
		$('#action').attr('value', 'view');
		document.flowview.submit();
	});

	$('#saveas').click(function() {
		$('#squery').attr('value', $('#query>option:selected').text()+' (New)');
		$('#fdialog').dialog('open');
		$('#qcancel').click(function() {
			$('#fdialog').dialog('close');
		});
		$('#qsave').click(function() {
			$('#new_query').attr('value', $('#squery').val());
			$('#action').attr('value', 'save');
			$.post('flowview.php', $('#flowview').serialize(), function(data) {
				if (data!="error") {
					$('#query').append("<option value='"+data+"'>"+$('#new_query').val()+"</option>");
					$('#query').attr('value', data);
				}
			});
			$('#fdialog').dialog('close');
		});
	});

	$('#save').click(function() {
		if ($('#query').val() == 0) {
			$('#fdialog').dialog('open');
			$('#qcancel').click(function() {
				$('#fdialog').dialog('close');
			});
			$('#qsave').click(function() {
				$('#new_query').attr('value', $('#squery').val());
				$('#action').attr('value', 'save');
				$.post('flowview.php', $('#flowview').serialize(), function(data) {
					if (data!="error") {
						$('#query').append("<option value='"+data+"'>"+$('#new_query').val()+"</option>");
						$('#query').attr('value', data);
					}
				});
				$('#fdialog').dialog('close');
			});
		}else{
			$('#action').attr('value', 'save');
			$.post('flowview.php', $('#flowview').serialize());
		}
	});

	$('#delete').click(function() {
		document.location="flowview.php?action=delete&query="+$('#query').val();
	});

	$('#defaults').click(function() {
		setDefaults();
	});

	function setDefaults() {
		// Flow Filter Settings
		$('#device').attr('value',0);
		$('#start_date').attr('value', '');
		$('#start_time').attr('value','-8 HOURS');
		$('#end_date').attr('value','');
		$('#end_time').attr('value','NOW');
		$('#source_address').attr('value','');
		$('#source_port').attr('value','');
		$('#source_if').attr('value','');
		$('#source_as').attr('value','');
		$('#dest_address').attr('value','');
		$('#dest_port').attr('value','');
		$('#dest_if').attr('value','');
		$('#dest_as').attr('value','');
		$('#protocols').attr('value',0);
		$('#tos_fields').attr('value','');
		$('#tcp_flags').attr('value','');
		// Report Settings
		$('#stat_report').attr('value',10);
		$('#print_report').attr('value',0);
		$('#flow_select').attr('value',1);
		$('#sort_field').attr('value',4);
		$('#cutoff_lines').attr('value','100');
		$('#cutoff_octets').attr('value', '');
		$('#resolve_addresses').attr('value',0);
		statSelect();
	}

	function setStatOption(choose) {
		stat = document.flowview.sort_field;
		stat.options.length = 0;
		defsort = 1;
		if (choose == 10) {
			stat.options[stat.options.length] = new Option('Source IP', '1');
			stat.options[stat.options.length] = new Option('Destination IP', '2');
			stat.options[stat.options.length] = new Option('Flows', '3');
			stat.options[stat.options.length] = new Option('Bytes', '4');
			stat.options[stat.options.length] = new Option('Packets', '5');
			defsort = 4;
		} else if (choose == 5 || choose == 6 || choose == 7) {
			stat.options[stat.options.length] = new Option('Port', '1');
			stat.options[stat.options.length] = new Option('Flows', '2');
			stat.options[stat.options.length] = new Option('Bytes', '3');
			stat.options[stat.options.length] = new Option('Packets', '4');
			defsort = 3;
		} else if (choose == 8 || choose == 9 || choose == 11) {
			stat.options[stat.options.length] = new Option('IP', '1');
			stat.options[stat.options.length] = new Option('Flows', '2');
			stat.options[stat.options.length] = new Option('Bytes', '3');
			stat.options[stat.options.length] = new Option('Packets', '4');
			defsort = 3;
		} else if (choose == 12) {
			stat.options[stat.options.length] = new Option('Protocol', '1');
			stat.options[stat.options.length] = new Option('Flows', '2');
			stat.options[stat.options.length] = new Option('Bytes', '3');
			stat.options[stat.options.length] = new Option('Packets', '4');
			defsort = 3;
		} else if (choose == 17 || choose == 18) {
			stat.options[stat.options.length] = new Option('Interface', '1');
			stat.options[stat.options.length] = new Option('Flows', '2');
			stat.options[stat.options.length] = new Option('Bytes', '3');
			stat.options[stat.options.length] = new Option('Packets', '4');
			defsort = 3;
		} else if (choose == 23) {
			stat.options[stat.options.length] = new Option('Input Interface', '1');
			stat.options[stat.options.length] = new Option('Output Interface', '2');
			stat.options[stat.options.length] = new Option('Flows', '3');
			stat.options[stat.options.length] = new Option('Bytes', '4');
			stat.options[stat.options.length] = new Option('Packets', '5');
			defsort = 4;
		} else if (choose == 19 || choose == 20) {
			stat.options[stat.options.length] = new Option('AS', '1');
			stat.options[stat.options.length] = new Option('Flows', '2');
			stat.options[stat.options.length] = new Option('Bytes', '3');
			stat.options[stat.options.length] = new Option('Packets', '4');
			defsort = 3;
		} else if (choose == 21) {
			stat.options[stat.options.length] = new Option('Source AS', '1');
			stat.options[stat.options.length] = new Option('Destination AS', '2');
			stat.options[stat.options.length] = new Option('Flows', '3');
			stat.options[stat.options.length] = new Option('Bytes', '4');
			stat.options[stat.options.length] = new Option('Packets', '5');
			defsort = 4;
		} else if (choose == 22) {
			stat.options[stat.options.length] = new Option('TOS', '1');
			stat.options[stat.options.length] = new Option('Flows', '2');
			stat.options[stat.options.length] = new Option('Bytes', '3');
			stat.options[stat.options.length] = new Option('Packets', '4');
			defsort = 3;
		} else if (choose == 24 || choose == 25) {
			stat.options[stat.options.length] = new Option('Prefix', '1');
			stat.options[stat.options.length] = new Option('Flows', '2');
			stat.options[stat.options.length] = new Option('Bytes', '3');
			stat.options[stat.options.length] = new Option('Packets', '4');
			defsort = 3;
		} else if (choose == 26) {
			stat.options[stat.options.length] = new Option('Source Prefix', '1');
			stat.options[stat.options.length] = new Option('Destination Prefix', '2');
			stat.options[stat.options.length] = new Option('Flows', '3');
			stat.options[stat.options.length] = new Option('Bytes', '4');
			stat.options[stat.options.length] = new Option('Packets', '5');
			defsort = 4;
		} else {

		}

		if (statreport == choose) {
			stat.value = sortfield;
		} else {
			stat.value = defsort;
		}
	}

	var sortfield='<?php 
    echo $sort_field;
    ?>
';
	var statreport='<?php 
    echo $stat_report > 0 ? $stat_report : 0;
    ?>
';

	-->
	</script>

	<?php 
}